YotogiSkillContainerViewer.cs 13 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428
  1. using System;
  2. using System.Collections;
  3. using UnityEngine;
  4. using wf;
  5. using Yotogis;
  6. public class YotogiSkillContainerViewer
  7. {
  8. public YotogiSkillContainerViewer(GameObject root_obj, MonoBehaviour parent)
  9. {
  10. this.root_obj_ = root_obj;
  11. this.parent_obj_ = UTY.GetChildObject(this.root_obj_, "SkillContainerViewer", false);
  12. GameObject childObject = UTY.GetChildObject(this.parent_obj_, "HpGroup", false);
  13. this.setting_hp_gauge_transform_ = UTY.GetChildObject(childObject, "Gauge", false).GetComponent<Transform>();
  14. GameObject childObject2 = UTY.GetChildObject(childObject, "Values", false);
  15. this.setting_max_hp_ = UTY.GetChildObject(childObject2, "MaxHp", false).GetComponent<UILabel>();
  16. this.setting_cur_hp_ = UTY.GetChildObject(childObject2, "CurrentHp", false).GetComponent<UILabel>();
  17. GameObject childObject3 = UTY.GetChildObject(this.parent_obj_, "SkillParent", false);
  18. this.skill_parent_grid_ = childObject3.GetComponent<UIGrid>();
  19. this.select_object_array_ = new YotogiSkillContainerViewer.YotogiSkillSelectSlot[7];
  20. for (int i = 0; i < this.select_object_array_.Length; i++)
  21. {
  22. this.select_object_array_[i] = new YotogiSkillContainerViewer.YotogiSkillSelectSlot(UTY.GetChildObject(childObject3, "SkillIconUnit" + i, false), new YotogiSkillIconDrag.OnDragChangeCallback(this.OnDragChangeCallback));
  23. YotogiSkillIcon component = this.select_object_array_[i].skill_icon_obj.GetComponent<YotogiSkillIcon>();
  24. component.SetOnClickEvent(new YotogiSkillIcon.OnClickEvent(this.OnRightClickIcon));
  25. }
  26. EventDelegate.Add(UTY.GetChildObject(this.parent_obj_, "DeselectAll", false).GetComponent<UIButton>().onClick, new EventDelegate(parent, "OnClickAllReset"));
  27. }
  28. public void Init(Maid maid)
  29. {
  30. this.maid_ = maid;
  31. for (int i = 0; i < this.select_object_array_.Length; i++)
  32. {
  33. this.select_object_array_[i].SetMaid(this.maid_);
  34. this.select_object_array_[i].SetSkillData(null, false);
  35. }
  36. }
  37. public void SetOnSkillChangeEvent(Action<YotogiSkillContainerViewer> call_back)
  38. {
  39. this.on_change_call_back_ = call_back;
  40. }
  41. public void SetMaxHp(int max_hp)
  42. {
  43. this.setting_max_hp_.text = max_hp.ToString();
  44. int num = int.Parse(this.setting_cur_hp_.text);
  45. if (max_hp < num)
  46. {
  47. this.SetCurrentHp(max_hp);
  48. }
  49. }
  50. public void SetCurrentHp(int cur_hp)
  51. {
  52. int num = int.Parse(this.setting_max_hp_.text);
  53. if (num < cur_hp)
  54. {
  55. cur_hp = num;
  56. }
  57. if (cur_hp <= 0)
  58. {
  59. this.setting_cur_hp_.color = Color.red;
  60. }
  61. else
  62. {
  63. this.setting_cur_hp_.color = Color.white;
  64. }
  65. this.setting_cur_hp_.text = cur_hp.ToString();
  66. if (cur_hp < 0)
  67. {
  68. cur_hp = 0;
  69. }
  70. Hashtable args = TweenHash.EaseOutSine(TweenHash.Type.Scale, new Vector3((float)cur_hp / (float)num, 1f, 1f), 0.4f);
  71. iTween.ScaleTo(this.setting_hp_gauge_transform_.gameObject, args);
  72. }
  73. public bool AddSkill(Skill.Data data, bool lockSkillExp)
  74. {
  75. for (int i = 0; i < this.select_object_array_.Length; i++)
  76. {
  77. if (this.select_object_array_[i].skill_data == null)
  78. {
  79. this.select_object_array_[i].SetSkillData(data, lockSkillExp);
  80. if (this.on_change_call_back_ != null)
  81. {
  82. this.on_change_call_back_(this);
  83. }
  84. return true;
  85. }
  86. }
  87. return false;
  88. }
  89. public void ResetAllSkill()
  90. {
  91. for (int i = 0; i < this.select_object_array_.Length; i++)
  92. {
  93. this.select_object_array_[i].SetSkillData(null, false);
  94. }
  95. if (this.on_change_call_back_ != null)
  96. {
  97. this.on_change_call_back_(this);
  98. }
  99. }
  100. public Skill.Data[] GetSettingSkillArray()
  101. {
  102. int num = 0;
  103. for (int i = 0; i < this.select_object_array_.Length; i++)
  104. {
  105. if (this.select_object_array_[i].skill_data != null)
  106. {
  107. num++;
  108. }
  109. }
  110. Skill.Data[] array = new Skill.Data[num];
  111. int num2 = 0;
  112. for (int j = 0; j < this.select_object_array_.Length; j++)
  113. {
  114. if (this.select_object_array_[j].skill_data != null)
  115. {
  116. array[num2] = this.select_object_array_[j].skill_data;
  117. num2++;
  118. }
  119. }
  120. return array;
  121. }
  122. public bool[] GetSettingSkillLockArray()
  123. {
  124. int num = 0;
  125. for (int i = 0; i < this.select_object_array_.Length; i++)
  126. {
  127. if (this.select_object_array_[i].skill_data != null)
  128. {
  129. num++;
  130. }
  131. }
  132. bool[] array = new bool[num];
  133. int num2 = 0;
  134. for (int j = 0; j < this.select_object_array_.Length; j++)
  135. {
  136. if (this.select_object_array_[j].skill_data != null)
  137. {
  138. array[num2] = this.select_object_array_[j].lock_skill_exp;
  139. num2++;
  140. }
  141. }
  142. return array;
  143. }
  144. private void OnRightClickIcon(GameObject my, YotogiSkillIcon click_obj)
  145. {
  146. if (UICamera.currentKey != KeyCode.Mouse1)
  147. {
  148. return;
  149. }
  150. YotogiSkillContainerViewer.YotogiSkillSelectSlot yotogiSkillSelectSlot = null;
  151. for (int i = 0; i < this.select_object_array_.Length; i++)
  152. {
  153. if (this.select_object_array_[i].skill_icon_obj == my)
  154. {
  155. yotogiSkillSelectSlot = this.select_object_array_[i];
  156. break;
  157. }
  158. }
  159. NDebug.AssertNull(yotogiSkillSelectSlot != null);
  160. yotogiSkillSelectSlot.SetSkillData(null, false);
  161. for (int j = 0; j < this.select_object_array_.Length; j++)
  162. {
  163. 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)
  164. {
  165. this.select_object_array_[j].Swap(this.select_object_array_[j + 1]);
  166. this.select_object_array_[j].skill_icon_obj.GetComponent<YotogiSkillIconDrag>().MoveReset();
  167. this.select_object_array_[j + 1].skill_icon_obj.transform.localPosition = Vector3.zero;
  168. }
  169. }
  170. if (this.on_change_call_back_ != null)
  171. {
  172. this.on_change_call_back_(this);
  173. }
  174. }
  175. private void OnDragChangeCallback(GameObject my_obj, GameObject change_obj)
  176. {
  177. YotogiSkillContainerViewer.YotogiSkillSelectSlot yotogiSkillSelectSlot = null;
  178. YotogiSkillContainerViewer.YotogiSkillSelectSlot yotogiSkillSelectSlot2 = null;
  179. for (int i = 0; i < this.select_object_array_.Length; i++)
  180. {
  181. if (this.select_object_array_[i].skill_icon_obj == my_obj)
  182. {
  183. yotogiSkillSelectSlot = this.select_object_array_[i];
  184. }
  185. else if (this.select_object_array_[i].skill_icon_obj == change_obj)
  186. {
  187. yotogiSkillSelectSlot2 = this.select_object_array_[i];
  188. }
  189. if (yotogiSkillSelectSlot != null && yotogiSkillSelectSlot2 != null)
  190. {
  191. break;
  192. }
  193. }
  194. yotogiSkillSelectSlot.Swap(yotogiSkillSelectSlot2);
  195. }
  196. private Maid maid_;
  197. private GameObject root_obj_;
  198. private GameObject parent_obj_;
  199. private UIGrid skill_parent_grid_;
  200. private Transform setting_hp_gauge_transform_;
  201. private UILabel setting_cur_hp_;
  202. private UILabel setting_max_hp_;
  203. private YotogiSkillContainerViewer.YotogiSkillSelectSlot[] select_object_array_;
  204. private Action<YotogiSkillContainerViewer> on_change_call_back_;
  205. private class YotogiSkillSelectSlot
  206. {
  207. public YotogiSkillSelectSlot(GameObject skill_icon_parent, YotogiSkillIconDrag.OnDragChangeCallback event_call_back)
  208. {
  209. this.skill_icon_obj = UTY.GetChildObject(skill_icon_parent, "SkillIconDrag", false);
  210. this.skill_icon_collider_ = this.skill_icon_obj.GetComponent<BoxCollider>();
  211. this.icon_btn_obj_ = this.skill_icon_obj.GetComponent<UIButton>();
  212. this.skill_icon_scripts_ = this.skill_icon_obj.GetComponent<YotogiSkillIcon>();
  213. this.btn_event_trigger_ = this.skill_icon_obj.gameObject.GetComponent<UIEventTrigger>();
  214. EventDelegate.Add(this.btn_event_trigger_.onHoverOver, delegate()
  215. {
  216. this.VisibleSkillName(true);
  217. });
  218. EventDelegate.Add(this.btn_event_trigger_.onHoverOut, delegate()
  219. {
  220. this.VisibleSkillName(false);
  221. });
  222. EventDelegate.Add(this.btn_event_trigger_.onDragStart, delegate()
  223. {
  224. this.VisibleSkillName(false);
  225. });
  226. this.skill_name_bg_ = UTY.GetChildObject(skill_icon_parent, "SkillName", false).GetComponent<UISprite>();
  227. this.skill_name_label_ = UTY.GetChildObject(this.skill_name_bg_.gameObject, "Val", false).GetComponent<UILabel>();
  228. GameObject childObject = UTY.GetChildObject(skill_icon_parent, "StarGroup", false);
  229. this.star_obj = new GameObject[3];
  230. for (int i = 0; i < this.star_obj.Length; i++)
  231. {
  232. this.star_obj[i] = UTY.GetChildObject(childObject, "Star" + i, false);
  233. }
  234. if (event_call_back != null)
  235. {
  236. this.skill_icon_obj.GetComponent<YotogiSkillIconDrag>().SetOnOnDragChangeCallback(event_call_back);
  237. }
  238. }
  239. public void VisibleSkillName(bool val)
  240. {
  241. if (!this.skill_icon_collider_.enabled || this.skill_data_ == null)
  242. {
  243. val = false;
  244. }
  245. float alpha = 0f;
  246. if (val)
  247. {
  248. alpha = 1f;
  249. }
  250. this.skill_name_bg_.alpha = alpha;
  251. this.skill_name_label_.alpha = alpha;
  252. }
  253. public void Swap(YotogiSkillContainerViewer.YotogiSkillSelectSlot target)
  254. {
  255. GameObject gameObject = this.skill_icon_obj;
  256. this.skill_icon_obj = target.skill_icon_obj;
  257. target.skill_icon_obj = gameObject;
  258. this.skill_icon_collider_ = this.skill_icon_obj.GetComponent<BoxCollider>();
  259. this.icon_btn_obj_ = this.skill_icon_obj.GetComponent<UIButton>();
  260. this.skill_icon_scripts_ = this.skill_icon_obj.GetComponent<YotogiSkillIcon>();
  261. this.btn_event_trigger_ = this.skill_icon_obj.gameObject.GetComponent<UIEventTrigger>();
  262. this.btn_event_trigger_.onHoverOver.Clear();
  263. this.btn_event_trigger_.onHoverOut.Clear();
  264. this.btn_event_trigger_.onDragStart.Clear();
  265. EventDelegate.Add(this.btn_event_trigger_.onHoverOver, delegate()
  266. {
  267. this.VisibleSkillName(true);
  268. });
  269. EventDelegate.Add(this.btn_event_trigger_.onHoverOut, delegate()
  270. {
  271. this.VisibleSkillName(false);
  272. });
  273. EventDelegate.Add(this.btn_event_trigger_.onDragStart, delegate()
  274. {
  275. this.VisibleSkillName(false);
  276. });
  277. target.skill_icon_collider_ = target.skill_icon_obj.GetComponent<BoxCollider>();
  278. target.icon_btn_obj_ = target.skill_icon_obj.GetComponent<UIButton>();
  279. target.skill_icon_scripts_ = target.skill_icon_obj.GetComponent<YotogiSkillIcon>();
  280. target.btn_event_trigger_ = target.skill_icon_obj.gameObject.GetComponent<UIEventTrigger>();
  281. target.btn_event_trigger_.onHoverOver.Clear();
  282. target.btn_event_trigger_.onHoverOut.Clear();
  283. target.btn_event_trigger_.onDragStart.Clear();
  284. EventDelegate.Add(target.btn_event_trigger_.onHoverOver, delegate()
  285. {
  286. target.VisibleSkillName(true);
  287. });
  288. EventDelegate.Add(target.btn_event_trigger_.onHoverOut, delegate()
  289. {
  290. target.VisibleSkillName(false);
  291. });
  292. EventDelegate.Add(target.btn_event_trigger_.onDragStart, delegate()
  293. {
  294. target.VisibleSkillName(false);
  295. });
  296. Skill.Data skill_data = this.skill_data;
  297. this.skill_data_ = target.skill_data;
  298. target.skill_data_ = skill_data;
  299. bool lock_skill_exp = this.lock_skill_exp;
  300. this.lock_skill_exp_ = target.lock_skill_exp;
  301. target.lock_skill_exp_ = lock_skill_exp;
  302. this.SetSkillData(this.skill_data, this.lock_skill_exp);
  303. target.SetSkillData(target.skill_data, target.lock_skill_exp);
  304. Transform parent = this.skill_icon_obj.transform.parent;
  305. this.skill_icon_obj.transform.parent = target.skill_icon_obj.transform.parent;
  306. target.skill_icon_obj.transform.parent = parent;
  307. }
  308. public void SetSkillData(Skill.Data skill_data, bool lockSkillExp)
  309. {
  310. this.skill_data_ = skill_data;
  311. this.lock_skill_exp_ = lockSkillExp;
  312. if (this.skill_data_ == null)
  313. {
  314. this.icon_btn_obj_.SetState(UIButtonColor.State.Normal, true);
  315. this.skill_icon_collider_.enabled = false;
  316. }
  317. else
  318. {
  319. this.skill_icon_collider_.enabled = true;
  320. }
  321. this.skill_icon_scripts_.SetSkillData(this.skill_data_);
  322. this.UpdateData();
  323. }
  324. public void UpdateData()
  325. {
  326. int num = 0;
  327. if (this.skill_data != null && this.maid_ != null)
  328. {
  329. num = this.maid_.status.yotogiSkill.Get(this.skill_data.id).level;
  330. }
  331. num = ((this.star_obj.Length >= num) ? num : this.star_obj.Length);
  332. for (int i = 0; i < this.star_obj.Length; i++)
  333. {
  334. this.star_obj[i].SetActive(i <= num - 1);
  335. }
  336. YotogiSkillNameHoverPlate yotogiSkillNameHoverPlate = this.skill_name_label_.GetComponent<YotogiSkillNameHoverPlate>();
  337. if (yotogiSkillNameHoverPlate == null)
  338. {
  339. yotogiSkillNameHoverPlate = this.skill_name_label_.gameObject.AddComponent<YotogiSkillNameHoverPlate>();
  340. }
  341. if (this.skill_data_ == null)
  342. {
  343. yotogiSkillNameHoverPlate.ClearName();
  344. this.VisibleSkillName(false);
  345. }
  346. else
  347. {
  348. yotogiSkillNameHoverPlate.SetName(this.skill_data_.name, this.skill_data_.termName, this.lock_skill_exp);
  349. }
  350. }
  351. public void SetMaid(Maid maid)
  352. {
  353. this.maid_ = maid;
  354. }
  355. public Skill.Data skill_data
  356. {
  357. get
  358. {
  359. return this.skill_data_;
  360. }
  361. }
  362. public bool lock_skill_exp
  363. {
  364. get
  365. {
  366. return this.lock_skill_exp_;
  367. }
  368. }
  369. public UIEventTrigger btn_event_trigger
  370. {
  371. get
  372. {
  373. return this.btn_event_trigger_;
  374. }
  375. }
  376. private Maid maid_;
  377. public GameObject skill_icon_obj;
  378. public GameObject[] star_obj;
  379. private UIEventTrigger btn_event_trigger_;
  380. private UISprite skill_name_bg_;
  381. private UILabel skill_name_label_;
  382. private UIButton icon_btn_obj_;
  383. private YotogiSkillIcon skill_icon_scripts_;
  384. private BoxCollider skill_icon_collider_;
  385. private Skill.Data skill_data_;
  386. private bool lock_skill_exp_;
  387. }
  388. }