Newer
Older
DungeonShooting / DungeonShooting_Godot / src / game / ui / pauseMenu / PauseMenuPanel.cs
@小李xl 小李xl on 13 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. public override void OnShowUi()
  29. {
  30. GameCamera.Main.LockCamera();
  31. }
  32. public override void OnHideUi()
  33. {
  34. GameCamera.Main.UnLockCamera();
  35. }
  36.  
  37. public override void Process(float delta)
  38. {
  39. if (Input.IsActionJustPressed("ui_cancel")) //返回游戏
  40. {
  41. OnContinueClick();
  42. }
  43. }
  44.  
  45. //继续游戏
  46. private void OnContinueClick()
  47. {
  48. World.Current.Pause = false;
  49. GameApplication.Instance.Cursor.SetGuiMode(false);
  50. Destroy();
  51. }
  52.  
  53. //设置
  54. private void OnSettingClick()
  55. {
  56. OpenNextUi(UiManager.UiNames.Setting);
  57. }
  58.  
  59. //图鉴
  60. private void OnEncyclopediaClick()
  61. {
  62. OpenNextUi(UiManager.UiNames.Encyclopedia);
  63. }
  64.  
  65. //重新开始
  66. private void OnRestartClick()
  67. {
  68. Destroy();
  69. if (GameApplication.Instance.DungeonManager.IsEditorMode) //在编辑器模式下打开的Ui
  70. {
  71. EditorPlayManager.Restart();
  72. }
  73. else //正常重新开始
  74. {
  75. UiManager.Open_Loading();
  76. GameApplication.Instance.DungeonManager.RestartDungeon(false, GameApplication.Instance.DungeonConfig, () =>
  77. {
  78. UiManager.Destroy_Loading();
  79. });
  80. }
  81. }
  82.  
  83. //退出地牢
  84. private void OnExitClick()
  85. {
  86. Destroy();
  87. if (GameApplication.Instance.DungeonManager.IsEditorMode) //在编辑器模式下打开的Ui
  88. {
  89. EditorPlayManager.Exit();
  90. }
  91. else if (World.Current is Dungeon) //在游戏地牢中
  92. {
  93. UiManager.Open_Loading();
  94. GameApplication.Instance.DungeonManager.ExitDungeon(false, () =>
  95. {
  96. GameApplication.Instance.DungeonManager.LoadHall(() =>
  97. {
  98. UiManager.Destroy_Loading();
  99. });
  100. });
  101. }
  102. else //在大厅中
  103. {
  104. UiManager.Open_Loading();
  105. GameApplication.Instance.DungeonManager.ExitHall(false, () =>
  106. {
  107. UiManager.Destroy_Loading();
  108. UiManager.Open_Main();
  109. });
  110. }
  111. }
  112. }