using System;
using MaidStatus;
using UnityEngine;

public class ClassUnit : MonoBehaviour
{
	public void Awake()
	{
		this.button_ = base.GetComponentInChildren<UIWFTabButton>();
		this.class_name_ = UTY.GetChildObject(base.gameObject, "ClassName", false).GetComponent<UILabel>();
		this.class_level_ = UTY.GetChildObject(base.gameObject, "Level/Value", false).GetComponent<UILabel>();
		EventDelegate.Add(this.button_.onSelect, new EventDelegate.Callback(this.OnSelect));
		this.job_class_type_ = (this.yotogi_class_type_ = int.MinValue);
	}

	public void SetOnSelectEvent(Action<ClassUnit> event_delgate)
	{
		this.select_event_ = event_delgate;
	}

	public void SetClassChangePanel(ClassChangePanel class_change_panel)
	{
		this.class_change_panel_ = class_change_panel;
	}

	public void UpdateMaidData(Maid maid)
	{
		if (this.job_class_type_ != -2147483648)
		{
			if (maid.status.jobClass.Contains(this.job_class_type_))
			{
				ClassData<JobClass.Data> classData = maid.status.jobClass.Get(this.job_class_type_);
				this.class_level_.text = classData.level.ToString();
				this.class_level_.transform.parent.gameObject.SetActive(true);
			}
			else
			{
				this.class_level_.transform.parent.gameObject.SetActive(false);
			}
		}
		else if (this.yotogi_class_type_ != -2147483648)
		{
			if (maid.status.yotogiClass.Contains(this.yotogi_class_type_))
			{
				ClassData<YotogiClass.Data> classData2 = maid.status.yotogiClass.Get(this.yotogi_class_type_);
				this.class_level_.text = classData2.level.ToString();
				this.class_level_.transform.parent.gameObject.SetActive(true);
			}
			else
			{
				this.class_level_.transform.parent.gameObject.SetActive(false);
			}
		}
	}

	public void SetJobClassType(int class_type)
	{
		this.yotogi_class_type_ = int.MinValue;
		this.job_class_type_ = class_type;
		this.class_name_.text = JobClass.GetData(class_type).drawName;
		this.class_level_.text = "0";
	}

	public void SetYotogiClassType(int class_type)
	{
		this.job_class_type_ = int.MinValue;
		this.yotogi_class_type_ = class_type;
		this.class_name_.text = YotogiClass.GetData(class_type).drawName;
		this.class_level_.text = "0";
	}

	public void UpdateInfo()
	{
		if (this.job_class_type_ != -2147483648)
		{
			this.class_change_panel_.SetInfoData(this.job_class_type_);
		}
		else if (this.yotogi_class_type_ != -2147483648)
		{
			this.class_change_panel_.SetInfoDataYotogi(this.yotogi_class_type_);
		}
	}

	private void OnSelect()
	{
		if (this.select_event_ != null && this.button_.isSelected)
		{
			this.select_event_(this);
		}
	}

	public int maid_class_type
	{
		get
		{
			return this.job_class_type_;
		}
	}

	public int yotogi_class_type
	{
		get
		{
			return this.yotogi_class_type_;
		}
	}

	public UIWFTabButton button
	{
		get
		{
			return this.button_;
		}
	}

	public UIWFTabPanel tab_panel
	{
		get
		{
			return this.tab_panel_;
		}
	}

	private Action<ClassUnit> select_event_;

	private UIWFTabPanel tab_panel_;

	private UIWFTabButton button_;

	private UILabel class_name_;

	private UILabel class_level_;

	private int job_class_type_;

	private int yotogi_class_type_;

	private ClassChangePanel class_change_panel_;
}
