制作商店标记中

This commit is contained in:
小李xl 2024-03-22 01:37:04 +08:00
parent 22b2ed7650
commit cb4794ec5e
24 changed files with 177 additions and 87 deletions

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.2 KiB

After

Width:  |  Height:  |  Size: 3.3 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.2 KiB

After

Width:  |  Height:  |  Size: 2.9 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

After

Width:  |  Height:  |  Size: 3.0 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 2.5 KiB

File diff suppressed because one or more lines are too long

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

After

Width:  |  Height:  |  Size: 2.7 KiB

File diff suppressed because one or more lines are too long

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.7 KiB

After

Width:  |  Height:  |  Size: 3.4 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.1 KiB

After

Width:  |  Height:  |  Size: 2.7 KiB

File diff suppressed because one or more lines are too long

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.5 KiB

After

Width:  |  Height:  |  Size: 4.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

After

Width:  |  Height:  |  Size: 2.8 KiB

View File

@ -1 +1 @@
[{"Name":"Preinstall1","Weight":100,"Remark":"","AutoFill":true,"WaveList":[[]]}] [{"Name":"Preinstall1","Weight":100,"Remark":"","AutoFill":true,"WaveList":[[{"Position":{"X":48,"Y":15},"Size":{"X":0,"Y":0},"SpecialMarkType":3,"DelayTime":0,"MarkList":[]}]]}]

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.2 KiB

After

Width:  |  Height:  |  Size: 2.2 KiB

View File

@ -1 +1 @@
[{"Name":"Preinstall1","Weight":100,"Remark":"","AutoFill":true,"WaveList":[[]]}] [{"Name":"Preinstall1","Weight":100,"Remark":"","AutoFill":true,"WaveList":[[{"Position":{"X":0,"Y":0},"Size":{"X":0,"Y":0},"SpecialMarkType":4,"DelayTime":0,"MarkList":[]}]]}]

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.5 KiB

After

Width:  |  Height:  |  Size: 3.2 KiB

View File

@ -106,6 +106,14 @@ public static class PreinstallMarkManager
{ {
return "出口标记"; return "出口标记";
} }
else if (type == SpecialMarkType.ShopBoss)
{
return "商店老板标记";
}
else if (type == SpecialMarkType.Box)
{
return "奖励箱子标记";
}
return string.Empty; return string.Empty;
} }

View File

