Ejemplo n.º 1
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.º 2
0
 public void Upgrade(int upgradeIdx = 0)
 {
     if (GetUpgradeType() == 0)
     {
         RscManager.SpendRsc(GetUpgradeCost(0));
         Build(true);
     }
     else
     {
         TowerManager.RemoveTower(this);
         if (buildPlatform != null)
         {
             buildPlatform.RemoveTower(nodeID);
         }
         TowerManager.BuildTower(upgradeTowerList[upgradeIdx], buildPlatform, nodeID);
         Destroy(thisObj);
     }
 }