Newer
Older
DungeonShooting / DungeonShooting_Godot / src / game / ui / pauseMenu / PauseMenuPanel.cs
@小李xl 小李xl on 9 Mar 2024 2 KB 制作图鉴
  1. using Godot;
  2.  
  3. namespace UI.PauseMenu;
  4.  
  5. public partial class PauseMenuPanel : PauseMenu
  6. {
  7.  
  8. public override void OnCreateUi()
  9. {
  10. S_Continue.Instance.Pressed += OnContinueClick;
  11. S_Setting.Instance.Pressed += OnSettingClick;
  12. S_Encyclopedia.Instance.Pressed += OnEncyclopediaClick;
  13. S_Restart.Instance.Pressed += OnRestartClick;
  14. S_Exit.Instance.Pressed += OnExitClick;
  15. if (GameApplication.Instance.DungeonManager.IsEditorMode) //在编辑器模式下打开的Ui
  16. {
  17. S_Exit.Instance.Text = "返回编辑器";
  18. }
  19. else if (World.Current is Dungeon) //在游戏地牢中
  20. {
  21. S_Exit.Instance.Text = "退出地牢";
  22. }
  23. else //在大厅中
  24. {
  25. S_Restart.Instance.Visible = false;
  26. }
  27. }
  28.  
  29. public override void Process(float delta)
  30. {
  31. if (Input.IsActionJustPressed("ui_cancel")) //返回游戏
  32. {
  33. OnContinueClick();
  34. }
  35. }
  36.  
  37. //继续游戏
  38. private void OnContinueClick()
  39. {
  40. World.Current.Pause = false;
  41. GameApplication.Instance.Cursor.SetGuiMode(false);
  42. Destroy();
  43. }
  44.  
  45. //设置
  46. private void OnSettingClick()
  47. {
  48. OpenNextUi(UiManager.UiNames.Setting);
  49. }
  50.  
  51. //图鉴
  52. private void OnEncyclopediaClick()
  53. {
  54. OpenNextUi(UiManager.UiNames.Encyclopedia);
  55. }
  56.  
  57. //重新开始
  58. private void OnRestartClick()
  59. {
  60. Destroy();
  61. if (GameApplication.Instance.DungeonManager.IsEditorMode) //在编辑器模式下打开的Ui
  62. {
  63. EditorPlayManager.Restart();
  64. }
  65. else //正常重新开始
  66. {
  67. UiManager.Open_Loading();
  68. GameApplication.Instance.DungeonManager.RestartDungeon(false, GameApplication.Instance.DungeonConfig, () =>
  69. {
  70. UiManager.Destroy_Loading();
  71. });
  72. }
  73. }
  74.  
  75. //退出地牢
  76. private void OnExitClick()
  77. {
  78. Destroy();
  79. if (GameApplication.Instance.DungeonManager.IsEditorMode) //在编辑器模式下打开的Ui
  80. {
  81. EditorPlayManager.Exit();
  82. }
  83. else if (World.Current is Dungeon) //在游戏地牢中
  84. {
  85. UiManager.Open_Loading();
  86. GameApplication.Instance.DungeonManager.ExitDungeon(false, () =>
  87. {
  88. GameApplication.Instance.DungeonManager.LoadHall(() =>
  89. {
  90. UiManager.Destroy_Loading();
  91. });
  92. });
  93. }
  94. else //在大厅中
  95. {
  96. UiManager.Open_Loading();
  97. GameApplication.Instance.DungeonManager.ExitHall(false, () =>
  98. {
  99. UiManager.Destroy_Loading();
  100. UiManager.Open_Main();
  101. });
  102. }
  103. }
  104. }