예제 #1
0
    IEnumerator MovePlayer(SNLPlayer player, int spaces)
    {
        // Move selected player the specified number of spaces.
        int pos = player.spaceNumber - 1 + spaces;
        int nextSpace;

        for (int i = spaces - 1; i >= 0; i--)
        {
            if (pos - i > 100)
            {
                nextSpace = 100 - (pos - i - 100);
            }
            else
            {
                nextSpace = pos - i;
            }
            targetSpace    = Spaces[nextSpace].position;
            squareMoveTime = 0;
            yield return(new WaitForSeconds(TIME_TO_ONE_SQUARE));
        }

        //TODO: If the spot the player landed on is a snake or ladder, move player to it.
        SNLGameSquare targetSquare = Spaces[pos];

        if (targetSquare.state == SNLGameSquare.SNLSquareState.ladder)
        {
            // Ladder! Do some stuff to go there!
            targetSquare = Spaces[targetSquare.targetSpaceNumber - 1];
            targetSpace  = targetSquare.position;
            yield return(new WaitForSeconds(TIME_TO_ONE_SQUARE * 2));
        }
        else if (targetSquare.state == SNLGameSquare.SNLSquareState.snake)
        {
            // Snake! Do some stuff to go there!
            targetSquare = Spaces[targetSquare.targetSpaceNumber - 1];
            targetSpace  = targetSquare.position;
            yield return(new WaitForSeconds(TIME_TO_ONE_SQUARE * 2));
        }
        else if (targetSquare.state == SNLGameSquare.SNLSquareState.goal)
        {
            // Oh, the player won the game?
            CompleteGame(player);
        }

        // Set the player's current space now.
        player.currentSpace = targetSquare;

        // Reset the target space so the next player doesn't try taking it.
        targetSpace = Vector3.zero;
        EndTurn();
    }
예제 #2
0
 void CompleteGame(SNLPlayer winningPlayer)
 {
     // TODO: Show a screen or something to signify winning.
     PrepareEnd();
 }