YotogiSkillUnit.cs 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291
  1. using System;
  2. using System.Collections.Generic;
  3. using MaidStatus;
  4. using UnityEngine;
  5. using Yotogis;
  6. public class YotogiSkillUnit : MonoBehaviour
  7. {
  8. public void Awake()
  9. {
  10. this.icon_ = UTY.GetChildObject(base.gameObject, "Icon", false).GetComponent<YotogiSkillIcon>();
  11. this.new_icon_ = UTY.GetChildObject(base.gameObject, "IconNew", false).GetComponent<UISprite>();
  12. UTY.GetChildObject(base.gameObject, "levelup", false).SetActive(false);
  13. GameObject childObject = UTY.GetChildObject(base.gameObject, "Description", false);
  14. this.gauge_obj_ = UTY.GetChildObject(childObject, "Gauge", false);
  15. this.name_obj_ = UTY.GetChildObject(childObject, "Name", false);
  16. this.stargroup_obj_ = UTY.GetChildObject(childObject, "StarGroup", false);
  17. GameObject childObject2 = UTY.GetChildObject(childObject, "UnderGroup", false);
  18. this.acquired_experience_obj = UTY.GetChildObject(UTY.GetChildObject(childObject2, "AcquiredExperience", false), "Value", false);
  19. this.cost_of_hp_obj = UTY.GetChildObject(UTY.GetChildObject(childObject2, "CostOfHp", false), "Value", false);
  20. this.button_ = UTY.GetChildObject(base.gameObject, "Button", false).GetComponent<UIButton>();
  21. this.mouseEventObject = UTY.GetChildObject(base.gameObject, "OverHit", false);
  22. UIEventTrigger component = this.mouseEventObject.GetComponent<UIEventTrigger>();
  23. EventDelegate.Add(component.onHoverOver, new EventDelegate.Callback(this.OnHoverOverItem));
  24. EventDelegate.Add(component.onHoverOut, new EventDelegate.Callback(this.OnHoverOutItem));
  25. EventDelegate.Add(component.onRelease, new EventDelegate.Callback(this.OnHoverOutItem));
  26. this.mouseEventObject.SetActive(false);
  27. }
  28. public void SetConditionsPanel(GameObject conditionsObject)
  29. {
  30. this.conditionsObject = conditionsObject;
  31. this.conditionList = conditionsObject.GetComponentInChildren<UIWFConditionList>();
  32. NDebug.AssertNull(this.conditionList != null);
  33. this.conditionBG = UTY.GetChildObject(conditionsObject, "BG", false).GetComponent<UIWidget>();
  34. this.conditionTitleLabel = UTY.GetChildObject(conditionsObject, "Condition/Title/Name", false).GetComponent<UILabel>();
  35. this.initCondtionTitleFontSize = this.conditionTitleLabel.fontSize;
  36. conditionsObject.SetActive(false);
  37. }
  38. public bool isEnabled
  39. {
  40. get
  41. {
  42. return this.button_.isEnabled;
  43. }
  44. set
  45. {
  46. if (this.lock_unit_ != null)
  47. {
  48. this.lock_unit_.enabled = value;
  49. }
  50. this.button_.isEnabled = value;
  51. if (!value)
  52. {
  53. this.new_icon_.color = new Color(0.5f, 0.5f, 0.5f, this.new_icon_.color.a);
  54. this.icon_.color = Color.gray;
  55. }
  56. else
  57. {
  58. this.new_icon_.color = new Color(1f, 1f, 1f, this.new_icon_.color.a);
  59. this.icon_.color = Color.white;
  60. if (this.lock_unit_ != null)
  61. {
  62. this.lock_unit_.SetSkillData(this.param_data_);
  63. }
  64. }
  65. this.mouseEventObject.SetActive(!value);
  66. }
  67. }
  68. public void SetSkillData(Maid maid, Skill.Data set_skill_data, YotogiSkillData param_data, YotogiSkillLockUnit lock_unit, KeyValuePair<string, bool>[] conditionDatas = null)
  69. {
  70. this.maid_ = maid;
  71. this.skill_data_ = set_skill_data;
  72. this.param_data_ = param_data;
  73. this.lock_unit_ = lock_unit;
  74. this.conditionDatas_ = null;
  75. if (this.lock_unit_ != null)
  76. {
  77. this.lock_unit_.SetSkillData(param_data);
  78. }
  79. this.name_obj_.GetComponent<UILabel>().text = this.skill_data_.name;
  80. this.acquired_experience_obj.GetComponent<UILabel>().text = this.skill_data_.add_yotogi_class_exp.ToString();
  81. this.cost_of_hp_obj.GetComponent<UILabel>().text = this.skill_data_.exec_need_hp.ToString();
  82. this.icon_.SetSkillData(this.skill_data_);
  83. if (this.param_data_ == null || 0u < this.param_data_.playCount)
  84. {
  85. this.new_icon_.gameObject.SetActive(false);
  86. }
  87. else
  88. {
  89. this.new_icon_.gameObject.SetActive(true);
  90. }
  91. this.UpdateGage((this.param_data_ == null) ? null : this.param_data_.expSystem);
  92. if (this.param_data_ == null)
  93. {
  94. if (conditionDatas != null && 0 < conditionDatas.Length)
  95. {
  96. this.conditionDatas_ = new KeyValuePair<string, Color>[conditionDatas.Length];
  97. int num = 0;
  98. foreach (KeyValuePair<string, bool> keyValuePair in conditionDatas)
  99. {
  100. this.conditionDatas_[num++] = new KeyValuePair<string, Color>(keyValuePair.Key, (!keyValuePair.Value) ? Color.gray : Color.white);
  101. }
  102. }
  103. this.isEnabled = false;
  104. }
  105. }
  106. public void SetExpAnime(int start_total_exp, int add_exp, float anime_time)
  107. {
  108. if (anime_time <= 0f)
  109. {
  110. return;
  111. }
  112. this.result_anime_exp_system_ = (SimpleExperienceSystem)this.param_data_.expSystem.Clone();
  113. this.result_anime_exp_system_.SetTotalExp(start_total_exp + add_exp);
  114. add_exp = this.result_anime_exp_system_.GetTotalExp() - start_total_exp;
  115. if (add_exp <= 0)
  116. {
  117. return;
  118. }
  119. this.result_anime_exp_system_.SetTotalExp(start_total_exp);
  120. this.UpdateGage(this.result_anime_exp_system_);
  121. this.anime_event_ = delegate
  122. {
  123. iTween.ValueTo(this.gameObject, iTween.Hash(new object[]
  124. {
  125. "from",
  126. start_total_exp,
  127. "to",
  128. start_total_exp + add_exp,
  129. "time",
  130. anime_time,
  131. "onupdate",
  132. "UpdateValue"
  133. }));
  134. };
  135. }
  136. public void StartAnime()
  137. {
  138. if (this.anime_event_ != null)
  139. {
  140. this.anime_event_();
  141. this.anime_event_ = null;
  142. }
  143. }
  144. public void UpdateValue(int value)
  145. {
  146. if (this.result_anime_exp_system_ == null)
  147. {
  148. return;
  149. }
  150. int currentLevel = this.result_anime_exp_system_.GetCurrentLevel();
  151. this.result_anime_exp_system_.SetTotalExp(value);
  152. if (currentLevel < this.result_anime_exp_system_.GetCurrentLevel() && !UTY.GetChildObject(base.gameObject, "levelup", false).activeSelf)
  153. {
  154. GameMain.Instance.SoundMgr.PlaySystem("SE008.ogg");
  155. UTY.GetChildObject(base.gameObject, "levelup", false).SetActive(true);
  156. }
  157. this.UpdateGage(this.result_anime_exp_system_);
  158. }
  159. public void UpdateGage(IExperienceSystem exp_system)
  160. {
  161. if (this.skill_data_ == null)
  162. {
  163. return;
  164. }
  165. int num = 0;
  166. if (exp_system != null)
  167. {
  168. num = exp_system.GetCurrentLevel();
  169. }
  170. GameObject[] array = new GameObject[3];
  171. for (int i = 0; i < array.Length; i++)
  172. {
  173. array[i] = UTY.GetChildObject(this.stargroup_obj_, "Star" + i.ToString(), false);
  174. array[i].SetActive(i <= num - 1);
  175. }
  176. float num2 = 0f;
  177. if (exp_system != null && exp_system.GetNextLevelExp(num) != 0)
  178. {
  179. num2 = (float)exp_system.GetCurrentExp() / (float)exp_system.GetNextLevelExp(num);
  180. }
  181. if (float.IsNaN(num2))
  182. {
  183. num2 = 0f;
  184. }
  185. else if (float.IsInfinity(num2))
  186. {
  187. num2 = 1f;
  188. }
  189. this.gauge_obj_.GetComponent<Transform>().localScale = new Vector3(num2, 1f, 1f);
  190. }
  191. private void OnHoverOverItem()
  192. {
  193. if (this.conditionsObject == null)
  194. {
  195. return;
  196. }
  197. if (this.conditionDatas_ == null)
  198. {
  199. this.OnHoverOutItem();
  200. return;
  201. }
  202. this.conditionTitleLabel.text = this.skill_data_.name + " 習得条件";
  203. if (20 < this.conditionTitleLabel.text.Length)
  204. {
  205. this.conditionTitleLabel.fontSize = 20;
  206. }
  207. else
  208. {
  209. this.conditionTitleLabel.fontSize = this.initCondtionTitleFontSize;
  210. }
  211. this.conditionList.SetTexts(this.conditionDatas_, -1);
  212. this.conditionBG.height = 90 + this.conditionList.height;
  213. this.conditionsObject.SetActive(true);
  214. }
  215. private void OnHoverOutItem()
  216. {
  217. if (this.conditionsObject == null)
  218. {
  219. return;
  220. }
  221. this.conditionsObject.SetActive(false);
  222. }
  223. public Skill.Data skill_data
  224. {
  225. get
  226. {
  227. return this.skill_data_;
  228. }
  229. }
  230. public YotogiSkillData skill_param_data
  231. {
  232. get
  233. {
  234. return this.param_data_;
  235. }
  236. }
  237. private Maid maid_;
  238. private Skill.Data skill_data_;
  239. private YotogiSkillData param_data_;
  240. private YotogiSkillLockUnit lock_unit_;
  241. private UIButton button_;
  242. private YotogiSkillIcon icon_;
  243. private UISprite new_icon_;
  244. private GameObject gauge_obj_;
  245. private GameObject name_obj_;
  246. private GameObject stargroup_obj_;
  247. private GameObject acquired_experience_obj;
  248. private GameObject cost_of_hp_obj;
  249. private GameObject mouseEventObject;
  250. private KeyValuePair<string, Color>[] conditionDatas_;
  251. private GameObject conditionsObject;
  252. private UILabel conditionTitleLabel;
  253. private UIWFConditionList conditionList;
  254. private UIWidget conditionBG;
  255. private int initCondtionTitleFontSize;
  256. private IExperienceSystem result_anime_exp_system_;
  257. private Action anime_event_;
  258. }