예제 #1
0
    public static void Main()
    {
        // This works:
        HelloPrinter printer = new HelloPrinter();

        ActionCaller.Call(printer.Print);

        // This doesn't:
        ActionCaller.Call(((IHelloPrinter)printer).Print);
    }
예제 #2
0
    public void ResetHand()
    {
        if (player1Score < maxScore && player2Score < maxScore)
        {
            matchOnCourse = true;
        }

        // Clean game states
        gameOnCourse        = true;
        round               = 1;
        trucoState          = TrucoState.NADA;
        whoCalledLastTruco  = ActionCaller.NO_ONE;
        envidoState         = EnvidoState.NADA;
        whoCalledLastEnvido = ActionCaller.NO_ONE;
        envidoWinnedPoints  = 0;
        florState           = FlorState.NADA;
        whoCalledLastFlor   = ActionCaller.NO_ONE;
        envidoWinner        = EnvidoWinner.NO_ONE;
        florWinner          = FlorWinner.NO_ONE;
        handWinner          = HandWinner.NO_ONE;
        florWinnedPoints    = 0;
        player1EnvidoPoints = 0;
        player2EnvidoPoints = 0;
        player1Flor         = false;
        player2Flor         = false;
        player1FlorPoints   = 0;
        player2FlorPoints   = 0;

        // Clean cards
        player1Cards.Clear();
        player1PlayedCards.Clear();
        player2Cards.Clear();
        player2PlayedCards.Clear();

        // Reset values
        if (playerFirst == Player.PLAYER_1)
        {
            playerFirst = Player.PLAYER_2;
            playerPlay  = Player.PLAYER_2;
        }
        else
        {
            playerFirst = Player.PLAYER_1;
            playerPlay  = Player.PLAYER_1;
        }

        playerMustAnswer = Player.NO_ONE;

        // Shuffle the cards
        List <int> randomIndx = new List <int>();
        int        indx;
        bool       cloneIndx = false;

        //while (randomIndx.Count < 6)
        //{
        //	indx = Random.Range(0, trucoDeck.deck.Count - 1);
        //	try
        //	{
        //		randomIndx.Single(x => x == indx);
        //	}
        //	catch (System.Exception)
        //	{
        //		randomIndx.Insert(randomIndx.Count, indx);
        //	}
        //}

        while (randomIndx.Count < 6)
        {
            indx      = Random.Range(0, trucoDeck.deck.Count - 1);
            cloneIndx = false;
            for (int i = 0; i < randomIndx.Count; i++)
            {
                if (randomIndx[i] == indx)
                {
                    cloneIndx = true;
                }
            }

            if (!cloneIndx)
            {
                randomIndx.Add(indx);
            }
        }

        if (playerFirst == Player.PLAYER_1)
        {
            player1Cards.Add(trucoDeck.deck[randomIndx[0]]);
            player1Cards.Add(trucoDeck.deck[randomIndx[2]]);
            player1Cards.Add(trucoDeck.deck[randomIndx[4]]);

            player2Cards.Add(trucoDeck.deck[randomIndx[1]]);
            player2Cards.Add(trucoDeck.deck[randomIndx[3]]);
            player2Cards.Add(trucoDeck.deck[randomIndx[5]]);
        }
        else
        {
            player1Cards.Add(trucoDeck.deck[randomIndx[1]]);
            player1Cards.Add(trucoDeck.deck[randomIndx[3]]);
            player1Cards.Add(trucoDeck.deck[randomIndx[5]]);

            player2Cards.Add(trucoDeck.deck[randomIndx[0]]);
            player2Cards.Add(trucoDeck.deck[randomIndx[2]]);
            player2Cards.Add(trucoDeck.deck[randomIndx[4]]);
        }
    }