diff --git a/DungeonShooting_Godot/scene/Room.tscn b/DungeonShooting_Godot/scene/Room.tscn index 6c5db9e..5098935 100644 --- a/DungeonShooting_Godot/scene/Room.tscn +++ b/DungeonShooting_Godot/scene/Room.tscn @@ -1,4 +1,4 @@ -[gd_scene load_steps=12 format=2] +[gd_scene load_steps=16 format=2] [ext_resource path="res://resource/sprite/environment/itch-io-DungeonTileset4/16x16 dungeon ii wall reconfig v04 spritesheet.png" type="Texture" id=1] [ext_resource path="res://src/game/room/RoomManager.cs" type="Script" id=3] @@ -26,6 +26,18 @@ [sub_resource type="ConvexPolygonShape2D" id=8] points = PoolVector2Array( 0, 0, 16, 0, 16, 12, 0, 12 ) +[sub_resource type="ConvexPolygonShape2D" id=9] +points = PoolVector2Array( 0, 0, 16, 0, 16, 16, 0, 16 ) + +[sub_resource type="ConvexPolygonShape2D" id=10] +points = PoolVector2Array( 0, 0, 16, 0, 16, 16, 0, 16 ) + +[sub_resource type="ConvexPolygonShape2D" id=11] +points = PoolVector2Array( 0, 0, 16, 0, 16, 12, 0, 12 ) + +[sub_resource type="ConvexPolygonShape2D" id=12] +points = PoolVector2Array( 0, 0, 16, 0, 16, 12, 0, 12 ) + [sub_resource type="TileSet" id=2] 0/name = "16x16 dungeon ii wall reconfig v04 spritesheet.png 0" 0/texture = ExtResource( 1 ) @@ -83,6 +95,30 @@ "one_way_margin": 1.0, "shape": SubResource( 8 ), "shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 ) +}, { +"autotile_coord": Vector2( 1, 2 ), +"one_way": false, +"one_way_margin": 1.0, +"shape": SubResource( 9 ), +"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 ) +}, { +"autotile_coord": Vector2( 3, 2 ), +"one_way": false, +"one_way_margin": 1.0, +"shape": SubResource( 10 ), +"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 ) +}, { +"autotile_coord": Vector2( 1, 7 ), +"one_way": false, +"one_way_margin": 1.0, +"shape": SubResource( 11 ), +"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 ) +}, { +"autotile_coord": Vector2( 3, 7 ), +"one_way": false, +"one_way_margin": 1.0, +"shape": SubResource( 12 ), +"shape_transform": Transform2D( 1, 0, 0, 1, 0, 0 ) } ] 0/z_index = 0 diff --git a/DungeonShooting_Godot/src/game/role/Player.cs b/DungeonShooting_Godot/src/game/role/Player.cs index e0b2826..02784c9 100644 --- a/DungeonShooting_Godot/src/game/role/Player.cs +++ b/DungeonShooting_Godot/src/game/role/Player.cs @@ -48,7 +48,9 @@ MaxShield = 30; Shield = 30; - //MoveSpeed = 800; + // Acceleration = 3000; + // Friction = 3000; + // MoveSpeed = 800; } protected override void Process(float delta) diff --git a/DungeonShooting_Godot/src/game/room/AutoTileConfig.cs b/DungeonShooting_Godot/src/game/room/AutoTileConfig.cs index 7c49573..d19dc6b 100644 --- a/DungeonShooting_Godot/src/game/room/AutoTileConfig.cs +++ b/DungeonShooting_Godot/src/game/room/AutoTileConfig.cs @@ -6,13 +6,18 @@ /// public class AutoTileConfig { - public TileCellInfo LT = new TileCellInfo(0, new Vector2(3, 3)); - public TileCellInfo LB = new TileCellInfo(0, new Vector2(11, 2)); - public TileCellInfo RT = new TileCellInfo(0, new Vector2(1, 3)); - public TileCellInfo RB = new TileCellInfo(0, new Vector2(13, 2)); + public TileCellInfo IN_LT = new TileCellInfo(0, new Vector2(3, 3)); + public TileCellInfo IN_LB = new TileCellInfo(0, new Vector2(11, 2)); + public TileCellInfo IN_RT = new TileCellInfo(0, new Vector2(1, 3)); + public TileCellInfo IN_RB = new TileCellInfo(0, new Vector2(13, 2)); public TileCellInfo R = new TileCellInfo(0, new Vector2(1, 3)); public TileCellInfo L = new TileCellInfo(0, new Vector2(3, 3)); public TileCellInfo T = new TileCellInfo(0, new Vector2(2, 7)); public TileCellInfo B = new TileCellInfo(0, new Vector2(2, 2)); - public TileCellInfo In = new TileCellInfo(0, new Vector2(0, 8)); + public TileCellInfo Ground = new TileCellInfo(0, new Vector2(0, 8)); + + public TileCellInfo OUT_LT = new TileCellInfo(0, new Vector2(1, 2)); + public TileCellInfo OUT_LB = new TileCellInfo(0, new Vector2(1, 7)); + public TileCellInfo OUT_RT = new TileCellInfo(0, new Vector2(3, 2)); + public TileCellInfo OUT_RB = new TileCellInfo(0, new Vector2(3, 7)); } \ No newline at end of file diff --git a/DungeonShooting_Godot/src/game/room/DungeonTileManager.cs b/DungeonShooting_Godot/src/game/room/DungeonTileManager.cs index bd6592b..ab3d072 100644 --- a/DungeonShooting_Godot/src/game/room/DungeonTileManager.cs +++ b/DungeonShooting_Godot/src/game/room/DungeonTileManager.cs @@ -12,18 +12,18 @@ } //铺房间 - FillRect(floor, config.In, roomInfo.Position + Vector2.One, roomInfo.Size - new Vector2(2, 2)); + FillRect(floor, config.Ground, roomInfo.Position + Vector2.One, roomInfo.Size - new Vector2(2, 2)); - FillRect(top, config.LT, roomInfo.Position, Vector2.One); + FillRect(top, config.IN_LT, roomInfo.Position, Vector2.One); FillRect(top, config.L, roomInfo.Position + new Vector2(0, 1), new Vector2(1, roomInfo.Size.y - 2)); - FillRect(top, config.LB, roomInfo.Position + new Vector2(0, roomInfo.Size.y - 1), new Vector2(1, 1)); + FillRect(top, config.IN_LB, roomInfo.Position + new Vector2(0, roomInfo.Size.y - 1), new Vector2(1, 1)); FillRect(top, config.B, roomInfo.Position + new Vector2(1, roomInfo.Size.y - 1), new Vector2(roomInfo.Size.x - 2, 1)); - FillRect(top, config.RB, roomInfo.Position + new Vector2(roomInfo.Size.x - 1, roomInfo.Size.y - 1), + FillRect(top, config.IN_RB, roomInfo.Position + new Vector2(roomInfo.Size.x - 1, roomInfo.Size.y - 1), Vector2.One); FillRect(top, config.R, roomInfo.Position + new Vector2(roomInfo.Size.x - 1, 1), new Vector2(1, roomInfo.Size.y - 2)); - FillRect(top, config.RT, roomInfo.Position + new Vector2(roomInfo.Size.x - 1, 0), Vector2.One); + FillRect(top, config.IN_RT, roomInfo.Position + new Vector2(roomInfo.Size.x - 1, 0), Vector2.One); FillRect(middle, config.T, roomInfo.Position + Vector2.Right, new Vector2(roomInfo.Size.x - 2, 1)); //铺过道 @@ -32,6 +32,8 @@ if (doorInfo.ConnectRoom.Id > roomInfo.Id) { //普通的直线连接 + var doorDir1 = doorInfo.Direction; + var doorDir2 = doorInfo.ConnectDoor.Direction; if (!doorInfo.HasCross) { //方向, 0横向, 1纵向 @@ -42,7 +44,7 @@ doorInfo.ConnectDoor.OriginPosition.x, doorInfo.ConnectDoor.OriginPosition.y ); - if (doorInfo.Direction == DoorDirection.N || doorInfo.Direction == DoorDirection.S) + if (doorDir1 == DoorDirection.N || doorDir1 == DoorDirection.S) { rect.Size = new Vector2(GenerateDungeon.CorridorWidth, rect.Size.y); dir = 1; @@ -71,7 +73,7 @@ Rect2 rect2; //计算范围 - switch (doorInfo.Direction) + switch (doorDir1) { case DoorDirection.E: //→ rect = new Rect2( @@ -111,7 +113,8 @@ rect = new Rect2(); break; } - switch (doorInfo.ConnectDoor.Direction) + + switch (doorDir2) { case DoorDirection.E: //→ rect2 = new Rect2( @@ -152,10 +155,10 @@ break; } - FillRect(floor, config.In, rect.Position, rect.Size); - FillRect(floor, config.In, rect2.Position, rect2.Size); - FillRect(floor, config.In, doorInfo.Cross, new Vector2(GenerateDungeon.CorridorWidth, GenerateDungeon.CorridorWidth)); + FillRect(floor, config.Ground, doorInfo.Cross + Vector2.One, + new Vector2(GenerateDungeon.CorridorWidth - 2, GenerateDungeon.CorridorWidth - 2)); + //墙壁 if (dir1 == 0) { FullHorizontalGalleryWall(floor, middle, top, config, rect); @@ -172,44 +175,90 @@ { FullVerticalGalleryWall(floor, middle, top, config, rect2); } + + if ((doorDir1 == DoorDirection.N && doorDir2 == DoorDirection.E) || //↑→ + (doorDir2 == DoorDirection.N && doorDir1 == DoorDirection.E)) + { + FillRect(top, config.OUT_RT, + doorInfo.Cross + new Vector2(0, GenerateDungeon.CorridorWidth - 1), + Vector2.One); + FillRect(top, config.IN_RT, doorInfo.Cross + new Vector2(GenerateDungeon.CorridorWidth - 1, 0), Vector2.One); + FillRect(middle, config.T, doorInfo.Cross, new Vector2(GenerateDungeon.CorridorWidth - 1, 1)); + FillRect(top, config.R, doorInfo.Cross + new Vector2(GenerateDungeon.CorridorWidth - 1, 1), + new Vector2(1, GenerateDungeon.CorridorWidth - 1)); + } + else if ((doorDir1 == DoorDirection.E && doorDir2 == DoorDirection.S) || //→↓ + (doorDir2 == DoorDirection.E && doorDir1 == DoorDirection.S)) + { + FillRect(middle, config.OUT_RB, doorInfo.Cross, Vector2.One); + FillRect(top, config.IN_RB, doorInfo.Cross + new Vector2(GenerateDungeon.CorridorWidth - 1, GenerateDungeon.CorridorWidth - 1), + Vector2.One); + FillRect(top, config.R, doorInfo.Cross + new Vector2(GenerateDungeon.CorridorWidth - 1, 0), + new Vector2(1, GenerateDungeon.CorridorWidth - 1)); + FillRect(top, config.B, doorInfo.Cross + new Vector2(0, GenerateDungeon.CorridorWidth - 1), + new Vector2(GenerateDungeon.CorridorWidth - 1, 1)); + } + else if ((doorDir1 == DoorDirection.S && doorDir2 == DoorDirection.W) || //↓← + (doorDir2 == DoorDirection.S && doorDir1 == DoorDirection.W)) + { + FillRect(middle, config.OUT_LB, + doorInfo.Cross + new Vector2(GenerateDungeon.CorridorWidth - 1, 0), Vector2.One); + FillRect(top, config.IN_LB, doorInfo.Cross + new Vector2(0, GenerateDungeon.CorridorWidth - 1), + Vector2.One); + FillRect(top, config.L, doorInfo.Cross, new Vector2(1, GenerateDungeon.CorridorWidth - 1)); + FillRect(top, config.B, doorInfo.Cross + new Vector2(1, GenerateDungeon.CorridorWidth - 1), + new Vector2(GenerateDungeon.CorridorWidth - 1, 1)); + } + else if ((doorDir1 == DoorDirection.W && doorDir2 == DoorDirection.N) || //←↑ + (doorDir2 == DoorDirection.W && doorDir1 == DoorDirection.N)) + { + FillRect(top, config.OUT_LT, + doorInfo.Cross + new Vector2(GenerateDungeon.CorridorWidth - 1, GenerateDungeon.CorridorWidth - 1), + Vector2.One); + FillRect(top, config.IN_LT, doorInfo.Cross, Vector2.One); + FillRect(middle, config.T, doorInfo.Cross + new Vector2(1, 0), + new Vector2(GenerateDungeon.CorridorWidth - 1, 1)); + FillRect(top, config.L, doorInfo.Cross + new Vector2(0, 1), + new Vector2(1, GenerateDungeon.CorridorWidth - 1)); + } //在房间墙上开洞 - switch (doorInfo.Direction) + switch (doorDir1) { case DoorDirection.E: //→ ClearRect(top, doorInfo.OriginPosition + new Vector2(-1, 1), new Vector2(1, rect.Size.y - 2)); - FillRect(floor, config.In, doorInfo.OriginPosition + new Vector2(-1, 1), new Vector2(1, rect.Size.y - 2)); + FillRect(floor, config.Ground, doorInfo.OriginPosition + new Vector2(-1, 1), new Vector2(1, rect.Size.y - 2)); break; case DoorDirection.W: //← ClearRect(top, doorInfo.OriginPosition + new Vector2(0, 1), new Vector2(1, rect.Size.y - 2)); - FillRect(floor, config.In, doorInfo.OriginPosition + new Vector2(0, 1), new Vector2(1, rect.Size.y - 2)); + FillRect(floor, config.Ground, doorInfo.OriginPosition + new Vector2(0, 1), new Vector2(1, rect.Size.y - 2)); break; case DoorDirection.S: //↓ ClearRect(top, doorInfo.OriginPosition + new Vector2(1, -1), new Vector2(rect.Size.x - 2, 1)); - FillRect(floor, config.In, doorInfo.OriginPosition + new Vector2(1, -1), new Vector2(rect.Size.x - 2, 1)); + FillRect(floor, config.Ground, doorInfo.OriginPosition + new Vector2(1, -1), new Vector2(rect.Size.x - 2, 1)); break; case DoorDirection.N: //↑ ClearRect(middle, doorInfo.OriginPosition + new Vector2(1, 2), new Vector2(rect.Size.x - 2, 1)); - FillRect(floor, config.In, doorInfo.OriginPosition + new Vector2(1, 0), new Vector2(rect.Size.x - 2, 1)); + FillRect(floor, config.Ground, doorInfo.OriginPosition + new Vector2(1, 0), new Vector2(rect.Size.x - 2, 1)); break; } - switch (doorInfo.ConnectDoor.Direction) + switch (doorDir2) { case DoorDirection.E: //→ ClearRect(top, doorInfo.ConnectDoor.OriginPosition + new Vector2(-1, 1), new Vector2(1, rect2.Size.y - 2)); - FillRect(floor, config.In, doorInfo.ConnectDoor.OriginPosition + new Vector2(-1, 1), new Vector2(1, rect2.Size.y - 2)); + FillRect(floor, config.Ground, doorInfo.ConnectDoor.OriginPosition + new Vector2(-1, 1), new Vector2(1, rect2.Size.y - 2)); break; case DoorDirection.W: //← ClearRect(top, doorInfo.ConnectDoor.OriginPosition + new Vector2(0, 1), new Vector2(1, rect2.Size.y - 2)); - FillRect(floor, config.In, doorInfo.ConnectDoor.OriginPosition + new Vector2(0, 1), new Vector2(1, rect2.Size.y - 2)); + FillRect(floor, config.Ground, doorInfo.ConnectDoor.OriginPosition + new Vector2(0, 1), new Vector2(1, rect2.Size.y - 2)); break; case DoorDirection.S: //↓ ClearRect(top, doorInfo.ConnectDoor.OriginPosition + new Vector2(1, -1), new Vector2(rect2.Size.x - 2, 1)); - FillRect(floor, config.In, doorInfo.ConnectDoor.OriginPosition + new Vector2(1, -1), new Vector2(rect2.Size.x - 2, 1)); + FillRect(floor, config.Ground, doorInfo.ConnectDoor.OriginPosition + new Vector2(1, -1), new Vector2(rect2.Size.x - 2, 1)); break; case DoorDirection.N: //↑ ClearRect(middle, doorInfo.ConnectDoor.OriginPosition + new Vector2(1, 0), new Vector2(rect2.Size.x - 2, 1)); - FillRect(floor, config.In, doorInfo.ConnectDoor.OriginPosition + new Vector2(1, 0), new Vector2(rect2.Size.x - 2, 1)); + FillRect(floor, config.Ground, doorInfo.ConnectDoor.OriginPosition + new Vector2(1, 0), new Vector2(rect2.Size.x - 2, 1)); break; } } @@ -241,28 +290,28 @@ private static void FullHorizontalGalleryWall(TileMap floor, TileMap middle, TileMap top, AutoTileConfig config, Rect2 rect) { - FillRect(floor, config.In, rect.Position + new Vector2(0, 1), rect.Size - new Vector2(0, 2)); + FillRect(floor, config.Ground, rect.Position + new Vector2(0, 1), rect.Size - new Vector2(0, 2)); FillRect(middle, config.T, rect.Position, new Vector2(rect.Size.x, 1)); FillRect(top, config.B, rect.Position + new Vector2(0, rect.Size.y - 1), new Vector2(rect.Size.x, 1)); //左 ClearRect(top, rect.Position + new Vector2(-1, 1), new Vector2(1, rect.Size.y - 2)); - FillRect(floor, config.In, rect.Position + new Vector2(-1, 1), new Vector2(1, rect.Size.y - 2)); + FillRect(floor, config.Ground, rect.Position + new Vector2(-1, 1), new Vector2(1, rect.Size.y - 2)); //右 ClearRect(top, rect.Position + new Vector2(rect.Size.x, 1), new Vector2(1, rect.Size.y - 2)); - FillRect(floor, config.In, rect.Position + new Vector2(rect.Size.x, 1), new Vector2(1, rect.Size.y - 2)); + FillRect(floor, config.Ground, rect.Position + new Vector2(rect.Size.x, 1), new Vector2(1, rect.Size.y - 2)); } private static void FullVerticalGalleryWall(TileMap floor, TileMap middle, TileMap top, AutoTileConfig config, Rect2 rect) { - FillRect(floor, config.In, rect.Position + new Vector2(1, 0), rect.Size - new Vector2(2, 0)); + FillRect(floor, config.Ground, rect.Position + new Vector2(1, 0), rect.Size - new Vector2(2, 0)); FillRect(top, config.L, rect.Position, new Vector2(1, rect.Size.y)); FillRect(top, config.R, rect.Position + new Vector2(rect.Size.x - 1, 0), new Vector2(1, rect.Size.y)); //上 ClearRect(top, rect.Position + new Vector2(1, -1), new Vector2(rect.Size.x - 2, 1)); - FillRect(floor, config.In, rect.Position + new Vector2(1, -1), new Vector2(rect.Size.x - 2, 1)); + FillRect(floor, config.Ground, rect.Position + new Vector2(1, -1), new Vector2(rect.Size.x - 2, 1)); //下 ClearRect(middle, rect.Position + new Vector2(1, rect.Size.y), new Vector2(rect.Size.x - 2, 1)); - FillRect(floor, config.In, rect.Position + new Vector2(1, rect.Size.y), new Vector2(rect.Size.x - 2, 1)); + FillRect(floor, config.Ground, rect.Position + new Vector2(1, rect.Size.y), new Vector2(rect.Size.x - 2, 1)); } } \ No newline at end of file