| | |
| | | /// <summary> |
| | | /// 当前波索引 |
| | | /// </summary> |
| | | protected int currentWaveIndex; |
| | | public int CurrentWaveIndex { get; protected set; } |
| | | |
| | | /// <summary> |
| | | /// 当前波数据 |
| | |
| | | public int Level { get; protected set; } |
| | | |
| | | /// <summary> |
| | | /// 法阵 |
| | | /// </summary> |
| | | public List<MeshRenderer> TunelList; |
| | | |
| | | private string tunelMaterialPath = "UI/Endless/Tunel/tunel_"; |
| | | |
| | | private string faZhenPath = "UI/Endless/Tunel/EndlessFaZhen"; |
| | | |
| | | private void Start() |
| | | { |
| | | HideTunel(); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 隐藏法阵,即怪出生的圈圈 |
| | | /// </summary> |
| | | public void HideTunel() |
| | | { |
| | | for (int i = 0; i < TunelList.Count; ++i) |
| | | { |
| | | TunelList[i].gameObject.SetActive(false); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 显示法阵 |
| | | /// </summary> |
| | | public void ShowTunel() |
| | | { |
| | | for (int i = 0; i < TunelList.Count; ++i) |
| | | { |
| | | TunelList[i].gameObject.SetActive(true); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// Starts the waves |
| | | /// </summary> |
| | | /// <param name="level">关卡等级</param> |
| | |
| | | Level = level; |
| | | LevelData = EndlessPortData.GetLevelWaveData(level); |
| | | TotalWaves = LevelData.Count; |
| | | currentWaveIndex = 0; |
| | | CurrentWaveIndex = 0; |
| | | EndlessBossHPManager.instance.InitHP(); |
| | | EndlessLevelManager.instance.DecrementEnemies -= DecrementEnemies; |
| | | EndlessLevelManager.instance.DecrementEnemies += DecrementEnemies; |
| | |
| | | return waves[waveline].StartingNode.GetNextNode().transform.position; |
| | | } |
| | | |
| | | private void RefreshBoss() |
| | | { |
| | | if (CurrentWaveIndex > 0) |
| | | EndlessBossHPManager.instance.SwitchHP(CurrentWaveIndex == TotalWaves - 1); |
| | | EndlessBossHPManager.instance.SetBossInfo($"{waveData[0].Config.boss_name} Lv.{Level}"); |
| | | EndlessBossHPManager.instance.UpdateWave(TotalWaves - CurrentWaveIndex); |
| | | EndlessBossHPManager.instance.SetBossImage(waveData[0].Config.resource); |
| | | EndlessBossHPManager.instance.ShowHP(); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 更新波 |
| | | /// </summary> |
| | |
| | | { |
| | | if (EndlessGameUI.instance.state == EndlessGameUI.State.GameOver) return; |
| | | |
| | | |
| | | if (currentWaveIndex > 0) |
| | | EndlessBossHPManager.instance.SwitchHP(currentWaveIndex == TotalWaves -1); |
| | | EndlessBossHPManager.instance.UpdateWave(TotalWaves - currentWaveIndex); |
| | | EndlessBossHPManager.instance.ShowHP(); |
| | | TotalEnemies = EndlessPortData.GetWaveEnemiesCount(Level, currentWaveIndex); |
| | | RemainEnemies = TotalEnemies; |
| | | |
| | | waveData = LevelData[currentWaveIndex]; |
| | | waveData = LevelData[CurrentWaveIndex]; |
| | | // 直接取第一条就行了 |
| | | WaveInterval = waveData[0].Config.cooldown / 1000f; |
| | | TotalWaveLines = waveData.Count; |
| | | CompletedWaveLine = 0; |
| | | |
| | | HideTunel(); |
| | | |
| | | // 刷新法阵的显示 |
| | | for (int i = 0; i < waveData.Count; ++i) |
| | | { |
| | | int tunel = waveData[i].Config.tunel; |
| | | TunelList[tunel - 1].material = Resources.Load<Material>($"{tunelMaterialPath}{tunel}"); |
| | | GameObject obj = Resources.Load<GameObject>($"{faZhenPath}{tunel}"); |
| | | GameObject faZhen = Instantiate(obj); |
| | | faZhen.transform.SetParent(TunelList[tunel - 1].gameObject.transform); |
| | | faZhen.transform.localPosition = new Vector3(0, 1, 0); |
| | | faZhen.transform.localScale = new Vector3(2, 2, 2); |
| | | TunelList[tunel - 1].gameObject.SetActive(true); |
| | | ParticleSystem ps = faZhen.transform.GetChild(0).GetComponent<ParticleSystem>(); |
| | | ps.Play(); |
| | | Destroy(ps.gameObject, ps.main.duration * 3); |
| | | } |
| | | |
| | | RefreshBoss(); |
| | | TotalEnemies = EndlessPortData.GetWaveEnemiesCount(Level, CurrentWaveIndex); |
| | | RemainEnemies = TotalEnemies; |
| | | |
| | | foreach (EndlessPortConfig data in waveData) |
| | | { |
| | |
| | | |
| | | if (TotalWaveLines != 0) |
| | | isWaveStarted = true; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 暂停所有兵线出兵 |
| | | /// </summary> |
| | | public void PauseAllWave() |
| | | { |
| | | foreach (EndlessPortConfig data in waveData) |
| | | { |
| | | if (waves[data.Config.tunel - 1].LineState == EndlessWaveLineState.Spawning) |
| | | waves[data.Config.tunel - 1].PauseWave(); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 恢复所有兵线出兵 |
| | | /// </summary> |
| | | public void RestartAllWave() |
| | | { |
| | | foreach (EndlessPortConfig data in waveData) |
| | | { |
| | | if (waves[data.Config.tunel - 1].LineState == EndlessWaveLineState.Spawning) |
| | | waves[data.Config.tunel - 1].RestartWave(); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | } |
| | | |
| | | // 更新波索引 |
| | | ++currentWaveIndex; |
| | | ++CurrentWaveIndex; |
| | | EndlessBuffManager.instance.UpdateBuffList(); |
| | | |
| | | if (currentWaveIndex >= TotalWaves) |
| | | if (CurrentWaveIndex >= TotalWaves) |
| | | // 当前关卡的所有波次全部完成 |
| | | SafelyCallSpawningCompleted(); |
| | | else |
| | |
| | | protected virtual void SafelyCallSpawningCompleted() |
| | | { |
| | | isWaveStarted = false; |
| | | EndlessBossHPManager.instance.UpdateWave(TotalWaves - currentWaveIndex); |
| | | EndlessBossHPManager.instance.UpdateWave(TotalWaves - CurrentWaveIndex); |
| | | |
| | | if (AllWaveCompleted != null) |
| | | AllWaveCompleted(); |