| | |
| | | using UnityEngine; |
| | | using TowerDefense.UI.HUD; |
| | | using Core.Utilities; |
| | | using Core.Health; |
| | | |
| | | namespace TowerDefense.Level |
| | | { |
| | |
| | | |
| | | private Timer faZhenRefreshTimer; |
| | | |
| | | |
| | | /// <summary> |
| | | /// 管理法阵的对象池 |
| | | /// </summary> |
| | | /// <returns></returns> |
| | | private Dictionary<string, List<GameObject>> faZhenDic = new Dictionary<string, List<GameObject>>(); |
| | | private void Start() |
| | | { |
| | | faZhenDic = new Dictionary<string, List<GameObject>>(); |
| | | HideTunel(); |
| | | EventCenter.Ins.Add<float>((int)KTGMGemClient.EventType.EndlessAgentTaskDamage, OnHit); |
| | | EventCenter.Ins.Add<int>((int)KTGMGemClient.EventType.WaveLineFinish, WaveLineFinish); |
| | | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// Agent掉血,不管是中毒还是乱七八糟的掉血,只要掉血就会接收到 |
| | | /// </summary> |
| | | /// <param name="value"></param> |
| | | private void OnHit(float value) |
| | | { |
| | | float nowHP = EndlessBossHPManager.instance.CurrentHP - value; |
| | | EndlessBossHPManager.instance.SetCurrentHP(nowHP); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | /// <param name="level"></param> |
| | | public void InitPort(int level) |
| | | { |
| | | EndlessPortData.InitPortList(); |
| | | InitPortData(level); |
| | | InitWaveData(); |
| | | RefreshBoss(); |
| | |
| | | LevelData = EndlessPortData.GetLevelWaveData(level); |
| | | TotalWaves = LevelData.Count; |
| | | CurrentWaveIndex = 0; |
| | | EndlessBossHPManager.instance.InitHP(); |
| | | EndlessBossHPManager.instance.Init(); |
| | | EndlessLevelManager.instance.DecrementEnemies -= DecrementEnemies; |
| | | EndlessLevelManager.instance.DecrementEnemies += DecrementEnemies; |
| | | |
| | |
| | | private void OnEndlessBossSummonEnd() |
| | | { |
| | | EventCenter.Ins.Remove((int)KTGMGemClient.EventType.EndlessBossSummonEnd, OnEndlessBossSummonEnd); |
| | | EndlessBossCtrl.instance.ChangeState(EndlessBossActionState.Standing); |
| | | HideTunel(); |
| | | RefreshFaZhen(); |
| | | } |
| | |
| | | int tunel = waveData[i].Config.tunel; |
| | | int tunelBgId = waveData[i].Config.tunel_bg; |
| | | |
| | | // string key = $"{faZhenPath}{tunelBgId}{tunelBgId}"; |
| | | // List<GameObject> allPS; |
| | | // GameObject tmpPSObj = null; |
| | | // if (faZhenDic.ContainsKey(key)) |
| | | // { |
| | | // allPS = faZhenDic[key]; |
| | | // foreach (GameObject item in allPS) |
| | | // { |
| | | // if (item.activeSelf) |
| | | // { |
| | | // tmpPSObj = item; |
| | | // break; |
| | | // } |
| | | // } |
| | | // } |
| | | |
| | | // if (tmpPSObj == null) |
| | | // { |
| | | // allPS = new List<GameObject>(); |
| | | // GameObject obj = Resources.Load<GameObject>($"{faZhenPath}{tunelBgId}{tunelBgId}"); |
| | | // GameObject faZhen = Instantiate(obj); |
| | | // tmpPSObj = faZhen; |
| | | // allPS.Add(faZhen); |
| | | // faZhenDic.Add(key, allPS); |
| | | // } |
| | | |
| | | // tmpPSObj.transform.SetParent(TunelList[tunel - 1].gameObject.transform); |
| | | // tmpPSObj.transform.localPosition = new Vector3(0, 1, 0); |
| | | // tmpPSObj.transform.localScale = new Vector3(2, 2, 2); |
| | | // TunelList[tunel - 1].gameObject.SetActive(true); |
| | | TunelList[tunel - 1].material = Resources.Load<Material>($"{tunelMaterialPath}{tunelBgId}"); |
| | | GameObject obj = Resources.Load<GameObject>($"{faZhenPath}{tunelBgId}"); |
| | | GameObject obj = Resources.Load<GameObject>($"{faZhenPath}{tunelBgId}{tunelBgId}"); |
| | | GameObject faZhen = Instantiate(obj); |
| | | |
| | | faZhen.transform.SetParent(TunelList[tunel - 1].gameObject.transform); |
| | |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 延迟关闭法阵 |
| | | /// </summary> |
| | | /// <param name="WaveLineId"></param> |
| | | private void WaveLineFinish(int WaveLineId) |
| | | { |
| | | //StartCoroutine(CloseFaZhen(WaveLineId)); |
| | | } |
| | | |
| | | IEnumerator CloseFaZhen(int WaveLineId) |
| | | { |
| | | yield return new WaitForSeconds(1.0f); |
| | | Debug.Log("当前列出怪完成,WaveLineId:" + WaveLineId); |
| | | |
| | | TunelList[WaveLineId - 1].gameObject.SetActive(false); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 敌人数量减少 |
| | | /// </summary> |
| | | /// <param name="count"></param> |
| | | public void DecrementEnemies(int count) |
| | | { |
| | | RemainEnemies -= count; |
| | | // 改变血条的进度 |
| | | EndlessBossHPManager.instance.SetCurrentProgress(RemainEnemies * 1f / TotalEnemies); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | return waves[waveline].StartingNode.GetNextNode().transform.position; |
| | | } |
| | | |
| | | |
| | | private void RefreshBoss() |
| | | { |
| | | if (CurrentWaveIndex > 0 || TotalWaves == 1) |
| | | EndlessBossHPManager.instance.SwitchHP(CurrentWaveIndex == TotalWaves - 1); |
| | | EndlessBossHPManager.instance.SetBossInfo($"{waveData[0].Config.boss_name} Lv.{Level}"); |
| | | EndlessBossHPManager.instance.InitHP(EndlessPortData.GetWaveEnemiesTotalHP(Level, CurrentWaveIndex)); |
| | | EndlessBossHPManager.instance.SetBossInfo($"第{Level}关 {waveData[0].Config.boss_name}"); |
| | | EndlessBossHPManager.instance.UpdateWave(TotalWaves - CurrentWaveIndex); |
| | | EndlessBossHPManager.instance.SetBossImage(waveData[0].Config.resource); |
| | | EndlessBossHPManager.instance.ShowHP(); |
| | | EndlessScoreManager.instance.ShowScore(); |
| | | EndlessLevelManager.instance.DropRate = EndlessPortData.GetDropRate(Level, CurrentWaveIndex); |
| | | reward tmpData = EndlessPortData.GetDropReward(Level, CurrentWaveIndex); |
| | | //if(tmpData!=null && tmpData.type == Protobuf.CURRENCY.Arenaexp)//暂时没法判断,需要新加字段 |
| | | if (tmpData != null) |
| | | EndlessLevelManager.instance.DropCoin = tmpData != null ? tmpData.count : 0; |
| | | |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | { |
| | | ++SpawnedTotalEnemies; |
| | | |
| | | if (GameConfig.IsNewbie && EndlessUIStart.instance.beginSkillStep && SpawnedTotalEnemies >= 8) |
| | | if (GameConfig.IsNewbie) |
| | | { |
| | | EndlessUIStart.instance.beginSkillStep = false; |
| | | EndlessLevelManager.instance.StopSecondWave(); |
| | | if (EndlessUIStart.instance.beginDragStep && SpawnedTotalEnemies >= 3) |
| | | { |
| | | EndlessUIStart.instance.beginDragStep = false; |
| | | EndlessLevelManager.instance.StopSecondWave(); |
| | | } |
| | | else if (EndlessUIStart.instance.guideThirdWaveStep) |
| | | { |
| | | //Debug.Log($"当前波次是木属性的 总怪物数量:{TotalEnemies} 当前已经生成了:{SpawnedTotalEnemies * 2}"); |
| | | if (TotalEnemies - (SpawnedTotalEnemies * 2) <= 0) |
| | | { |
| | | Debug.Log("延迟第三波生成完毕"); |
| | | StartCoroutine(BroadCastCreateThirdWaveDone()); |
| | | } |
| | | } |
| | | } |
| | | } |
| | | |
| | | IEnumerator BroadCastCreateThirdWaveDone() |
| | | { |
| | | yield return new WaitForSeconds(0.5f); |
| | | EndlessUIStart.instance.guideThirdWaveStep = false; |
| | | EventCenter.Ins.BroadCast((int)KTGMGemClient.EventType.CreateThirdWaveDone); |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | { |
| | | foreach (EndlessPortConfig data in waveData) |
| | | { |
| | | if (waves[data.Config.tunel - 1].LineState == EndlessWaveLineState.Spawning) |
| | | waves[data.Config.tunel - 1].PauseWave(); |
| | | waves[data.Config.tunel - 1].PauseWave(); |
| | | } |
| | | } |
| | | |
| | |
| | | { |
| | | foreach (EndlessPortConfig data in waveData) |
| | | { |
| | | if (waves[data.Config.tunel - 1].LineState == EndlessWaveLineState.Spawning) |
| | | waves[data.Config.tunel - 1].RestartWave(); |
| | | waves[data.Config.tunel - 1].RestartWave(); |
| | | } |
| | | } |
| | | |
| | |
| | | faZhenRefreshTimer = null; |
| | | } |
| | | |
| | | if (!isWaveStarted) return; |
| | | if (!isWaveStarted || EndlessGameUI.instance.state == EndlessGameUI.State.GameOver) return; |
| | | |
| | | // 所有赛道都完成 |
| | | if (CompletedWaveLine >= TotalWaveLines) |