Beispiel #1
0
    public void showMenu(bool cond, Rodent r)
    {
        _active = cond;
        //Debug.Log("ShowMENU:" + r.getName());
        if (cond)
        {
            // Tell the MVC were the active menu
            MVCController.Instance.SetRecruitMenu(this);


            _Rodent = r;
            buttons[0].gameObject.SetActive(true);
            buttons[1].gameObject.SetActive(false);
            buttons[2].gameObject.SetActive(false);

            Vector3 loc = r.transform.position;
            loc.y = loc.y + 1;
            this.transform.position = loc;

            //get costs
            _FoodCost = r.getRecruitmentCost();
            _PopCost  = r.getPopulationCost();
            //show costs
            _CostPop.text  = _PopCost.ToString();
            _CostFood.text = _FoodCost.ToString();

            //show class
            if (r.isRanged())
            {
                _weaponClass.sprite = _iconRanged;
            }
            else
            {
                _weaponClass.sprite = _iconMelee;
            }


            //Check if we have enough food
            if (ResourceManagerScript.Instance.GetResourceCount(ResourceManagerScript.ResourceType.Food) < _FoodCost)
            {
                _CostFood.color = bad;
            }
            else
            {
                _CostFood.color = good;
            }

            //Check if there is enough population capacity
            if (ResourceManagerScript.Instance.getCurrentPopulation() >= ResourceManagerScript.Instance.getPopulationCapacity())
            {
                _CostPop.color = bad;
            }
            else
            {
                _CostPop.color = good;
            }

            _Name.text = r.getName();
        }
        else // will turn off all buttons
        {
            foreach (Button b in buttons)
            {
                b.gameObject.SetActive(false);
            }
        }
    }