using System; using System.Collections; using UnityEngine; using wf; using Yotogis; public class YotogiSkillContainerViewer { public YotogiSkillContainerViewer(GameObject root_obj, MonoBehaviour parent) { this.root_obj_ = root_obj; this.parent_obj_ = UTY.GetChildObject(this.root_obj_, "SkillContainerViewer", false); GameObject childObject = UTY.GetChildObject(this.parent_obj_, "HpGroup", false); this.setting_hp_gauge_transform_ = UTY.GetChildObject(childObject, "Gauge", false).GetComponent(); GameObject childObject2 = UTY.GetChildObject(childObject, "Values", false); this.setting_max_hp_ = UTY.GetChildObject(childObject2, "MaxHp", false).GetComponent(); this.setting_cur_hp_ = UTY.GetChildObject(childObject2, "CurrentHp", false).GetComponent(); GameObject childObject3 = UTY.GetChildObject(this.parent_obj_, "SkillParent", false); this.skill_parent_grid_ = childObject3.GetComponent(); this.select_object_array_ = new YotogiSkillContainerViewer.YotogiSkillSelectSlot[7]; for (int i = 0; i < this.select_object_array_.Length; i++) { this.select_object_array_[i] = new YotogiSkillContainerViewer.YotogiSkillSelectSlot(UTY.GetChildObject(childObject3, "SkillIconUnit" + i, false), new YotogiSkillIconDrag.OnDragChangeCallback(this.OnDragChangeCallback)); YotogiSkillIcon component = this.select_object_array_[i].skill_icon_obj.GetComponent(); component.SetOnClickEvent(new YotogiSkillIcon.OnClickEvent(this.OnRightClickIcon)); } EventDelegate.Add(UTY.GetChildObject(this.parent_obj_, "DeselectAll", false).GetComponent().onClick, new EventDelegate(parent, "OnClickAllReset")); } public void Init(Maid maid) { this.maid_ = maid; for (int i = 0; i < this.select_object_array_.Length; i++) { this.select_object_array_[i].SetMaid(this.maid_); this.select_object_array_[i].SetSkillData(null, false); } } public void SetOnSkillChangeEvent(Action call_back) { this.on_change_call_back_ = call_back; } public void SetMaxHp(int max_hp) { this.setting_max_hp_.text = max_hp.ToString(); int num = int.Parse(this.setting_cur_hp_.text); if (max_hp < num) { this.SetCurrentHp(max_hp); } } public void SetCurrentHp(int cur_hp) { int num = int.Parse(this.setting_max_hp_.text); if (num < cur_hp) { cur_hp = num; } if (cur_hp <= 0) { this.setting_cur_hp_.color = Color.red; } else { this.setting_cur_hp_.color = Color.white; } this.setting_cur_hp_.text = cur_hp.ToString(); if (cur_hp < 0) { cur_hp = 0; } Hashtable args = TweenHash.EaseOutSine(TweenHash.Type.Scale, new Vector3((float)cur_hp / (float)num, 1f, 1f), 0.4f); iTween.ScaleTo(this.setting_hp_gauge_transform_.gameObject, args); } public bool AddSkill(Skill.Data data, bool lockSkillExp) { for (int i = 0; i < this.select_object_array_.Length; i++) { if (this.select_object_array_[i].skill_data == null) { this.select_object_array_[i].SetSkillData(data, lockSkillExp); if (this.on_change_call_back_ != null) { this.on_change_call_back_(this); } return true; } } return false; } public void ResetAllSkill() { for (int i = 0; i < this.select_object_array_.Length; i++) { this.select_object_array_[i].SetSkillData(null, false); } if (this.on_change_call_back_ != null) { this.on_change_call_back_(this); } } public Skill.Data[] GetSettingSkillArray() { int num = 0; for (int i = 0; i < this.select_object_array_.Length; i++) { if (this.select_object_array_[i].skill_data != null) { num++; } } Skill.Data[] array = new Skill.Data[num]; int num2 = 0; for (int j = 0; j < this.select_object_array_.Length; j++) { if (this.select_object_array_[j].skill_data != null) { array[num2] = this.select_object_array_[j].skill_data; num2++; } } return array; } public bool[] GetSettingSkillLockArray() { int num = 0; for (int i = 0; i < this.select_object_array_.Length; i++) { if (this.select_object_array_[i].skill_data != null) { num++; } } bool[] array = new bool[num]; int num2 = 0; for (int j = 0; j < this.select_object_array_.Length; j++) { if (this.select_object_array_[j].skill_data != null) { array[num2] = this.select_object_array_[j].lock_skill_exp; num2++; } } return array; } private void OnRightClickIcon(GameObject my, YotogiSkillIcon click_obj) { if (UICamera.currentKey != KeyCode.Mouse1) { return; } YotogiSkillContainerViewer.YotogiSkillSelectSlot yotogiSkillSelectSlot = null; for (int i = 0; i < this.select_object_array_.Length; i++) { if (this.select_object_array_[i].skill_icon_obj == my) { yotogiSkillSelectSlot = this.select_object_array_[i]; break; } } NDebug.AssertNull(yotogiSkillSelectSlot != null); yotogiSkillSelectSlot.SetSkillData(null, false); for (int j = 0; j < this.select_object_array_.Length; j++) { if (this.select_object_array_[j].skill_data == null && j + 1 < this.select_object_array_.Length && this.select_object_array_[j + 1].skill_data != null) { this.select_object_array_[j].Swap(this.select_object_array_[j + 1]); this.select_object_array_[j].skill_icon_obj.GetComponent().MoveReset(); this.select_object_array_[j + 1].skill_icon_obj.transform.localPosition = Vector3.zero; } } if (this.on_change_call_back_ != null) { this.on_change_call_back_(this); } } private void OnDragChangeCallback(GameObject my_obj, GameObject change_obj) { YotogiSkillContainerViewer.YotogiSkillSelectSlot yotogiSkillSelectSlot = null; YotogiSkillContainerViewer.YotogiSkillSelectSlot yotogiSkillSelectSlot2 = null; for (int i = 0; i < this.select_object_array_.Length; i++) { if (this.select_object_array_[i].skill_icon_obj == my_obj) { yotogiSkillSelectSlot = this.select_object_array_[i]; } else if (this.select_object_array_[i].skill_icon_obj == change_obj) { yotogiSkillSelectSlot2 = this.select_object_array_[i]; } if (yotogiSkillSelectSlot != null && yotogiSkillSelectSlot2 != null) { break; } } yotogiSkillSelectSlot.Swap(yotogiSkillSelectSlot2); } private Maid maid_; private GameObject root_obj_; private GameObject parent_obj_; private UIGrid skill_parent_grid_; private Transform setting_hp_gauge_transform_; private UILabel setting_cur_hp_; private UILabel setting_max_hp_; private YotogiSkillContainerViewer.YotogiSkillSelectSlot[] select_object_array_; private Action on_change_call_back_; private class YotogiSkillSelectSlot { public YotogiSkillSelectSlot(GameObject skill_icon_parent, YotogiSkillIconDrag.OnDragChangeCallback event_call_back) { this.skill_icon_obj = UTY.GetChildObject(skill_icon_parent, "SkillIconDrag", false); this.skill_icon_collider_ = this.skill_icon_obj.GetComponent(); this.icon_btn_obj_ = this.skill_icon_obj.GetComponent(); this.skill_icon_scripts_ = this.skill_icon_obj.GetComponent(); this.btn_event_trigger_ = this.skill_icon_obj.gameObject.GetComponent(); EventDelegate.Add(this.btn_event_trigger_.onHoverOver, delegate() { this.VisibleSkillName(true); }); EventDelegate.Add(this.btn_event_trigger_.onHoverOut, delegate() { this.VisibleSkillName(false); }); EventDelegate.Add(this.btn_event_trigger_.onDragStart, delegate() { this.VisibleSkillName(false); }); this.skill_name_bg_ = UTY.GetChildObject(skill_icon_parent, "SkillName", false).GetComponent(); this.skill_name_label_ = UTY.GetChildObject(this.skill_name_bg_.gameObject, "Val", false).GetComponent(); GameObject childObject = UTY.GetChildObject(skill_icon_parent, "StarGroup", false); this.star_obj = new GameObject[3]; for (int i = 0; i < this.star_obj.Length; i++) { this.star_obj[i] = UTY.GetChildObject(childObject, "Star" + i, false); } if (event_call_back != null) { this.skill_icon_obj.GetComponent().SetOnOnDragChangeCallback(event_call_back); } } public void VisibleSkillName(bool val) { if (!this.skill_icon_collider_.enabled || this.skill_data_ == null) { val = false; } float alpha = 0f; if (val) { alpha = 1f; } this.skill_name_bg_.alpha = alpha; this.skill_name_label_.alpha = alpha; } public void Swap(YotogiSkillContainerViewer.YotogiSkillSelectSlot target) { GameObject gameObject = this.skill_icon_obj; this.skill_icon_obj = target.skill_icon_obj; target.skill_icon_obj = gameObject; this.skill_icon_collider_ = this.skill_icon_obj.GetComponent(); this.icon_btn_obj_ = this.skill_icon_obj.GetComponent(); this.skill_icon_scripts_ = this.skill_icon_obj.GetComponent(); this.btn_event_trigger_ = this.skill_icon_obj.gameObject.GetComponent(); this.btn_event_trigger_.onHoverOver.Clear(); this.btn_event_trigger_.onHoverOut.Clear(); this.btn_event_trigger_.onDragStart.Clear(); EventDelegate.Add(this.btn_event_trigger_.onHoverOver, delegate() { this.VisibleSkillName(true); }); EventDelegate.Add(this.btn_event_trigger_.onHoverOut, delegate() { this.VisibleSkillName(false); }); EventDelegate.Add(this.btn_event_trigger_.onDragStart, delegate() { this.VisibleSkillName(false); }); target.skill_icon_collider_ = target.skill_icon_obj.GetComponent(); target.icon_btn_obj_ = target.skill_icon_obj.GetComponent(); target.skill_icon_scripts_ = target.skill_icon_obj.GetComponent(); target.btn_event_trigger_ = target.skill_icon_obj.gameObject.GetComponent(); target.btn_event_trigger_.onHoverOver.Clear(); target.btn_event_trigger_.onHoverOut.Clear(); target.btn_event_trigger_.onDragStart.Clear(); EventDelegate.Add(target.btn_event_trigger_.onHoverOver, delegate() { target.VisibleSkillName(true); }); EventDelegate.Add(target.btn_event_trigger_.onHoverOut, delegate() { target.VisibleSkillName(false); }); EventDelegate.Add(target.btn_event_trigger_.onDragStart, delegate() { target.VisibleSkillName(false); }); Skill.Data skill_data = this.skill_data; this.skill_data_ = target.skill_data; target.skill_data_ = skill_data; bool lock_skill_exp = this.lock_skill_exp; this.lock_skill_exp_ = target.lock_skill_exp; target.lock_skill_exp_ = lock_skill_exp; this.SetSkillData(this.skill_data, this.lock_skill_exp); target.SetSkillData(target.skill_data, target.lock_skill_exp); Transform parent = this.skill_icon_obj.transform.parent; this.skill_icon_obj.transform.parent = target.skill_icon_obj.transform.parent; target.skill_icon_obj.transform.parent = parent; } public void SetSkillData(Skill.Data skill_data, bool lockSkillExp) { this.skill_data_ = skill_data; this.lock_skill_exp_ = lockSkillExp; if (this.skill_data_ == null) { this.icon_btn_obj_.SetState(UIButtonColor.State.Normal, true); this.skill_icon_collider_.enabled = false; } else { this.skill_icon_collider_.enabled = true; } this.skill_icon_scripts_.SetSkillData(this.skill_data_); this.UpdateData(); } public void UpdateData() { int num = 0; if (this.skill_data != null && this.maid_ != null) { num = this.maid_.status.yotogiSkill.Get(this.skill_data.id).level; } num = ((this.star_obj.Length >= num) ? num : this.star_obj.Length); for (int i = 0; i < this.star_obj.Length; i++) { this.star_obj[i].SetActive(i <= num - 1); } YotogiSkillNameHoverPlate yotogiSkillNameHoverPlate = this.skill_name_label_.GetComponent(); if (yotogiSkillNameHoverPlate == null) { yotogiSkillNameHoverPlate = this.skill_name_label_.gameObject.AddComponent(); } if (this.skill_data_ == null) { yotogiSkillNameHoverPlate.ClearName(); this.VisibleSkillName(false); } else { yotogiSkillNameHoverPlate.SetName(this.skill_data_.name, this.skill_data_.termName, this.lock_skill_exp); } } public void SetMaid(Maid maid) { this.maid_ = maid; } public Skill.Data skill_data { get { return this.skill_data_; } } public bool lock_skill_exp { get { return this.lock_skill_exp_; } } public UIEventTrigger btn_event_trigger { get { return this.btn_event_trigger_; } } private Maid maid_; public GameObject skill_icon_obj; public GameObject[] star_obj; private UIEventTrigger btn_event_trigger_; private UISprite skill_name_bg_; private UILabel skill_name_label_; private UIButton icon_btn_obj_; private YotogiSkillIcon skill_icon_scripts_; private BoxCollider skill_icon_collider_; private Skill.Data skill_data_; private bool lock_skill_exp_; } }