public void UseHatch() { SlowPrint.Print("You flick the switch, and the hatch slowly slides open..."); Thread.Sleep(100); Console.Clear(); Win.WinSequence(); }
public static void WinSequence() { SlowPrint.Print("Congratulations! You have managed to escape the perilous forest with your life."); SlowPrint.Print("Press RETURN to exit."); Console.ReadKey(); Environment.Exit(0); }
public void Options(int gens) { if (gens >= 4) { SlowPrint.Print("You are stood next to a hatch, which seems to be powered."); } else { SlowPrint.Print("You are stood next to a hatch, which is locked shut, and has no power."); } }
public void Options(int gensActive) { if (!this.Searched) { SlowPrint.Print("You are stood by a tree, which you can search."); } else { Console.WriteLine("You are stood by a tree, which you have searched before."); } }
public void Options(int gensActive) { if (this.Activated) { SlowPrint.Print("You are stood by an active generator."); } else { SlowPrint.Print("You are stood by a generator, which you can activate."); } }
public static void LoseSequence() { Console.Clear(); SlowPrint.Print("You begin to fiddle with the generator, listening closely for a faint hum."); SlowPrint.Print("...", 1000); Console.WriteLine("BANG!"); SlowPrint.Print("\nYou died to an explosion, caused by the old generator."); SlowPrint.Print("\nPress RETURN to exit."); Console.ReadKey(); Environment.Exit(0); }
private static void RunMenu() { using (StreamReader s = new StreamReader("menutext.txt")) { string t; while ((t = s.ReadLine()) != null) { SlowPrint.Print(t); } } Console.ReadKey(); }
public void Move(int dir) { if (dir == 0) { if (this.Location[0] != 0) { this.Location[0] -= 1; SlowPrint.Print("You headed north."); } else { SlowPrint.Print("You can't see - it's too dangerous to go further north!"); } } else if (dir == 1) { if (this.Location[0] != 9) { this.Location[0] += 1; SlowPrint.Print("You ventured south."); } else { SlowPrint.Print("You can't see - it's too dangerous to go further south!"); } } else if (dir == 2) { if (this.Location[1] != 9) { this.Location[1] += 1; SlowPrint.Print("You moved east."); } else { SlowPrint.Print("You can't see - it's too dangerous to go further east!"); } } else if (dir == 3) { if (this.Location[1] != 0) { this.Location[1] -= 1; SlowPrint.Print("You moved west."); } else { SlowPrint.Print("You can't see - it's too dangerous to go further west!"); } } }
public void ActivateGenerator() { if (this.Activated) { SlowPrint.Print("This generator is already running..."); } else if (!this.Unlucky) { this.Activated = true; SlowPrint.Print("You hear a soft hum, and lights blink on. The generator is now running."); } else { Lose.LoseSequence(); } }
private static void ShowMap(int[] location, IMapSection[,] map) { Console.Clear(); for (int i = 0; i < 10; i++) { for (int j = 0; j < 10; j++) { if (location[0] == i && location[1] == j) { Console.Write("X\t"); } else if (map[i, j] is Grassland) { Console.Write("-\t"); } else if (map[i, j] is Hatch) { Console.Write("h\t"); } else if (map[i, j] is Tree) { Console.Write("t\t"); } else if (map[i, j] is Generator) { Console.Write("g\t"); } } Console.WriteLine(); } Console.WriteLine("\nX: PLAYER; h: hatch; t: tree; g: generator"); Console.WriteLine("\nPress RETURN to return to game."); Console.ReadKey(); SlowPrint.Print("The map fell to pieces."); }
private static void LookAround(int[] location, IMapSection[,] map, Player player) { int pY = location[0]; int pX = location[1]; try { if (!(map[pY - 1, pX] is Grassland)) { SlowPrint.Print($"North of you, you see a {map[pY - 1, pX].Name}"); } if (player.FlashActive) { if (!(map[pY - 2, pX] is Grassland)) { SlowPrint.Print($"Far north of you, you see a {map[pY - 2, pX].Name}"); } } } catch { SlowPrint.Print("You cannot see further north..."); } try { if (!(map[pY + 1, pX] is Grassland)) { SlowPrint.Print($"South of you, there is a {map[pY + 1, pX].Name}"); } if (player.FlashActive) { if (!(map[pY + 2, pX] is Grassland)) { SlowPrint.Print($"Far south of you, you see a {map[pY + 2, pX].Name}"); } } } catch { SlowPrint.Print("You cannot see further south..."); } try { if (!(map[pY, pX + 1] is Grassland)) { SlowPrint.Print($"East of you, there is a {map[pY, pX + 1].Name}"); } if (player.FlashActive) { if (!(map[pY, pX + 2] is Grassland)) { SlowPrint.Print($"Far east of you, you see a {map[pY, pX + 2].Name}"); } } } catch { SlowPrint.Print("You cannot see further east..."); } try { if (!(map[pY, pX - 1] is Grassland)) { SlowPrint.Print($"West of you, there is a {map[pY, pX - 1].Name}"); } if (player.FlashActive) { if (!(map[pY, pX - 2] is Grassland)) { SlowPrint.Print($"Far west of you, you see a {map[pY, pX - 2].Name}"); } } } catch { SlowPrint.Print("You cannot see further west..."); } player.FlashActive = false; }
private static void ParseInput(string input, GameInstance game) { // Inventory management/items if (input.Contains("inventory") || input.Contains("bag")) { game.Player.ViewInventory(); } else if (input.Contains("map") || input.Contains("flashlight")) { int useItem = game.Player.UseItem(input.Contains("map") ? "Map" : "Flashlight"); if (useItem % 2 == 0) { SlowPrint.Print("You don't have the required item for that."); } else { if (useItem == 1) { ShowMap(game.Player.Location, game.Map.Matrix); } else if (useItem == 3) { game.Player.FlashActive = true; } } } // Movement if (input.Contains("north")) { game.Player.Move(0); } else if (input.Contains("south")) { game.Player.Move(1); } else if (input.Contains("east")) { game.Player.Move(2); } else if (input.Contains("west")) { game.Player.Move(3); } // World actions if (input.Contains("generator") || input.Contains("fix") || input.Contains("activate")) { if (game.Map.Matrix[game.Player.Location[0], game.Player.Location[1]] is Generator) { /* I don't like downcasting like this, but without implementing a blank method in each class * it's the easiest method. For safety, this checks if the instance is Generator anyway! * Note to self in the future: C# 8.0 has default implementations in an interface. */ ((Generator)game.Map.Matrix[game.Player.Location[0], game.Player.Location[1]]).ActivateGenerator(); game.Map.ActiveGenerators += 1; } else { SlowPrint.Print("You aren't near a generator at the moment. Try to find one."); } } if (input.Contains("tree") || input.Contains("search") || input.Contains("item")) { IMapSection tile = game.Map.Matrix[game.Player.Location[0], game.Player.Location[1]]; if (game.Map.Matrix[game.Player.Location[0], game.Player.Location[1]].Item != null) { if (game.Player.ItemsHeld < 3) { for (int i = 0; i < 3; i++) { if (game.Player.Inventory[i] == null) { game.Player.Inventory[i] = tile.Item; SlowPrint.Print($"You found a {tile.Item.Type} in the {tile.Name}!"); game.Map.Matrix[game.Player.Location[0], game.Player.Location[1]].Item = null; break; } if (tile is Tree) { ((Tree)game.Map.Matrix[game.Player.Location[0], game.Player.Location[1]]).Searched = true; } } game.Player.ItemsHeld += 1; } else { SlowPrint.Print("Your bag is already full."); } } else { SlowPrint.Print("You can't find any items here. Try a tree."); } } if (input.Contains("drop")) { if (game.Map.Matrix[game.Player.Location[0], game.Player.Location[1]].Item == null) { SlowPrint.Print("Which item would you like to drop?"); string i = Console.ReadLine(); if (i == "0" || i == "1" || i == "2") { game.Map.Matrix[game.Player.Location[0], game.Player.Location[1]].Item = game.Player.Inventory[int.Parse(i)]; game.Player.Inventory[int.Parse(i)] = null; game.Player.ItemsHeld -= 1; } else { SlowPrint.Print("You chose not to drop anything."); } } else { SlowPrint.Print("There's already an item on the ground here."); } } if (input.Contains("hatch") || input.Contains("escape")) { if (game.Map.Matrix[game.Player.Location[0], game.Player.Location[1]] is Hatch) { if (game.Map.ActiveGenerators == 4) { ((Hatch)game.Map.Matrix[game.Player.Location[0], game.Player.Location[1]]).UseHatch(); } else { SlowPrint.Print("The hatch isn't powered and can't currently be opened."); } } } }