CombatPanel.cs 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162
  1. using System;
  2. using System.Collections.Generic;
  3. using Common.Utility.CombatEvent;
  4. using Excel2Json;
  5. using Fort23.Core;
  6. using GameLogic.Bag;
  7. using GameLogic.Combat.CombatTool;
  8. using GameLogic.Combat.Skill;
  9. using UnityEngine;
  10. namespace Fort23.Mono
  11. {
  12. [UIBinding(prefab = "CombatPanel")]
  13. public partial class CombatPanel : UIPanel
  14. {
  15. private ZhuanPanPanel zhuanPanLogic;
  16. public static async CTask OpenCombatPanel()
  17. {
  18. CombatPanel combatPanel = await UIManager.Instance.LoadAndOpenPanel<CombatPanel>(null, UILayer.Middle);
  19. await combatPanel.ShowPanel();
  20. }
  21. protected override async CTask ProOpen()
  22. {
  23. zhuanPanLogic =
  24. await UIManager.Instance.CreateGComponentForObject<ZhuanPanPanel>(ZhuanPanPanel, null, null);
  25. zhuanPanLogic.ShowPanel();
  26. }
  27. private void Init()
  28. {
  29. }
  30. protected override void AddEvent()
  31. {
  32. CombatEventManager.Instance.AddEventListener(CombatEventType.AddRandomEvent, AddRandomEventEventData);
  33. CombatEventManager.Instance.AddEventListener(CombatEventType.AddMagicWeaponHeroEntity,
  34. AddMagicWeaponHeroEntity);
  35. CombatEventManager.Instance.AddEventListener(CombatEventType.AddUseGongFa, AddUseGongFa);
  36. StaticUpdater.Instance.AddLateUpdateCallBack(Update);
  37. CameraSelect.value = 0.7f;
  38. }
  39. private async void AddUseGongFa(IEventData ieveData)
  40. {
  41. AddUseGongFaEventData eventData = ieveData as AddUseGongFaEventData;
  42. SkillBasic skillBasic = eventData.SkillBasic;
  43. if (skillBasic.CombatHeroEntity.IsEnemy)
  44. {
  45. return;
  46. }
  47. UseQuqueSkill useQuqueSkill =
  48. await UIManager.Instance.CreateGComponentForObject<UseQuqueSkill>(UseQuqueSkill, null,
  49. UseQuqueSkillRoot, isInstance: true);
  50. useQuqueSkill.ShowWidget(skillBasic);
  51. useQuqueSkill.transform.SetAsLastSibling();
  52. }
  53. private async void AddMagicWeaponHeroEntity(IEventData ieveData)
  54. {
  55. AddMagicWeaponHeroEntityEventData eventData = ieveData as AddMagicWeaponHeroEntityEventData;
  56. MagicWeaponWidget shengShiEventWidget =
  57. await UIManager.Instance.CreateGComponentForObject<MagicWeaponWidget>(MagicWeaponWidget, null,
  58. MagicWeapon,
  59. isInstance: true);
  60. shengShiEventWidget.InitWidget(eventData.CombatMagicWeaponEntity);
  61. // shengShiEventWidget.InitShengShiEventWidget(configId);
  62. }
  63. private async void AddRandomEventEventData(IEventData ieveData)
  64. {
  65. AddRandomEventEventData eventData = ieveData as AddRandomEventEventData;
  66. int configId = eventData.randomEventID;
  67. ShengShiEventWidget shengShiEventWidget =
  68. await UIManager.Instance.CreateGComponentForObject<ShengShiEventWidget>(ShengShiEventWidget, null,
  69. DynamicEvent,
  70. isInstance: true);
  71. shengShiEventWidget.InitShengShiEventWidget(configId);
  72. }
  73. public async CTask ShowPanel()
  74. {
  75. HeroHpWidget heroHpWidget =
  76. await UIManager.Instance.CreateGComponentForObject<HeroHpWidget>(PlayerHpWidget, null);
  77. heroHpWidget.size = 250;
  78. heroHpWidget.shieldSize = 100;
  79. heroHpWidget.isFollowTarget = false;
  80. heroHpWidget.Init(CombatController.currActiveCombat.CombatHeroController.playerHeroEntity);
  81. CombatHeroEntity[] allEnemy = CombatController.currActiveCombat.CombatHeroController.GetHero(true);
  82. for (int i = 0; i < allEnemy.Length; i++)
  83. {
  84. CombatHeroEntity enemy = allEnemy[i];
  85. BossHpWidget bossHpWidget =
  86. await UIManager.Instance.CreateGComponentForObject<BossHpWidget>(BossHpWidget, null, BossHpRoot,
  87. isInstance: true);
  88. bossHpWidget.ShowWidget(enemy);
  89. }
  90. }
  91. protected override void DelEvent()
  92. {
  93. CombatEventManager.Instance.RemoveEventListener(CombatEventType.AddRandomEvent, AddRandomEventEventData);
  94. CombatEventManager.Instance.RemoveEventListener(CombatEventType.AddMagicWeaponHeroEntity,
  95. AddMagicWeaponHeroEntity);
  96. StaticUpdater.Instance.RemoveLateUpdateCallBack(Update);
  97. }
  98. public override void AddButtonEvent()
  99. {
  100. bnt_shengShi.onClick.AddListener(Bnt_shengShi_onClick);
  101. CameraSelect.onValueChanged.AddListener(CameraSelect_onValueChanged);
  102. AutoUse.onValueChanged.AddListener((x) =>
  103. {
  104. CombatController.currActiveCombat.CombatHeroController.playerHeroEntity.MagicWeaponControl.isAutoUse =
  105. x;
  106. });
  107. }
  108. private async void Bnt_shengShi_onClick()
  109. {
  110. UIManager.Instance.DormancyAllGComponent<ShengShiEventWidget>();
  111. CombatController.currActiveCombat.CombatSenceController.StartPayShengShi(CombatController.currActiveCombat
  112. .CombatHeroController.playerHeroEntity.GameObject.transform);
  113. List<EventConfig> eventConfigs = EventSystemManager.Instance.UseDivinesense(1);
  114. if (eventConfigs == null || eventConfigs.Count == 0)
  115. return;
  116. for (var i = 0; i < eventConfigs.Count; i++)
  117. {
  118. ShengShiEventWidget shengShiEventWidget =
  119. await UIManager.Instance.CreateGComponentForObject<ShengShiEventWidget>(ShengShiEventWidget, null,
  120. DynamicEvent,
  121. isInstance: true);
  122. shengShiEventWidget.InitShengShiEventWidget(eventConfigs[i].ID);
  123. }
  124. //
  125. // CombatController.currActiveCombat.RandomEventController.StartRandomEvent(CombatController.currActiveCombat
  126. // .CombatHeroController.playerHeroEntity.GameObject.transform);
  127. }
  128. private void CameraSelect_onValueChanged(float value)
  129. {
  130. if (CombatController.currActiveCombat == null ||
  131. CombatController.currActiveCombat.CombatCameraControllder == null)
  132. {
  133. return;
  134. }
  135. CombatController.currActiveCombat.CombatCameraControllder.CameraSelect_onValueChanged(value);
  136. }
  137. public void Update()
  138. {
  139. }
  140. }
  141. }