Пример #1
0
    public void NewGame()
    {
        //TODO detect if there is a current game already and ask if player wants to abandon current

        // Reset everything
        EndGame();
        visualPlayerDeck.SpawnDeck();
        visualOpponentDeck.SpawnDeck();

        //TODO check if this is a rematch, if so, auto switch colors

        if (Random.value > 0.5f)
        {
            playerFirst = true;
            playerTurn  = true;
        }
        else
        {
            playerFirst = false;
            playerTurn  = false;
        }

        //Generate card lists
        List <PlayingCard> playerCards   = new List <PlayingCard>();
        List <PlayingCard> opponentCards = new List <PlayingCard>();

        if (playerFirst)
        {
            CardUtils.populateCardLists(playerCards, opponentCards);
        }
        else
        {
            CardUtils.populateCardLists(opponentCards, playerCards);
        }

        // check if joker rule
        if (addJokers)
        {
            playerCards.Add(new PlayingCard(Rank.JOKER, Suit.NONE));
            opponentCards.Add(new PlayingCard(Rank.JOKER, Suit.NONE));
        }

        playerDeck.AddRange(playerCards);
        playerDeck.ShuffleAll();
        opponentDeck.AddRange(opponentCards);
        opponentDeck.ShuffleAll();

        // Draw initial hands as a fast coroutine for animation to occur
        StartCoroutine(initialHandDraw());

        uiManager.showHelp(HelpDisplay.SETUP);
    }
Пример #2
0
    public override void OnInspectorGUI()
    {
        DrawDefaultInspector();

        DeckScript script = (DeckScript)target;

        if (GUILayout.Button("Draw"))
        {
            script.DrawCard();
        }
        if (GUILayout.Button("Spawn"))
        {
            script.SpawnDeck();
        }
    }