/// <summary> /// Gem request on the bottom /// </summary> /// <param name="gems">Gem grid on the board</param> /// <param name="gem">Which gem to watch</param> /// <param name="number">How many elements</param> /// <returns>Could he find the gem and the gem itself</returns> public static (bool, Gem) Bottom(this Gem[,] gems, Gem gem, int number) { var lines = gems.GetLength(1); if (gem.YPosition + number >= lines || gem.YPosition + number < 0) { return(false, null); } var nextGem = gems[gem.XPosition, gem.YPosition + number]; return(gem.Equals(nextGem), nextGem); }
/// <summary> /// Gem request on the right /// </summary> /// <param name="gems">Gem grid on the board</param> /// <param name="gem">Which gem to watch</param> /// <param name="number">How many elements</param> /// <returns>Could he find the gem and the gem itself</returns> public static (bool, Gem) Right(this Gem[,] gems, Gem gem, int number) { var columns = gems.GetLength(0); if (gem.XPosition + number >= columns || gem.XPosition + number < 0) { return(false, null); } var nextGem = gems[gem.XPosition + number, gem.YPosition]; return(gem.Equals(nextGem), nextGem); }