diff --git a/DungeonShooting_Godot/resource/map/tileMaps/Test1/reward/Award1/Preinstall.json b/DungeonShooting_Godot/resource/map/tileMaps/Test1/reward/Award1/Preinstall.json
index d5ca4fa..a9f951a 100644
--- a/DungeonShooting_Godot/resource/map/tileMaps/Test1/reward/Award1/Preinstall.json
+++ b/DungeonShooting_Godot/resource/map/tileMaps/Test1/reward/Award1/Preinstall.json
@@ -1 +1 @@
-[{"Name":"Preinstall1","Weight":100,"Remark":"","AutoFill":false,"WaveList":[[]]}]
\ No newline at end of file
+[{"Name":"Preinstall1","Weight":100,"Remark":"","AutoFill":true,"WaveList":[[]]}]
\ No newline at end of file
diff --git a/DungeonShooting_Godot/src/framework/map/DungeonGenerator.cs b/DungeonShooting_Godot/src/framework/map/DungeonGenerator.cs
index b516aad..5ff6d7c 100644
--- a/DungeonShooting_Godot/src/framework/map/DungeonGenerator.cs
+++ b/DungeonShooting_Godot/src/framework/map/DungeonGenerator.cs
@@ -474,7 +474,7 @@
{
_nextRoomType = DungeonRoomType.Inlet;
}
- else if (_count == 1) //奖励房间
+ else if (_count == 0) //奖励房间
{
_nextRoomType = DungeonRoomType.Reward;
}
diff --git a/DungeonShooting_Godot/src/framework/map/RandomPool.cs b/DungeonShooting_Godot/src/framework/map/RandomPool.cs
index a55040a..50d0e33 100644
--- a/DungeonShooting_Godot/src/framework/map/RandomPool.cs
+++ b/DungeonShooting_Godot/src/framework/map/RandomPool.cs
@@ -1,5 +1,7 @@
+using System.Collections.Generic;
using Config;
+using Godot;
public class RandomPool
{
@@ -42,4 +44,102 @@
{
return Random.RandomChoose(PreinstallMarkManager.GetMarkConfigsByType(ActivityType.Prop));
}
+
+ ///
+ /// 填充自动波次数据
+ ///
+ public void FillAutoWave(RoomPreinstall preinstall)
+ {
+ if (preinstall.RoomInfo.RoomType == DungeonRoomType.Battle)
+ {
+ FillBattleRoom(preinstall);
+ }
+ else if (preinstall.RoomInfo.RoomType == DungeonRoomType.Reward)
+ {
+ FillRewardRoom(preinstall);
+ }
+ }
+
+ //填充战斗房间
+ private void FillBattleRoom(RoomPreinstall preinstall)
+ {
+ var count = World.Random.RandomRangeInt(3, 10);
+ var tileInfo = preinstall.RoomInfo.RoomSplit.TileInfo;
+ var serializeVector2s = tileInfo.NavigationVertices;
+ var vertices = new List();
+ foreach (var sv2 in serializeVector2s)
+ {
+ vertices.Add(sv2.AsVector2());
+ }
+ var positionArray = World.Random.GetRandomPositionInPolygon(vertices, tileInfo.NavigationPolygon, count);
+ var arr = new ActivityType[] { ActivityType.Enemy, ActivityType.Weapon, ActivityType.Prop };
+ var weight = new int[] { 15, 2, 1 };
+ for (var i = 0; i < count; i++)
+ {
+ var tempWave = GetOrCreateWave(preinstall, World.Random.RandomRangeInt(0, 2));
+ var index = World.Random.RandomWeight(weight);
+ var activityType = arr[index];
+
+ //创建标记
+ var mark = CreateMark(activityType, i * 0.3f, preinstall.RoomInfo.ToGlobalPosition(positionArray[i]));
+
+ if (activityType == ActivityType.Enemy) //敌人
+ {
+ mark.Id = GetRandomEnemy().Id;
+ mark.Attr.Add("Face", "0");
+ mark.DerivedAttr = new Dictionary();
+ mark.DerivedAttr.Add("Face", World.Random.RandomChoose((int)FaceDirection.Left, (int)FaceDirection.Right).ToString()); //链朝向
+ if (World.Random.RandomBoolean(0.8f)) //手持武器
+ {
+ var weapon = GetRandomWeapon();
+ var weaponAttribute = Weapon.GetWeaponAttribute(weapon.Id);
+ mark.Attr.Add("Weapon", weapon.Id); //武器id
+ mark.Attr.Add("CurrAmmon", weaponAttribute.AmmoCapacity.ToString()); //弹夹弹药量
+ mark.Attr.Add("ResidueAmmo", weaponAttribute.AmmoCapacity.ToString()); //剩余弹药量
+ }
+ }
+ else if (activityType == ActivityType.Weapon) //武器
+ {
+ mark.Id = GetRandomWeapon().Id;
+ }
+ else if (activityType == ActivityType.Prop) //道具
+ {
+ mark.Id = GetRandomProp().Id;
+ }
+ tempWave.Add(mark);
+ }
+ }
+
+ //填充奖励房间
+ private void FillRewardRoom(RoomPreinstall preinstall)
+ {
+ var wave = GetOrCreateWave(preinstall, 0);
+ var mark = CreateMark(ActivityType.Prop, 0, (preinstall.RoomInfo.Waypoints + new Vector2(0.5f, 0.5f)) * GameConfig.TileCellSize);
+ mark.Id = GetRandomProp().Id;
+ wave.Add(mark);
+ }
+
+ private List GetOrCreateWave(RoomPreinstall preinstall,int waveIndex)
+ {
+ while (preinstall.WaveList.Count <= waveIndex)
+ {
+ preinstall.WaveList.Add(new List());
+ }
+
+ return preinstall.WaveList[waveIndex];
+ }
+
+ //创建标记
+ private ActivityMark CreateMark(ActivityType activityType, float delayTime, Vector2 pos)
+ {
+ var mark = new ActivityMark();
+ mark.Attr = new Dictionary();
+ mark.ActivityType = activityType;
+ mark.MarkType = SpecialMarkType.Normal;
+ mark.VerticalSpeed = 0;
+ mark.Altitude = activityType == ActivityType.Enemy ? 0 : 8;
+ mark.DelayTime = delayTime;
+ mark.Position = pos;
+ return mark;
+ }
}
\ No newline at end of file
diff --git a/DungeonShooting_Godot/src/framework/map/preinstall/RoomPreinstall.cs b/DungeonShooting_Godot/src/framework/map/preinstall/RoomPreinstall.cs
index 55c9ed3..458b8bc 100644
--- a/DungeonShooting_Godot/src/framework/map/preinstall/RoomPreinstall.cs
+++ b/DungeonShooting_Godot/src/framework/map/preinstall/RoomPreinstall.cs
@@ -191,58 +191,9 @@
}
//自动填充操作
- if (RoomPreinstallInfo.AutoFill && RoomInfo.RoomType == DungeonRoomType.Battle)
+ if (RoomPreinstallInfo.AutoFill)
{
- var count = world.Random.RandomRangeInt(3, 10);
- var tileInfo = RoomInfo.RoomSplit.TileInfo;
- var serializeVector2s = tileInfo.NavigationVertices;
- var vertices = new List();
- foreach (var sv2 in serializeVector2s)
- {
- vertices.Add(sv2.AsVector2());
- }
- var positionArray = world.Random.GetRandomPositionInPolygon(vertices, tileInfo.NavigationPolygon, count);
- var arr = new ActivityType[] { ActivityType.Enemy, ActivityType.Weapon, ActivityType.Prop };
- var weight = new int[] { 15, 2, 1 };
- for (var i = 0; i < count; i++)
- {
- var tempWave = GetOrCreateWave(world.Random.RandomRangeInt(0, 2));
- var mark = new ActivityMark();
- mark.Attr = new Dictionary();
- var index = world.Random.RandomWeight(weight);
- var activityType = arr[index];
- if (activityType == ActivityType.Enemy) //敌人
- {
- mark.Id = world.RandomPool.GetRandomEnemy().Id;
- mark.Attr.Add("Face", "0");
- mark.DerivedAttr = new Dictionary();
- mark.DerivedAttr.Add("Face", world.Random.RandomChoose((int)FaceDirection.Left, (int)FaceDirection.Right).ToString()); //链朝向
- if (world.Random.RandomBoolean(0.8f)) //手持武器
- {
- var weapon = world.RandomPool.GetRandomWeapon();
- var weaponAttribute = Weapon.GetWeaponAttribute(weapon.Id);
- mark.Attr.Add("Weapon", weapon.Id); //武器id
- mark.Attr.Add("CurrAmmon", weaponAttribute.AmmoCapacity.ToString()); //弹夹弹药量
- mark.Attr.Add("ResidueAmmo", weaponAttribute.AmmoCapacity.ToString()); //剩余弹药量
- }
- }
- else if (activityType == ActivityType.Weapon) //武器
- {
- mark.Id = world.RandomPool.GetRandomWeapon().Id;
- }
- else if (activityType == ActivityType.Prop) //道具
- {
- mark.Id = world.RandomPool.GetRandomProp().Id;
- }
-
- mark.ActivityType = activityType;
- mark.MarkType = SpecialMarkType.Normal;
- mark.VerticalSpeed = 0;
- mark.Altitude = activityType == ActivityType.Enemy ? 0 : 8;
- mark.DelayTime = i * 0.3f;
- mark.Position = RoomInfo.ToGlobalPosition(positionArray[i]);
- tempWave.Add(mark);
- }
+ world.RandomPool.FillAutoWave(this);
}
//排序操作
@@ -565,14 +516,4 @@
}
}
}
-
- private List GetOrCreateWave(int waveIndex)
- {
- while (WaveList.Count <= waveIndex)
- {
- WaveList.Add(new List());
- }
-
- return WaveList[waveIndex];
- }
}
\ No newline at end of file