|
|
@@ -21,6 +21,7 @@ public class EnemyCreater : MonoBehaviour
|
|
|
public List<List<float>> createEnemyTime1 = new();
|
|
|
public Dictionary<string, List<Enemy>> enemyDic;
|
|
|
public Dictionary<string, List<GameObject>> buildingDic;
|
|
|
+ public Dictionary<string, List<Boss>> bossDic;
|
|
|
public Vector2Int idRange; //当前关卡为出怪表[x,y]行
|
|
|
public Vector2Int idRange1; //当前关卡为出怪表[x,y]行
|
|
|
public Dictionary<string, EnemyTower> enemyCreateTowerDic;
|
|
|
@@ -98,6 +99,7 @@ public class EnemyCreater : MonoBehaviour
|
|
|
|
|
|
enemyDic = new Dictionary<string, List<Enemy>>();
|
|
|
buildingDic = new Dictionary<string, List<GameObject>>();
|
|
|
+ bossDic = new Dictionary<string, List<Boss>>();
|
|
|
enemyCreateTowerDic = new Dictionary<string, EnemyTower>();
|
|
|
createdEnemy = new List<bool>();
|
|
|
createEnemyTime = new List<List<float>>();
|
|
|
@@ -483,74 +485,94 @@ public class EnemyCreater : MonoBehaviour
|
|
|
pos = new Vector3(posx, posy <= 0 ? 0 : posy, 0);
|
|
|
GameObject enemyObj = Util.Instantiate(enemyStr, pos, active: active);
|
|
|
AttackInfo attackInfo;
|
|
|
- if(cfgEnemy.Type == "Tower")
|
|
|
+ switch (cfgEnemy.Type)
|
|
|
{
|
|
|
- EnemyTower enemyTower = enemyObj.GetComponent<EnemyTower>();
|
|
|
- Tower tower = enemyObj.GetComponent<Tower>();
|
|
|
- if (enemyTower != null)
|
|
|
- {
|
|
|
- enemyTower.name = cfgEnemy.Name;
|
|
|
+ case "Tower":
|
|
|
+ EnemyTower enemyTower = enemyObj.GetComponent<EnemyTower>();
|
|
|
+ Tower tower = enemyObj.GetComponent<Tower>();
|
|
|
+ if (enemyTower != null)
|
|
|
+ {
|
|
|
+ enemyTower.name = cfgEnemy.Name;
|
|
|
|
|
|
- enemyTower.totalHp = (int)(cfgEnemy.HP * HPRatio);
|
|
|
- enemyTower.hp = enemyTower.totalHp;
|
|
|
+ enemyTower.totalHp = (int)(cfgEnemy.HP * HPRatio);
|
|
|
+ enemyTower.hp = enemyTower.totalHp;
|
|
|
|
|
|
- attackInfo = enemyTower.attackController.curAttackMethod.attackInfo;
|
|
|
- attackInfo.damage = (int)(cfgEnemy.AttackMarch[0] * AttackRatio);
|
|
|
- enemyTower.attackController.curAttackMethod.attackInfo = attackInfo;
|
|
|
- enemyTower.Init();
|
|
|
- }
|
|
|
- if (tower != null)
|
|
|
- {
|
|
|
- tower.name = cfgEnemy.Name;
|
|
|
+ attackInfo = enemyTower.attackController.curAttackMethod.attackInfo;
|
|
|
+ attackInfo.damage = (int)(cfgEnemy.AttackMarch[0] * AttackRatio);
|
|
|
+ enemyTower.attackController.curAttackMethod.attackInfo = attackInfo;
|
|
|
+ enemyTower.Init();
|
|
|
+ }
|
|
|
+ if (tower != null)
|
|
|
+ {
|
|
|
+ tower.name = cfgEnemy.Name;
|
|
|
|
|
|
- tower.totalHp = (int)(cfgEnemy.HP * HPRatio);
|
|
|
- tower.hp = tower.totalHp;
|
|
|
+ tower.totalHp = (int)(cfgEnemy.HP * HPRatio);
|
|
|
+ tower.hp = tower.totalHp;
|
|
|
|
|
|
- attackInfo = tower.attackController.curAttackMethod.attackInfo;
|
|
|
- attackInfo.damage = (int)(cfgEnemy.AttackMarch[0] * AttackRatio);
|
|
|
- tower.attackController.curAttackMethod.attackInfo = attackInfo;
|
|
|
- tower.Init();
|
|
|
- }
|
|
|
- if (!buildingDic.ContainsKey(cfgEnemy.Name))
|
|
|
- {
|
|
|
- buildingDic.Add(cfgEnemy.Name, new List<GameObject>());
|
|
|
- }
|
|
|
- buildingDic[cfgEnemy.Name].Add(enemyObj);
|
|
|
- enemyCreateTowerDic[WaveName] = enemyTower;
|
|
|
+ attackInfo = tower.attackController.curAttackMethod.attackInfo;
|
|
|
+ attackInfo.damage = (int)(cfgEnemy.AttackMarch[0] * AttackRatio);
|
|
|
+ tower.attackController.curAttackMethod.attackInfo = attackInfo;
|
|
|
+ tower.Init();
|
|
|
+ }
|
|
|
+ if (!buildingDic.ContainsKey(cfgEnemy.Name))
|
|
|
+ {
|
|
|
+ buildingDic.Add(cfgEnemy.Name, new List<GameObject>());
|
|
|
+ }
|
|
|
+ buildingDic[cfgEnemy.Name].Add(enemyObj);
|
|
|
+ enemyCreateTowerDic[WaveName] = enemyTower;
|
|
|
+ break;
|
|
|
+ case "Boss":
|
|
|
+ Boss boss = enemyObj.GetComponent<Boss>();
|
|
|
+ boss.name = cfgEnemy.Name;
|
|
|
+ if (!bossDic.ContainsKey(cfgEnemy.Name))
|
|
|
+ {
|
|
|
+ bossDic.Add(cfgEnemy.Name, new List<Boss>());
|
|
|
+ }
|
|
|
+ bossDic[cfgEnemy.Name].Add(boss);
|
|
|
+ boss.hp = boss.totalHp;
|
|
|
+ boss.Init();
|
|
|
+ break;
|
|
|
+ default:
|
|
|
+ Enemy enemy = enemyObj.GetComponent<Enemy>();
|
|
|
+ enemy.name = cfgEnemy.Name;
|
|
|
+ if (!enemyDic.ContainsKey(cfgEnemy.Name))
|
|
|
+ {
|
|
|
+ enemyDic.Add(cfgEnemy.Name, new List<Enemy>());
|
|
|
+ }
|
|
|
+ enemyDic[cfgEnemy.Name].Add(enemy);
|
|
|
+
|
|
|
+ enemy.totalHp = (int)(cfgEnemy.HP * HPRatio);
|
|
|
+ enemy.hp = enemy.totalHp;
|
|
|
+ enemy.minMoveSpeed = cfgEnemy.MinMoveSpeed * SpeedRatio;
|
|
|
+ enemy.maxMoveSpeed = cfgEnemy.MaxMoveSpeed * SpeedRatio;
|
|
|
+
|
|
|
+ enemy.attributeStatus.resistances.armor = (int)(enemy.attributeStatus.resistances.armor * ArmorRatio + 0.5f);
|
|
|
+ foreach (var item in enemy.attackController.attackMethod_summon)
|
|
|
+ {
|
|
|
+ item.attackInfo.damage = (int)(cfgEnemy.AttackSummon * AttackRatio);
|
|
|
+ item.attackInfo.armorPiercing.rate = (int)(item.attackInfo.armorPiercing.rate * ArmorPiercingRatio);
|
|
|
+ }
|
|
|
+ for (int i = 0; i < enemy.attackController.attackMethod_march.Length; i++)
|
|
|
+ {
|
|
|
+ var item = enemy.attackController.attackMethod_march[i];
|
|
|
+ item.attackInfo.damage = (int)(cfgEnemy.AttackMarch[i] * AttackRatio);
|
|
|
+ item.attackInfo.armorPiercing.rate = (int)(item.attackInfo.armorPiercing.rate * ArmorPiercingRatio);
|
|
|
+ }
|
|
|
+ if (enemy.canFly)
|
|
|
+ {
|
|
|
+ enemy.flyHeight = enemy.transform.position.y;
|
|
|
+ }
|
|
|
+ enemy.Init();
|
|
|
+ enemy.SetSortingOrder(enemy.baseSortingOrder + enemyDic[cfgEnemy.Name].Count);
|
|
|
+ break;
|
|
|
}
|
|
|
- else
|
|
|
+ if(cfgEnemy.Type == "Tower")
|
|
|
{
|
|
|
- Enemy enemy = enemyObj.GetComponent<Enemy>();
|
|
|
- enemy.name = cfgEnemy.Name;
|
|
|
- if (!enemyDic.ContainsKey(cfgEnemy.Name))
|
|
|
- {
|
|
|
- enemyDic.Add(cfgEnemy.Name, new List<Enemy>());
|
|
|
- }
|
|
|
- enemyDic[cfgEnemy.Name].Add(enemy);
|
|
|
|
|
|
- enemy.totalHp = (int)(cfgEnemy.HP * HPRatio);
|
|
|
- enemy.hp = enemy.totalHp;
|
|
|
- enemy.minMoveSpeed = cfgEnemy.MinMoveSpeed * SpeedRatio;
|
|
|
- enemy.maxMoveSpeed = cfgEnemy.MaxMoveSpeed * SpeedRatio;
|
|
|
+ }
|
|
|
+ else
|
|
|
+ {
|
|
|
|
|
|
- enemy.attributeStatus.resistances.armor = (int)(enemy.attributeStatus.resistances.armor * ArmorRatio + 0.5f);
|
|
|
- foreach (var item in enemy.attackController.attackMethod_summon)
|
|
|
- {
|
|
|
- item.attackInfo.damage = (int)(cfgEnemy.AttackSummon * AttackRatio);
|
|
|
- item.attackInfo.armorPiercing.rate = (int)(item.attackInfo.armorPiercing.rate * ArmorPiercingRatio);
|
|
|
- }
|
|
|
- for(int i = 0; i < enemy.attackController.attackMethod_march.Length; i++)
|
|
|
- {
|
|
|
- var item = enemy.attackController.attackMethod_march[i];
|
|
|
- item.attackInfo.damage = (int)(cfgEnemy.AttackMarch[i] * AttackRatio);
|
|
|
- item.attackInfo.armorPiercing.rate = (int)(item.attackInfo.armorPiercing.rate * ArmorPiercingRatio);
|
|
|
- }
|
|
|
- if (enemy.canFly)
|
|
|
- {
|
|
|
- enemy.flyHeight = enemy.transform.position.y;
|
|
|
- }
|
|
|
- enemy.Init();
|
|
|
- enemy.SetSortingOrder(enemy.baseSortingOrder + enemyDic[cfgEnemy.Name].Count);
|
|
|
}
|
|
|
enemyObj.transform.position = pos;
|
|
|
return enemyObj;
|