public void UpdateActionInfo(ActionAvail aa) { //Some actions can be set on cooldown by other actions, check both max cd and current before blanking this.cooldownText.text = aa.actionParam.cooldown == 0 && aa.cooldown == 0 ? "-" : string.Format("{0}/{1}", aa.cooldown, aa.actionParam.cooldown); this.usesLeftText.text = aa.usesLeft < 0 ? "∞" : aa.usesLeft.ToString(); this.offenceCostText.text = aa.actionParam.factionCost.ToString(); this.defenceCostText.text = aa.actionParam.factionCost.ToString(); this.intelCostText.text = aa.actionParam.factionCost.ToString(); this.latestAA = aa; this.RefreshEnabled(); }
public void UpdateActionInfo(List <ActionAvail> aaList) { //Todo delete old buttons first foreach (pAction action in this.actions) // For each action we're specifying, find place it based on cost { ActionAvail aa = aaList.Find(x => x.actionParam.action == action); // What happens if we don't find it? //Determine which parameter we care about int cost = aa.actionParam.factionCost; ActionSelectButton button = this.buttons.Find(x => x.action == action); if (button == null) // If we don't have a button, spawn one and init { GameObject go = Instantiate(this.actionSelButtonPrefab, transform.position, transform.rotation, transform.Find("Bar/Buttons").transform); button = go.GetComponent <ActionSelectButton>(); button.Init(); button.SetAction(action); this.buttons.Add(button); } if (button.cost != cost) //Move button if needed { button.gameObject.GetComponent <RectTransform>().localPosition = new Vector3(-this.width / 2.0f + this.spacing * cost, 0, 0); button.cost = cost; } } }
public void UpdationActionAvail(ActionAvail aa) { this.actionAvail = aa; this.Enable(this.buttonEn); // Update the button }