gf_widget.cs 5.5 KB

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