Ejemplo n.º 1
0
    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));
    }
Ejemplo n.º 2
0
 void UpdateCardPos()
 {
     for (int i = 0; i < offeredCards.Count; i++)
     {
         ShopCardScript shopCard = offeredCards[i].GetComponent <ShopCardScript>();
         shopCard.targetPos = new Vector3(i, i, i);
     }
 }
Ejemplo n.º 3
0
    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;
        }
    }
Ejemplo n.º 4
0
    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));
    }
Ejemplo n.º 5
0
    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();
    }
Ejemplo n.º 6
0
 public void AddShopCard(ShopCardScript cardToAdd)
 {
     StopAllCoroutines();
     StartCoroutine(UpdateShop(cardToAdd));
 }
Ejemplo n.º 7
0
 public void AddPlayerCard(ShopCardScript cardToAdd)
 {
     StopAllCoroutines();
     inventory[cardToAdd.inventoryNum] = cardToAdd.info.relatedCard;
     StartCoroutine(UpdateInventory());
 }