示例#1
0
 void OnNewTower(UnitTower tower)
 {
     if (UIControl.UseDragNDropMode())
     {
         UpdateBuildableStatus();
     }
 }
示例#2
0
        void Update()
        {
            if (UIControl.UseDragNDropMode() || !UIControl.UsePieMenuForBuild())
            {
                return;
            }

            if (buttonLayoutGroup.enabled == UIControl.UsePieMenuForBuild())
            {
                buttonLayoutGroup.enabled = !UIControl.UsePieMenuForBuild();
            }

            if (sInfo == null)
            {
                return;
            }

            Vector3        screenPos = Camera.main.WorldToScreenPoint(sInfo.GetPos()) * UI.GetScaleFactor();
            List <Vector3> posList   = GetPieMenuPos(sInfo.buildableList.Count, screenPos);

            for (int i = 0; i < posList.Count; i++)
            {
                buildButtons[i].rectT.localPosition = posList[i];
            }
        }
示例#3
0
        public void OnHoverBuildButton(GameObject butObj)
        {
            Debug.Log(butObj);
            if (!ValidForInteraction())
            {
                return;
            }

            int idx = UI.GetItemIndex(butObj, buildButtons);

            if (UIControl.UseDragNDropMode())
            {
                UITooltip.Show(buildableList[idx], UI.GetCorner(buildButtons[idx].rectT, 1), 0, new Vector3(0, .25f, 0));
            }
            else
            {
                if (UIControl.UsePieMenuForBuild())
                {
                    UITooltip.Show(sInfo.buildableList[idx]);
                }
                else
                {
                    UITooltip.Show(sInfo.buildableList[idx], UI.GetCorner(buildButtons[idx].rectT, 1), 0, new Vector3(0, .25f, 0));
                }
            }

            if (UIControl.UsePointNBuildMode())
            {
                TowerManager.ShowSampleTower(sInfo.buildableList[idx].prefabID, sInfo);
            }
        }
示例#4
0
        public void OnBuildButton(GameObject butObj, int pointerID = -1)
        {
            if (!ValidForInteraction())
            {
                return;
            }

            int idx = UI.GetItemIndex(butObj, buildButtons);

            if (UIControl.UsePointNBuildMode() && UIControl.InTouchMode())
            {
                if (touchModeButtonIdx != idx)
                {
                    if (touchModeButtonIdx >= 0)
                    {
                        ClearTouchModeSelect();
                    }

                    touchModeButtonIdx = idx;
                    buildButtons[touchModeButtonIdx].imgHighlight.gameObject.SetActive(true);
                    OnHoverBuildButton(butObj);
                    return;
                }

                ClearTouchModeSelect();
            }

            if (UIControl.UsePointNBuildMode())
            {
                if (!CheckCost(sInfo.buildableList[idx].GetCost()))
                {
                    return;
                }

                TowerManager.BuildTower(sInfo.buildableList[idx], sInfo.platform, sInfo.nodeID);
                SelectControl.ClearNode();
                OnExitBuildButton(null);
                Hide();

                TowerManager.HideSampleTower();
            }

            if (UIControl.UseDragNDropMode())
            {
                if (!CheckCost(buildableList[idx].GetCost()))
                {
                    return;
                }

                SelectControl.ClearUnit();
                UITowerSelect.Hide();

                TowerManager.CreateDragNDropTower(buildableList[idx]);
            }
        }
        private RectTransform dndLabelRectT; //for drag n drop tower when build is invalid

        void Start()
        {
            if (UIControl.UseDragNDropMode() && dndLabel != null)
            {
                dndLabelObj   = dndLabel.gameObject;
                dndLabelRectT = dndLabelObj.GetComponent <RectTransform>();
            }
            else
            {
                gameObject.SetActive(false);
            }
        }
示例#6
0
        public override void Start()
        {
            base.Start();

            buildableList = TowerManager.GetBuildableList();
            for (int i = 0; i < buildableList.Count; i++)
            {
                AddBuildButton(i, buildableList[i].icon, buildableList[i].GetCost()[0].ToString("f0"));
            }

            if (UIControl.UsePointNBuildMode())
            {
                thisObj.SetActive(false);
            }
            else if (UIControl.UseDragNDropMode())
            {
                UpdateBuildableStatus(); canvasGroup.alpha = 1; thisObj.SetActive(true);
            }
        }