@ -99,72 +99,7 @@ public class RoomPreinstall : IDestroy
var mark = new ActivityMark(); var mark = new ActivityMark();
if (markInfo.SpecialMarkType == SpecialMarkType.Normal) //普通标记 if (markInfo.SpecialMarkType == SpecialMarkType.Normal) //普通标记
{ {
MarkInfoItem markInfoItem; if (HandlerNormalMark(world, markInfo, mark)) continue;
if (markInfo.MarkList.Count == 0)
{
continue;
}
else if (markInfo.MarkList.Count == 1)
{
markInfoItem = markInfo.MarkList[0];
}
else
{
var tempArray = markInfo.MarkList.Select(item => item.Weight).ToArray();
var index = world.Random.RandomWeight(tempArray);
markInfoItem = markInfo.MarkList[index];
}
var activityBase = PreinstallMarkManager.GetMarkConfig(markInfoItem.Id);
mark.Attr = markInfoItem.Attr;
mark.VerticalSpeed = markInfoItem.VerticalSpeed;
mark.Altitude = markInfoItem.Altitude;
if (activityBase is RandomActivityBase) //随机物体
{
if (markInfoItem.Id == PreinstallMarkManager.RandomWeapon.Id) //随机武器
{
mark.Id = world.RandomPool.GetRandomWeapon()?.Id;
mark.ActivityType = ActivityType.Weapon;
}
else if (markInfoItem.Id == PreinstallMarkManager.RandomEnemy.Id) //随机敌人
{
mark.Id = world.RandomPool.GetRandomEnemy()?.Id;
mark.ActivityType = ActivityType.Enemy;
}
else if (markInfoItem.Id == PreinstallMarkManager.RandomProp.Id) //随机道具
{
mark.Id = world.RandomPool.GetRandomProp()?.Id;
mark.ActivityType = ActivityType.Prop;
}
else //非随机物体
{
Debug.LogError("未知的随机物体:" + markInfoItem.Id);
continue;
}
}
else
{
mark.Id = markInfoItem.Id;
mark.ActivityType = (ActivityType)activityBase.Type;
if (mark.ActivityType == ActivityType.Enemy) //敌人类型
{
mark.DerivedAttr = new Dictionary<string, string>();
if (!mark.Attr.TryGetValue("Face", out var face) || face == "0") //随机方向
{
mark.DerivedAttr.Add("Face",
world.Random.RandomChoose(
((int)FaceDirection.Left).ToString(),
((int)FaceDirection.Right).ToString()
)
);
}
else //指定方向
{
mark.DerivedAttr.Add("Face", face);
}
}
}
} }
else if (markInfo.SpecialMarkType == SpecialMarkType.BirthPoint) //玩家出生标记 else if (markInfo.SpecialMarkType == SpecialMarkType.BirthPoint) //玩家出生标记
{ {
@ -172,7 +107,15 @@ public class RoomPreinstall : IDestroy
} }
else if (markInfo.SpecialMarkType == SpecialMarkType.OutPoint) //出口标记 else if (markInfo.SpecialMarkType == SpecialMarkType.OutPoint) //出口标记
{ {
}
else if (markInfo.SpecialMarkType == SpecialMarkType.ShopBoss) //商店老板标记
{
}
else if (markInfo.SpecialMarkType == SpecialMarkType.Box) //奖励宝箱标记
{
} }
else else
{ {
@ -209,6 +152,78 @@ public class RoomPreinstall : IDestroy
CheckHasEnemy(); CheckHasEnemy();
} }
private static bool HandlerNormalMark(World world, MarkInfo markInfo, ActivityMark mark)
{
MarkInfoItem markInfoItem;
if (markInfo.MarkList.Count == 0)
{
return true;
}
else if (markInfo.MarkList.Count == 1)
{
markInfoItem = markInfo.MarkList[0];
}
else
{
var tempArray = markInfo.MarkList.Select(item => item.Weight).ToArray();
var index = world.Random.RandomWeight(tempArray);
markInfoItem = markInfo.MarkList[index];
}
var activityBase = PreinstallMarkManager.GetMarkConfig(markInfoItem.Id);
mark.Attr = markInfoItem.Attr;
mark.VerticalSpeed = markInfoItem.VerticalSpeed;
mark.Altitude = markInfoItem.Altitude;
if (activityBase is RandomActivityBase) //随机物体
{
if (markInfoItem.Id == PreinstallMarkManager.RandomWeapon.Id) //随机武器
{
mark.Id = world.RandomPool.GetRandomWeapon()?.Id;
mark.ActivityType = ActivityType.Weapon;
}
else if (markInfoItem.Id == PreinstallMarkManager.RandomEnemy.Id) //随机敌人
{
mark.Id = world.RandomPool.GetRandomEnemy()?.Id;
mark.ActivityType = ActivityType.Enemy;
}
else if (markInfoItem.Id == PreinstallMarkManager.RandomProp.Id) //随机道具
{
mark.Id = world.RandomPool.GetRandomProp()?.Id;
mark.ActivityType = ActivityType.Prop;
}
else //非随机物体
{
Debug.LogError("未知的随机物体:" + markInfoItem.Id);
return true;
}
}
else
{
mark.Id = markInfoItem.Id;
mark.ActivityType = (ActivityType)activityBase.Type;
if (mark.ActivityType == ActivityType.Enemy) //敌人类型
{
mark.DerivedAttr = new Dictionary<string, string>();
if (!mark.Attr.TryGetValue("Face", out var face) || face == "0") //随机方向
{
mark.DerivedAttr.Add("Face",
world.Random.RandomChoose(
((int)FaceDirection.Left).ToString(),
((int)FaceDirection.Right).ToString()
)
);
}
else //指定方向
{
mark.DerivedAttr.Add("Face", face);
}
}
}
return false;
}
private void CheckHasEnemy() private void CheckHasEnemy()
{ {
foreach (var marks in WaveList) foreach (var marks in WaveList)
@ -435,9 +450,9 @@ public class RoomPreinstall : IDestroy
} }
/// <summary> /// <summary>
/// 获取房间内的玩家生成标记 /// 获取房间内的特殊标记
/// </summary> /// </summary>
public ActivityMark GetPlayerBirthMark() public ActivityMark GetSpecialMark(SpecialMarkType specialMarkType)
{ {
if (WaveList.Count == 0) if (WaveList.Count == 0)
{ {
@ -445,7 +460,7 @@ public class RoomPreinstall : IDestroy
} }
var activityMarks = WaveList[0]; var activityMarks = WaveList[0];
var activityMark = activityMarks.FirstOrDefault(mark => mark.MarkType == SpecialMarkType.BirthPoint); var activityMark = activityMarks.FirstOrDefault(mark => mark.MarkType == specialMarkType);
return activityMark; return activityMark;
} }

View File

@ -16,4 +16,12 @@ public enum SpecialMarkType
/// 地牢出口 /// 地牢出口
/// </summary> /// </summary>
OutPoint, OutPoint,
/// <summary>
/// 宝箱房刷新点
/// </summary>
Box,
/// <summary>
/// 商店房商店老板刷新点
/// </summary>
ShopBoss,
} }

