Esempio n. 1
0
    public Robot.Command DrawCard()
    {
        if (deckCards.Count < 1)
        {
            Debug.Log("Not enough cards!");
            return(Robot.Command.None);
        }


        Robot.Command cardToDraw = deckCards[0];
        discardPile.Add(cardToDraw);
        deckCards.RemoveAt(0);
        return(cardToDraw);
    }
Esempio n. 2
0
    public CommandCard CreateCommandCardForCommand(Robot.Command command)
    {
        foreach (CommandCard card in commandCardPrefabs)
        {
            if (card.command == command)
            {
                return((CommandCard)GameObject.Instantiate(card));
            }
        }

        if (command != Robot.Command.None)
        {
            Debug.Log("No appropriate card found for command: " + command);
        }

        return(null);
    }
Esempio n. 3
0
    public void Shuffle()
    {
        foreach (Robot.Command card in discardPile)
        {
            deckCards.Add(card);
        }

        discardPile.Clear();

        int n = deckCards.Count;

        while (n > 1)
        {
            --n;
            int           randomIndex = Random.Range(0, n + 1);
            Robot.Command tempCard    = deckCards[randomIndex];
            deckCards[randomIndex] = deckCards[n];
            deckCards[n]           = tempCard;
        }
    }