CombatHeroDiePanel.cs 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. using Core.Audio;
  2. using Fort23.Core;
  3. using GameLogic.Combat.CombatTool;
  4. using GameLogic.Combat.CombatType;
  5. namespace Fort23.Mono
  6. {
  7. [UIBinding(prefab = "CombatHeroDiePanel")]
  8. public partial class CombatHeroDiePanel : UIPanel
  9. {
  10. private int time;
  11. private TimerEntity _timerEntity;
  12. public static async void OpenCombatHeroDiePanel()
  13. {
  14. CombatHeroDiePanel combatHeroDiePanel =
  15. await UIManager.Instance.LoadAndOpenPanel<CombatHeroDiePanel>(null, layer: UILayer.Top);
  16. combatHeroDiePanel.ShowCombatHeroDiePanel();
  17. }
  18. private void Init()
  19. {
  20. }
  21. protected override void AddEvent()
  22. {
  23. }
  24. protected override void DelEvent()
  25. {
  26. }
  27. public override void AddButtonEvent()
  28. {
  29. Button_ok.onClick.AddListener(Button_ok_onClick);
  30. }
  31. private void Button_ok_onClick()
  32. {
  33. LevelBattleCombatType levelBattleCombatType =
  34. CombatController.currActiveCombat.CombatTypeBasic as LevelBattleCombatType;
  35. levelBattleCombatType.Resume();
  36. TimerComponent.Instance.Remove(_timerEntity);
  37. _timerEntity = null;
  38. UIManager.Instance.HideUIUIPanel(this);
  39. }
  40. public void ShowCombatHeroDiePanel()
  41. {
  42. AudioManager.Instance.PauseBGM();
  43. AudioManager.Instance.PlayAudio("shibai.wav");
  44. time = 30;
  45. clickTime.text = time.ToString();
  46. _timerEntity = TimerComponent.Instance.AddTimer(1000, delegate { }, 10000, delegate
  47. {
  48. if (_timerEntity == null)
  49. {
  50. return;
  51. }
  52. time--;
  53. clickTime.text = time.ToString();
  54. if (time <= 0)
  55. {
  56. TimerComponent.Instance.Remove(_timerEntity);
  57. _timerEntity = null;
  58. Button_ok_onClick();
  59. }
  60. });
  61. }
  62. }
  63. }