Ejemplo n.º 1
0
        private void OnCursorDown()
        {
            SelectInfo sInfo = TowerManager.GetSelectInfo(Input.mousePosition);

            bool select = false;
            bool build  = false;

            if (sInfo.HasValidPoint())
            {
                if (sInfo.GetTower() != null)
                {
                    select = true;
                    SelectControl.SelectUnit(sInfo.GetTower());
                    UITowerSelect.Show(sInfo.GetTower());
                }
                else if (buildMode == _BuildMode.PointNBuild && sInfo.AvailableForBuild())
                {
                    build = true;
                    UIBuildButton.Show(sInfo);
                    SelectControl.SelectNode(sInfo.platform, sInfo.nodeID);
                }
            }

            if (buildMode == _BuildMode.PointNBuild && !build)
            {
                SelectControl.ClearNode();
                UIBuildButton.Hide();
            }
            if (!select)
            {
                SelectControl.ClearUnit();
                UITowerSelect.Hide();
            }
        }
Ejemplo n.º 2
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]);
            }
        }
Ejemplo n.º 3
0
        public override void Awake()
        {
            base.Awake();

            instance = this;
        }