【战斗】【轰炸区】增加关卡数据 及 辅助方法
parent
6824b7fb09
commit
5df447a5b8
|
|
@ -24,6 +24,44 @@ namespace Framework.Utils
|
|||
sb.Append("]");
|
||||
return sb.ToString();
|
||||
}
|
||||
|
||||
public static List<T> RandomArray<T>(this List<T> list, int requireCount)
|
||||
{
|
||||
if (list == null)
|
||||
{
|
||||
return null;
|
||||
}
|
||||
|
||||
if (requireCount >= list.Count)
|
||||
{
|
||||
return new List<T>(list);
|
||||
}
|
||||
|
||||
if (requireCount <= 0)
|
||||
{
|
||||
return new List<T>(0);
|
||||
}
|
||||
|
||||
var random = new System.Random(UnityEngine.Time.frameCount);
|
||||
var result = new List<T>(requireCount);
|
||||
var indexList = new List<int>(list.Count);
|
||||
for (int i = 0; i < list.Count; i++)
|
||||
{
|
||||
indexList.Add(i);
|
||||
}
|
||||
|
||||
for (int i = 0; i < requireCount; i++)
|
||||
{
|
||||
int randomIndex = random.Next(0, indexList.Count);
|
||||
result.Add(list[indexList[randomIndex]]);
|
||||
|
||||
int lastIndex = indexList.Count - 1;
|
||||
indexList[randomIndex] = indexList[lastIndex];
|
||||
indexList.RemoveAt(lastIndex);
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -175,6 +175,7 @@ namespace Gameplay.Level
|
|||
public class BombAreaInfo
|
||||
{
|
||||
[HideInInspector] [LabelText("触发条件")] public int triggerTaskID;
|
||||
[LabelText("使用的子弹id")] public int bombBulletId;
|
||||
[LabelText("轰炸间隔")] public float intervalTime;
|
||||
[LabelText("轰炸次数")] public int bombCount;
|
||||
[LabelText("最小轰炸中心数量")] public int bombMinCount;
|
||||
|
|
|
|||
Loading…
Reference in New Issue