Esempio n. 1
0
    // Update is called once per frame
    void Update()
    {
        // *When in main menu:
        if (GameManager.ActiveState != GameManager.Gamestate.InGame)
        {
            // Find the card collections in main menu if we haven't cached it yet:
            if (!dtbase)
            {
                dtbase = GameObject.FindObjectOfType <V_CardCollections> ();
            }

            // Load cards in deck:
            if (deckData != null)
            {
                myDeck = new V_Card[deckData [selectedDeck].cards.Length];
                for (int i = 0; i < deckData[selectedDeck].cards.Length; i++)
                {
                    myDeck [i] = dtbase.gameCards [deckData [selectedDeck].cards[i]];
                }
            }
        }
        // *When in game:
        else
        {
            if (!gm)
            {
                gm = FindObjectOfType <V_GameManager> ();
                return;
            }

            // Clamp health:
            health = Mathf.Clamp(health, 0, gm.maxHealth);
        }
    }
Esempio n. 2
0
    public static V_CardPresenter selectedCard;                         // The card presenter we're currently selecting

    void Start()
    {
        // load saved decks if there's any, else, make a random one....
        if (PlayerPrefs.HasKey("deck0"))
        {
            ReloadDecks();
        }
        else
        {
            for (int i = 0; i < decks.Length; i++)
            {
                SaveDeckJson(i);
            }
            ReloadDecks();
        }

        // Card previews for card database (in future updates, an inventory system will be implemented so this will be revised):
        cardDatabase = FindObjectOfType <V_CardCollections>();

        foreach (V_Card card in cardDatabase.gameCards)
        {
            V_CardPresenter prsntr = Instantiate(cardDatabase.cardPresenter, cardDatabase.cardsListContent.transform).GetComponent <V_CardPresenter>();
            prsntr.index = System.Array.IndexOf(cardDatabase.gameCards, card);
            prsntr.index = cardDatabase.cardsListContent.transform.childCount - 1;
            prsntr.Refresh();
        }
    }
Esempio n. 3
0
 // Update is called once per frame
 void Update()
 {
     if (health <= 0)
     {
         health = 0;
     }
     if (!isInGame)
     {
         V_CardCollections dtbase = GameObject.FindGameObjectWithTag("CardDatabase").GetComponent <V_CardCollections> ();
         if (deckData != null)
         {
             for (int i = 0; i < deckData.Length; i++)
             {
                 myDeck [i] = dtbase.gameCards [deckData [i]];
             }
         }
     }
 }