public void DecreaseRespectiveGadgetCounter(GadgetTypes type) { foreach (GadgetTemplate gadget in gadgets) { if (gadget.type == type) { gadget.counter.DecrementCounter(); } } }
private Sprite GetRespectiveIcon(GadgetTypes type) { switch (type) { case GadgetTypes.FlashBang: return(flashBangIcon); default: return(flashBangIcon); } }
public void SetUpGadget(GadgetTypes[] gadgets, int primaryAmount, int secondaryAmount) { //if there is a secondary and primary gadget if (gadgets.Length > 1 && gadgets.Length < 3) { //assign gadgets primaryGadget = gadgets[0]; secondaryGadget = gadgets[1]; //Update UI UIManager.instance.gadgetDisplay.GenerateNewGadgetTemplate(primaryGadget, primaryAmount); } else { //assign gadgets primaryGadget = gadgets[0]; //Update UI UIManager.instance.gadgetDisplay.GenerateNewGadgetTemplate(primaryGadget, primaryAmount); } }
public void GenerateNewGadgetTemplate(GadgetTypes type, int amount) { GadgetTemplate newTemplate = Instantiate(gadgetTemplatePrefab, transform.position, Quaternion.identity).GetComponent <GadgetTemplate>(); Debug.Log(newTemplate); newTemplate.transform.SetParent(rt.transform); RectTransform templateRect = newTemplate.gameObject.GetComponent <RectTransform>(); int positionOffset = gadgets.Count - 1; if (templateRect == true) { Vector2 targetPos = rt.transform.position; templateRect.anchoredPosition = new Vector2(taskXOffset * positionOffset, taskYOffset); } Sprite icon = GetRespectiveIcon(type); newTemplate.SetUpTemplate(icon, amount, type); gadgets.Add(newTemplate); }
public void SetUpTemplate(Sprite icon, int amount, GadgetTypes typeOfGadget) { counter.SetUpCounter(amount); type = typeOfGadget; gadgetIcon.sprite = icon; }