diff --git a/DungeonShooting_Godot/DungeonShooting.csproj b/DungeonShooting_Godot/DungeonShooting.csproj index 69ed320..4546f15 100644 --- a/DungeonShooting_Godot/DungeonShooting.csproj +++ b/DungeonShooting_Godot/DungeonShooting.csproj @@ -1,4 +1,4 @@ - + net6.0 true diff --git a/DungeonShooting_Godot/DungeonShooting.csproj.old.2 b/DungeonShooting_Godot/DungeonShooting.csproj.old.2 new file mode 100644 index 0000000..69ed320 --- /dev/null +++ b/DungeonShooting_Godot/DungeonShooting.csproj.old.2 @@ -0,0 +1,11 @@ + + + net6.0 + true + + + + + + + \ No newline at end of file diff --git a/DungeonShooting_Godot/project.godot b/DungeonShooting_Godot/project.godot index 4a33b1d..601f8cb 100644 --- a/DungeonShooting_Godot/project.godot +++ b/DungeonShooting_Godot/project.godot @@ -109,7 +109,7 @@ } fire={ "deadzone": 0.5, -"events": [Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"button_mask":0,"position":Vector2(0, 0),"global_position":Vector2(0, 0),"factor":1.0,"button_index":1,"pressed":false,"double_click":false,"script":null) +"events": [Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"button_mask":0,"position":Vector2(0, 0),"global_position":Vector2(0, 0),"factor":1.0,"button_index":1,"canceled":false,"pressed":false,"double_click":false,"script":null) ] } move_left={ @@ -144,12 +144,12 @@ } mouse_roll_up={ "deadzone": 0.5, -"events": [Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"button_mask":0,"position":Vector2(0, 0),"global_position":Vector2(0, 0),"factor":1.0,"button_index":4,"pressed":false,"double_click":false,"script":null) +"events": [Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"button_mask":0,"position":Vector2(0, 0),"global_position":Vector2(0, 0),"factor":1.0,"button_index":4,"canceled":false,"pressed":false,"double_click":false,"script":null) ] } mouse_roll_down={ "deadzone": 0.5, -"events": [Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"button_mask":0,"position":Vector2(0, 0),"global_position":Vector2(0, 0),"factor":1.0,"button_index":5,"pressed":false,"double_click":false,"script":null) +"events": [Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"button_mask":0,"position":Vector2(0, 0),"global_position":Vector2(0, 0),"factor":1.0,"button_index":5,"canceled":false,"pressed":false,"double_click":false,"script":null) ] } interactive={ @@ -164,7 +164,7 @@ } meleeAttack={ "deadzone": 0.5, -"events": [Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"button_mask":2,"position":Vector2(34.8, 12.8),"global_position":Vector2(38, 46),"factor":1.0,"button_index":2,"pressed":true,"double_click":false,"script":null) +"events": [Object(InputEventMouseButton,"resource_local_to_scene":false,"resource_name":"","device":-1,"window_id":0,"alt_pressed":false,"shift_pressed":false,"ctrl_pressed":false,"meta_pressed":false,"button_mask":2,"position":Vector2(34.8, 12.8),"global_position":Vector2(38, 46),"factor":1.0,"button_index":2,"canceled":false,"pressed":true,"double_click":false,"script":null) ] } roll={ diff --git a/DungeonShooting_Godot/src/game/GameApplication.cs b/DungeonShooting_Godot/src/game/GameApplication.cs index c340fe1..704edb3 100644 --- a/DungeonShooting_Godot/src/game/GameApplication.cs +++ b/DungeonShooting_Godot/src/game/GameApplication.cs @@ -75,6 +75,11 @@ /// 像素缩放 /// public int PixelScale { get; private set; } = 4; + + /// + /// 地牢配置信息 + /// + public DungeonConfig DungeonConfig { get; private set; } //开启的协程 private List _coroutineList; @@ -87,6 +92,10 @@ //初始化 ActivityObject ActivityObject.InitActivity(); + + DungeonConfig = new DungeonConfig(); + DungeonConfig.GroupName = "testGroup"; + DungeonConfig.RoomCount = 20; } public override void _EnterTree() diff --git a/DungeonShooting_Godot/src/game/room/DungeonManager.cs b/DungeonShooting_Godot/src/game/room/DungeonManager.cs index 7f8ec97..9806ca5 100644 --- a/DungeonShooting_Godot/src/game/room/DungeonManager.cs +++ b/DungeonShooting_Godot/src/game/room/DungeonManager.cs @@ -53,19 +53,19 @@ /// /// 加载地牢 /// - public void LoadDungeon(DungeonConfig config) + public void LoadDungeon(DungeonConfig config, Action finish = null) { _config = config; - GameApplication.Instance.StartCoroutine(RunLoadDungeonCoroutine()); + GameApplication.Instance.StartCoroutine(RunLoadDungeonCoroutine(finish)); } /// /// 退出地牢 /// - public void ExitDungeon() + public void ExitDungeon(Action finish = null) { IsInDungeon = false; - GameApplication.Instance.StartCoroutine(RunExitDungeonCoroutine()); + GameApplication.Instance.StartCoroutine(RunExitDungeonCoroutine(finish)); } public override void _PhysicsProcess(double delta) @@ -95,11 +95,11 @@ } //执行加载地牢协程 - private IEnumerator RunLoadDungeonCoroutine() + private IEnumerator RunLoadDungeonCoroutine(Action finish) { - yield return 0; //打开 loading UI UiManager.Open_Loading(); + yield return 0; //创建世界场景 _world = GameApplication.Instance.CreateNewWorld(); yield return new WaitForFixedProcess(10); @@ -157,20 +157,24 @@ roomUi.InitData(player); //派发进入地牢事件 EventManager.EmitEvent(EventEnum.OnEnterDungeon); - //关闭 loading UI - UiManager.Dispose_Loading(); IsInDungeon = true; yield return 0; + //关闭 loading UI + UiManager.Dispose_Loading(); + if (finish != null) + { + finish(); + } } - private IEnumerator RunExitDungeonCoroutine() + private IEnumerator RunExitDungeonCoroutine(Action finish) { + //打开 loading UI + UiManager.Open_Loading(); yield return 0; _world.Pause = true; yield return 0; - //打开 loading UI - UiManager.Open_Loading(); _dungeonGenerator.EachRoom(DisposeRoomInfo); yield return 0; _dungeonTile = null; @@ -189,9 +193,13 @@ GameApplication.Instance.Cursor.SetGuiMode(false); //派发退出地牢事件 EventManager.EmitEvent(EventEnum.OnExitDungeon); + yield return 0; //关闭 loading UI UiManager.Dispose_Loading(); - yield return 0; + if (finish != null) + { + finish(); + } } // 初始化房间 diff --git a/DungeonShooting_Godot/src/game/ui/main/MainPanel.cs b/DungeonShooting_Godot/src/game/ui/main/MainPanel.cs index 89a385b..0c0b36b 100644 --- a/DungeonShooting_Godot/src/game/ui/main/MainPanel.cs +++ b/DungeonShooting_Godot/src/game/ui/main/MainPanel.cs @@ -21,10 +21,7 @@ //点击开始游戏 private void OnStartGameClick() { - var config = new DungeonConfig(); - config.GroupName = "testGroup"; - config.RoomCount = 20; - GameApplication.Instance.DungeonManager.LoadDungeon(config); + GameApplication.Instance.DungeonManager.LoadDungeon(GameApplication.Instance.DungeonConfig); HideUi(); } diff --git a/DungeonShooting_Godot/src/game/ui/settlement/SettlementPanel.cs b/DungeonShooting_Godot/src/game/ui/settlement/SettlementPanel.cs index 831cd87..33ffc6d 100644 --- a/DungeonShooting_Godot/src/game/ui/settlement/SettlementPanel.cs +++ b/DungeonShooting_Godot/src/game/ui/settlement/SettlementPanel.cs @@ -19,14 +19,21 @@ private void OnRestartClick() { - GD.Print("重新开始还没做..."); + //GD.Print("重新开始还没做..."); + HideUi(); + GameApplication.Instance.DungeonManager.ExitDungeon(() => + { + GameApplication.Instance.DungeonManager.LoadDungeon(GameApplication.Instance.DungeonConfig); + }); } private void OnToMenuClick() { HideUi(); - GameApplication.Instance.DungeonManager.ExitDungeon(); - UiManager.Open_Main(); + GameApplication.Instance.DungeonManager.ExitDungeon(() => + { + UiManager.Open_Main(); + }); } }