Example #1
0
    public void SetUpgradeLevel(UpgradeLvl upgradeLevel)
    {
        _upgradeLevel = upgradeLevel;
        ResourceCost myResource = null;
        switch(_buildingType)
        {
            case BuildingType.Tower:
                switch(_upgradeLevel)
                {
                    case UpgradeLvl.L1:
                        myResource = VillageController.Instance.TowerLvl1;
                        break;
                    case UpgradeLvl.L2:
                        myResource = VillageController.Instance.TowerLvl2;
                        break;
                    case UpgradeLvl.L3:
                        myResource = VillageController.Instance.TowerLvl3;
                        break;
                }
                break;
            case BuildingType.Cannon:
                switch (_upgradeLevel)
                {
                    case UpgradeLvl.L1:
                        myResource = VillageController.Instance.CannonLvl1;
                        break;
                    case UpgradeLvl.L2:
                        myResource = VillageController.Instance.CannonLvl2;
                        break;
                    case UpgradeLvl.L3:
                        myResource = VillageController.Instance.CannonLvl3;
                        break;
                }
                break;
            case BuildingType.Mortar:
                switch (_upgradeLevel)
                {
                    case UpgradeLvl.L1:
                        myResource = VillageController.Instance.MortarLvl1;
                        break;
                    case UpgradeLvl.L2:
                        myResource = VillageController.Instance.MortarLvl2;
                        break;
                    case UpgradeLvl.L3:
                        myResource = VillageController.Instance.MortarLvl3;
                        break;
                }
                break;
        }

        Text.text = "Food: " + myResource.FoodCost + "\n";
        Text.text += "Wood: " + myResource.WoodCost + "\n";
        Text.text += "Stones: " + myResource.StoneCost + "\n";
        Text.text += "Iron: " + myResource.IronCost;
    }
Example #2
0
 void Start()
 {
     switch(TowerKind)
     {
         case TowerKindEnum.Tower:
             _buildingType = BuildingType.Tower;
             break;
         case TowerKindEnum.Cannon:
             _buildingType = BuildingType.Cannon;
             break;
         case TowerKindEnum.Mortar:
             _buildingType = BuildingType.Mortar;
             break;
     }
     _upgradeLevel = UpgradeLvl.L1;
     _spriteRenderer = GetComponent<SpriteRenderer>();
 }
Example #3
0
 void Update()
 {
     if(VillageController.Instance.CanUpgradeBuilding(_buildingType, _upgradeLevel))
     {
         for (int i = 0; i < _playerIndex.Count; ++i)
         {
             _spriteRenderer.color = Color.white;
             bool condition = false;
             switch (TowerKind)
             {
                 case TowerKindEnum.Tower:
                     condition = InputManager.Instance.GetBButton(_playerIndex[i]);
                     break;
                 case TowerKindEnum.Cannon:
                     condition = InputManager.Instance.GetYButton(_playerIndex[i]);
                     _upgradeLevel = UpgradeLvl.L3;
                     break;
                 case TowerKindEnum.Mortar:
                     condition = InputManager.Instance.GetXButton(_playerIndex[i]);
                     _upgradeLevel = UpgradeLvl.L3;
                     break;
             }
             if (condition)
             {
                 VillageController.Instance.BuyBuilding(_buildingType, _upgradeLevel);
                 _towerSlot.SetUpgrade(TowerKind);
             }
         }
     }
     else
     {
         _spriteRenderer.color = Color.gray;
     }
 }
    public void SetUpgrade(TowerKindEnum newTower)
    {
        TowerKindEnum prevTowerKind = _towerKind;
        _towerKind = newTower;
        switch (_towerKind)
        {
            case TowerKindEnum.None:
                Tower.SetActive(false);
                Cannon.SetActive(false);
                Mortar.SetActive(false);
                _upgradeLvl = UpgradeLvl.L1;
                break;
            case TowerKindEnum.Tower:
                switch(prevTowerKind)
                {
                    case TowerKindEnum.Tower:
                        if(Tower.activeSelf)
                        {
                            Tower.SetActive(false);
                            TowerUpgrade2.SetActive(true);
                            _upgradeLvl = UpgradeLvl.L3;
                        }
                        else if(TowerUpgrade2.activeSelf)
                        {
                            TowerUpgrade2.SetActive(false);
                            TowerUpgrade3.SetActive(true);
                        }
                        break;
                    default:
                        Tower.SetActive(true);
                        _upgradeLvl = UpgradeLvl.L2;
                        break;
                }

                Cannon.SetActive(false);
                CannonUpgrade2.SetActive(false);
                CannonUpgrade3.SetActive(false);
                Mortar.SetActive(false);
                MortarUpgrade2.SetActive(false);
                MortarUpgrade3.SetActive(false);
                TowerSlotMesh.enabled = false;
                break;
            case TowerKindEnum.Cannon:
                switch(prevTowerKind)
                {
                    case TowerKindEnum.Cannon:
                        if(Cannon.activeSelf)
                        {
                            Cannon.SetActive(false);
                            CannonUpgrade2.SetActive(true);
                            _upgradeLvl = UpgradeLvl.L3;
                        }
                        else if(CannonUpgrade2.activeSelf)
                        {
                            CannonUpgrade2.SetActive(false);
                            CannonUpgrade3.SetActive(true);
                        }
                        break;
                    default:
                        Cannon.SetActive(true);
                        _upgradeLvl = UpgradeLvl.L2;
                        break;
                }

                Tower.SetActive(false);
                TowerUpgrade2.SetActive(false);
                TowerUpgrade3.SetActive(false);
                Mortar.SetActive(false);
                MortarUpgrade2.SetActive(false);
                MortarUpgrade3.SetActive(false);
                TowerSlotMesh.enabled = false;
                break;
            case TowerKindEnum.Mortar:
                switch (prevTowerKind)
                {
                    case TowerKindEnum.Mortar:
                        if (Mortar.activeSelf)
                        {
                            Mortar.SetActive(false);
                            MortarUpgrade2.SetActive(true);
                            _upgradeLvl = UpgradeLvl.L3;
                        }
                        else if (MortarUpgrade2.activeSelf)
                        {
                            MortarUpgrade2.SetActive(false);
                            MortarUpgrade3.SetActive(true);
                        }
                        break;
                    default:
                        Mortar.SetActive(true);
                        _upgradeLvl = UpgradeLvl.L2;
                        break;
                }

                Tower.SetActive(false);
                TowerUpgrade2.SetActive(false);
                TowerUpgrade3.SetActive(false);
                Cannon.SetActive(false);
                CannonUpgrade2.SetActive(false);
                CannonUpgrade3.SetActive(false);
                TowerSlotMesh.enabled = false;
                break;
        }
        TowerCard.gameObject.SetActive(false);
        CannonCard.gameObject.SetActive(false);
        MortarCard.gameObject.SetActive(false);
        AButton.SetActive(true);
        _isPlayerCloseEnough = true;
    }