using System;
using MaidStatus;
using UnityEngine;
using Yotogis;

public class YotogiOldSkillUnit : MonoBehaviour
{
	public void Awake()
	{
		this.icon_ = UTY.GetChildObject(base.gameObject, "Icon", false).GetComponent<YotogiOldSkillIcon>();
		UTY.GetChildObject(base.gameObject, "levelup", false).SetActive(false);
		GameObject childObject = UTY.GetChildObject(base.gameObject, "Description", false);
		this.gauge_obj_ = UTY.GetChildObject(childObject, "Gauge", false);
		this.name_obj_ = UTY.GetChildObject(childObject, "Name", false);
		this.stargroup_obj_ = UTY.GetChildObject(childObject, "StarGroup", false);
		GameObject childObject2 = UTY.GetChildObject(childObject, "UnderGroup", false);
		this.acquired_experience_obj = UTY.GetChildObject(UTY.GetChildObject(childObject2, "AcquiredExperience", false), "Value", false);
		this.cost_of_hp_obj = UTY.GetChildObject(UTY.GetChildObject(childObject2, "CostOfHp", false), "Value", false);
		this.button_ = UTY.GetChildObject(base.gameObject, "Button", false).GetComponent<UIButton>();
	}

	public void SetSkillData(Maid maid, Skill.Old.Data set_skill_data, YotogiSkillData param_data)
	{
		this.maid_ = maid;
		this.skill_data_ = set_skill_data;
		this.param_data_ = param_data;
		this.name_obj_.GetComponent<UILabel>().text = this.skill_data_.name;
		this.acquired_experience_obj.GetComponent<UILabel>().text = this.skill_data_.add_yotogi_class_exp.ToString();
		this.cost_of_hp_obj.GetComponent<UILabel>().text = this.skill_data_.exec_need_hp.ToString();
		this.icon_.SetSkillData(this.skill_data_);
		if (0u < this.param_data_.playCount)
		{
			UTY.GetChildObject(base.gameObject, "IconNew", false).SetActive(false);
		}
		else
		{
			UTY.GetChildObject(base.gameObject, "IconNew", false).SetActive(true);
		}
		this.UpdateGage(this.param_data_.expSystem);
	}

	public void SetExpAnime(int start_total_exp, int add_exp, float anime_time)
	{
		if (anime_time <= 0f)
		{
			return;
		}
		this.result_anime_exp_system_ = (SimpleExperienceSystem)this.param_data_.expSystem.Clone();
		this.result_anime_exp_system_.SetTotalExp(start_total_exp + add_exp);
		add_exp = this.result_anime_exp_system_.GetTotalExp() - start_total_exp;
		if (add_exp <= 0)
		{
			return;
		}
		this.result_anime_exp_system_.SetTotalExp(start_total_exp);
		this.UpdateGage(this.result_anime_exp_system_);
		this.anime_event_ = delegate()
		{
			iTween.ValueTo(this.gameObject, iTween.Hash(new object[]
			{
				"from",
				start_total_exp,
				"to",
				start_total_exp + add_exp,
				"time",
				anime_time,
				"onupdate",
				"UpdateValue"
			}));
		};
	}

	public void StartAnime()
	{
		if (this.anime_event_ != null)
		{
			this.anime_event_();
			this.anime_event_ = null;
		}
	}

	public void UpdateValue(int value)
	{
		if (this.result_anime_exp_system_ == null)
		{
			return;
		}
		int currentLevel = this.result_anime_exp_system_.GetCurrentLevel();
		this.result_anime_exp_system_.SetTotalExp(value);
		if (currentLevel < this.result_anime_exp_system_.GetCurrentLevel() && !UTY.GetChildObject(base.gameObject, "levelup", false).activeSelf)
		{
			GameMain.Instance.SoundMgr.PlaySystem("SE008.ogg");
			UTY.GetChildObject(base.gameObject, "levelup", false).SetActive(true);
		}
		this.UpdateGage(this.result_anime_exp_system_);
	}

	public void UpdateGage(IExperienceSystem exp_system)
	{
		if (this.skill_data_ == null)
		{
			return;
		}
		int currentLevel = exp_system.GetCurrentLevel();
		GameObject[] array = new GameObject[3];
		for (int i = 0; i < array.Length; i++)
		{
			array[i] = UTY.GetChildObject(this.stargroup_obj_, "Star" + i.ToString(), false);
			array[i].SetActive(i <= currentLevel - 1);
		}
		float num = 0f;
		if (exp_system.GetNextLevelExp(currentLevel) != 0)
		{
			num = (float)exp_system.GetCurrentExp() / (float)exp_system.GetNextLevelExp(currentLevel);
		}
		if (float.IsNaN(num))
		{
			num = 0f;
		}
		else if (float.IsInfinity(num))
		{
			num = 1f;
		}
		this.gauge_obj_.GetComponent<Transform>().localScale = new Vector3(num, 1f, 1f);
	}

	public Skill.Old.Data skill_data
	{
		get
		{
			return this.skill_data_;
		}
	}

	public YotogiSkillData skill_param_data
	{
		get
		{
			return this.param_data_;
		}
	}

	private Maid maid_;

	private Skill.Old.Data skill_data_;

	private YotogiSkillData param_data_;

	private UIButton button_;

	private YotogiOldSkillIcon icon_;

	private GameObject gauge_obj_;

	private GameObject name_obj_;

	private GameObject stargroup_obj_;

	private GameObject acquired_experience_obj;

	private GameObject cost_of_hp_obj;

	private IExperienceSystem result_anime_exp_system_;

	private Action anime_event_;
}
