gf_widget.cs 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143
  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.icon_name=SkillBasic.SelfSkillConfig.icon;
  84. cd.fillAmount = 0;
  85. if (SkillBasic.SelfSkillConfig.SkillType == 2)
  86. {
  87. quan.color = new Color(0.81f, 0.21f, 1f);
  88. return;
  89. }
  90. quan.color = CombatCalculateTool.Instance.GetColor((WuXingType)SkillBasic.SelfSkillConfig.attribute);
  91. }
  92. public void Update()
  93. {
  94. if (SkillSlots == null || SkillBasic == null)
  95. {
  96. return;
  97. }
  98. SkillBasic skillBasic = SkillBasic;
  99. if (skillBasic.SelfSkillConfig.SkillType != 1)
  100. {
  101. return;
  102. }
  103. float bl = 1 - SkillSlots.GetFinishBl();
  104. cd.fillAmount = bl;
  105. }
  106. public void InitSkillWidget(SkillBasic SkillBasic, CombatHeroEntity combatHeroEntity)
  107. {
  108. this.combatHeroEntity = combatHeroEntity;
  109. this.SkillBasic = SkillBasic;
  110. this.SkillSlots = null;
  111. SetUIInfo();
  112. }
  113. public void InitWidget(SkillSlots skillSlots, CombatHeroEntity combatHeroEntity)
  114. {
  115. this.combatHeroEntity = combatHeroEntity;
  116. this.SkillSlots = skillSlots;
  117. SkillBasic = skillSlots.SkillBasic;
  118. SetUIInfo();
  119. }
  120. }
  121. }