Newer
Older
DungeonShooting / DungeonShooting_Godot / src / game / ui / pauseMenu / PauseMenuPanel.cs
  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_Restart.Instance.Pressed += OnRestartClick;
  12. S_Exit.Instance.Pressed += OnExitClick;
  13. if (GameApplication.Instance.DungeonManager.IsEditorMode) //在编辑器模式下打开的Ui
  14. {
  15. S_Exit.Instance.Text = "返回编辑器";
  16. }
  17. else if (World.Current is Dungeon) //在游戏地牢中
  18. {
  19. S_Exit.Instance.Text = "退出地牢";
  20. }
  21. else //在大厅中
  22. {
  23. S_Restart.Instance.Visible = false;
  24. }
  25. }
  26.  
  27. public override void Process(float delta)
  28. {
  29. if (Input.IsActionJustPressed("ui_cancel")) //返回游戏
  30. {
  31. OnContinueClick();
  32. }
  33. }
  34.  
  35. //继续游戏
  36. private void OnContinueClick()
  37. {
  38. World.Current.Pause = false;
  39. GameApplication.Instance.Cursor.SetGuiMode(false);
  40. Destroy();
  41. }
  42.  
  43. //重新开始
  44. private void OnRestartClick()
  45. {
  46. Destroy();
  47. if (GameApplication.Instance.DungeonManager.IsEditorMode) //在编辑器模式下打开的Ui
  48. {
  49. EditorPlayManager.Restart();
  50. }
  51. else //正常重新开始
  52. {
  53. UiManager.Open_Loading();
  54. GameApplication.Instance.DungeonManager.RestartDungeon(false, GameApplication.Instance.DungeonConfig, () =>
  55. {
  56. UiManager.Destroy_Loading();
  57. });
  58. }
  59. }
  60.  
  61. //退出地牢
  62. private void OnExitClick()
  63. {
  64. Destroy();
  65. if (GameApplication.Instance.DungeonManager.IsEditorMode) //在编辑器模式下打开的Ui
  66. {
  67. EditorPlayManager.Exit();
  68. }
  69. else if (World.Current is Dungeon) //在游戏地牢中
  70. {
  71. UiManager.Open_Loading();
  72. GameApplication.Instance.DungeonManager.ExitDungeon(false, () =>
  73. {
  74. GameApplication.Instance.DungeonManager.LoadHall(() =>
  75. {
  76. UiManager.Destroy_Loading();
  77. });
  78. });
  79. }
  80. else //在大厅中
  81. {
  82. UiManager.Open_Loading();
  83. GameApplication.Instance.DungeonManager.ExitHall(false, () =>
  84. {
  85. UiManager.Destroy_Loading();
  86. UiManager.Open_Main();
  87. });
  88. }
  89. }
  90. }