diff --git a/DungeonShooting_Godot/src/framework/map/DungeonTile.cs b/DungeonShooting_Godot/src/framework/map/DungeonTile.cs index 7b6d0fc..cd49fef 100644 --- a/DungeonShooting_Godot/src/framework/map/DungeonTile.cs +++ b/DungeonShooting_Godot/src/framework/map/DungeonTile.cs @@ -436,6 +436,7 @@ FillRect(TopMapLayer, config.R, rect.Position + new Vector2(rect.Size.X - 1, 0), new Vector2(1, rect.Size.Y)); } + //横向过道, 门朝右, 连接方向向左 private void FullHorizontalAisleLeft(AutoTileConfig config, Rect2 rect, RoomDoorInfo doorInfo = null) { //左 @@ -447,6 +448,9 @@ } else { + FillRect(TopMapLayer, config.OUT_LB, rect.Position + new Vector2(-1, 0), Vector2.One); + FillRect(TopMapLayer, config.OUT_LT, rect.Position + new Vector2(-1, 3), Vector2.One); + FillRect(FloorMapLayer, config.Floor, rect.Position + new Vector2(-1, 1), new Vector2(1, rect.Size.Y - 2)); //生成门的导航区域 var x = rect.Position.X * GenerateDungeon.TileCellSize; @@ -460,6 +464,8 @@ ); } } + + //横向过道, 门朝左, 连接方向向右 private void FullHorizontalAisleRight(AutoTileConfig config, Rect2 rect, RoomDoorInfo doorInfo = null) { //右 @@ -470,6 +476,9 @@ } else { + FillRect(TopMapLayer, config.OUT_RB, rect.Position + new Vector2(rect.Size.X, 0), Vector2.One); + FillRect(TopMapLayer, config.OUT_RT, rect.Position + new Vector2(rect.Size.X, 3), Vector2.One); + FillRect(FloorMapLayer, config.Floor, rect.Position + new Vector2(rect.Size.X, 1), new Vector2(1, rect.Size.Y - 2)); //生成门的导航区域 var x = rect.Position.X * GenerateDungeon.TileCellSize; @@ -484,6 +493,7 @@ } } + //纵向过道, 门朝下, 连接方向向上 private void FullVerticalAisleUp(AutoTileConfig config, Rect2 rect, RoomDoorInfo doorInfo = null) { //上 @@ -495,6 +505,9 @@ } else { + FillRect(TopMapLayer, config.OUT_RT, rect.Position + new Vector2(0, -1), Vector2.One); + FillRect(TopMapLayer, config.OUT_LT, rect.Position + new Vector2(3, -1), Vector2.One); + FillRect(FloorMapLayer, config.Floor, rect.Position + new Vector2(1, -1), new Vector2(rect.Size.X - 2, 1)); //生成门的导航区域 var x = rect.Position.X * GenerateDungeon.TileCellSize; @@ -508,6 +521,8 @@ ); } } + + //纵向过道, 门朝上, 连接方向向下 private void FullVerticalAisleDown(AutoTileConfig config, Rect2 rect, RoomDoorInfo doorInfo = null) { //下 @@ -518,6 +533,9 @@ } else { + FillRect(MiddleMapLayer, config.OUT_RB, rect.Position + new Vector2(0, rect.Size.Y), Vector2.One); + FillRect(MiddleMapLayer, config.OUT_LB, rect.Position + new Vector2(3, rect.Size.Y), Vector2.One); + FillRect(FloorMapLayer, config.Floor, rect.Position + new Vector2(1, rect.Size.Y), new Vector2(rect.Size.X - 2, 1)); //生成门的导航区域 var x = rect.Position.X * GenerateDungeon.TileCellSize; diff --git a/DungeonShooting_Godot/src/game/room/RoomDoor.cs b/DungeonShooting_Godot/src/game/room/RoomDoor.cs index 6eda787..597f1be 100644 --- a/DungeonShooting_Godot/src/game/room/RoomDoor.cs +++ b/DungeonShooting_Godot/src/game/room/RoomDoor.cs @@ -12,11 +12,15 @@ public void OpenDoor() { + Visible = false; + Collision.Disabled = true; _door.Navigation.NavigationNode.Enabled = true; } public void CloseDoor() { + Visible = true; + Collision.Disabled = false; _door.Navigation.NavigationNode.Enabled = false; } } \ No newline at end of file diff --git a/DungeonShooting_Godot/src/game/room/RoomManager.cs b/DungeonShooting_Godot/src/game/room/RoomManager.cs index fc4a42b..3dd2f02 100644 --- a/DungeonShooting_Godot/src/game/room/RoomManager.cs +++ b/DungeonShooting_Godot/src/game/room/RoomManager.cs @@ -68,10 +68,8 @@ _dungeonTile.MountNavigationPolygon(this); _roomStaticNavigationList.AddRange(_dungeonTile.GetPolygonData()); _roomStaticNavigationList.AddRange(_dungeonTile.GetConnectDoorPolygonData()); - //挂载所有房间的导航区域 - _generateDungeon.EachRoom(MountNavFromRoomInfo); - //创建门实例 - _generateDungeon.EachRoom(CreateDoor); + //初始化所有房间 + _generateDungeon.EachRoom(InitRoom); GD.Print("生成地牢用时: " + (DateTime.Now.Ticks - nowTicks) / 10000 + "毫秒"); @@ -83,9 +81,9 @@ // Player.PickUpWeapon(ActivityObject.Create(ActivityIdPrefix.Weapon + "0004")); Player.PickUpWeapon(ActivityObject.Create(ActivityIdPrefix.Weapon + "0003")); - var enemy1 = ActivityObject.Create(ActivityIdPrefix.Enemy + "0001"); - enemy1.PutDown(new Vector2(160, 160), RoomLayerEnum.YSortLayer); - enemy1.PickUpWeapon(ActivityObject.Create(ActivityIdPrefix.Weapon + "0001")); + // var enemy1 = ActivityObject.Create(ActivityIdPrefix.Enemy + "0001"); + // enemy1.PutDown(new Vector2(160, 160), RoomLayerEnum.YSortLayer); + // enemy1.PickUpWeapon(ActivityObject.Create(ActivityIdPrefix.Weapon + "0001")); // for (int i = 0; i < 10; i++) // { @@ -168,6 +166,17 @@ } } + // 初始化房间 + private void InitRoom(RoomInfo roomInfo) + { + //挂载房间导航区域 + MountNavFromRoomInfo(roomInfo); + //创建门 + CreateDoor(roomInfo); + + //创建房间区域 + } + //挂载房间导航区域 private void MountNavFromRoomInfo(RoomInfo roomInfo) { @@ -200,6 +209,7 @@ AddChild(navigationPolygon); } + //创建门 private void CreateDoor(RoomInfo roomInfo) { foreach (var doorInfo in roomInfo.Doors) @@ -226,6 +236,7 @@ } door.Position = (doorInfo.OriginPosition + offset) * GenerateDungeon.TileCellSize; door.Init(doorInfo); + door.OpenDoor(); door.PutDown(RoomLayerEnum.NormalLayer, false); } }