public void showKingGuardMenu(bool cond, Rodent r) { // Tell the MVC were the active menu MVCController.Instance.SetRecruitMenu(this); _active = cond; buttons[1].gameObject.SetActive(cond); _Name2.text = r.getName(); }
public void showDismissMenu(bool cond, Rodent r) { //MVCController.Instance.TurnThingsoff(); // Tell the MVC were the active menu MVCController.Instance.SetRecruitMenu(this); _Rodent = r; _active = cond; buttons[2].gameObject.SetActive(cond); _Name2.text = r.getName(); if (r.isRanged()) { _weaponClass2.sprite = _iconRanged; } else { _weaponClass2.sprite = _iconMelee; } }
//Will need to send in portrait later on? public void CreateButton(Rodent rodent) { // Debug.Log("Make a Button for :" +rodent.getName()); //Make new Buttons if (_index >= _used) { // Debug.Log("Make a new Button!"); //Make a new button from prefab GameObject o = Instantiate(_buttonTemplate); o.gameObject.transform.SetParent(this.transform); //offset it to stack upwards o.transform.localPosition = new Vector3(0, -_aspectHeight + (_index * _aspectHeight), 0); Button b = o.GetComponent <Button>(); if (b) { UIRodentHolder holder = b.GetComponent <UIRodentHolder>(); if (holder) { holder.setRodent(rodent); } _buttons[_index] = b; if (_index < _buttons.Length) // need to find a way to scroll someday { ++_index; ++_used; } //Assign Text Transform t = b.transform.Find("Name"); if (t) { TextMeshProUGUI text = t.GetComponent <TextMeshProUGUI>(); if (text) { text.text = rodent.getName(); } } //Assign Image t = b.transform.Find("Portrait"); if (t) { Image image = t.GetComponent <Image>(); if (image) { image.sprite = rodent.GetPortrait(); } } t = b.transform.Find("Weapon"); if (t) { Image image2 = t.GetComponent <Image>(); if (image2) { if (rodent.isRanged()) { image2.sprite = _iconRanged; } else { image2.sprite = _iconMelee; } } } } } //Reuse Old Buttons else { // Debug.Log("Reuse a Button! for " + rodent.getName()+ " @Index:" +_index +" used:"+ _used ); Button b = _buttons[_index]; if (b) { UIRodentHolder holder = b.GetComponent <UIRodentHolder>(); if (holder) { holder.setRodent(rodent); } ++_index; Transform t = b.transform.Find("Name"); TextMeshProUGUI text = t.GetComponent <TextMeshProUGUI>(); if (t) { if (text) { text.text = rodent.getName(); } } //Assign Image t = b.transform.Find("Portrait"); if (t) { Image image = t.GetComponent <Image>(); if (image) { image.sprite = rodent.GetPortrait(); } } t = b.transform.Find("Weapon"); if (t) { Image image2 = t.GetComponent <Image>(); if (image2) { if (rodent.isRanged()) { image2.sprite = _iconRanged; } else { image2.sprite = _iconMelee; } } } } } showMenu(true); }
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); } } }