diff --git a/DungeonShooting_Godot/src/framework/common/Utils.cs b/DungeonShooting_Godot/src/framework/common/Utils.cs index 052042d..8f95edf 100644 --- a/DungeonShooting_Godot/src/framework/common/Utils.cs +++ b/DungeonShooting_Godot/src/framework/common/Utils.cs @@ -13,7 +13,7 @@ static Utils() { - _random = new Random(); + _random = new Random(123); } /// diff --git a/DungeonShooting_Godot/src/framework/map/GenerateDungeon.cs b/DungeonShooting_Godot/src/framework/map/GenerateDungeon.cs index 5baba5b..1c3a61e 100644 --- a/DungeonShooting_Godot/src/framework/map/GenerateDungeon.cs +++ b/DungeonShooting_Godot/src/framework/map/GenerateDungeon.cs @@ -21,7 +21,7 @@ /// /// 生成的房间数量 /// - private int _maxCount = 15; + private int _maxCount = 3; //用于标记地图上的坐标是否被占用 private Grid _roomGrid { get; } = new Grid(); @@ -291,25 +291,25 @@ nextRoomDoor.ConnectRoom = room; nextRoomDoor.ConnectDoor = roomDoor; - //先寻找直通门 - if (Utils.RandomBoolean()) - { - //直行通道, 优先横轴 - if (TryConnectHorizontalDoor(room, roomDoor, nextRoom, nextRoomDoor) - || TryConnectVerticalDoor(room, roomDoor, nextRoom, nextRoomDoor)) - { - return true; - } - } - else - { - //直行通道, 优先纵轴 - if (TryConnectVerticalDoor(room, roomDoor, nextRoom, nextRoomDoor) - || TryConnectHorizontalDoor(room, roomDoor, nextRoom, nextRoomDoor)) - { - return true; - } - } + // //先寻找直通门 + // if (Utils.RandomBoolean()) + // { + // //直行通道, 优先横轴 + // if (TryConnectHorizontalDoor(room, roomDoor, nextRoom, nextRoomDoor) + // || TryConnectVerticalDoor(room, roomDoor, nextRoom, nextRoomDoor)) + // { + // return true; + // } + // } + // else + // { + // //直行通道, 优先纵轴 + // if (TryConnectVerticalDoor(room, roomDoor, nextRoom, nextRoomDoor) + // || TryConnectHorizontalDoor(room, roomDoor, nextRoom, nextRoomDoor)) + // { + // return true; + // } + // } //包含拐角的通道 return TryConnectCrossDoor(room, roomDoor, nextRoom, nextRoomDoor); @@ -576,11 +576,13 @@ //交集范围够生成门 if (range.Y - range.X >= GameConfig.CorridorWidth) { - var tempRange = new Vector2I(Mathf.Abs(room1.Position.X - (int)range.X), - Mathf.Abs(room1.Position.X - (int)range.Y) - GameConfig.CorridorWidth); - if (areaRange == null || tempRange.X < areaRange.Value.X) + // var tempRange = new Vector2I(Mathf.Abs(room1.Position.X - (int)range.X), + // Mathf.Abs(room1.Position.X - (int)range.Y) - GameConfig.CorridorWidth); + + var rangeValue = Mathf.Abs(room1.Position.X - (int)range.Y) - GameConfig.CorridorWidth; + if (areaRange == null || rangeValue < areaRange.Value.X) { - areaRange = tempRange; + areaRange = new Vector2I(rangeValue, rangeValue); } } } @@ -591,11 +593,13 @@ //交集范围够生成门 if (range.Y - range.X >= GameConfig.CorridorWidth) { - var tempRange = new Vector2I(Mathf.Abs(room1.Position.X - (int)range.X), - Mathf.Abs(room1.Position.X - (int)range.Y) - GameConfig.CorridorWidth); - if (areaRange == null || tempRange.Y > areaRange.Value.Y) + // var tempRange = new Vector2I(Mathf.Abs(room1.Position.X - (int)range.X), + // Mathf.Abs(room1.Position.X - (int)range.Y) - GameConfig.CorridorWidth); + + var rangeValue = Mathf.Abs(room1.Position.X - (int)range.Y) - GameConfig.CorridorWidth; + if (areaRange == null || rangeValue > areaRange.Value.Y) { - areaRange = tempRange; + areaRange = new Vector2I(rangeValue, rangeValue); } } } @@ -613,11 +617,13 @@ //交集范围够生成门 if (range.Y - range.X >= GameConfig.CorridorWidth) { - var tempRange = new Vector2I(Mathf.Abs(room1.Position.Y - (int)range.X), - Mathf.Abs(room1.Position.Y - (int)range.Y) - GameConfig.CorridorWidth); - if (areaRange == null || tempRange.X < areaRange.Value.X) + // var tempRange = new Vector2I(Mathf.Abs(room1.Position.Y - (int)range.X), + // Mathf.Abs(room1.Position.Y - (int)range.Y) - GameConfig.CorridorWidth); + + var rangeValue = Mathf.Abs(room1.Position.Y - (int)range.X); + if (areaRange == null || rangeValue < areaRange.Value.X) { - areaRange = tempRange; + areaRange = new Vector2I(rangeValue, rangeValue); } } } @@ -628,11 +634,13 @@ //交集范围够生成门 if (range.Y - range.X >= GameConfig.CorridorWidth) { - var tempRange = new Vector2I(Mathf.Abs(room1.Position.Y - (int)range.X), - Mathf.Abs(room1.Position.Y - (int)range.Y) - GameConfig.CorridorWidth); - if (areaRange == null || tempRange.Y > areaRange.Value.Y) + // var tempRange = new Vector2I(Mathf.Abs(room1.Position.Y - (int)range.X), + // Mathf.Abs(room1.Position.Y - (int)range.Y) - GameConfig.CorridorWidth); + + var rangeValue = Mathf.Abs(room1.Position.Y - (int)range.Y) - GameConfig.CorridorWidth; + if (areaRange == null || rangeValue > areaRange.Value.Y) { - areaRange = tempRange; + areaRange = new Vector2I(rangeValue, rangeValue); } } } diff --git a/DungeonShooting_Godot/src/game/GameApplication.cs b/DungeonShooting_Godot/src/game/GameApplication.cs index f47b11d..4fbf5a0 100644 --- a/DungeonShooting_Godot/src/game/GameApplication.cs +++ b/DungeonShooting_Godot/src/game/GameApplication.cs @@ -133,10 +133,10 @@ var areaInfos = roomSplit.RoomInfo.DoorAreaInfos; if (areaInfos.Count == 0) { - areaInfos.Add(new DoorAreaInfo(DoorDirection.N, GameConfig.TileCellSize, (roomSplit.RoomInfo.Size.X - 2) * GameConfig.TileCellSize)); - areaInfos.Add(new DoorAreaInfo(DoorDirection.S, GameConfig.TileCellSize, (roomSplit.RoomInfo.Size.X - 2) * GameConfig.TileCellSize)); - areaInfos.Add(new DoorAreaInfo(DoorDirection.W, GameConfig.TileCellSize, (roomSplit.RoomInfo.Size.Y - 2) * GameConfig.TileCellSize)); - areaInfos.Add(new DoorAreaInfo(DoorDirection.E, GameConfig.TileCellSize, (roomSplit.RoomInfo.Size.Y - 2) * GameConfig.TileCellSize)); + areaInfos.Add(new DoorAreaInfo(DoorDirection.N, GameConfig.TileCellSize, (roomSplit.RoomInfo.Size.X - 1) * GameConfig.TileCellSize)); + areaInfos.Add(new DoorAreaInfo(DoorDirection.S, GameConfig.TileCellSize, (roomSplit.RoomInfo.Size.X - 1) * GameConfig.TileCellSize)); + areaInfos.Add(new DoorAreaInfo(DoorDirection.W, GameConfig.TileCellSize, (roomSplit.RoomInfo.Size.Y - 1) * GameConfig.TileCellSize)); + areaInfos.Add(new DoorAreaInfo(DoorDirection.E, GameConfig.TileCellSize, (roomSplit.RoomInfo.Size.Y - 1) * GameConfig.TileCellSize)); } } } diff --git a/DungeonShooting_Godot/src/game/role/Player.cs b/DungeonShooting_Godot/src/game/role/Player.cs index e4d9b24..f768681 100644 --- a/DungeonShooting_Godot/src/game/role/Player.cs +++ b/DungeonShooting_Godot/src/game/role/Player.cs @@ -46,12 +46,12 @@ Shield = 30; // debug用 - // Acceleration = 3000; - // Friction = 3000; - // MoveSpeed = 500; - // CollisionLayer = 0; - // CollisionMask = 0; - // GameCamera.Main.Zoom = new Vector2(0.5f, 0.5f); + Acceleration = 3000; + Friction = 3000; + MoveSpeed = 500; + CollisionLayer = 0; + CollisionMask = 0; + GameCamera.Main.Zoom = new Vector2(0.5f, 0.5f); } protected override void Process(float delta)