public static IDisplayPiece GetQuest(string questName, int id, int widthCoo, int debthCoo) { //// TODO: make the quests drop items //// TODO: make items that show on the side of the board (3 items are more than enough) Position initPosition = new Position(widthCoo, debthCoo); if (questName == "QuizQuest") { QuizQuest quest = new QuizQuest(initPosition); quest.Id = id; return(quest); } else if (questName == "FallingRocks") { FallingRocks quest = new FallingRocks(initPosition); quest.Id = id; return(quest); } else if (questName == "FlappyBird") { FlappyBirdQuest quest = new FlappyBirdQuest(initPosition); quest.Id = id; return(quest); } else if (questName == "GuessTheNumber") { GuessTheNumber quest = new GuessTheNumber(initPosition); quest.Id = id; return(quest); } else if (questName == "Hangman") { Hangman quest = new Hangman(initPosition); quest.Id = id; return(quest); } return(null); }
public static void Main() { FallingRocks inst = new FallingRocks(); Console.SetWindowSize(45, 45); Console.SetBufferSize(45, 45); lastLine[curPos - 2] = '('; lastLine[curPos - 1] = '0'; lastLine[curPos] = ')'; for (int i = 0; i < field.GetLength(0); i++) { for (int j = 0; j < field.GetLength(1); j++) { field[i, j] = 0; } } while (lives > 0) { Console.Clear(); int[] lastFalling = new int[field.GetLength(1)]; for (int i = 0; i < field.GetLength(1); i++) { lastFalling[i] = field[field.GetLength(0) - 1, i]; } CheckCollision(lastFalling, curPos); FallDown(field, ref curPos); Draw(field, lastLine); inst.StartTimer(50); Thread.Sleep(150); } Console.WriteLine(" GAME OVER!"); Thread.Sleep(10000); }
static void Main() { ResetBuffer(); Random rand = new Random(); List <Unit> RocksList = new List <Unit>(); int speed = 150; int livesCount = 3; int score = 0; string[] rocks = { "^", "@", "*", "&", "+", "%", "$", "#", "!", ".", ";", "^^", "@@", "**", "&&", "++", "%%", "$$", "##", "!!", "..", ";;", "^^^", "@@@", "***", "&&&", "+++", "%%%", "$$$", "###", "!!!", "...", ";;;" }; Unit Dwarf = new Unit(); Dwarf.x = Console.WindowWidth / 2 - 1; Dwarf.y = Console.WindowHeight - 1; Dwarf.color = ConsoleColor.White; Dwarf.symbol = "(O)"; while (true) { bool hitted = false; Unit newInitRock = new Unit(); newInitRock.x = rand.Next(0, Console.WindowWidth - 2); newInitRock.y = 5; newInitRock.color = (ConsoleColor)rand.Next((int)ConsoleColor.Blue, (int)ConsoleColor.Yellow); int randRock = rand.Next(1, 3); string sinlgeRock = rocks[rand.Next(0, 32)]; newInitRock.symbol = sinlgeRock; RocksList.Add(newInitRock); if (Console.KeyAvailable) { ConsoleKeyInfo keyPressed = Console.ReadKey(true); while (Console.KeyAvailable) { Console.ReadKey(true); } if (keyPressed.Key == ConsoleKey.LeftArrow) { if (Dwarf.x > 0) { Dwarf.x--; } } if (keyPressed.Key == ConsoleKey.RightArrow) { if (Dwarf.x < Console.WindowWidth - 2) { Dwarf.x++; } } } List <Unit> newList = new List <Unit>(); for (int i = 0; i < RocksList.Count; i++) { Unit oldRock = RocksList[i]; Unit NewMovedRock = new Unit(); NewMovedRock.x = oldRock.x; NewMovedRock.y = oldRock.y + 1; NewMovedRock.color = oldRock.color; NewMovedRock.symbol = oldRock.symbol; if (FallingRocks.Collision(NewMovedRock, Dwarf)) { livesCount--; hitted = true; if (livesCount == 0) { PrintStringAtPosition(10, 2, "Lives: " + livesCount, ConsoleColor.Green); PrintStringAtPosition(42, 2, "Game over!", ConsoleColor.Red); PrintStringAtPosition(33, 3, "Press [enter] to restart.", ConsoleColor.Red); Console.ReadLine(); livesCount = 3; RocksList = newList; Console.Clear(); score = 0; } } if (NewMovedRock.y < Console.WindowHeight) { newList.Add(NewMovedRock); } else { score++; } } RocksList = newList; Console.Clear(); if (hitted) { PrintAtPosition(Dwarf.x, Dwarf.y, "???", ConsoleColor.Red); } else { PrintAtPosition(Dwarf.x, Dwarf.y, Dwarf.symbol, Dwarf.color); } foreach (Unit rock in RocksList) { PrintAtPosition(rock.x, rock.y, rock.symbol, rock.color); } for (int i = 1; i < Console.WindowWidth - 1; i++) { PrintAtPosition(i, 5, "-", ConsoleColor.Gray); } PrintStringAtPosition(10, 2, "Lives: " + livesCount, ConsoleColor.Green); PrintStringAtPosition(20, 2, "Score: " + score, ConsoleColor.Green); PrintStringAtPosition(20, 3, "Speed: " + speed, ConsoleColor.Green); Thread.Sleep(150); } }
private void Start() { Instance = this; }