Beispiel #1
0
    /// <summary>
    /// Adds a piece to this tower.
    /// If the colour doesn't match the tower's colour, the piece will be captured or flipped
    /// </summary>
    /// <param name="piece">Piece to be moved into this tower</param>
    public void AddPiece(PieceData piece)
    {
        pieces.Add(piece);
        piece.SetFlipped(piece.colour != owningColour);

        if (piece.colour != Player.PlayerColour.Hook)
        {
            if (piece.colour == owningColour)
            {
                piece.value = 0;

                // starting value
                piece.sortingValue = 0;

                // seperate by color
                piece.sortingValue -= ((int)piece.colour + 1) * 100;

                // seperate by pieces count
                piece.sortingValue -= pieces.Count;
            }
            else
            {
                piece.value = 1;

                // starting value
                piece.sortingValue = -1000;

                // seperate by colour
                piece.sortingValue -= ((int)piece.colour + 1) * 100;

                // seperate by pieces count
                piece.sortingValue -= pieces.Count;
            }
        }
        else
        {
            piece.sortingValue = -10000000;
        }

        if (piece.type == PieceData.Type.Hook)
        {
            Debug.Assert(hook == null);
            hook = piece;
        }
        else
        {
            Debug.Assert(colourCount != null);
            colourCount[(int)piece.colour]++;
        }

        SortTower();
    }