From ac76c8913e3497e8789411105e541cb6afa189b2 Mon Sep 17 00:00:00 2001
From: wangguan <wangguan@kt007.com>
Date: Thu, 05 Nov 2020 15:46:33 +0800
Subject: [PATCH] MainCanvas为Space,调整新手引导在Bottom上,还原魏哥UI适配代码,改为延迟执行

---
 Assets/Scripts/TowerDefense/Towers/Placement/TowerPlacementGridEndless.cs |  108 +++++++++++-------------------------------------------
 1 files changed, 22 insertions(+), 86 deletions(-)

diff --git a/Assets/Scripts/TowerDefense/Towers/Placement/TowerPlacementGridEndless.cs b/Assets/Scripts/TowerDefense/Towers/Placement/TowerPlacementGridEndless.cs
index ea019ad..b5a102f 100644
--- a/Assets/Scripts/TowerDefense/Towers/Placement/TowerPlacementGridEndless.cs
+++ b/Assets/Scripts/TowerDefense/Towers/Placement/TowerPlacementGridEndless.cs
@@ -1,5 +1,4 @@
 using System;
-using System.Collections.Generic;
 using Core.Utilities;
 using KTGMGemClient;
 using TowerDefense.Level;
@@ -7,25 +6,8 @@
 using UnityEngine;
 using UnityEngine.UI;
 
-namespace TowerDefense.Towers.Placement { 
-
-
-
-    public class BuyButtonGroup
-    {
-        public BuyButtonGroup(Transform t,int x,int y)
-        {
-            this.button = t;
-            this.x = x;
-            this.y = y;
-        }
-
-
-        public Transform button;
-        public int x;
-        public int y;
-    };
-
+namespace TowerDefense.Towers.Placement
+{
     /// <summary>
     /// A tower placement location made from a grid.
     /// Its origin is centered in the middle of the lower-right cell. It can be oriented in any direction
@@ -33,10 +15,6 @@
     [RequireComponent(typeof(BoxCollider))]
     public class TowerPlacementGridEndless : MonoBehaviour, IPlacementArea
     {
-        [Range(0,100)]
-        public float buyButtonScaler=1.9f;
-
-        private List<BuyButtonGroup> mBuyButtons = new List<BuyButtonGroup>();
         public static float GRID_OPENCASH = 100;
 
         /// <summary>
@@ -341,15 +319,9 @@
                 }
             }
         }
-        void FixedUpdate()
-        {
-            // this.resizeBuyButtonSize(this.buyButtonScaler);
-        }
 
         void Update()
         {
-
-            
             if (m_arrCoinGenTime == null || !EndlessUIStart.instance.IsGameRunning) return;
 
             float delta = Time.deltaTime;
@@ -557,8 +529,6 @@
             m_AvailableCells = new bool[dimensions.x, dimensions.y];
 
             opponent = false;
-
-            
         }
 
         /// <summary>
@@ -574,51 +544,25 @@
 
             SetUpGrid();
 
-            // 初始化格子对应的屏幕坐标数据
-            preCalculateGridUIPos();
+            // 初始化格子对应的屏幕坐标数据 延迟执行
+            Invoke("preCalculateGridUIPos",0.3f);
+            //preCalculateGridUIPos();
         }
 
-        void resizeBuyButtonSize(float defaultVal=1.9f)
+        /// <summary>
+        /// OnGUI is called for rendering and handling GUI events.
+        /// This function can be called multiple times per frame (one call per event).
+        /// </summary>
+        void OnGUI()
         {
-          
-
-
-            foreach(BuyButtonGroup bbg in this.mBuyButtons)
+            if (GUILayout.Button("11111111111111111111111111111111111111111111111111"))
             {
-                Vector3 pos = bbg.button.position;
-                pos.x = arrGridCentPos[bbg.x, bbg.y].x;
-                pos.z = arrGridCentPos[bbg.x, bbg.y].y + (bbg.y - AttackRowNumbers) * defaultVal;
-                pos.y = 30;
-                bbg.button.position = pos;
-                bbg.button.localRotation = Quaternion.identity;
-                bbg.button.localScale = Vector3.one;
+                //AudioSourceManager.Ins.Play(AudioEnum.BGM1);
+                preCalculateGridUIPos();
             }
-            //for (int x = 0; x < dimensions.x; ++x)
-            //{
-            //    for (int y = dimensions.y - AttackRowNumbers; y < dimensions.y; ++y)
-            //    {
-            //        if (m_arrGridType[x, y] != PlacementGridType.EGridWaitBuy) continue;
+        }
 
-            //        GameObject container = GameObject.Find("BuyButtonContainer");
-            //        Button buyButton = Instantiate(waitBuyBtnPrefab);
-            //        buyButton.transform.SetParent(container.transform);
-
-
-            //        mBuyButtons.Add(new BuyButtonGroup(buyButton.transform, x, y));
-            //        //Camera.main.WorldToViewportPoint()
-
-            //        Vector3 pos = buyButton.transform.position;
-            //        pos.x = arrGridCentPos[x, y].x;
-            //        pos.z = arrGridCentPos[x, y].y + (y - AttackRowNumbers) * 1.9f;
-            //        pos.y = 30;
-            //        buyButton.transform.position = pos;
-            //        buyButton.transform.localRotation = Quaternion.identity;
-            //        buyButton.transform.localScale = Vector3.one;
-
-                   
-            //    }
-            //}
-
+        void ResetPos(){
 
         }
         /// <summary>
@@ -628,7 +572,6 @@
         /// </summary>
         void preCalculateGridUIPos()
         {
-
             arrGridCentPos = new Vector2[dimensions.x, dimensions.y];
 
             Vector3 targetPos = GridToWorld(new IntVector2(0, 0), new IntVector2(1, 1));
@@ -647,7 +590,6 @@
                 }
             }
 
-
             // 血条位置的设定
             PreCalculateTowerBloodUi();
 
@@ -663,17 +605,13 @@
                     Button buyButton = Instantiate(waitBuyBtnPrefab);
                     buyButton.transform.SetParent(container.transform);
 
-
-                    mBuyButtons.Add(new BuyButtonGroup(buyButton.transform, x, y));
-                    //Camera.main.WorldToViewportPoint()
-
-                    //Vector3 pos = buyButton.transform.position;
-                    //pos.x = arrGridCentPos[x, y].x;
-                    //pos.z = arrGridCentPos[x, y].y + (y - AttackRowNumbers) * 1.9f;
-                    //pos.y = 30;
-                    //buyButton.transform.position = pos;
-                    //buyButton.transform.localRotation = Quaternion.identity;
-                    //buyButton.transform.localScale = Vector3.one;
+                    Vector3 pos = buyButton.transform.position;
+                    pos.x = arrGridCentPos[x, y].x;
+                    pos.z = arrGridCentPos[x, y].y + (y - AttackRowNumbers) * 1.9f;
+                    pos.y = 30;
+                    buyButton.transform.position = pos;
+                    buyButton.transform.localRotation = Quaternion.identity;
+                    buyButton.transform.localScale = Vector3.one;
 
                     // 设置按钮对应的点击功能
                     EndlessTowerGridOpen tgo = buyButton.GetComponent<EndlessTowerGridOpen>();
@@ -685,8 +623,6 @@
                     }
                 }
             }
-
-            this.resizeBuyButtonSize();
         }
 
         /// <summary>

--
Gitblit v1.9.1