wangguan
2020-12-26 d66fdae8a885ff6ab23bedd423f6eade1779365c
Assets/Scripts/TowerDefense/UI/EndlessUIStart.cs
@@ -15,7 +15,7 @@
/// </summary>
public class EndlessUIStart : Singleton<EndlessUIStart>
{
    public TextMeshProUGUI countDownTextNew = null;
    //public TextMeshProUGUI countDownTextNew = null;
    public TextMeshProUGUI timeTextNew = null;
@@ -62,25 +62,32 @@
    protected override void Awake()
    {
        base.Awake();
        if (Application.platform == RuntimePlatform.WindowsEditor ||
         Application.platform == RuntimePlatform.WindowsPlayer)
        {
            GameConfig.useSDK = false;
            GameConfig.OpenDebug = true;
            GMBtn.SetActive(true);
        }
        else
        {
            GMBtn.SetActive(false);
        }
        //这里为了方便直接使用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 = new GameObject("ManagerRoot");
                root.AddComponent<DoNotDestory>();
                root.AddComponent<MasterSocket>();
                root.AddComponent<TDAA_SDKManager>();
                root.AddComponent<AudioSourceManager>();
                root.AddComponent<JsonDataReader>();
                root.AddComponent<JsonDataInit>();
            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);
@@ -150,13 +157,15 @@
        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;
@@ -189,13 +198,43 @@
            GameConfig.CanDragTower = false;
            Pause();
            HideUIMask();
            countDownTextNew.text = "";
            countDownTextNew.gameObject.SetActive(false);
            //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();
        }
        else
        {
            //开始倒计时
            StartCoroutine(StartCountDown());
        }
    }
    public GameObject countDownPS;
    IEnumerator StartCountDown()
    {
        countDownPS.SetActive(true);
        //MMVibrationManager.Haptic(HapticTypes.MediumImpact);
        yield return new WaitForSeconds(1.0f);
        //MMVibrationManager.Haptic(HapticTypes.MediumImpact);
        yield return new WaitForSeconds(1.0f);
        //MMVibrationManager.Haptic(HapticTypes.MediumImpact);
        yield return new WaitForSeconds(1.0f);
        HideUIMask();
        //countDownTextNew.text = "";
        countDownPS.SetActive(false);
        bGameStart = true;
        // 开始关卡
        EndlessLevelManager.instance.StartLevel();
        timeTextNew.gameObject.SetActive(true);
        JsonDataReadDone();
        // 开始播放背景音乐.
        if (bgMusic != null)
            bgMusic.Play();
    }
    public void GameOver()
@@ -498,7 +537,7 @@
    private Color disColor = new Color(1.0f, 1.0f, 1.0f, 0);
    private Text fireSkillLevelText;
    private Image fireSkillBgImg;
    private GameObject skillPS1, skillPS2;
    private GameObject skillPS1, skillPS2, skillPS3;
    /// <summary>
    /// 点击火技能
@@ -558,7 +597,7 @@
                }
                if (!skillPS1.activeSelf) skillPS1.SetActive(true);
                if (!skillPS2.activeSelf) skillPS2.SetActive(true);
                if (skillPS3.activeSelf) skillPS3.SetActive(false);
                //skillPS1.Play();
                //skillPS2.Play();
            }
@@ -571,6 +610,8 @@
                }
                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();
            }
@@ -584,6 +625,7 @@
            }
            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();
@@ -616,7 +658,7 @@
            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;
            fireSkillLevelText.text = GameConfig.SkillLevel + "级";
        }
    }
@@ -667,75 +709,7 @@
            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 (GameConfig.IsNewbie)
        {
            // 新手走的流程
            if (!bFirstLoaded && !bGameStart)
@@ -753,5 +727,6 @@
                    bgMusic.Play();
            }
        }
    }
}