Beispiel #1
0
    /// executes the given action
    private void executeAction(PlayerAction action)
    {
        if (action == null || !action.isUsable())
        {
            return;
        }

        switch (action.type)
        {
        case PlayerAction.Type.END_TURN:
            actionPoints = 0;
            break;

        case PlayerAction.Type.BUY_GOLDEN_BRICK:
            playerBelongings[activePlayer].addGoldenBrick();
            players[activePlayer].PlayPickupSound();
            brickManager.relocate();
            currentActionFSM = null;
            break;

        case PlayerAction.Type.ITEM_CREDIT_THIEF:
            // item is "used" -> remove it from the inventory
            playerBelongings[activePlayer].removeItem(ItemD.Type.CREDIT_THIEF);
            currentState     = TurnState.EXECUTING_ACTION;
            currentActionFSM = new ItemCreditThief(camera, activePlayer, playerBelongings);
            break;

        case PlayerAction.Type.SET_TRAP:
            GameObject trapObject = trapSpawner.spawnTrap(trapSpawner.transform.position);
            playerData[activePlayer].currentTile().setTrap(true, trapObject, activePlayer);
            currentState     = TurnState.EXECUTING_ACTION;
            currentActionFSM = new SetTrap(playerData[activePlayer], players[activePlayer].transform, trapObject);
            playerBelongings[activePlayer].removeItem(ItemD.Type.TRAP);
            break;

        case PlayerAction.Type.BUY_AP:
            currentState     = TurnState.EXECUTING_ACTION;
            currentActionFSM = null;
            break;

        case PlayerAction.Type.SHOP:
            currentState     = TurnState.SHOWING_SHOP;
            currentActionFSM = null;
            itemShop.open();
            break;
        }

        actionPoints -= action.requiredAP;
        playerBelongings[activePlayer].addCreditAmount(-action.requiredCredits);
    }
Beispiel #2
0
    private FSM getOrangeTileAction()
    {
        float selection = UnityEngine.Random.Range(0, 3);

        if (selection >= 2)
        {
            // lose a few coins
            return(new TileLoseCoins(playerBelongings[activePlayer]));
        }
        else if (selection >= 1 && currentTileHasNoTrap())
        {
            // place a trap on the players tile
            GameObject trapObject = trapSpawner.spawnTrap(trapSpawner.transform.position);
            playerData[activePlayer].currentTile().setTrap(true, trapObject, -1); // invalid player number -> dangerous to all players
            return(new SetTrap(playerData[activePlayer], players[activePlayer].transform, trapObject));
        }
        else
        {
            // relocate the golden brick
            return(new TileMasterHand(brickManager, camera, audioSource, relocateBrickAudioClip));
        }
    }