using TowerDefense.Towers;
|
using Core.Utilities;
|
using System;
|
using TMPro;
|
using UnityEngine;
|
using UnityEngine.UI;
|
using MoreMountains.NiceVibrations;
|
using TowerDefense.Level;
|
using KTGMGemClient;
|
using TowerDefense.UI.HUD;
|
using System.Collections;
|
|
/// <summary>
|
/// 无尽模式用自己的EndlessUIStart
|
/// </summary>
|
public class EndlessUIStart : Singleton<EndlessUIStart>
|
{
|
public TextMeshProUGUI countDownTextNew = null;
|
|
public TextMeshProUGUI timeTextNew = null;
|
|
//public TextMeshProUGUI timeStatic = null;
|
|
/// <summary>
|
/// 结算界面
|
/// </summary>
|
public GameObject SettlementUI;
|
|
/// <summary>
|
/// 倒计时整体的背景图片Mask
|
/// </summary>
|
public Image uiStartMssk = null;
|
|
public AudioSource bgMusic;
|
|
public static bool bFirstLoaded = false;
|
|
public static bool bGameStart = false;
|
|
protected float secToDo = 3f;
|
|
protected float startTime = 0.0f;
|
|
protected bool bossCreate = false;
|
|
protected bool[] bVibrate;
|
|
private bool isPause;
|
|
public bool beginDragStep = false;
|
public bool guideFourthWaveStep = false;
|
|
public GameObject darkGroundImg;
|
|
private CanvasGroup canvasGroup;
|
|
public GameObject GMBtn;
|
|
/// <summary>
|
/// Awake is called when the script instance is being loaded.
|
/// </summary>
|
protected override void Awake()
|
{
|
base.Awake();
|
//这里为了方便直接使用Endless2D
|
GameObject root = GameObject.Find("ManagerRoot");
|
|
if (root == null)
|
{
|
if (Application.platform == RuntimePlatform.WindowsEditor ||
|
Application.platform == RuntimePlatform.WindowsPlayer)
|
{
|
GameConfig.useSDK = false;
|
}
|
|
root = new GameObject("ManagerRoot");
|
|
root.AddComponent<DoNotDestory>();
|
root.AddComponent<MasterSocket>();
|
root.AddComponent<TDAA_SDKManager>();
|
root.AddComponent<AudioSourceManager>();
|
root.AddComponent<JsonDataReader>();
|
root.AddComponent<JsonDataInit>();
|
}
|
firstStart = true;
|
//EventCenter.Ins.Add((int)KTGMGemClient.EventType.JsonDataReadDone, JsonDataReadDone);
|
}
|
|
Vector2 tmpOffect;//计算适配的偏移量
|
bool firstStart = true;
|
// Start is called before the first frame update
|
void Start()
|
{
|
InitSDK();
|
bGameStart = false;
|
bFirstLoaded = false;
|
GameConfig.IsUpgradeTowerLevel = false;
|
GameConfig.CreateRandomTower = true;
|
|
bVibrate = new bool[4];
|
bVibrate[0] = bVibrate[1] = bVibrate[2] = bVibrate[3] = false;
|
|
EndlessBuffSelect.instance.HideBuffUI();
|
EndlessSettlement settlement = SettlementUI.transform.Find("BgMask").GetComponent<EndlessSettlement>();
|
settlement.Init();
|
SettlementUI.SetActive(false);
|
EndlessMaskUI.instance.Hide();
|
EndlessBossHPManager.instance.HideHP();
|
EndlessScoreManager.instance.HideScore();
|
|
|
float ratio = 0.06666667f;
|
RectTransform ts = GetComponent<RectTransform>();
|
float tmpScale = ratio / ts.localScale.x - 1.0f;
|
float offect = tmpScale * (ts.sizeDelta.y * 0.5f);
|
//Debug.Log($"tmpScale:{tmpScale} offect:{offect}");
|
tmpOffect = new Vector2(0, offect);
|
transform.Find("Panel/Bottom").GetComponent<RectTransform>().anchoredPosition += tmpOffect;
|
transform.Find("Panel/TowerBuyBtn").GetComponent<RectTransform>().anchoredPosition += tmpOffect;
|
transform.Find("Panel/SwitchSpeed").GetComponent<RectTransform>().anchoredPosition += tmpOffect;
|
transform.Find("Panel/BuffPreviewButton").GetComponent<RectTransform>().anchoredPosition += tmpOffect;
|
|
transform.Find("Panel/BossHPBar").GetComponent<RectTransform>().anchoredPosition -= tmpOffect * 0.5f;
|
transform.Find("Panel/Score").GetComponent<RectTransform>().anchoredPosition -= tmpOffect * 0.5f;
|
transform.Find("Panel/TimeInfo").GetComponent<RectTransform>().anchoredPosition -= tmpOffect * 0.5f;
|
//transform.Find("Panel/Boss").GetComponent<RectTransform>().anchoredPosition -= tmpOffect*0.5f;
|
|
|
//darkGroundImg = transform.Find("Image_DarkGround").gameObject;
|
darkGroundImg.GetComponent<RectTransform>().offsetMin += tmpOffect;
|
darkGroundImg.GetComponent<RectTransform>().offsetMax -= tmpOffect * 0.5f;
|
|
darkGroundImg.SetActive(false);
|
|
//查询是否已经做过了新手引导
|
//CheckIsNewbie();
|
|
GameConfig.EndlessOpenAttackTowerCount = 0;
|
GameConfig.EndlessBuyTowerCount = 0;
|
GameConfig.EndlessPortUseSkillTowerCount = 0;
|
|
AudioSourceManager.Ins.Play(AudioEnum.BGM2);
|
|
fireSkillBgImg = transform.Find("Panel/Energy/FireSkillBg").GetComponent<Image>();
|
transform.Find("Panel/Energy/FireSkillBg/SkillBtn").GetComponent<Button>().onClick.AddListener(OnClickFireSkillBtn);
|
fireSkillLevelText = transform.Find("Panel/Energy/FireSkillBg/Level/Text").GetComponent<Text>();
|
skillSliderValueRect = transform.Find("Panel/Energy/FireSkillBg/SliderValue").GetComponent<RectTransform>();
|
skillSliderVStartP = skillSliderValueRect.anchoredPosition;
|
skillSliderVStartHeight = skillSliderValueRect.sizeDelta;
|
|
skillPS1 = transform.Find("Panel/Energy/FireSkillBg/Effect_UI_JiNengTuBiao/03").gameObject;
|
skillPS2 = transform.Find("Panel/Energy/FireSkillBg/Effect_UI_JiNengTuBiao_02/03").gameObject;
|
skillPS3 = transform.Find("Panel/Energy/FireSkillBg/Effect_UI_JiNengTuBiao_03/03 (8)").gameObject;
|
|
skillPS1.SetActive(false);
|
skillPS2.SetActive(false);
|
skillPS3.SetActive(false);
|
|
transform.Find("Panel/BuffPreviewButton").gameObject.SetActive(false);
|
transform.Find("Panel/SwitchSpeed").gameObject.SetActive(false);
|
GMBtn.SetActive(false);
|
|
GameConfig.EnergyCount = 0;
|
GameConfig.SkillLevel = 1;
|
|
//CalculateSkillSliderValue();
|
transform.Find("Panel/Energy").gameObject.SetActive(false);
|
|
canvasGroup = transform.Find("Panel").GetComponent<CanvasGroup>();
|
|
EventCenter.Ins.Add<int>((int)KTGMGemClient.EventType.EnergyUp, EnergyUp);
|
EventCenter.Ins.Add((int)KTGMGemClient.EventType.SkillLevelUpBuff, SkillLevelUpBuff);
|
|
|
}
|
|
private void CheckIsNewbie()
|
{
|
int guide = PlayerPrefs.GetInt("GemBattleGuide");
|
GameConfig.IsNewbie = guide == 0;
|
|
//GameConfig.IsNewbie = true;
|
|
GameConfig.IsNewbieStart = GameConfig.IsNewbie;
|
|
if (GameConfig.IsNewbie)
|
{
|
EndlessRandomTower.instance.SetCountDown(false);
|
|
Debug.Log("开始新手引导");
|
GameConfig.CanDragTower = false;
|
Pause();
|
HideUIMask();
|
countDownTextNew.text = "";
|
countDownTextNew.gameObject.SetActive(false);
|
GameObject prefab = Resources.Load<GameObject>("UI/Guide/GuidePanel");
|
GameObject guideObj = Instantiate(prefab, transform.Find("Panel"));
|
guideObj.GetComponent<RectTransform>().offsetMin += tmpOffect;
|
AddGuideEvent();
|
}
|
}
|
|
public void GameOver()
|
{
|
canvasGroup.alpha = 0;
|
canvasGroup.interactable = false;
|
GuideEnergyUp(0);
|
}
|
|
/// <summary>
|
/// 所有数据读取完毕
|
/// </summary>
|
private void JsonDataReadDone()
|
{
|
Debug.Log("设置激活");
|
transform.Find("Panel/Energy").gameObject.SetActive(true);
|
|
if (!GameConfig.IsNewbie)
|
{
|
transform.Find("Panel/BuffPreviewButton").gameObject.SetActive(true);
|
transform.Find("Panel/SwitchSpeed").gameObject.SetActive(true);
|
// cx test
|
// GMBtn.SetActive(true);
|
}
|
|
fireSkillCost = JsonDataCenter.GetSkillLevelInfo(fireSkillID, GameConfig.SkillLevel).cost;
|
bombSkillCost = JsonDataCenter.GetSkillLevelInfo(bombSkillID, GameConfig.SkillLevel).cost;
|
|
energyMax = JsonDataCenter.GetById<battle>(22).value;
|
|
//transform.Find("Panel/Energy/FireSkillBtn/Image/EnergyText").GetComponent<TextMeshProUGUI>().text = fireSkillCost.ToString();
|
//transform.Find("Panel/Energy/BombSkillBtn/Image/EnergyText").GetComponent<TextMeshProUGUI>().text = bombSkillCost.ToString();
|
|
EnergyUp(0);
|
}
|
|
/// <summary>
|
/// 拖拽时候黑色背景
|
/// </summary>
|
/// <param name="isOn"></param>
|
public void SetDarkGround(bool isOn)
|
{
|
if (darkGroundImg.activeSelf != isOn)
|
darkGroundImg.SetActive(isOn);
|
}
|
private void InitSDK()
|
{
|
if (TDAA_SDKManager.Ins == null)
|
gameObject.AddComponent<TDAA_SDKManager>();
|
TDAA_SDKManager.Ins.ArriveBattle();//埋点
|
TDAA_SDKManager.Ins.Statistics(4);//埋点
|
|
if (AudioSourceManager.Ins == null)
|
gameObject.AddComponent<AudioSourceManager>();
|
}
|
|
public void ShowUIMask()
|
{
|
uiStartMssk.gameObject.SetActive(true);
|
}
|
|
public void HideUIMask()
|
{
|
uiStartMssk.gameObject.SetActive(false);
|
}
|
|
/// <summary>
|
/// 添加新手引导事件
|
/// </summary>
|
private void AddGuideEvent()
|
{
|
EventCenter.Ins.Add((int)KTGMGemClient.EventType.CreateWoodLv2, CreateWoodLv2);
|
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.CreateFireLv1, CreateFireLv1);
|
EventCenter.Ins.Add((int)KTGMGemClient.EventType.CreateWaterLv1, CreateWaterLv1);
|
|
EventCenter.Ins.Add((int)KTGMGemClient.EventType.CreateSecondWave, CreateSecondWave);
|
EventCenter.Ins.Add((int)KTGMGemClient.EventType.CreateThirdWave, CreateThirdWave);
|
|
EventCenter.Ins.Add((int)KTGMGemClient.EventType.CreateFourthWave, CreateFourthWave);
|
EventCenter.Ins.Add((int)KTGMGemClient.EventType.CreateFourthWaveDone, CreateFourthWaveDone);
|
EventCenter.Ins.Add<int>((int)KTGMGemClient.EventType.GuideEnergyUp, GuideEnergyUp);
|
|
|
//EventCenter.Ins.Add((int)KTGMGemClient.EventType.SkillRelease, SkillRelease);
|
EventCenter.Ins.Add((int)KTGMGemClient.EventType.GuideFinish, NewbieGuideEnd);
|
|
//EventCenter.Ins.Add<Vector3>((int)KTGMGemClient.EventType.PlayAppearEffect, GuidePlayAppearEffect);
|
EventCenter.Ins.Add<Vector3>((int)KTGMGemClient.EventType.GuidePlayUpgradeEffect, GuidePlayUpgradeEffect);
|
}
|
|
/// <summary>
|
/// 在(2,3)位置放置一个火元素的塔
|
/// </summary>
|
private void CreateWoodLv2()
|
{
|
//GrowUpTower 火
|
//BlinkTower 木
|
//CopyCatTower 水
|
|
Tower aTower = EndlessRandomTower.instance.getTowerByName("BlinkTower");
|
EndlessGameUI.instance.PlaceTowerForce(aTower, new IntVector2(2, 3), 2);
|
}
|
|
/// <summary>
|
/// 开始第一关的第一个波次
|
/// </summary>
|
private void CreateFirstWave()
|
{
|
Restart();
|
//EventCenter.Ins.Add((int)KTGMGemClient.EventType.FireTowerChargeEnd, OnFireTowerChargeEnd);
|
}
|
|
/// <summary>
|
/// 火塔充能释放完成
|
/// </summary>
|
private void OnFireTowerChargeEnd()
|
{
|
Pause();
|
EndlessLevelManager.instance.PauseWave();
|
//EventCenter.Ins.Remove((int)KTGMGemClient.EventType.FireTowerChargeEnd, OnFireTowerChargeEnd);
|
//EventCenter.Ins.BroadCast((int)KTGMGemClient.EventType.ChargingEnd);
|
}
|
|
/// <summary>
|
/// 恢复波次
|
/// </summary>
|
private void RestartWave()
|
{
|
Restart();
|
EndlessLevelManager.instance.RestartWave();
|
}
|
|
/// <summary>
|
/// 获得金币
|
/// </summary>
|
/// <param name="gold"></param>
|
private void AddGold(int gold)
|
{
|
EndlessLevelManager.instance.Currency.AddCurrency(gold);
|
}
|
|
/// <summary>
|
/// 新手引导生成特效
|
/// </summary>
|
private void GuidePlayAppearEffect(Vector3 worldPos)
|
{
|
EndlessGameUI.instance.PlayAppearEffectGuide(worldPos);
|
}
|
|
/// <summary>
|
/// 新手引导合成特效
|
/// </summary>
|
private void GuidePlayUpgradeEffect(Vector3 worldPos)
|
{
|
EndlessGameUI.instance.GuidePlayUpgradeEffect(worldPos);
|
}
|
|
/// <summary>
|
/// 在攻击位置上创建一个1级的木塔
|
/// </summary>
|
private void CreateFireLv1()
|
{
|
Tower aTower = EndlessRandomTower.instance.getTowerByName("GrowUpTower");
|
EndlessGameUI.instance.PlaceTowerForce(aTower, new IntVector2(1, 3), 1);
|
}
|
|
/// <summary>
|
/// 在攻击位置上创建一个1级的木塔
|
/// </summary>
|
private void CreateWaterLv1()
|
{
|
Tower aTower = EndlessRandomTower.instance.getTowerByName("CopyCatTower");
|
EndlessGameUI.instance.PlaceTowerForce(aTower, new IntVector2(3, 3), 1);
|
}
|
|
/// <summary>
|
/// 开始第二关
|
/// </summary>
|
private void CreateSecondWave()
|
{
|
EndlessLevelManager.instance.NewbieUpdateLevel();
|
beginDragStep = true;
|
}
|
|
/// <summary>
|
/// 开始第三关
|
/// </summary>
|
private void CreateThirdWave()
|
{
|
CommonDebugHelper.Debug($"开始下一关");
|
|
EndlessLevelManager.instance.NewbieUpdateLevel();
|
beginDragStep = false;
|
}
|
|
/// <summary>
|
/// 第三关出兵完毕,暂停出兵
|
/// </summary>
|
private void CreateFourthWaveDone()
|
{
|
EndlessLevelManager.instance.PauseWave();
|
}
|
|
/// <summary>
|
/// 开始第四关
|
/// </summary>
|
private void CreateFourthWave()
|
{
|
CommonDebugHelper.Debug($"开始下一关");
|
|
EndlessLevelManager.instance.NewbieUpdateLevel();
|
guideFourthWaveStep = true;
|
}
|
|
|
/// <summary>
|
/// 在第三条兵线释放技能宝石
|
/// </summary>
|
private void SkillRelease()
|
{
|
int attributeId = 99902;
|
int level = 1;
|
int waveLineIndex = 1;
|
|
// 播放特效,并处理伤害.
|
EndlessWaveLineManager.instance.PlayWaveLineEffect(waveLineIndex);
|
AgentInsManager.instance.ExecWavelineAttack(waveLineIndex, attributeId, level, false);
|
++GameConfig.EndlessPortUseSkillTowerCount;
|
StartCoroutine(Delay1());
|
}
|
|
private IEnumerator Delay1()
|
{
|
yield return new WaitForSeconds(1f);
|
EventCenter.Ins.BroadCast((int)KTGMGemClient.EventType.SkillReleaseDone);
|
}
|
|
/// <summary>
|
/// 新手引导结束
|
/// </summary>
|
private void NewbieGuideEnd()
|
{
|
EndlessLevelManager.instance.RestartWave();
|
GameConfig.IsNewbie = false;
|
transform.Find("Panel/SwitchSpeed").gameObject.SetActive(true);
|
transform.Find("Panel/BuffPreviewButton").gameObject.SetActive(true);
|
}
|
|
/// <summary>
|
/// 当前游戏局的开始时间.
|
/// </summary>
|
public float GameStartTime
|
{
|
get { return startTime; }
|
}
|
|
protected string ConvertSec(float sec)
|
{
|
if (sec < 10)
|
return "0" + Math.Floor(sec).ToString();
|
else
|
return Math.Floor(sec).ToString();
|
}
|
|
/// <summary>
|
/// 把当前的秒数变成字符串.
|
/// </summary>
|
/// <param name="sec"></param>
|
/// <returns></returns>
|
protected string ConvertTime(float sec)
|
{
|
if (sec < 60)
|
{
|
return "00:" + ConvertSec(sec);
|
}
|
else
|
{
|
float min = sec / 60;
|
if (min < 10)
|
{
|
return "0" + Math.Floor(min).ToString() + ":" + ConvertSec(sec % 60);
|
}
|
else
|
{
|
return Math.Floor(min).ToString() + ":" + ConvertSec(sec % 60);
|
}
|
}
|
}
|
|
#region 点击右侧技能按钮释放技能
|
|
private int fireSkillCost, bombSkillCost;//两个技能花费
|
private int fireSkillID = 99902;
|
private int bombSkillID = 99901;
|
private int energyMax = 0;//能量最大值,目前写死
|
private Color normalColor = new Color(1.0f, 1.0f, 1.0f, 1.0f);
|
private Color disColor = new Color(1.0f, 1.0f, 1.0f, 0);
|
private Text fireSkillLevelText;
|
private Image fireSkillBgImg;
|
private GameObject skillPS1, skillPS2, skillPS3;
|
|
/// <summary>
|
/// 点击火技能
|
/// </summary>
|
private void OnClickFireSkillBtn()
|
{
|
if (GameConfig.InfiniteSkill)
|
{
|
GuideEnergyUp(200);
|
EndlessWaveLineManager.instance.PlayAllWaveLineEffect();
|
AgentInsManager.instance.ExecAllWavelineAttack(fireSkillID, GameConfig.SkillLevel, false);
|
return;
|
}
|
|
//Debug.Log("释放了火技能:" + GameConfig.EnergyCount + " fireSkillCost:" + fireSkillCost);
|
if (GameConfig.EnergyCount >= fireSkillCost)
|
{
|
EnergyUp(-fireSkillCost);
|
Debug.Log("释放了火技能" + GameConfig.SkillLevel);
|
// 播放特效,并处理伤害.
|
EndlessWaveLineManager.instance.PlayAllWaveLineEffect();
|
AgentInsManager.instance.ExecAllWavelineAttack(fireSkillID, GameConfig.SkillLevel, false);
|
++GameConfig.EndlessPortUseSkillTowerCount;
|
}
|
else
|
{
|
AudioSourceManager.Ins.Play(AudioEnum.UIDisable);
|
}
|
}
|
|
public void GuideEnergyUp(int count)
|
{
|
GameConfig.EnergyCount = count;
|
EnergyUp(0);
|
}
|
|
/// <summary>
|
/// 击杀小怪能量(释放技能使用)
|
/// </summary>
|
private void EnergyUp(int upCount)
|
{
|
GameConfig.EnergyCount += upCount;
|
if (GameConfig.EnergyCount > energyMax)
|
{
|
GameConfig.EnergyCount = energyMax;
|
}
|
CalculateSkillSliderValue();
|
|
if (GameConfig.EnergyCount >= fireSkillCost)
|
{
|
if (GameConfig.EnergyCount == energyMax)
|
{
|
//Debug.Log("能量已满");
|
if (fireSkillBgImg.color != disColor)
|
{
|
fireSkillBgImg.color = disColor;
|
}
|
if (!skillPS1.activeSelf) skillPS1.SetActive(true);
|
if (!skillPS2.activeSelf) skillPS2.SetActive(true);
|
if (skillPS3.activeSelf) skillPS3.SetActive(false);
|
//skillPS1.Play();
|
//skillPS2.Play();
|
}
|
else
|
{
|
//Debug.Log("能量达到一次使用");
|
if (fireSkillBgImg.color != normalColor)
|
{
|
fireSkillBgImg.color = normalColor;
|
}
|
if (skillPS1.activeSelf) skillPS1.SetActive(false);
|
if (!skillPS2.activeSelf) skillPS2.SetActive(true);
|
if (!skillPS3.activeSelf) skillPS3.SetActive(true);
|
|
//if (skillPS1.isPlaying) skillPS1.Stop();
|
//if (!skillPS2.isPlaying) skillPS2.Play();
|
}
|
}
|
else
|
{
|
//Debug.Log("能量不够");
|
if (fireSkillBgImg.color != normalColor)
|
{
|
fireSkillBgImg.color = normalColor;
|
}
|
if (skillPS1.activeSelf) skillPS1.SetActive(false);
|
if (skillPS2.activeSelf) skillPS2.SetActive(false);
|
if (skillPS3.activeSelf) skillPS3.SetActive(false);
|
// if (skillPS1.isPlaying) skillPS1.Stop();
|
// if (skillPS2.isPlaying) skillPS2.Stop();
|
|
}
|
}
|
|
RectTransform skillSliderValueRect;
|
Vector2 skillSliderVStartP;
|
Vector2 skillSliderVStartHeight;
|
|
private void CalculateSkillSliderValue()
|
{
|
float value = (float)GameConfig.EnergyCount / 200.0f;
|
float height = skillSliderVStartHeight.y * value;
|
float y = skillSliderVStartP.y - (skillSliderVStartHeight.y - height) * 0.5f;
|
skillSliderValueRect.sizeDelta = new Vector2(skillSliderVStartHeight.x, height);
|
skillSliderValueRect.anchoredPosition = new Vector2(skillSliderVStartP.x, y);
|
|
}
|
|
|
/// <summary>
|
/// 增加技能等级的事件监听
|
/// </summary>
|
private void SkillLevelUpBuff()
|
{
|
if (GameConfig.SkillLevel <= 5)
|
{
|
GameConfig.SkillLevel++;
|
fireSkillCost = JsonDataCenter.GetSkillLevelInfo(fireSkillID, GameConfig.SkillLevel).cost;
|
bombSkillCost = JsonDataCenter.GetSkillLevelInfo(bombSkillID, GameConfig.SkillLevel).cost;
|
//Debug.Log($"技能最高5级,当前技能等级:{GameConfig.SkillLevel} fireSkillCost:{fireSkillCost} ");
|
fireSkillLevelText.text = "Lv." + GameConfig.SkillLevel;
|
}
|
}
|
|
|
|
|
#endregion
|
|
public void Pause()
|
{
|
isPause = true;
|
}
|
|
public void Restart()
|
{
|
isPause = false;
|
}
|
|
public bool IsGameRunning { get { return !isPause; } }
|
|
private bool isUpgradeTowerLevel;
|
|
// Update is called once per frame
|
void Update()
|
{
|
if (firstStart)
|
{
|
if (!GameConfig.JsonReadDone)
|
return;
|
else
|
{
|
firstStart = false;
|
CheckIsNewbie();
|
}
|
}
|
if (isPause) return;
|
|
if (bGameStart)
|
{
|
startTime += Time.deltaTime;
|
|
// if (!isUpgradeTowerLevel && startTime >= JsonDataCenter.DOUBLE_GEM_TIME)
|
// {
|
// EndlessRandomTower.instance.UpdateDescDisplay();
|
// isUpgradeTowerLevel = true;
|
// }
|
|
timeTextNew.text = ConvertTime((float)Math.Ceiling(startTime));
|
}
|
|
if (!GameConfig.IsNewbie)
|
{
|
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)
|
{
|
HideUIMask();
|
countDownTextNew.text = "";
|
countDownTextNew.gameObject.SetActive(false);
|
bGameStart = true;
|
// 开始关卡
|
EndlessLevelManager.instance.StartLevel();
|
timeTextNew.gameObject.SetActive(true);
|
|
JsonDataReadDone();
|
// 开始播放背景音乐.
|
if (bgMusic != null)
|
bgMusic.Play();
|
}
|
}
|
}
|
else
|
{
|
// 新手走的流程
|
if (!bFirstLoaded && !bGameStart)
|
bFirstLoaded = true;
|
|
if (bFirstLoaded && !bGameStart)
|
{
|
bGameStart = true;
|
EndlessLevelManager.instance.StartLevel();
|
timeTextNew.gameObject.SetActive(true);
|
|
JsonDataReadDone();
|
|
if (bgMusic != null)
|
bgMusic.Play();
|
}
|
}
|
}
|
}
|