gf_widget.cs 4.4 KB

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