void Start() { if (gameManager == null) { gameManager = GameManager.Instance; } UpdateCoinText(); for (int i = 0; i < itemsToBuy.Length; i++) { itemsToBuy [i] = Instantiate(itemsToBuy [i], itemPosition.position, itemPosition.rotation, transform) as BuyableItem; itemsToBuy [i].gameObject.SetActive(false); itemsToBuy [i].owned = gameManager.data.shopItemsOwned [i]; itemsToBuy [i].equipped = gameManager.data.shopItemsEquipped [i]; ShopInterfaceButton shopInterfaceButton = CreateShopInterfaceButton(i); itemsToBuy [i].shopInterfaceButton = shopInterfaceButton; //interfacePanel.pivot = new Vector2 ((i % 2) * 20f, i * 20f); } //Set first item to active activeIndex = 1; SetItemActive(0); EquipActives(); }
public void SetOwned(int index) { ShopInterfaceButton shopInterfaceButton = itemsToBuy [index].shopInterfaceButton; shopInterfaceButton.setOwned(); gameManager.data.shopItemsOwned [index] = true; checkAllOwned(); }
ShopInterfaceButton CreateShopInterfaceButton(int index) { GameObject interfacePanel = Instantiate(InterfacePanelPrefab, new Vector3(0f, 0f, 0f), Quaternion.identity, interfaceScreen.transform) as GameObject; interfacePanel.transform.position = interfaceScreen.transform.position; interfacePanel.transform.localRotation = Quaternion.Euler(new Vector3(0f, 0f, 0f)); float x = -160f + 150f * (index % 3); int yFactor = (int)(index / 3); float y = -85f + yFactor * -150; interfacePanel.transform.localPosition = interfacePanel.transform.localPosition + new Vector3(x, y, 0f); ShopInterfaceButton shopInterfaceButton = interfacePanel.GetComponent <ShopInterfaceButton> (); shopInterfaceButton.Setup(this, index); return(shopInterfaceButton); }