From b5460cd3e55d1c5120bf5567502c051e0c7cdb2b Mon Sep 17 00:00:00 2001
From: wangguan <wangguan@kt007.com>
Date: Thu, 19 Nov 2020 16:07:43 +0800
Subject: [PATCH] 动态修改背景

---
 Assets/Scripts/TowerDefense/UI/EndlessUIStart.cs |  109 +++++++++++++++++++++++++++++++++++++++++++++---------
 1 files changed, 91 insertions(+), 18 deletions(-)

diff --git a/Assets/Scripts/TowerDefense/UI/EndlessUIStart.cs b/Assets/Scripts/TowerDefense/UI/EndlessUIStart.cs
index 4e3c949..c57ef4d 100644
--- a/Assets/Scripts/TowerDefense/UI/EndlessUIStart.cs
+++ b/Assets/Scripts/TowerDefense/UI/EndlessUIStart.cs
@@ -19,7 +19,7 @@
 
     public TextMeshProUGUI timeTextNew = null;
 
-    public TextMeshProUGUI timeStatic = null;
+    //public TextMeshProUGUI timeStatic = null;
 
     /// <summary>
     /// 结算界面
@@ -49,40 +49,96 @@
 
     public bool beginSkillStep = false;
 
+    public GameObject darkGroundImg;
+
     // Start is called before the first frame update
     void Start()
     {
-        GA_SDK_Manager.Ins.ArriveBattle();//埋点
-        GA_SDK_Manager.Ins.Statistics(4);//埋点
+        InitSDK();
+
+        bGameStart = false;
+        bFirstLoaded = false;
 
         bVibrate = new bool[4];
         bVibrate[0] = bVibrate[1] = bVibrate[2] = bVibrate[3] = false;
 
-        // 设置为顶层渲染:
-        countDownTextNew.transform.SetAsLastSibling();
-
-        if (timeStatic)
-            timeStatic.gameObject.SetActive(false);
         EndlessBuffSelect.instance.HideBuffUI();
-        EndlessBossHPManager.instance.HideHP();
-        EndlessSettlement settlement = SettlementUI.transform.GetChild(0).GetComponent<EndlessSettlement>();
+        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}");
+        Vector2 tmpOffect = new Vector2(0, offect);
+        transform.Find("Panel/Bottom").GetComponent<RectTransform>().anchoredPosition += tmpOffect;
+        transform.Find("Panel/TowerBuyBtn").GetComponent<RectTransform>().anchoredPosition += tmpOffect;
+
+        //darkGroundImg = transform.Find("Image_DarkGround").gameObject;
+        darkGroundImg.GetComponent<RectTransform>().offsetMin += tmpOffect;
+        darkGroundImg.GetComponent<RectTransform>().offsetMax -= tmpOffect*0.5f;
+
+        darkGroundImg.SetActive(false);
         //查询是否已经做过了新手引导
         int guide = PlayerPrefs.GetInt("GemBattleGuide");
         GameConfig.IsNewbie = guide == 0;
-
+        //GameConfig.IsNewbie = false;
         if (GameConfig.IsNewbie)
         {
+            Debug.Log("开始新手引导");
             Pause();
-            uiStartMssk.gameObject.SetActive(false);
+            HideUIMask();
             countDownTextNew.text = "";
             countDownTextNew.gameObject.SetActive(false);
 
-            Instantiate(Resources.Load<GameObject>("UI/Guide/GuidePanel"), this.transform);
+            GameObject guideObj = Instantiate(Resources.Load<GameObject>("UI/Guide/GuidePanel"), transform.Find("Panel"));
+            guideObj.GetComponent<RectTransform>().offsetMin += tmpOffect;
             AddGuideEvent();
         }
+
+        GameConfig.EndlessOpenAttackTowerCount = 0;
+        GameConfig.EndlessBuyTowerCount = 0;
+        GameConfig.EndlessPortUseSkillTowerCount = 0;
+
+        AudioSourceManager.Ins.Play(AudioEnum.BGM2);
+
+
+    }
+
+    /// <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>
@@ -98,6 +154,9 @@
         EventCenter.Ins.Add((int)KTGMGemClient.EventType.CreateSecondWave, CreateSecondWave);
         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>
@@ -148,6 +207,22 @@
     }
 
     /// <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 CreateWaterLv1()
@@ -170,14 +245,14 @@
     /// </summary>
     private void SkillRelease()
     {
-        EndlessLevelManager.instance.RestartWave();
         int attributeId = 99902;
         int level = 1;
-        int waveLineIndex = 2;
+        int waveLineIndex = 1;
 
         // 播放特效,并处理伤害.
         EndlessWaveLineManager.instance.PlayWaveLineEffect(waveLineIndex);
         AgentInsManager.instance.ExecWavelineAttack(waveLineIndex, attributeId, level, false);
+        ++GameConfig.EndlessPortUseSkillTowerCount;
         StartCoroutine(Delay1());
     }
 
@@ -185,8 +260,6 @@
     {
         yield return new WaitForSeconds(1f);
         EventCenter.Ins.BroadCast((int)KTGMGemClient.EventType.SkillReleaseDone);
-        GameConfig.IsNewbie = false;
-        EndlessLevelManager.instance.PauseWave();
     }
 
     /// <summary>
@@ -315,7 +388,7 @@
                 // 开启游戏,且隐藏中间的数字.
                 if (secToDo <= 0)
                 {
-                    uiStartMssk.gameObject.SetActive(false);
+                    HideUIMask();
                     countDownTextNew.text = "";
                     countDownTextNew.gameObject.SetActive(false);
                     bGameStart = true;

--
Gitblit v1.9.1