|
|
@@ -311,90 +311,34 @@ public class EnemyCreater : MonoBehaviour
|
|
|
return maxID;
|
|
|
}
|
|
|
|
|
|
- public GameObject CreateEnemy(SingleCreateEnemyConfig cfgCreateEnemy, Vector3 pos, bool active = false)
|
|
|
+ //出怪表每一行怪
|
|
|
+ public void CreateEnemy(SingleCreateEnemyConfig cfg, Vector3 pos, bool active = false)
|
|
|
{
|
|
|
- SingleEnemyConfig cfgEnemy = GameManager.instance.allCfgData.CfgEnemy.Get(cfgCreateEnemy.EnemyName);
|
|
|
- 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);
|
|
|
- AttackInfo attackInfo;
|
|
|
- if(cfgEnemy.Type == "Tower")
|
|
|
- {
|
|
|
- EnemyTower enemyTower = enemyObj.GetComponent<EnemyTower>();
|
|
|
- Tower tower = enemyObj.GetComponent<Tower>();
|
|
|
- if (enemyTower != null)
|
|
|
- {
|
|
|
- enemyTower.name = cfgEnemy.Name;
|
|
|
-
|
|
|
- enemyTower.totalHp = (int)(cfgEnemy.HP * cfgCreateEnemy.HPRatio);
|
|
|
- enemyTower.hp = enemyTower.totalHp;
|
|
|
-
|
|
|
- attackInfo = enemyTower.attackController.attackInfo;
|
|
|
- attackInfo.damage = (int)(cfgEnemy.AttackMarch * cfgCreateEnemy.AttackRatio);
|
|
|
- enemyTower.attackController.attackInfo = attackInfo;
|
|
|
- enemyTower.Init();
|
|
|
- }
|
|
|
- if (tower != null)
|
|
|
- {
|
|
|
- tower.name = cfgEnemy.Name;
|
|
|
-
|
|
|
- tower.totalHp = (int)(cfgEnemy.HP * cfgCreateEnemy.HPRatio);
|
|
|
- tower.hp = tower.totalHp;
|
|
|
-
|
|
|
- attackInfo = tower.attackController.attackInfo;
|
|
|
- attackInfo.damage = (int)(cfgEnemy.AttackMarch * cfgCreateEnemy.AttackRatio);
|
|
|
- tower.attackController.attackInfo = attackInfo;
|
|
|
- tower.Init();
|
|
|
- }
|
|
|
- if (!buildingDic.ContainsKey(cfgEnemy.Name))
|
|
|
- {
|
|
|
- buildingDic.Add(cfgEnemy.Name, new List<GameObject>());
|
|
|
- }
|
|
|
- buildingDic[cfgEnemy.Name].Add(enemyObj);
|
|
|
- enemyCreateTowerDic[cfgCreateEnemy.WaveName] = enemyTower;
|
|
|
- }
|
|
|
- else if(cfgEnemy.Type == "Enemy")
|
|
|
- {
|
|
|
- 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 * cfgCreateEnemy.HPRatio);
|
|
|
- enemy.hp = enemy.totalHp;
|
|
|
- enemy.minMoveSpeed = cfgEnemy.MinMoveSpeed * cfgCreateEnemy.SpeedRatio;
|
|
|
- enemy.maxMoveSpeed = cfgEnemy.MaxMoveSpeed * cfgCreateEnemy.SpeedRatio;
|
|
|
-
|
|
|
- attackInfo = enemy.attackController.attackMethod[0].attackInfo;
|
|
|
- attackInfo.damage = (int)(cfgEnemy.AttackMarch * cfgCreateEnemy.AttackRatio);
|
|
|
- enemy.attackController.attackMethod[0].attackInfo = attackInfo;
|
|
|
+ CreateEnemyInit(cfg.EnemyName, cfg.WaveName,
|
|
|
+ cfg.HPRatio, cfg.AttackRatio, cfg.SpeedRatio, cfg.ArmorRatio, cfg.ArmorPiercingRatio,
|
|
|
+ pos, active);
|
|
|
+ }
|
|
|
|
|
|
- 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;
|
|
|
+ //动态出怪表每一波怪
|
|
|
+ public void CreateEnemy(SingleDynamicEnemyConfig cfg, Vector3 pos, bool active = false)
|
|
|
+ {
|
|
|
+ CreateEnemyInit(cfg.EnemyName, cfg.WaveName,
|
|
|
+ cfg.HPRatio, cfg.AttackRatio, cfg.SpeedRatio, cfg.ArmorRatio, cfg.ArmorPiercingRatio,
|
|
|
+ pos, active);
|
|
|
}
|
|
|
|
|
|
- public GameObject CreateEnemy(SingleDynamicEnemyConfig cfgCreateEnemy, Vector3 pos, bool active = false)
|
|
|
+ public GameObject CreateEnemyInit(string EnemyName, string WaveName,
|
|
|
+ float HPRatio, float AttackRatio, float SpeedRatio, float ArmorRatio, float ArmorPiercingRatio,
|
|
|
+ Vector3 pos, bool active = false)
|
|
|
{
|
|
|
- SingleEnemyConfig cfgEnemy = GameManager.instance.allCfgData.CfgEnemy.Get(cfgCreateEnemy.EnemyName);
|
|
|
+ SingleEnemyConfig cfgEnemy = GameManager.instance.allCfgData.CfgEnemy.Get(EnemyName);
|
|
|
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);
|
|
|
AttackInfo attackInfo;
|
|
|
- if (cfgEnemy.Type == "Tower")
|
|
|
+ if(cfgEnemy.Type == "Tower")
|
|
|
{
|
|
|
EnemyTower enemyTower = enemyObj.GetComponent<EnemyTower>();
|
|
|
Tower tower = enemyObj.GetComponent<Tower>();
|
|
|
@@ -402,11 +346,11 @@ public class EnemyCreater : MonoBehaviour
|
|
|
{
|
|
|
enemyTower.name = cfgEnemy.Name;
|
|
|
|
|
|
- enemyTower.totalHp = (int)(cfgEnemy.HP * cfgCreateEnemy.HPRatio);
|
|
|
+ enemyTower.totalHp = (int)(cfgEnemy.HP * HPRatio);
|
|
|
enemyTower.hp = enemyTower.totalHp;
|
|
|
|
|
|
attackInfo = enemyTower.attackController.attackInfo;
|
|
|
- attackInfo.damage = (int)(cfgEnemy.AttackMarch * cfgCreateEnemy.AttackRatio);
|
|
|
+ attackInfo.damage = (int)(cfgEnemy.AttackMarch * AttackRatio);
|
|
|
enemyTower.attackController.attackInfo = attackInfo;
|
|
|
enemyTower.Init();
|
|
|
}
|
|
|
@@ -414,11 +358,11 @@ public class EnemyCreater : MonoBehaviour
|
|
|
{
|
|
|
tower.name = cfgEnemy.Name;
|
|
|
|
|
|
- tower.totalHp = (int)(cfgEnemy.HP * cfgCreateEnemy.HPRatio);
|
|
|
+ tower.totalHp = (int)(cfgEnemy.HP * HPRatio);
|
|
|
tower.hp = tower.totalHp;
|
|
|
|
|
|
attackInfo = tower.attackController.attackInfo;
|
|
|
- attackInfo.damage = (int)(cfgEnemy.AttackMarch * cfgCreateEnemy.AttackRatio);
|
|
|
+ attackInfo.damage = (int)(cfgEnemy.AttackMarch * AttackRatio);
|
|
|
tower.attackController.attackInfo = attackInfo;
|
|
|
tower.Init();
|
|
|
}
|
|
|
@@ -427,9 +371,9 @@ public class EnemyCreater : MonoBehaviour
|
|
|
buildingDic.Add(cfgEnemy.Name, new List<GameObject>());
|
|
|
}
|
|
|
buildingDic[cfgEnemy.Name].Add(enemyObj);
|
|
|
- enemyCreateTowerDic[cfgCreateEnemy.WaveName] = enemyTower;
|
|
|
+ enemyCreateTowerDic[WaveName] = enemyTower;
|
|
|
}
|
|
|
- else if (cfgEnemy.Type == "Enemy")
|
|
|
+ else if(cfgEnemy.Type == "Enemy")
|
|
|
{
|
|
|
Enemy enemy = enemyObj.GetComponent<Enemy>();
|
|
|
enemy.name = cfgEnemy.Name;
|
|
|
@@ -439,14 +383,19 @@ public class EnemyCreater : MonoBehaviour
|
|
|
}
|
|
|
enemyDic[cfgEnemy.Name].Add(enemy);
|
|
|
|
|
|
- enemy.totalHp = (int)(cfgEnemy.HP * cfgCreateEnemy.HPRatio);
|
|
|
+ enemy.totalHp = (int)(cfgEnemy.HP * HPRatio);
|
|
|
enemy.hp = enemy.totalHp;
|
|
|
- enemy.minMoveSpeed = cfgEnemy.MinMoveSpeed * cfgCreateEnemy.SpeedRatio;
|
|
|
- enemy.maxMoveSpeed = cfgEnemy.MaxMoveSpeed * cfgCreateEnemy.SpeedRatio;
|
|
|
+ enemy.minMoveSpeed = cfgEnemy.MinMoveSpeed * SpeedRatio;
|
|
|
+ enemy.maxMoveSpeed = cfgEnemy.MaxMoveSpeed * SpeedRatio;
|
|
|
|
|
|
attackInfo = enemy.attackController.attackMethod[0].attackInfo;
|
|
|
- attackInfo.damage = (int)(cfgEnemy.AttackMarch * cfgCreateEnemy.AttackRatio);
|
|
|
+ attackInfo.damage = (int)(cfgEnemy.AttackMarch * AttackRatio);
|
|
|
enemy.attackController.attackMethod[0].attackInfo = attackInfo;
|
|
|
+ enemy.attributeStatus.resistances.armor = (int)(enemy.attributeStatus.resistances.armor * ArmorRatio + 0.5f);
|
|
|
+ foreach (var item in enemy.attackController.attackMethod)
|
|
|
+ {
|
|
|
+ item.attackInfo.armorPiercing.rate = (int)(item.attackInfo.armorPiercing.rate * ArmorPiercingRatio);
|
|
|
+ }
|
|
|
|
|
|
if (enemy.canFly)
|
|
|
{
|