Esempio n. 1
0
    /// <summary>
    /// Checks if given pawn can be moved by current player in current state of the game.
    /// </summary>
    /// <param name="InPawn">The pawn that we want to know if can be moved or not.</param>
    /// <returns>Whether given pawn can be moved or not.</returns>
    public bool CanPawnBeMoved(PawnController InPawn)
    {
        if (InPawn != null && CurrentPlayer == InPawn.GetColor())
        {
            return(InPawn.GetColor() == PlayerColor.Red ? State == GameState.RedPlayerMoves : State == GameState.WhitePlayerMoves);
        }

        return(false);
    }
    public virtual void AddPawn(PawnController InPawn, bool bInDoRearrange = false)
    {
        if (InPawn != null)
        {
            if (Pawns.Count == 1)
            {
                if (GetPawn().GetColor() != InPawn.GetColor())
                {
                    PawnController tempPawn = GetPawn();
                    RemovePawn(tempPawn);
                    Band.AddPawn(tempPawn, true);
                }
            }

            Pawns.Add(InPawn);

            InPawn.SetParent(this);
            InPawn.SetOrder(Pawns.Count + 10);
            InPawn.SetGameManager(GameManager);

            if (bInDoRearrange)
            {
                Rearrange();
            }
        }
        else
        {
            // error
        }
    }