Exemplo n.º 1
0
    public void Move(int jumps, Card.Direction direction, Board.Player.Type player)
    {
        if (position == null)
        {
            return;
        }

        foreach (Pawn pawns in FindObjectOfType <Board>().mintPlayer.pawns)
        {
            pawns.GetComponent <SpriteRenderer>().sortingOrder = 3;
        }
        foreach (Pawn pawns in FindObjectOfType <Board>().violetPlayer.pawns)
        {
            pawns.GetComponent <SpriteRenderer>().sortingOrder = 3;
        }

        for (int i = 0; i < jumps; ++i)
        {
            Debug.Log("Moving " + jumps + " in direction" + direction + " by player " + player);

            if (direction == Card.Direction.Forward &&
                position.NextWaypoint() != null)
            {
                foreach (Waypoint next_position in position.NextWaypoint())
                {
                    if (next_position.IsPreferedBy(player))
                    {
                        position = next_position;
                        this.GetComponent <SpriteRenderer>().sortingOrder = 4;
                        break;
                    }
                }
            }
            else if (direction == Card.Direction.Back &&
                     position.PreviousWaypoint() != null)
            {
                position = position.PreviousWaypoint()[0];
                this.GetComponent <SpriteRenderer>().sortingOrder = 4;
            }
        }
    }
Exemplo n.º 2
0
    public bool IsPreferedBy(Board.Player.Type type)
    {
        // Dedicated field is always prefered
        if (type == playerType)
        {
            return(true);
        }

        // If this field is not for Anyone => we should not be here
        // If this field is for Anyone, but there might be better
        // waypoint for this player
        if (playerType != Board.Player.Type.Any ||
            (previousFields.Count == 1 &&
             previousFields[0].nextFields.Count == 2 &&
             (previousFields[0].nextFields[0].playerType == type || previousFields[0].nextFields[1].playerType == type)))
        {
            return(false);
        }

        return(true);
    }
Exemplo n.º 3
0
 public void UseBy(Board.Player.Type type)
 {
     playerType = type;
 }