YotogiSkillContainerViewer.cs 13 KB

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