Example #1
0
 public int GetBuildingCap()
 {
     if (_TownCenter)
     {
         BuildableObject bo = _TownCenter.transform.GetComponent <BuildableObject>();
         if (bo)
         {
             return(bo.getLevel() * 4);
         }
     }
     Debug.LogWarning("No TownCenter");
     return(0);
 }
Example #2
0
    public float getGatherBonus()
    {
        BuildableObject building = GetComponent <BuildableObject>();
        int             level    = building.getLevel();

        if (level == 1)
        {
            return(_gatherBonusLvl1);
        }
        else if (level == 2)
        {
            return(_gatherBonusLvl2);
        }
        else if (level == 3)
        {
            return(_gatherBonusLvl3);
        }

        return(0);
    }
Example #3
0
    public void showMenu(bool cond, Vector2 loc, GameObject o, BuildableObject building)
    {
        // dont want to enable buttons if we are in override mode
        if (cond && _cameraController.getOverrideMode())
        {
            return;
        }

        _active  = cond;
        _current = o;

        //Tell MVC which building this is on
        if (cond)
        {
            MVCController.Instance.setLastClicked(o);
        }


        //Move the location up a bit?
        loc.y = loc.y + 30;

        this.transform.position = loc;

        // Debug.Log("The Menu loc moves to :" + loc);

        foreach (Button b in buttons)
        {
            b.gameObject.SetActive(cond);

            //Dont want to do this if were turning them off
            if (cond && building != null)
            {
                //When Enabling Upgrade Buttons, change the button based on the type and level of last structure clicked
                if (b.name == "Button_Upgrade")
                {
                    UIButtonCosts buttonScript = b.GetComponent <UIButtonCosts>();
                    if (buttonScript != null)
                    {
                        BuildableObject.BuildingType type = building.getType();
                        int level = building.getLevel();

                        switch (type)
                        {
                        case (BuildableObject.BuildingType.House):
                            buttonScript.ChangeButton("house", level + 1);
                            break;

                        case (BuildableObject.BuildingType.Farm):
                            buttonScript.ChangeButton("farm", level + 1);
                            break;

                        case (BuildableObject.BuildingType.Outpost):
                            buttonScript.ChangeButton("outpost", level + 1);
                            break;

                        case (BuildableObject.BuildingType.Banner):
                            buttonScript.ChangeButton("banner", level + 1);
                            break;

                        case (BuildableObject.BuildingType.TownCenter):
                            buttonScript.ChangeButton("towncenter", level + 1);
                            break;

                        case (BuildableObject.BuildingType.GarbageCan):
                            buttonScript.ChangeButton("garbagecan", level + 1);
                            break;

                        case (BuildableObject.BuildingType.WoodPile):
                            buttonScript.ChangeButton("woodpile", level + 1);
                            break;

                        case (BuildableObject.BuildingType.StonePile):
                            buttonScript.ChangeButton("stonepile", level + 1);
                            break;
                        }
                    }
                }
                //If building clicked is town hall, disable demolish button, else enable it
                if (b.name == "Button_Demolish")
                {
                    BuildableObject.BuildingType type = building.getType();
                    if (type == BuildableObject.BuildingType.TownCenter || type == BuildableObject.BuildingType.GarbageCan || type == BuildableObject.BuildingType.WoodPile || type == BuildableObject.BuildingType.StonePile)
                    {
                        b.GetComponent <Button>().interactable = false;
                    }
                    else
                    {
                        b.GetComponent <Button>().interactable = true;
                    }
                }
            }
        }
    }