| | |
| | | using Core.Utilities; |
| | | using TowerDefense.Towers; |
| | | using Core.Utilities; |
| | | using System; |
| | | using TMPro; |
| | | using UnityEngine; |
| | |
| | | using MoreMountains.NiceVibrations; |
| | | using TowerDefense.Level; |
| | | using KTGMGemClient; |
| | | using TowerDefense.UI.HUD; |
| | | |
| | | /// <summary> |
| | | /// 无尽模式用自己的EndlessUIStart |
| | |
| | | public TextMeshProUGUI timeStatic = null; |
| | | |
| | | /// <summary> |
| | | /// 选择buff界面 |
| | | /// 结算界面 |
| | | /// </summary> |
| | | public GameObject SelectBuffUI; |
| | | public GameObject SettlementUI; |
| | | |
| | | /// <summary> |
| | | /// 倒计时整体的背景图片Mask |
| | |
| | | |
| | | protected bool[] bVibrate; |
| | | |
| | | private bool isPause; |
| | | |
| | | // Start is called before the first frame update |
| | | void Start() |
| | | { |
| | |
| | | |
| | | if (timeStatic) |
| | | timeStatic.gameObject.SetActive(false); |
| | | SelectBuffUI.SetActive(false); |
| | | EndlessBuffSelect.instance.HideBuffUI(); |
| | | EndlessBossHPManager.instance.HideHP(); |
| | | EndlessSettlement settlement = SettlementUI.transform.GetChild(0).GetComponent<EndlessSettlement>(); |
| | | settlement.Init(); |
| | | SettlementUI.SetActive(false); |
| | | |
| | | //查询是否已经做过了新手引导 |
| | | int guide = PlayerPrefs.GetInt("GemBattleGuide"); |
| | | GameConfig.IsNewbie = guide == 0; |
| | | |
| | | if (GameConfig.IsNewbie) |
| | | { |
| | | Pause(); |
| | | uiStartMssk.gameObject.SetActive(false); |
| | | countDownTextNew.text = ""; |
| | | countDownTextNew.gameObject.SetActive(false); |
| | | |
| | | Instantiate(Resources.Load<GameObject>("UI/Guide/GuidePanel"), this.transform); |
| | | AddGuideEvent(); |
| | | //bGameStart = true; |
| | | // 开始关卡 |
| | | //EndlessLevelManager.instance.StartLevel(); |
| | | //timeTextNew.gameObject.SetActive(true); |
| | | |
| | | // 开始播放背景音乐. |
| | | // if (bgMusic != null) |
| | | // bgMusic.Play(); |
| | | } |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 添加新手引导事件 |
| | | /// </summary> |
| | | private void AddGuideEvent() |
| | | { |
| | | EventCenter.Ins.Add((int)KTGMGemClient.EventType.CreateFireLv2, CreateFireLv2); |
| | | EventCenter.Ins.Add((int)KTGMGemClient.EventType.CreateFirstWave, CreateFirstWave); |
| | | EventCenter.Ins.Add((int)KTGMGemClient.EventType.RestartWave, RestartWave); |
| | | EventCenter.Ins.Add<int>((int)KTGMGemClient.EventType.AddGold, AddGold); |
| | | EventCenter.Ins.Add((int)KTGMGemClient.EventType.CreateWaterLv1, CreateWaterLv1); |
| | | EventCenter.Ins.Add((int)KTGMGemClient.EventType.CreateSecondWave, CreateSecondWave); |
| | | EventCenter.Ins.Add((int)KTGMGemClient.EventType.SkillRelease, SkillRelease); |
| | | } |
| | | |
| | | /// <summary> |
| | | /// 在(2,3)位置放置一个火元素的塔 |
| | | /// </summary> |
| | | private void CreateFireLv2() |
| | | { |
| | | Tower aTower = EndlessRandomTower.instance.getTowerByName("GrowUpTower"); |
| | | EndlessGameUI.instance.PlaceTowerForce(aTower, new IntVector2(2, 3), 2); |
| | | } |
| | | |
| | | private void CreateFirstWave() |
| | | { |
| | | Restart(); |
| | | EventCenter.Ins.Add((int)KTGMGemClient.EventType.FireTowerChargeEnd, OnFireTowerChargeEnd); |
| | | } |
| | | |
| | | private void OnFireTowerChargeEnd() |
| | | { |
| | | Pause(); |
| | | EndlessLevelManager.instance.PauseWave(); |
| | | EventCenter.Ins.Remove((int)KTGMGemClient.EventType.FireTowerChargeEnd, OnFireTowerChargeEnd); |
| | | EventCenter.Ins.BroadCast((int)KTGMGemClient.EventType.ChargingEnd); |
| | | } |
| | | |
| | | private void RestartWave() |
| | | { |
| | | Restart(); |
| | | EndlessLevelManager.instance.RestartWave(); |
| | | } |
| | | |
| | | private void AddGold(int gold) |
| | | { |
| | | EndlessLevelManager.instance.Currency.AddCurrency(gold); |
| | | } |
| | | |
| | | private void CreateWaterLv1() |
| | | { |
| | | Tower aTower = EndlessRandomTower.instance.getTowerByName("CopyCatTower"); |
| | | EndlessGameUI.instance.PlaceTowerForce(aTower, new IntVector2(1, 3), 1); |
| | | } |
| | | |
| | | private void CreateSecondWave() |
| | | { |
| | | |
| | | } |
| | | |
| | | private void SkillRelease() |
| | | { |
| | | |
| | | } |
| | | |
| | | /// <summary> |
| | |
| | | } |
| | | } |
| | | |
| | | public void Pause() |
| | | { |
| | | isPause = true; |
| | | } |
| | | |
| | | public void Restart() |
| | | { |
| | | isPause = false; |
| | | } |
| | | |
| | | public bool IsGameRunning { get { return !isPause; } } |
| | | |
| | | // Update is called once per frame |
| | | void Update() |
| | | { |
| | | if (isPause) return; |
| | | |
| | | if (bGameStart) |
| | | { |
| | | startTime += Time.deltaTime; |
| | | timeTextNew.text = ConvertTime((float)Math.Ceiling(startTime)); |
| | | } |
| | | |
| | | if ((!bFirstLoaded) && (!bGameStart)) |
| | | if (!GameConfig.IsNewbie) |
| | | { |
| | | bFirstLoaded = true; |
| | | secToDo = 4; |
| | | if (!bFirstLoaded && !bGameStart) |
| | | { |
| | | bFirstLoaded = true; |
| | | secToDo = 4; |
| | | } |
| | | |
| | | if (bFirstLoaded && !bGameStart) |
| | | { |
| | | secToDo -= Time.deltaTime; |
| | | countDownTextNew.gameObject.SetActive(true); |
| | | |
| | | if (secToDo >= 3) |
| | | { |
| | | countDownTextNew.text = "3"; |
| | | if (!bVibrate[3]) |
| | | { |
| | | bVibrate[3] = true; |
| | | MMVibrationManager.Haptic(HapticTypes.SoftImpact); |
| | | } |
| | | } |
| | | else if (secToDo >= 2) |
| | | { |
| | | countDownTextNew.text = "2"; |
| | | if (!bVibrate[2]) |
| | | { |
| | | bVibrate[2] = true; |
| | | MMVibrationManager.Haptic(HapticTypes.MediumImpact); |
| | | } |
| | | } |
| | | else if (secToDo >= 1) |
| | | { |
| | | countDownTextNew.text = "1"; |
| | | if (!bVibrate[1]) |
| | | { |
| | | bVibrate[1] = true; |
| | | MMVibrationManager.Haptic(HapticTypes.HeavyImpact); |
| | | } |
| | | } |
| | | else if (secToDo < 1) |
| | | { |
| | | countDownTextNew.text = "GO!"; |
| | | if (!bVibrate[0]) |
| | | { |
| | | bVibrate[0] = true; |
| | | MMVibrationManager.Haptic(HapticTypes.HeavyImpact); |
| | | } |
| | | } |
| | | |
| | | // 开启游戏,且隐藏中间的数字. |
| | | if (secToDo <= 0) |
| | | { |
| | | uiStartMssk.gameObject.SetActive(false); |
| | | countDownTextNew.text = ""; |
| | | countDownTextNew.gameObject.SetActive(false); |
| | | bGameStart = true; |
| | | // 开始关卡 |
| | | EndlessLevelManager.instance.StartLevel(); |
| | | timeTextNew.gameObject.SetActive(true); |
| | | |
| | | // 开始播放背景音乐. |
| | | if (bgMusic != null) |
| | | bgMusic.Play(); |
| | | } |
| | | } |
| | | } |
| | | |
| | | if (bFirstLoaded && (!bGameStart)) |
| | | else |
| | | { |
| | | secToDo -= (Time.deltaTime * 1.0f); // 放慢时间用于调试 |
| | | // 新手走的流程 |
| | | if (!bFirstLoaded && !bGameStart) |
| | | bFirstLoaded = true; |
| | | |
| | | if (secToDo >= 3) |
| | | if (bFirstLoaded && !bGameStart) |
| | | { |
| | | countDownTextNew.text = "3"; |
| | | if (!bVibrate[3]) |
| | | { |
| | | bVibrate[3] = true; |
| | | MMVibrationManager.Haptic(HapticTypes.SoftImpact); |
| | | } |
| | | } |
| | | else if (secToDo >= 2) |
| | | { |
| | | countDownTextNew.text = "2"; |
| | | if (!bVibrate[2]) |
| | | { |
| | | bVibrate[2] = true; |
| | | MMVibrationManager.Haptic(HapticTypes.MediumImpact); |
| | | } |
| | | } |
| | | else if (secToDo >= 1) |
| | | { |
| | | countDownTextNew.text = "1"; |
| | | if (!bVibrate[1]) |
| | | { |
| | | bVibrate[1] = true; |
| | | MMVibrationManager.Haptic(HapticTypes.HeavyImpact); |
| | | } |
| | | } |
| | | else if (secToDo < 1) |
| | | { |
| | | countDownTextNew.text = "GO!"; |
| | | if (!bVibrate[0]) |
| | | { |
| | | bVibrate[0] = true; |
| | | MMVibrationManager.Haptic(HapticTypes.HeavyImpact); |
| | | } |
| | | } |
| | | |
| | | // 开启游戏,且隐藏中间的数字. |
| | | if (secToDo <= 0) |
| | | { |
| | | uiStartMssk.gameObject.SetActive(false); |
| | | countDownTextNew.text = ""; |
| | | |
| | | // 开始关卡 |
| | | EndlessLevelManager.instance.StartLevel(); |
| | | |
| | | timeTextNew.gameObject.SetActive(true); |
| | | bGameStart = true; |
| | | EndlessLevelManager.instance.StartLevel(); |
| | | timeTextNew.gameObject.SetActive(true); |
| | | |
| | | // 开始播放背景音乐. |
| | | if (bgMusic != null) |
| | | bgMusic.Play(); |
| | | } |