View File

@ -53,16 +53,7 @@ public class RoomPreinstallInfo
/// </summary> /// </summary>
public void InitSpecialMark(DungeonRoomType roomType) public void InitSpecialMark(DungeonRoomType roomType)
{ {
var type = SpecialMarkType.Normal; var type = GetRoomSpecialMark(roomType);
if (roomType == DungeonRoomType.Inlet) //初始房间
{
type = SpecialMarkType.BirthPoint;
}
else if (roomType == DungeonRoomType.Outlet) //结束房间
{
type = SpecialMarkType.OutPoint;
}
if (type != SpecialMarkType.Normal) if (type != SpecialMarkType.Normal)
{ {
var preloading = WaveList[0]; var preloading = WaveList[0];
@ -74,4 +65,56 @@ public class RoomPreinstallInfo
preloading.Add(markInfo); preloading.Add(markInfo);
} }
} }
/// <summary>
/// 检查是否创建了特殊标记, 如果没有, 则会自动创建并返回false
/// </summary>
public bool CheckSpecialMark(DungeonRoomType roomType)
{
var type = GetRoomSpecialMark(roomType);
if (type == SpecialMarkType.Normal)
{
return true;
}
if (WaveList.Count> 0)
{
var markInfos = WaveList[0];
foreach (var markInfo in markInfos)
{
if (markInfo.SpecialMarkType == type)
{
return true;
}
}
}
InitSpecialMark(roomType);
return false;
}
/// <summary>
/// 获取指定类型房间中应该存在的特殊标记数据类型
/// </summary>
public SpecialMarkType GetRoomSpecialMark(DungeonRoomType roomType)
{
if (roomType == DungeonRoomType.Inlet) //初始房间
{
return SpecialMarkType.BirthPoint;
}
else if (roomType == DungeonRoomType.Outlet) //结束房间
{
return SpecialMarkType.OutPoint;
}
else if (roomType == DungeonRoomType.Shop) //商店房间
{
return SpecialMarkType.ShopBoss;
}
else if (roomType == DungeonRoomType.Reward) //奖励房间
{
return SpecialMarkType.Box;
}
return SpecialMarkType.Normal;
}
} }

View File

@ -10,6 +10,9 @@ public static class EditorPlayManager
private static DungeonConfig _config; private static DungeonConfig _config;
/// <summary>
/// 地牢编辑器中的播放按钮
/// </summary>
public static void Play(UiBase prevUi) public static void Play(UiBase prevUi)
{ {
if (IsPlay) if (IsPlay)

View File

@ -186,6 +186,14 @@ public static class ResourceManager
{ {
return LoadTexture2D(ResourcePath.resource_sprite_ui_commonIcon_BirthMark_png); return LoadTexture2D(ResourcePath.resource_sprite_ui_commonIcon_BirthMark_png);
} }
else if (markInfo.SpecialMarkType == SpecialMarkType.Box) //宝箱
{
return LoadTexture2D(ResourcePath.resource_sprite_ui_commonIcon_BirthMark_png);
}
else if (markInfo.SpecialMarkType == SpecialMarkType.ShopBoss) //商店老板
{
return LoadTexture2D(ResourcePath.resource_sprite_ui_commonIcon_BirthMark_png);
}
else if (markInfo.MarkList != null) //普通标记 else if (markInfo.MarkList != null) //普通标记
{ {
if (markInfo.MarkList.Count > 1) //多个物体 if (markInfo.MarkList.Count > 1) //多个物体

View File

@ -480,7 +480,7 @@ public partial class DungeonManager : Node2D
yield return 0; yield return 0;
//初始房间创建玩家标记 //初始房间创建玩家标记
var playerBirthMark = StartRoomInfo.RoomPreinstall.GetPlayerBirthMark(); var playerBirthMark = StartRoomInfo.RoomPreinstall.GetSpecialMark(SpecialMarkType.BirthPoint);
//创建玩家 //创建玩家
var player = Player.Current; var player = Player.Current;

View File

@ -151,7 +151,12 @@ public partial class MapEditorMapMarkPanel : MapEditorMapMark
{ {
item.InitWaveList(); item.InitWaveList();
} }
//检测是否创建特殊标记
if (!item.CheckSpecialMark(EditorTileMapManager.SelectRoom.RoomInfo.RoomType))
{
EventManager.EmitEvent(EventEnum.OnTileMapDirty);
}
optionButton.AddItem($"{item.Name} ({item.Weight})"); optionButton.AddItem($"{item.Name} ({item.Weight})");
} }