IEnumerator UpdateShop(ShopCardScript card) { int i = 0; for (int r = 0; r < 3; r++) { for (int c = 0; c < 3; c++) { if (card.inventoryNum == i) { GameObject CardObject = Instantiate(shopPrefab, Vector3.zero, Quaternion.identity, shopCenter.transform); Vector3 pos = new Vector3((r - 1) * 10, 0, (c - 1) * 12); ShopCardScript cardScript = CardObject.GetComponent <ShopCardScript>(); cardScript.targetPos = pos; cardScript.info = card.info; cardScript.shopScript = this; cardScript.isShopCard = true; cardScript.inventoryNum = i; } i++; } } yield return(new WaitForSeconds(0.1f)); }
void UpdateCardPos() { for (int i = 0; i < offeredCards.Count; i++) { ShopCardScript shopCard = offeredCards[i].GetComponent <ShopCardScript>(); shopCard.targetPos = new Vector3(i, i, i); } }
void UpdateMoney() { //Debug.Log("Updating Money"); points = 0; for (int i = 0; i < offeredCards.Count; i++) { ShopCardScript shopCard = offeredCards[i].GetComponent <ShopCardScript>(); points += shopCard.info.relatedCard.price; } }
IEnumerator UpdateInventory() { foreach (GameObject objectToDestroy in inventoryCards) { Destroy(objectToDestroy); } inventoryCards.Clear(); int c = 0; int r = startingCollumn; for (int i = 0; i < playerDeck.unactiveDeck.Count; i++) { //Looping through getting the rows a collums set up if (c >= 3) { c = 0; r++; } //Debug.Log(c + " - " + r); //if we only want the currently focused cards to be shown //if (r == 0 || r == 1 || r == 2) //{ //Check if there is a card in that slot if (inventory[i] != null) { GameObject CardObject = Instantiate(shopPrefab, inventoryCenter.transform.position, Quaternion.identity, inventoryCenter.transform); Vector3 pos = new Vector3((c - 1) * 10, 0, (r - 1) * 12); ShopCardScript cardScript = CardObject.GetComponent <ShopCardScript>(); cardScript.targetPos = pos; cardScript.info = DrawPlayerCard(i); cardScript.shopScript = this; cardScript.isShopCard = false; cardScript.inventoryNum = i; inventoryCards.Add(CardObject); yield return(new WaitForSeconds(0.1f)); } //} c++; } yield return(new WaitForSeconds(1)); }
public void RemoveCard(GameObject cardToRemove) { //if its the player card add back to the referenced deck offeredCards.Remove(cardToRemove); ShopCardScript shopCard = cardToRemove.GetComponent <ShopCardScript>(); if (shopCard.isShopCard) { //add back into the shop shopMan.AddShopCard(shopCard); Destroy(cardToRemove); } else { //add back into the player inventory shopMan.AddPlayerCard(shopCard); Destroy(cardToRemove); } UpdateMoney(); UpdateCardPos(); }
public void AddShopCard(ShopCardScript cardToAdd) { StopAllCoroutines(); StartCoroutine(UpdateShop(cardToAdd)); }
public void AddPlayerCard(ShopCardScript cardToAdd) { StopAllCoroutines(); inventory[cardToAdd.inventoryNum] = cardToAdd.info.relatedCard; StartCoroutine(UpdateInventory()); }