EnemyGf_skill.cs 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180
  1. using Common.Utility.CombatEvent;
  2. using Core.Language;
  3. using Excel2Json;
  4. using Fort23.Core;
  5. using GameLogic.Combat.CombatTool;
  6. using GameLogic.Combat.Hero.Turntable;
  7. using GameLogic.Combat.Skill;
  8. using GameLogic.Player;
  9. using UnityEngine;
  10. namespace Fort23.Mono
  11. {
  12. [UIBinding(prefab = "EnemyGf_skill")]
  13. public partial class EnemyGf_skill : UIComponent
  14. {
  15. public SkillSlots SkillSlots;
  16. public SkillBasic SkillBasic;
  17. public float jd;
  18. public int useCount;
  19. public WuXingType HuangDaoWuXingType;
  20. public CombatHeroEntity combatHeroEntity;
  21. private void Init()
  22. {
  23. }
  24. public override void AddEvent()
  25. {
  26. CombatEventManager.Instance.AddEventListener(CombatEventType.SkillSlotsAlter, SkillSlotsAlter);
  27. CombatEventManager.Instance.AddEventListener(CombatEventType.HuangDaoAlterSlots, HuangDaoAlterSlots);
  28. }
  29. public override void DelEvent()
  30. {
  31. CombatEventManager.Instance.RemoveEventListener(CombatEventType.SkillSlotsAlter, SkillSlotsAlter);
  32. CombatEventManager.Instance.RemoveEventListener(CombatEventType.HuangDaoAlterSlots, HuangDaoAlterSlots);
  33. }
  34. private void HuangDaoAlterSlots(IEventData iEventData)
  35. {
  36. HuangDaoAlterSlotsEventData huangDaoAlterSlotsEventData = iEventData as HuangDaoAlterSlotsEventData;
  37. if (huangDaoAlterSlotsEventData.CombatHeroEntity != combatHeroEntity || SkillSlots == null)
  38. {
  39. return;
  40. }
  41. if (huangDaoAlterSlotsEventData.index != SkillSlots.index)
  42. {
  43. return;
  44. }
  45. HuangDaoWuXingType = huangDaoAlterSlotsEventData.WuXingType;
  46. switch ((int)HuangDaoWuXingType)
  47. {
  48. case 1:
  49. quan.color = new Color(1f, 0.98f, 0.09f);
  50. break;
  51. case 2:
  52. quan.color = new Color(0.19f, 0.51f, 1f);
  53. break;
  54. case 4:
  55. quan.color = new Color(0.17f, 1f, 0.35f);
  56. break;
  57. case 8:
  58. quan.color = new Color(1f, 0.19f, 0.04f);
  59. break;
  60. case 16:
  61. quan.color = new Color(1f, 0.65f, 0.17f);
  62. break;
  63. }
  64. }
  65. public void SkillSlotsAlter(IEventData eventData)
  66. {
  67. SkillSlotsAlterEventData skillSlotsAlterEventData = (SkillSlotsAlterEventData)eventData;
  68. if (skillSlotsAlterEventData.SkillSlots == SkillSlots)
  69. {
  70. SkillBasic = SkillSlots.SkillBasic;
  71. SetUIInfo();
  72. }
  73. }
  74. public override void AddButtonEvent()
  75. {
  76. mybutton.onClick.AddListener(OnClick);
  77. }
  78. private void OnClick()
  79. {
  80. SkillConfig skillConfig = SkillBasic.SelfSkillConfig;
  81. CombatController.currActiveCombat.isUpdate = false;
  82. SkillMassgePanel.OpenSkillSelectPanel(LanguageManager.Instance.Text(skillConfig.name), LanguageManager.Instance.Text(skillConfig.dec),
  83. delegate()
  84. {
  85. CombatController.currActiveCombat.isUpdate = true;
  86. });
  87. }
  88. private void SetUIInfo()
  89. {
  90. if (SkillBasic == null)
  91. {
  92. useSkillIcon.transform.parent.gameObject.SetActive(false);
  93. quan.color = new Color(1, 1, 1, 0.2f);
  94. // if (PlayerGf_widget != null)
  95. // {
  96. // PlayerGf_widget.Play("likai",false);
  97. // }
  98. return;
  99. }
  100. useSkillIcon.transform.parent.gameObject.SetActive(true);
  101. useSkillIcon.icon_name = SkillBasic.SelfSkillConfig.icon;
  102. cd.fillAmount = 0;
  103. if (SkillBasic.SelfSkillConfig.SkillType == 2)
  104. {
  105. quan.color = new Color(0.81f, 0.21f, 1f);
  106. return;
  107. }
  108. // useCount= SkillBasic.UseCount;
  109. switch (SkillBasic.SelfSkillConfig.attribute)
  110. {
  111. case 1:
  112. quan.color = new Color(1f, 0.98f, 0.09f);
  113. break;
  114. case 2:
  115. quan.color = new Color(0.19f, 0.51f, 1f);
  116. break;
  117. case 4:
  118. quan.color = new Color(0.17f, 1f, 0.35f);
  119. break;
  120. case 8:
  121. quan.color = new Color(1f, 0.19f, 0.04f);
  122. break;
  123. case 16:
  124. quan.color = new Color(1f, 0.65f, 0.17f);
  125. break;
  126. }
  127. }
  128. public void Update()
  129. {
  130. if (SkillSlots == null || SkillBasic == null)
  131. {
  132. return;
  133. }
  134. SkillBasic skillBasic = SkillBasic;
  135. if (skillBasic.SelfSkillConfig.SkillType != 1)
  136. {
  137. return;
  138. }
  139. float bl = 1 - SkillSlots.GetFinishBl();
  140. cd.fillAmount = bl;
  141. }
  142. public void InitSkillWidget(SkillBasic SkillBasic, CombatHeroEntity combatHeroEntity)
  143. {
  144. this.combatHeroEntity = combatHeroEntity;
  145. this.SkillBasic = SkillBasic;
  146. this.SkillSlots = null;
  147. SetUIInfo();
  148. }
  149. public void InitWidget(SkillSlots skillSlots, CombatHeroEntity combatHeroEntity)
  150. {
  151. this.combatHeroEntity = combatHeroEntity;
  152. this.SkillSlots = skillSlots;
  153. SkillBasic = skillSlots.SkillBasic;
  154. SetUIInfo();
  155. }
  156. }
  157. }