自定义房间生成规则, 开发中
1 parent eb4a25a commit 8cc629d392495bcbaec24c4dc854ce6fe6bcfcce
@小李xl 小李xl authored on 24 Jan 2024
Showing 6 changed files
View
94
DungeonShooting_Godot/src/framework/map/DungeonGenerator.cs
private DungeonRule _rule;
//上一个房间
private RoomInfo prevRoomInfo = null;
private readonly List<RoomInfo> _tempList = new List<RoomInfo>();
public DungeonGenerator(DungeonConfig config, SeedRandom seedRandom)
{
Config = config;
{
Debug.LogError("当前房间还有连接的子房间, 不能回滚!");
return false;
}
 
if (!roomInfo.CanRollback)
{
Debug.LogError("当前房间不能回滚!");
return false;
}
var prevRoom = roomInfo.Prev;
//退掉占用的房间区域和过道占用区域
_roomGrid.RemoveRect(roomInfo.Position, roomInfo.Size);
foreach (var rect2 in roomInfo.AisleArea)
{
_roomGrid.RemoveRect(rect2.Position, rect2.Size);
}
//roomInfo.Doors[0].
if (roomInfo.Prev != null)
if (prevRoom != null)
{
roomInfo.Prev.Next.Remove(roomInfo);
}
 
roomInfo.Destroy();
_id--;
_nextRoomType = DungeonRoomType.None;
SetPrevRoom(prevRoom);
return true;
}
 
/// <summary>
{
RoomInfo temp = null;
foreach (var roomInfo in RoomInfos)
{
if (roomInfo.CanRollback)
{
continue;
}
if (temp == null || roomInfo.Layer > temp.Layer)
{
if (exclude == null || !exclude.Contains(roomInfo))
{
 
/// <summary>
/// 随机抽取层级小于 layer 的房间
/// </summary>
public RoomInfo RoundRoomLessThanLayer(int layer)
{
var list = new List<RoomInfo>();
public RoomInfo RandomRoomLessThanLayer(int layer)
{
_tempList.Clear();
foreach (var roomInfo in RoomInfos)
{
if (roomInfo.CanRollback)
{
continue;
}
if (roomInfo.Layer < layer)
{
list.Add(roomInfo);
}
}
 
return Random.RandomChoose(list);
_tempList.Add(roomInfo);
}
}
 
return Random.RandomChoose(_tempList);
}
/// <summary>
/// 随机抽取房间
/// </summary>
public RoomInfo GetRandomRoom()
{
_tempList.Clear();
foreach (var roomInfo in RoomInfos)
{
if (roomInfo.CanRollback)
{
continue;
}
_tempList.Add(roomInfo);
}
 
return Random.RandomChoose(_tempList);
}
 
/// <summary>
/// 提交所有可以回滚的房间
/// </summary>
public void SubmitCanRollbackRoom()
{
foreach (var roomInfo in RoomInfos)
{
roomInfo.CanRollback = false;
}
}
/// <summary>
/// 找两个房间的门
View
2
■■■
DungeonShooting_Godot/src/game/GameApplication.cs
Enemy.InitEnemyAttribute();
DungeonConfig = new DungeonConfig();
DungeonConfig.GroupName = "Test1";
DungeonConfig.BattleRoomCount = 5;
DungeonConfig.BattleRoomCount = 20;
}
 
public override void _EnterTree()
{
View
DungeonShooting_Godot/src/game/activity/role/player/Player.cs
View
DungeonShooting_Godot/src/game/room/DefaultDungeonRule.cs
View
DungeonShooting_Godot/src/game/room/World.cs
View
DungeonShooting_Godot/src/game/ui/roomMap/RoomMapPanel.cs