public void UpdateHighlights(FieldValue color)
        {
            var validMoves = OthelloRules.GetValidMovesForColor(color, m_board);

            foreach (var column in Rows)
            {
                foreach (var field in column)
                {
                    if (ShowValidMoves && validMoves.Contains(field.Coords))
                    {
                        field.BackgroundColor.Opacity = 0.4;
                    }
                    else
                    {
                        field.BackgroundColor.Opacity = 0.0;
                    }
                }
            }
        }
Example #2
0
        public bool MakeMove(MoveType type, Coords coords)
        {
            if (OthelloRules.IsValidMove(type, m_activePlayer.Color, coords, m_board))
            {
                if (type.Equals(MoveType.AddPiece))
                {
                    FieldValue color = m_activePlayer.Color;

                    var flipDirections = OthelloRules.GetPossibleDirections(color, coords, m_board);
                    foreach (var dir in flipDirections)
                    {
                        FlipDirection(color, coords, dir);
                    }
                    m_board.SetFieldValue(color, coords);
                }

                ToggleActivePlayer();
                return(true);
            }

            return(false);
        }