|
@@ -63,12 +63,12 @@ public class EnemyCreater : MonoBehaviour
|
|
|
if (haveStart)
|
|
if (haveStart)
|
|
|
{
|
|
{
|
|
|
createdEnemy.Add(false);
|
|
createdEnemy.Add(false);
|
|
|
- if(id != cfgCreateEnemy[i].WaveID)
|
|
|
|
|
|
|
+ createEnemyTime.Add(new List<float> { waveTime + cfgCreateEnemy[i].StartTime, waveTime + cfgCreateEnemy[i].EndTime });
|
|
|
|
|
+ if (id != cfgCreateEnemy[i].WaveID)
|
|
|
{
|
|
{
|
|
|
waveTime += cfgCreateEnemy[i].WaveTime;
|
|
waveTime += cfgCreateEnemy[i].WaveTime;
|
|
|
id = cfgCreateEnemy[i].WaveID;
|
|
id = cfgCreateEnemy[i].WaveID;
|
|
|
}
|
|
}
|
|
|
- createEnemyTime.Add(new List<float> { waveTime + cfgCreateEnemy[i].StartTime, waveTime + cfgCreateEnemy[i].EndTime });
|
|
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
if(end == -1)
|
|
if(end == -1)
|
|
@@ -108,32 +108,43 @@ public class EnemyCreater : MonoBehaviour
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ //ÿһÐйÖ
|
|
|
public async void StartCreateEnemy(SingleCreateEnemyConfig cfgCreateEnemy, SingleCreateEnemyConfig cfgCreateWave)
|
|
public async void StartCreateEnemy(SingleCreateEnemyConfig cfgCreateEnemy, SingleCreateEnemyConfig cfgCreateWave)
|
|
|
{
|
|
{
|
|
|
- for (int i = 0; i < cfgCreateEnemy.Count; i++)
|
|
|
|
|
|
|
+ if (!instance)
|
|
|
{
|
|
{
|
|
|
- if (!instance)
|
|
|
|
|
- {
|
|
|
|
|
- return;
|
|
|
|
|
- }
|
|
|
|
|
- for(int j= 0; j < cfgCreateEnemy.Position.Count; j+=2)
|
|
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ if (cfgCreateEnemy.Count == 1)
|
|
|
|
|
+ {
|
|
|
|
|
+ int randId = Random.Range(0, cfgCreateEnemy.Position.Count / 2 - 1);
|
|
|
|
|
+ Vector3 pos = new Vector3(cfgCreateEnemy.Position[randId * 2], cfgCreateEnemy.Position[randId * 2 + 1], 0);
|
|
|
|
|
+ CreateEnemy(cfgCreateEnemy, cfgCreateWave, pos, true);
|
|
|
|
|
+ return;
|
|
|
|
|
+ }
|
|
|
|
|
+ int num1 = cfgCreateEnemy.Count / (cfgCreateEnemy.Position.Count / 2);
|
|
|
|
|
+ int num2 = cfgCreateEnemy.Count % (cfgCreateEnemy.Position.Count / 2);
|
|
|
|
|
+ float TimeInterval = cfgCreateEnemy.StartTime >= cfgCreateEnemy.EndTime
|
|
|
|
|
+ ? 0
|
|
|
|
|
+ :(float)(cfgCreateEnemy.EndTime - cfgCreateEnemy.StartTime) / (cfgCreateEnemy.Count - 1);
|
|
|
|
|
+ for (int i = 0; i < num1; i++)
|
|
|
|
|
+ {
|
|
|
|
|
+ for (int j = 0; j < cfgCreateEnemy.Position.Count; j += 2)
|
|
|
{
|
|
{
|
|
|
- Vector3 pos = new Vector3(cfgCreateEnemy.Position[j], cfgCreateEnemy.Position[j+1],0);
|
|
|
|
|
|
|
+ Vector3 pos = new Vector3(cfgCreateEnemy.Position[j], cfgCreateEnemy.Position[j + 1], 0);
|
|
|
CreateEnemy(cfgCreateEnemy, cfgCreateWave, pos, true);
|
|
CreateEnemy(cfgCreateEnemy, cfgCreateWave, pos, true);
|
|
|
-
|
|
|
|
|
- }
|
|
|
|
|
-
|
|
|
|
|
- if(cfgCreateEnemy.Count == 1)
|
|
|
|
|
- {
|
|
|
|
|
- return;
|
|
|
|
|
- }
|
|
|
|
|
- float TimeInterval = (float)(cfgCreateEnemy.EndTime - cfgCreateEnemy.StartTime) / (cfgCreateEnemy.Count - 1);
|
|
|
|
|
- if (TimeInterval < 0)
|
|
|
|
|
- {
|
|
|
|
|
- return;
|
|
|
|
|
}
|
|
}
|
|
|
await Task.Delay((int)(TimeInterval * 1000));
|
|
await Task.Delay((int)(TimeInterval * 1000));
|
|
|
}
|
|
}
|
|
|
|
|
+ List<int> randomPos = cfgCreateEnemy.Position.GetRange(cfgCreateEnemy.Count - num2, num2 * 2);
|
|
|
|
|
+ for (int i = 0; i < num2; i++)
|
|
|
|
|
+ {
|
|
|
|
|
+ int randId = Random.Range(0, randomPos.Count / 2 - 1);
|
|
|
|
|
+ Vector3 pos = new Vector3(randomPos[randId * 2], randomPos[randId * 2 + 1], 0);
|
|
|
|
|
+ randomPos.Remove(randId * 2 + 1);
|
|
|
|
|
+ randomPos.Remove(randId * 2);
|
|
|
|
|
+ CreateEnemy(cfgCreateEnemy, cfgCreateWave, pos, true);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@@ -141,6 +152,9 @@ public class EnemyCreater : MonoBehaviour
|
|
|
{
|
|
{
|
|
|
SingleEnemyConfig cfgEnemy = GameManager.instance.allCfgData.CfgEnemy.Get(cfgCreateEnemy.EnemyName);
|
|
SingleEnemyConfig cfgEnemy = GameManager.instance.allCfgData.CfgEnemy.Get(cfgCreateEnemy.EnemyName);
|
|
|
string enemyStr = $"Prefab/{cfgEnemy.Type}/{cfgEnemy.EnemyPrefab}";
|
|
string enemyStr = $"Prefab/{cfgEnemy.Type}/{cfgEnemy.EnemyPrefab}";
|
|
|
|
|
+ float posx = pos.x + Random.Range(-cfgEnemy.Radius[0], cfgEnemy.Radius[0]);
|
|
|
|
|
+ float posy = pos.y + Random.Range(-cfgEnemy.Radius[1], cfgEnemy.Radius[1]) - 1;
|
|
|
|
|
+ pos = new Vector3(posx, posy <= 0 ? 0 : posy, 0);
|
|
|
GameObject enemyObj = Util.Instantiate(enemyStr, pos, active: active);
|
|
GameObject enemyObj = Util.Instantiate(enemyStr, pos, active: active);
|
|
|
AttackInfo attackInfo;
|
|
AttackInfo attackInfo;
|
|
|
if(cfgEnemy.Type == "Tower")
|
|
if(cfgEnemy.Type == "Tower")
|