|
|
@@ -232,23 +232,106 @@ public class EnemyCreater : MonoBehaviour
|
|
|
}
|
|
|
|
|
|
//计算是九个出怪表中的哪个出怪表
|
|
|
- public void GetLevelOrientation()
|
|
|
+ public void GetLevelOrientation(int id)
|
|
|
{
|
|
|
List<int> soldierRank = new List<int>();
|
|
|
for(int i = 0; i < 3; i++)
|
|
|
{
|
|
|
soldierRank.Add(SoldierEXP.expInstance.ssexp[i].level);
|
|
|
}
|
|
|
- int maxId = MaxSoldierLevel(soldierRank);
|
|
|
- List<int> typeDir = new List<int> { 6, 4, 1 };
|
|
|
- for(int i = 0; i < 2; i++)
|
|
|
+ List<List<int>> idSort = new List<List<int>>();
|
|
|
+ if (soldierRank[0] == soldierRank[1])
|
|
|
{
|
|
|
- levelTypes[i] = (typeDir[maxId] + 4 * i + Random.Range(-1, 2)+8)%8;
|
|
|
- if(levelTypes[i] == 0)
|
|
|
+ idSort.Add(new List<int> { 0, 1 });
|
|
|
+ if (soldierRank[2] == idSort[0][0])
|
|
|
{
|
|
|
- levelTypes[i] = 8;
|
|
|
+ idSort[0].Add(2);
|
|
|
+ }
|
|
|
+ else if (soldierRank[2] > idSort[0][0])
|
|
|
+ {
|
|
|
+ idSort.Insert(0, new List<int> { 2 });
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ idSort.Add(new List<int> { 2 });
|
|
|
+ }
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ if (soldierRank[0] > soldierRank[1])
|
|
|
+ {
|
|
|
+ idSort.Add(new List<int> { 0 });
|
|
|
+ idSort.Add(new List<int> { 1 });
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ idSort.Add(new List<int> { 1 });
|
|
|
+ idSort.Add(new List<int> { 0 });
|
|
|
+ }
|
|
|
+ for(int i = 0; i < 2; i++)
|
|
|
+ {
|
|
|
+ if(soldierRank[2] > idSort[i][0])
|
|
|
+ {
|
|
|
+ idSort.Insert(i, new List<int> { 2 });
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ if(soldierRank[2] == idSort[i][0])
|
|
|
+ {
|
|
|
+ idSort[i].Add(2);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ if(i == 1)
|
|
|
+ {
|
|
|
+ idSort.Add(new List<int> { 2 });
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
+ }
|
|
|
+
|
|
|
+ List<int> idList = new List<int> { 6,4,1 };
|
|
|
+ int x0;
|
|
|
+ int x1;
|
|
|
+ switch (idSort.Count)
|
|
|
+ {
|
|
|
+ case 1:
|
|
|
+ levelTypes[id] = Random.Range(1, 9);
|
|
|
+ break;
|
|
|
+ case 2:
|
|
|
+ switch (idSort[id].Count)
|
|
|
+ {
|
|
|
+ case 1:
|
|
|
+ levelTypes[id] = idList[idSort[id][0]];
|
|
|
+ break;
|
|
|
+ case 2:
|
|
|
+ x0 = idSort[id][0];
|
|
|
+ x1 = idSort[id][1];
|
|
|
+ if(x0 == 0 && x1 == 2)
|
|
|
+ {
|
|
|
+ levelTypes[id] = Random.Range(7, 9);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ levelTypes[id] = Random.Range(idList[x1] + 1, idList[x0]);
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ case 3:
|
|
|
+ x0 = Mathf.Min(idSort[0 + id * 2][0], idSort[1][0]);
|
|
|
+ x1 = Mathf.Max(idSort[0 + id * 2][0], idSort[1][0]);
|
|
|
+ if (x0 == 0 && x1 == 2)
|
|
|
+ {
|
|
|
+ levelTypes[id] = Random.Range(7, 9);
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
+ levelTypes[id] = Random.Range(idList[x1] + 1, idList[x0]);
|
|
|
+ }
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (id == 1 && levelTypes[1] == levelTypes[0])
|
|
|
+ {
|
|
|
+ GetLevelOrientation(1);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@@ -364,28 +447,6 @@ public class EnemyCreater : MonoBehaviour
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- //比较三个值里的最大值为哪个,等级相同则随机一个
|
|
|
- public int MaxSoldierLevel(List<int> soldierRank)
|
|
|
- {
|
|
|
- int a = soldierRank[0];
|
|
|
- int b = soldierRank[1];
|
|
|
- int c = soldierRank[2];
|
|
|
- int max = Mathf.Max(a, Mathf.Max(b, c)); // 先找到最大值
|
|
|
-
|
|
|
- // 收集所有等于最大值的变量名(可能有多个)
|
|
|
- List<int> maxVariables = new List<int>();
|
|
|
-
|
|
|
- if (a == max) maxVariables.Add(0);
|
|
|
- if (b == max) maxVariables.Add(1);
|
|
|
- if (c == max) maxVariables.Add(2);
|
|
|
-
|
|
|
- // 随机选择一个(如果有多个最大值)
|
|
|
-
|
|
|
- int maxID = maxVariables[Random.Range(0, maxVariables.Count)];
|
|
|
- Debug.Log($"等级:{a};{b};{c},取{maxID}");
|
|
|
- return maxID;
|
|
|
- }
|
|
|
-
|
|
|
//出怪表每一行怪
|
|
|
public void CreateEnemy(SingleCreateEnemyConfig cfg, Vector3 pos, bool active = false)
|
|
|
{
|