|
@@ -55,6 +55,14 @@ public class EnemyCreater : MonoBehaviour
|
|
|
createdBuilding.Add(false);
|
|
createdBuilding.Add(false);
|
|
|
createBuildingTime.Add(cfgCreateBuilding[i].Time);
|
|
createBuildingTime.Add(cfgCreateBuilding[i].Time);
|
|
|
}
|
|
}
|
|
|
|
|
+
|
|
|
|
|
+ //把所有怪物prefab生成一遍防止后面初次生成卡顿
|
|
|
|
|
+ foreach (var item in GameManager.instance.allCfgData.CfgEnemy.DataMap)
|
|
|
|
|
+ {
|
|
|
|
|
+ SingleEnemyConfig cfgEnemy = item.Value;
|
|
|
|
|
+ GameObject enemyObj = CreateEnemy(cfgEnemy.ID, Vector3.zero, 1, 1);
|
|
|
|
|
+ enemyObj.SetActive(false);
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public void OnGameTimeChange(float gameTime)
|
|
public void OnGameTimeChange(float gameTime)
|
|
@@ -276,7 +284,7 @@ public class EnemyCreater : MonoBehaviour
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
- public void CreateEnemy(int enemyId, Vector3 pos, float hpRatio, float attackRatio)
|
|
|
|
|
|
|
+ public GameObject CreateEnemy(int enemyId, Vector3 pos, float hpRatio, float attackRatio)
|
|
|
{
|
|
{
|
|
|
SingleEnemyConfig cfgEnemy = GameManager.instance.allCfgData.CfgEnemy.Get(enemyId);
|
|
SingleEnemyConfig cfgEnemy = GameManager.instance.allCfgData.CfgEnemy.Get(enemyId);
|
|
|
GameObject enemyObj = Util.Instantiate(cfgEnemy.EnemyPrefab, pos);
|
|
GameObject enemyObj = Util.Instantiate(cfgEnemy.EnemyPrefab, pos);
|
|
@@ -315,6 +323,7 @@ public class EnemyCreater : MonoBehaviour
|
|
|
enemy.Init();
|
|
enemy.Init();
|
|
|
enemy.SetSortingOrder(enemy.baseSortingOrder + enemyDic[enemyId].Count);
|
|
enemy.SetSortingOrder(enemy.baseSortingOrder + enemyDic[enemyId].Count);
|
|
|
}
|
|
}
|
|
|
|
|
+ return enemyObj;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
public void OnEnemyRecycle(Enemy enemy)
|
|
public void OnEnemyRecycle(Enemy enemy)
|