| | |
| | | using System.Collections; |
| | | using System.Collections.Generic; |
| | | using TowerDefense.Nodes; |
| | | using TowerDefense.UI.HUD; |
| | | |
| | | namespace TowerDefense.Level |
| | | { |
| | |
| | | public event Action LevelCompleted; |
| | | |
| | | /// <summary> |
| | | /// Fired when all of the home bases are destroyed |
| | | /// </summary> |
| | | public event Action LevelFailed; |
| | | |
| | | /// <summary> |
| | | /// Fired when the level state is changed - first parameter is the old state, second parameter is the new state |
| | | /// </summary> |
| | | public event Action<LevelState, LevelState> LevelStateChanged; |
| | |
| | | /// </summary> |
| | | /// <value></value> |
| | | public int SelectBuffNeddLevels { get; set; } |
| | | // cx test |
| | | // public int SelectBuffNeddLevels { get; set; } = 2; |
| | | |
| | | /// <summary> |
| | |
| | | } |
| | | } |
| | | |
| | | private void Start() |
| | | { |
| | | EndlessBuffSelect.instance.BuffSelectCompleted += OnBuffSelectCompleted; |
| | | EndlessGameUI.instance.GameOverEvent += SafelyCallLevelCompleted; |
| | | } |
| | | |
| | | /// <summary> |
| | | /// Updates the currency gain controller |
| | | /// </summary> |
| | |
| | | { |
| | | isBuffSelectCompleted = true; |
| | | WaveManager.StartWaves(CurrentLevel); |
| | | EndlessUIStart.instance.Restart(); |
| | | } |
| | | |
| | | // 本关卡所有波次全部生成完成 && 敌人全部被清理了,然后就去尝试进入下一关 |
| | |
| | | return; |
| | | } |
| | | |
| | | EndlessUIStart.instance.SelectBuffUI.SetActive(true); |
| | | |
| | | for (int i = 0; i < 3; ++i) |
| | | { |
| | | GameObject descObj = GameObject.Find($"BuffDesc{i}"); |
| | | Text obj = descObj.GetComponent<Text>(); |
| | | obj.text = list[i].Config.brief; |
| | | } |
| | | EndlessUIStart.instance.Pause(); |
| | | EndlessBuffSelect.instance.Refresh(list); |
| | | EndlessBuffSelect.instance.ShowBuffUI(); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// <param name="index"></param> |
| | | public void OnBuffSelectCompleted(int index) |
| | | { |
| | | EndlessUIStart.instance.SelectBuffUI.SetActive(false); |
| | | isBuffSelectCompleted = false; |
| | | EndlessBuffManager.instance.AddBuff(EndlessBuffData.GetBuffByIndex(index)); |
| | | } |
| | |
| | | ChangeLevelState(LevelState.Win); |
| | | break; |
| | | case LevelState.Lose: |
| | | SafelyCallLevelFailed(); |
| | | SafelyCallLevelCompleted(); |
| | | break; |
| | | case LevelState.Win: |
| | | SafelyCallLevelCompleted(); |
| | |
| | | homeBaseDestroyed(); |
| | | } |
| | | |
| | | // If there are no home bases left and the level is not over then set the level to lost |
| | | if ((NumberOfHomeBasesLeft < 3) && !isGameOver) |
| | | { |
| | | ChangeLevelState(LevelState.Lose); |
| | | } |
| | | // // If there are no home bases left and the level is not over then set the level to lost |
| | | // if ((NumberOfHomeBasesLeft < 3) && !isGameOver) |
| | | // { |
| | | // ChangeLevelState(LevelState.Lose); |
| | | // } |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | { |
| | | if (DecrementEnemies != null) |
| | | DecrementEnemies(1); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// Calls the <see cref="levelFailed"/> event |
| | | /// </summary> |
| | | protected virtual void SafelyCallLevelFailed() |
| | | { |
| | | if (LevelFailed != null) |
| | | LevelFailed(); |
| | | } |
| | | |
| | | /// <summary> |