| | |
| | | using System; |
| | | using UnityEngine; |
| | | using System; |
| | | using System.Collections.Generic; |
| | | using Core.Utilities; |
| | | using KTGMGemClient; |
| | |
| | | public event Action WaveCompleted; |
| | | |
| | | /// <summary> |
| | | /// 波次发生改变 |
| | | /// 有新的敌人生成 |
| | | /// </summary> |
| | | public event Action WaveChanged; |
| | | public event Action SpawnNewAgent; |
| | | |
| | | /// <summary> |
| | | /// 怪出生开始节点 |
| | |
| | | isWaveStoped = true; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// Handles spawning the current agent and sets up the next agent for spawning |
| | | /// 在场景内孵化出来一个Boss,这个核心函数最后被规则性的数据接管 |
| | | /// </summary> |
| | | public void PauseWave() |
| | | { |
| | | PauseTimer(spawnTimer); |
| | | } |
| | | |
| | | public void RestartWave() |
| | | { |
| | | if (spawnTimer != null) |
| | | StartTimer(spawnTimer); |
| | | } |
| | | |
| | | protected virtual void SpawnCurrent() |
| | | { |
| | | if (isWaveStoped) return; |
| | |
| | | SafelyBroadcastWaveCompletedEvent(); |
| | | } |
| | | else |
| | | { |
| | | ++spawnedEnemies; |
| | | |
| | | if (SpawnNewAgent != null) |
| | | SpawnNewAgent(); |
| | | |
| | | if (spawnedEnemies >= waveData.Config.amount) |
| | | { |
| | | StopWave(); |
| | | SafelyBroadcastWaveCompletedEvent(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 生成agent |
| | | /// </summary> |
| | | /// <returns>Agent</returns> |
| | | protected virtual Agent SpawnAgent() |
| | | 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 = 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) |
| | | { |
| | | Vector3 pos = newAgent.transform.position; |
| | | pos.x -= 2f; |
| | | newAgent.transform.position = pos; |
| | | } |
| | | |
| | | newAgent.transform.rotation = StartingNode.transform.rotation; |
| | | newAgent.SetNode(StartingNode, WaveLineId - 1); |
| | | newAgent.opponentAgent = false; |
| | | 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); |
| | | |
| | | return 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; |
| | | pos.x += 2f; |
| | | doubleAgent.transform.position = pos; |
| | | |
| | | doubleAgent.transform.rotation = StartingNode.transform.rotation; |
| | | doubleAgent.SetNode(StartingNode, WaveLineId - 1); |
| | | doubleAgent.opponentAgent = false; |
| | | doubleAgent.Initialize(); |
| | | |
| | | doubleAgent.SetAgentData(hp, speed, gold); |
| | | doubleAgent.healthBar.SetHealthLevel(1); |
| | | AgentInsManager.instance.addAgent(doubleAgent); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 从Tower的AttributeId获取到怪物的数据 |
| | | /// </summary> |
| | | /// <param name="id"></param> |
| | | /// <returns></returns> |
| | | protected List<int> GetMonsterDataFromAttributeId(int id) |
| | | { |
| | | geminfo tgem = new geminfo(); |
| | | if (JsonDataCenter.gemInfoDic.TryGetValue(id, out tgem)) |
| | | return tgem.summon; |
| | | else |
| | | { |
| | | Debug.Log("找不到对应ID的Gem:" + id); |
| | | return null; |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 暂时先这么处理 |
| | | /// 暂时先这么处理 cx test |
| | | /// </summary> |
| | | /// <param name="resId">endless_enemy表的资源id</param> |
| | | /// <returns>所有可选的agent列表的索引</returns> |