コード例 #1
0
    void PlayGame()
    {
        state = GameState.MATCHING_PLAYERS;

        cardSelection.GetComponent <SpriteRenderer>().enabled = false;

        switch (selected)
        {
        case CardType.ROCK:
            scissor.FadeOut();
            paper.FadeOut();
            break;

        case CardType.SCISSOR:
            rock.FadeOut();
            paper.FadeOut();
            scissor.ScissorMoveLeft();
            break;

        case CardType.PAPER:
            scissor.FadeOut();
            rock.FadeOut();
            paper.PaperMoveLeft();
            break;
        }

        AdjustRoundCounterText(1);

        computer.ComputerPlayCard();

        StartCoroutine("WaitGameValidation");
    }
コード例 #2
0
    void ValidateVictoryCard()
    {
        CardType playerCard   = selected;
        CardType computerCard = computer.type;

        computer.FadeOut();

        switch (selected)
        {
        case CardType.PAPER:
            paper.GetComponent <SpriteRenderer>().enabled = false;
            break;

        case CardType.ROCK:
            rock.GetComponent <SpriteRenderer>().enabled = false;
            break;

        case CardType.SCISSOR:
            scissor.GetComponent <SpriteRenderer>().enabled = false;
            break;
        }

        if (playerCard.Equals(computerCard))
        {
            texts.DefineResult(GameResult.DRAW);
        }
        else if ((playerCard.Equals(CardType.ROCK) && computerCard.Equals(CardType.SCISSOR)) ||
                 (playerCard.Equals(CardType.PAPER) && computerCard.Equals(CardType.ROCK)) ||
                 (playerCard.Equals(CardType.SCISSOR) && computerCard.Equals(CardType.PAPER)))
        {
            texts.DefineResult(GameResult.PLAYER1_VICTORY);
            texts.PlayerVictory();
        }
        else
        {
            texts.DefineResult(GameResult.PLAYER2_VICTORY);
            texts.ComputerVictory();
        }
    }