Beispiel #1
0
    // undo the lastMove
    // entry into this method comes as a result of two things; 1) a player has clicked on the
    // undo button and, 2) the .Update() method of this class has picked up the truthy value of
    // undoLastMoveButtonControllerScript.shouldUndoLastMove.
    private void revertLastMove()
    {
        undoLastMoveButtonControllerScript.disable();
        inturruptUndoLastMoveCoroutine();

        PlayerMoveModel lastMove = GameBoardHistory.findLastPlayerMove();

        if (GameBoardHistory.removeLastMoveFromHistory() &&
            GameBoardController.removePlayerAtPoint(lastMove))
        {
            removePlayerPieceFromPost(lastMove);
            finalizePlayerChange();
        }
    }
    // given an array of formations, find one that is a winner
    public static FormationModel findWinningFormation(PlayerMoveModel moveToMake)
    {
        if (GameBoardHistory.isWinPossible())
        {
            List <FormationModel> formations = FormationCollection.filterFormationsForPoint(moveToMake.point);
            List <FormationModel> formation  = formations.Where(f => isWinningFormation(moveToMake.player, f.points)).ToList();

            if (formation.Count != 0)
            {
                return(formation[0]);
            }
        }

        return(null);
    }
Beispiel #3
0
    // calculateGamePhase
    // more advanced games require a longer turn timer
    private void calculateGamePhase()
    {
        int currentMoveCount = GameBoardHistory.movesCount();

        if (currentMoveCount == (int)GamePhase.beginning)
        {
            // todo: refactor this to be calculated at start() with an enum
            elapsedTurnTimeLimit *= 1.5f;
        }
        else if (currentMoveCount == (int)GamePhase.middle)
        {
            // todo: shame!
            // todo: refactor this to be calculated at start() with an enum
            float originalTimeLimit = elapsedTurnTimeLimit / 1.5f;
            elapsedTurnTimeLimit = originalTimeLimit * 2;
        }
    }
Beispiel #4
0
    //////////////////////////////////////////////////////////////////
    //////////////////////////////////////////////////////////////////

    // place player piece in the view on the selected post
    private void executePlayerMove(PlayerMoveModel playerMove, Vector3 postPosition, string postName)
    {
        GameBoardController.addPlayerAtPoint(playerMove);
        GameBoardHistory.addMoveToHistory(playerMove);
        placePlayerPieceOnPost(postPosition, postName, playerMove.player);
    }