Exemplo n.º 1
0
        public void OnTowerButton(GameObject butObj)
        {
            //in drag and drop mode, player could be hitting the button while having an active tower selected
            //if that's the case, clear the selectedTower first. and we can show the tooltip properly
            if (UI.UseDragNDrop() && GameControl.GetSelectedTower() != null)
            {
                UI.ClearSelectedTower();
                return;
            }
            int ID = GetButtonID(butObj);
            List <UnitTower> towerList = BuildManager.GetTowerList();

            bool exception = true;

            if (!UI.UseDragNDrop())
            {
                exception = BuildManager.BuildTower(towerList[ID]);
            }
            else
            {
                exception = BuildManager.BuildTowerDragNDrop(towerList[ID]);
            }

            if (exception == false)
            {
                UIGameMessage.DisplayMessage("Can't build tower");
            }

            if (!UI.UseDragNDrop())
            {
                OnExitHoverButton(butObj);
            }

            Hide();
        }