YotogiSkillUnit.cs 9.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321
  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. if (Product.supportMultiLanguage)
  85. {
  86. Localize component = this.cost_of_hp_obj.transform.parent.GetComponent<Localize>();
  87. if (component != null)
  88. {
  89. component.TermArgs = new Localize.ArgsPair[]
  90. {
  91. Localize.ArgsPair.Create(this.skill_data_.exec_need_hp.ToString())
  92. };
  93. component.SetTerm("SceneYotogi/消費体力プラス数値");
  94. this.cost_of_hp_obj.SetActive(false);
  95. }
  96. }
  97. this.icon_.SetSkillData(this.skill_data_);
  98. if (this.param_data_ == null || 0u < this.param_data_.playCount)
  99. {
  100. this.new_icon_.gameObject.SetActive(false);
  101. }
  102. else
  103. {
  104. this.new_icon_.gameObject.SetActive(true);
  105. }
  106. this.UpdateGage((this.param_data_ == null) ? null : this.param_data_.expSystem);
  107. if (this.param_data_ == null)
  108. {
  109. if (conditionDatas != null && 0 < conditionDatas.Length)
  110. {
  111. this.conditionDatas_ = new KeyValuePair<string[], Color>[conditionDatas.Length];
  112. int num = 0;
  113. foreach (KeyValuePair<string[], bool> keyValuePair in conditionDatas)
  114. {
  115. this.conditionDatas_[num++] = new KeyValuePair<string[], Color>(keyValuePair.Key, (!keyValuePair.Value) ? Color.gray : Color.white);
  116. }
  117. }
  118. this.isEnabled = false;
  119. }
  120. }
  121. public void SetExpAnime(int start_total_exp, int add_exp, float anime_time)
  122. {
  123. if (anime_time <= 0f)
  124. {
  125. return;
  126. }
  127. this.result_anime_exp_system_ = (SimpleExperienceSystem)this.param_data_.expSystem.Clone();
  128. this.result_anime_exp_system_.SetTotalExp(start_total_exp + add_exp);
  129. add_exp = this.result_anime_exp_system_.GetTotalExp() - start_total_exp;
  130. if (add_exp <= 0)
  131. {
  132. return;
  133. }
  134. this.result_anime_exp_system_.SetTotalExp(start_total_exp);
  135. this.UpdateGage(this.result_anime_exp_system_);
  136. this.anime_event_ = delegate()
  137. {
  138. iTween.ValueTo(this.gameObject, iTween.Hash(new object[]
  139. {
  140. "from",
  141. start_total_exp,
  142. "to",
  143. start_total_exp + add_exp,
  144. "time",
  145. anime_time,
  146. "onupdate",
  147. "UpdateValue"
  148. }));
  149. };
  150. }
  151. public void StartAnime()
  152. {
  153. if (this.anime_event_ != null)
  154. {
  155. this.anime_event_();
  156. this.anime_event_ = null;
  157. }
  158. }
  159. public void UpdateValue(int value)
  160. {
  161. if (this.result_anime_exp_system_ == null)
  162. {
  163. return;
  164. }
  165. int currentLevel = this.result_anime_exp_system_.GetCurrentLevel();
  166. this.result_anime_exp_system_.SetTotalExp(value);
  167. if (currentLevel < this.result_anime_exp_system_.GetCurrentLevel() && !UTY.GetChildObject(base.gameObject, "levelup", false).activeSelf)
  168. {
  169. GameMain.Instance.SoundMgr.PlaySystem("SE008.ogg");
  170. UTY.GetChildObject(base.gameObject, "levelup", false).SetActive(true);
  171. }
  172. this.UpdateGage(this.result_anime_exp_system_);
  173. }
  174. public void UpdateGage(IExperienceSystem exp_system)
  175. {
  176. if (this.skill_data_ == null)
  177. {
  178. return;
  179. }
  180. int num = 0;
  181. if (exp_system != null)
  182. {
  183. num = exp_system.GetCurrentLevel();
  184. }
  185. GameObject[] array = new GameObject[3];
  186. for (int i = 0; i < array.Length; i++)
  187. {
  188. array[i] = UTY.GetChildObject(this.stargroup_obj_, "Star" + i.ToString(), false);
  189. array[i].SetActive(i <= num - 1);
  190. }
  191. float num2 = 0f;
  192. if (exp_system != null && exp_system.GetNextLevelExp(num) != 0)
  193. {
  194. num2 = (float)exp_system.GetCurrentExp() / (float)exp_system.GetNextLevelExp(num);
  195. }
  196. if (float.IsNaN(num2))
  197. {
  198. num2 = 0f;
  199. }
  200. else if (float.IsInfinity(num2))
  201. {
  202. num2 = 1f;
  203. }
  204. this.gauge_obj_.GetComponent<Transform>().localScale = new Vector3(num2, 1f, 1f);
  205. }
  206. private void OnHoverOverItem()
  207. {
  208. if (this.conditionsObject == null)
  209. {
  210. return;
  211. }
  212. if (this.conditionDatas_ == null)
  213. {
  214. this.OnHoverOutItem();
  215. return;
  216. }
  217. this.conditionTitleLabel.text = this.skill_data_.name + " 習得条件";
  218. if (Product.supportMultiLanguage)
  219. {
  220. Localize component = this.conditionTitleLabel.GetComponent<Localize>();
  221. if (component != null)
  222. {
  223. string termName = this.skill_data_.termName;
  224. Localize.ArgsPair[] termArgs = new Localize.ArgsPair[]
  225. {
  226. Localize.ArgsPair.Create(" {0}", false),
  227. Localize.ArgsPair.Create("System/取得条件", true)
  228. };
  229. component.TermArgs = termArgs;
  230. component.SetTerm(termName);
  231. }
  232. }
  233. else if (20 < this.conditionTitleLabel.text.Length)
  234. {
  235. this.conditionTitleLabel.fontSize = 20;
  236. }
  237. else
  238. {
  239. this.conditionTitleLabel.fontSize = this.initCondtionTitleFontSize;
  240. }
  241. this.conditionList.SetTexts(this.conditionDatas_, -1);
  242. this.conditionBG.height = 90 + this.conditionList.height;
  243. this.conditionsObject.SetActive(true);
  244. }
  245. private void OnHoverOutItem()
  246. {
  247. if (this.conditionsObject == null)
  248. {
  249. return;
  250. }
  251. this.conditionsObject.SetActive(false);
  252. }
  253. public Skill.Data skill_data
  254. {
  255. get
  256. {
  257. return this.skill_data_;
  258. }
  259. }
  260. public YotogiSkillData skill_param_data
  261. {
  262. get
  263. {
  264. return this.param_data_;
  265. }
  266. }
  267. private Maid maid_;
  268. private Skill.Data skill_data_;
  269. private YotogiSkillData param_data_;
  270. private YotogiSkillLockUnit lock_unit_;
  271. private UIButton button_;
  272. private YotogiSkillIcon icon_;
  273. private UISprite new_icon_;
  274. private GameObject gauge_obj_;
  275. private GameObject name_obj_;
  276. private GameObject stargroup_obj_;
  277. private GameObject acquired_experience_obj;
  278. private GameObject cost_of_hp_obj;
  279. private GameObject mouseEventObject;
  280. private KeyValuePair<string[], Color>[] conditionDatas_;
  281. private GameObject conditionsObject;
  282. private UILabel conditionTitleLabel;
  283. private UIWFConditionList conditionList;
  284. private UIWidget conditionBG;
  285. private int initCondtionTitleFontSize;
  286. private IExperienceSystem result_anime_exp_system_;
  287. private Action anime_event_;
  288. }