| | |
| | | public event Action SpawnNewAgent; |
| | | |
| | | /// <summary> |
| | | /// 波次发生改变 |
| | | /// </summary> |
| | | public event Action WaveChanged; |
| | | |
| | | /// <summary> |
| | | /// 怪出生开始节点 |
| | | /// </summary> |
| | | public Node StartingNode; |
| | |
| | | public void PauseWave() |
| | | { |
| | | PauseTimer(spawnTimer); |
| | | isWaveStoped = true; |
| | | } |
| | | |
| | | public void RestartWave() |
| | | { |
| | | StartTimer(spawnTimer); |
| | | isWaveStoped = false; |
| | | if (spawnTimer != null) |
| | | StartTimer(spawnTimer); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// Handles spawning the current agent and sets up the next agent for spawning |
| | | /// 在场景内孵化出来一个Boss,这个核心函数最后被规则性的数据接管 |
| | | /// </summary> |
| | | protected virtual void SpawnCurrent() |
| | | { |
| | | if (isWaveStoped) return; |
| | |
| | | else |
| | | { |
| | | ++spawnedEnemies; |
| | | |
| | | if (SpawnNewAgent != null) |
| | | SpawnNewAgent(); |
| | | |
| | | if (spawnedEnemies >= waveData.Config.amount) |
| | | { |
| | | StopWave(); |
| | | SafelyBroadcastWaveCompletedEvent(); |
| | | } |
| | | } |
| | | } |
| | | |
| | |
| | | /// <returns>Agent</returns> |
| | | protected virtual void SpawnAgent() |
| | | { |
| | | int index = GetIndexByResId(waveData.EnemyData.resource); |
| | | endless_enemy enemyData = waveData.EnemyDataList[waveData.Config.enemy_id > 0 ? 0 : spawnedEnemies]; |
| | | |
| | | int index = GetIndexByResId(enemyData.resource); |
| | | |
| | | // 木属性小怪需要同时生成两个,先这么写吧(WTF) |
| | | bool isDouble = waveData.EnemyData.resource == 103; |
| | | bool isDouble = enemyData.resource == 103; |
| | | |
| | | Poolable agentPoolable = Poolable.TryGetPoolable<Poolable>(AgentConfigurationList[index].agentPrefab.gameObject); |
| | | Agent newAgent = agentPoolable.GetComponent<Agent>(); |
| | | newAgent.EnemyData = enemyData; |
| | | newAgent.transform.position = StartingNode.transform.position; |
| | | |
| | | if (isDouble) |
| | |
| | | newAgent.Initialize(); |
| | | |
| | | // 最终血量 = 基础血量 * 血量增幅,速度和金币都是一个公式 |
| | | float hp = waveData.Config.b_hp * waveData.EnemyData.hp_rate; |
| | | float speed = waveData.Config.b_speed * waveData.EnemyData.speed_rate; |
| | | int gold = waveData.Config.b_coin * waveData.EnemyData.coin_rate; |
| | | float hp = waveData.Config.b_hp * enemyData.hp_rate; |
| | | float speed = waveData.Config.b_speed * enemyData.speed_rate; |
| | | int gold = waveData.Config.b_coin * enemyData.coin_rate; |
| | | |
| | | newAgent.SetAgentData(hp, speed, gold); |
| | | // todo 这里先填1级后面需要修改 |
| | |
| | | // 加入Manager统一管理. |
| | | AgentInsManager.instance.addAgent(newAgent); |
| | | |
| | | |
| | | if (isDouble) |
| | | { |
| | | Poolable agentPoolable2 = Poolable.TryGetPoolable<Poolable>(AgentConfigurationList[index].agentPrefab.gameObject); |
| | | Agent doubleAgent = agentPoolable2.GetComponent<Agent>(); |
| | | doubleAgent.EnemyData = enemyData; |
| | | doubleAgent.transform.position = StartingNode.transform.position; |
| | | |
| | | Vector3 pos = doubleAgent.transform.position; |
| | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 暂时先这么处理 |
| | | /// 暂时先这么处理 cx test |
| | | /// </summary> |
| | | /// <param name="resId">endless_enemy表的资源id</param> |
| | | /// <returns>所有可选的agent列表的索引</returns> |