Exemple #1
0
    private void _handleInputGameObject(GameObject input)
    {
        this.currentGameObjectHit = input;

        if (input != null &&
            (this.currentGameObjectHit != this.lastGameObjectHit ||
             lastInputType == Inputs.InputTypes.BUTTON ||
             (currentGameObjectHit.name.Length >= 11 &&
              currentGameObjectHit.name.Substring(0, 11) == "Player0Card")))
        {
            Debug.Log("Card: " + input.name + " Sprite: " + input.GetComponent <SpriteRenderer>().sprite);

            this.lastGameObjectHit = this.currentGameObjectHit;
            this.lastInputType     = Inputs.InputTypes.GAME_OBJECT;

            if (gameState == GameState.DRAWING)
            {
                _handleDraw(this.currentGameObjectHit);
                return;
            }

            if (gameState == GameState.DISCARDING || gameState == GameState.CONTRACT)
            {
                _handleDiscard(this.currentGameObjectHit);
                return;
            }

            if (gameState == GameState.PLACE_SET)
            {
                _handlePlaceContract();
            }
        }
    }
Exemple #2
0
    private void _handleInputButton(ButtonWrapper input)
    {
        this.currentButtonHit = input;

        if ((this.currentButtonHit != this.lastButtonHit ||
             lastInputType == Inputs.InputTypes.GAME_OBJECT) &&
            input != null)
        {
            this.lastButtonHit = input;
            this.lastInputType = Inputs.InputTypes.BUTTON;
            Debug.Log("Button Clicked: " + input.getText());

            //Lower any raised cards if the player isn't placing a contract
            if (gameState != GameState.PLACE_SET && gameState != GameState.PLACE_RUN)
            {
                for (int i = 0; i < playerList[0].hand.Count; i++)
                {
                    if (playerList[0].hand[i].locationTag != Card.LOCATIONTAGS.DEFAULT)
                    {
                        playerList[0].hand[i].setLocationTag(Card.LOCATIONTAGS.DEFAULT);
                    }
                }
            }

            if (input.getText() == Drawing.sortSuitButtonName)
            {
                Debug.Log(gameState);
                playerList[0].sortBySuit();
            }

            else if (input.getText() == Drawing.sortValueButtonName)
            {
                playerList[0].sortByValue();
            }

            //Note the contract button is used to enter contract placement mode
            //and to confirm a selected run or set to place
            else if (input.getText() == Drawing.contractButtonName)
            {
                if (playerList[0].hasContract() && gameState == GameState.CONTRACT)
                {
                    _handlePlaceContract();
                }

                if (playerList[0].hasPlacedContract() &&
                    playerList[0].hasBonusContract() &&
                    (gameState == GameState.CONTRACT || gameState == GameState.DISCARDING))
                {
                    _handlePlaceContract();
                }
            }

            else if (input.getText() == Drawing.setButtonName)
            {
                if (gameState == GameState.PLACE_SET)
                {
                    if (playerList[0].hasPlacedContract())
                    {
                        gameState = GameState.DISCARDING;
                    }
                    if (selectedSetIsValid())
                    {
                        Debug.Log("Valid Set");
                        _placeSelectedCards();
                    }
                    else
                    {
                        Debug.Log("Selected set is not valid");
                    }
                }
            }

            else if (input.getText() == Drawing.runButtonName)
            {
                if (gameState == GameState.PLACE_RUN)
                {
                    if (selectedSetIsValid())
                    {
                        Debug.Log("Valid Run");
                    }
                    else
                    {
                        Debug.Log("Selected run is not valid");
                    }
                }
            }
        }
    }