123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443 |
- using System;
- using System.Collections;
- using I2.Loc;
- 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<Transform>();
- GameObject childObject2 = UTY.GetChildObject(childObject, "Values", false);
- this.setting_max_hp_ = UTY.GetChildObject(childObject2, "MaxHp", false).GetComponent<UILabel>();
- this.setting_cur_hp_ = UTY.GetChildObject(childObject2, "CurrentHp", false).GetComponent<UILabel>();
- GameObject childObject3 = UTY.GetChildObject(this.parent_obj_, "SkillParent", false);
- this.skill_parent_grid_ = childObject3.GetComponent<UIGrid>();
- 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<YotogiSkillIcon>();
- component.SetOnClickEvent(new YotogiSkillIcon.OnClickEvent(this.OnRightClickIcon));
- }
- EventDelegate.Add(UTY.GetChildObject(this.parent_obj_, "DeselectAll", false).GetComponent<UIButton>().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<YotogiSkillContainerViewer> 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<YotogiSkillIconDrag>().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<YotogiSkillContainerViewer> 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<BoxCollider>();
- this.icon_btn_obj_ = this.skill_icon_obj.GetComponent<UIButton>();
- this.skill_icon_scripts_ = this.skill_icon_obj.GetComponent<YotogiSkillIcon>();
- this.btn_event_trigger_ = this.skill_icon_obj.gameObject.GetComponent<UIEventTrigger>();
- 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<UISprite>();
- this.skill_name_label_ = UTY.GetChildObject(this.skill_name_bg_.gameObject, "Val", false).GetComponent<UILabel>();
- 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<YotogiSkillIconDrag>().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<BoxCollider>();
- this.icon_btn_obj_ = this.skill_icon_obj.GetComponent<UIButton>();
- this.skill_icon_scripts_ = this.skill_icon_obj.GetComponent<YotogiSkillIcon>();
- this.btn_event_trigger_ = this.skill_icon_obj.gameObject.GetComponent<UIEventTrigger>();
- 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<BoxCollider>();
- target.icon_btn_obj_ = target.skill_icon_obj.GetComponent<UIButton>();
- target.skill_icon_scripts_ = target.skill_icon_obj.GetComponent<YotogiSkillIcon>();
- target.btn_event_trigger_ = target.skill_icon_obj.gameObject.GetComponent<UIEventTrigger>();
- 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);
- }
- if (this.skill_data_ == null)
- {
- this.skill_name_label_.text = string.Empty;
- this.VisibleSkillName(false);
- }
- else
- {
- if (this.lock_skill_exp)
- {
- this.skill_name_label_.text = this.skill_data_.name + "(EXPロック)";
- }
- else
- {
- this.skill_name_label_.text = this.skill_data_.name;
- }
- if (Product.SPP)
- {
- string translation = LocalizationManager.GetTranslation(this.skill_data_.termName, true, 0, true, false, null, null);
- if (!string.IsNullOrEmpty(translation))
- {
- string str = (!this.lock_skill_exp) ? string.Empty : LocalizationManager.GetTranslation("SceneYotogi/(EXPロック)", true, 0, true, false, null, null);
- this.skill_name_label_.text = translation + str;
- }
- }
- this.skill_name_label_.width = 0;
- this.skill_name_label_.MakePixelPerfect();
- this.skill_name_bg_.width = this.skill_name_label_.width + 20;
- }
- }
- 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_;
- }
- }
|