//Change the position of the rocks and return if the game is over. static bool ChangeRockPosition() { List <int> removingRocks = new List <int>(); for (int i = 0; i < rocksCollection.Count; i++) { var itemValue = rocksCollection.ElementAt(i).Value; if (itemValue.PositionRow > 0) { DrawOnTheConsole.RemoveFromConsole(itemValue.PositionColumn, itemValue.PositionRow); } if (itemValue.PositionRow < Console.WindowHeight - 1) { itemValue.PositionRow++; bool isGameOver = CollisionDetect(itemValue.PositionColumn, itemValue.PositionRow); if (isGameOver == true) { return(false); } DrawOnTheConsole.DrawRocks(itemValue.PositionColumn, itemValue.PositionRow, itemValue.Character, itemValue.Color); } else { removingRocks.Add(rocksCollection.ElementAt(i).Key); } } DrawOnTheConsole.PrintScore(removingRocks.Count); foreach (var rock in removingRocks) { rocksCollection.Remove(rock); } return(true); }
//Change the position of the dwarf on the screen. static void MoveDwarf() { if (IsOutOfBoundry() == false) { if (dwarfDirection == right) { DrawOnTheConsole.RemoveFromConsole(dwarfBeginPositionColumn, dwarfBeginPositionRow); dwarfBeginPositionColumn++; } if (dwarfDirection == left) { DrawOnTheConsole.RemoveFromConsole(dwarfBeginPositionColumn + 2, dwarfBeginPositionRow); dwarfBeginPositionColumn--; } } }