Newer
Older
DungeonShooting / DungeonShooting_Godot / src / game / ui / pauseMenu / PauseMenuPanel.cs
@小李xl 小李xl on 20 Sep 2023 1 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_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. }
  18.  
  19. public override void Process(float delta)
  20. {
  21. if (Input.IsActionJustPressed("ui_cancel")) //返回游戏
  22. {
  23. OnContinueClick();
  24. }
  25. }
  26.  
  27. //继续游戏
  28. private void OnContinueClick()
  29. {
  30. GameApplication.Instance.World.Pause = false;
  31. GameApplication.Instance.Cursor.SetGuiMode(false);
  32. Destroy();
  33. }
  34.  
  35. //重新开始
  36. private void OnRestartClick()
  37. {
  38. Destroy();
  39. if (GameApplication.Instance.DungeonManager.IsEditorMode) //在编辑器模式下打开的Ui
  40. {
  41. EditorPlayManager.Restart();
  42. }
  43. else //正常重新开始
  44. {
  45. GameApplication.Instance.DungeonManager.RestartDungeon(GameApplication.Instance.DungeonConfig);
  46. }
  47. }
  48.  
  49. //退出地牢
  50. private void OnExitClick()
  51. {
  52. Destroy();
  53. if (GameApplication.Instance.DungeonManager.IsEditorMode) //在编辑器模式下打开的Ui
  54. {
  55. EditorPlayManager.Exit();
  56. }
  57. else //正常关闭Ui
  58. {
  59. GameApplication.Instance.DungeonManager.ExitDungeon(() =>
  60. {
  61. UiManager.Open_Main();
  62. });
  63. }
  64. }
  65. }