Exemplo n.º 1
0
 /// <summary>
 /// Returns the locations of all the ligts that should be toggled
 /// if the specified location is used for a move.
 /// </summary>
 /// <param name="ligt">The (Top Left) 0-based co-ord of the selected light.</param>
 /// <returns></returns>
 private IEnumerable <LightLocation> ValidLightsToToggle(LightLocation ligt)
 {
     // Get all relevant light locations and then filter out the invalid ones
     return(AllLightsToToggle(ligt)
            .Where(c => c.Row >= 0 &&
                   c.Row < BoardSize &&
                   c.Column >= 0 &&
                   c.Column < BoardSize));
 }
Exemplo n.º 2
0
        /// <summary>
        /// Updates the board to reflect selecting the given light.
        /// </summary>
        /// <param name="light">The (Top Left) 0-based co-ord of the selected light.</param>
        public void MakeMove(LightLocation light)
        {
            var lightsToToggle = ValidLightsToToggle(light);

            foreach (var togglee in lightsToToggle)
            {
                var currentState = _lights[togglee.Row][togglee.Column];
                var newState     = ToggledState(currentState);
                _lights[togglee.Row][togglee.Column] = newState;
            }

            GameCreated = true;
        }
Exemplo n.º 3
0
 private IEnumerable <LightLocation> AllLightsToToggle(LightLocation light)
 {
     var deltas = new (int Row, int Column)[] {