YotogiSkillUnit.cs 8.6 KB

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