private void EscapeMethod(string s) { Game.Instace.OutputPane.Write(new FormattedString("You wrench the ", "ropes".Cyan(), " with all your strength. They give way.")); InternalVerbs.Remove(_escape); InternalVerbs.Add(_blind); _bound = false; }
public Office(string name, OfficeType type, bool top, int x, int y) : base(name) { Props.Add(new Desk(this, type, x - 1, top ? y - 3 : y + 3)); DoorToHallway = new Door(this, Hallway.Instance, "the door", x, y); //DoorToHallway.DoorUsed += door => Player.Instance.ChangeLocation(door.To); Props.Add(DoorToHallway); InternalVerbs.Add(new Verb("Look around", s => { var props = Props.Select(o => o.Name).ToArray(); if (props.Length <= 0) { return; } Game.Instace.OutputPane.Write("You are next to "); if (props.Length == 1) { Game.Instace.OutputPane.Write(props.First() + "."); } else { Game.Instace.OutputPane.Write(FormattedString.Join(", ", props.WithoutLast())); Game.Instace.OutputPane.Write(new FormattedString(", and ") + props.Last() + "."); } })); }
public Shelf(Location parent) : base(parent, "the shelf", 2, 0) { _pickUpBookVerb = new Verb(new FormattedString("Pick up the ", "Notebook".Cyan()), s => { _hasBook = false; InternalVerbs.Remove(_pickUpBookVerb); Player.Instance.AddItem(new NotebookItem()); }) { Enabled = false }; InternalVerbs.Add(_pickUpBookVerb); InternalVerbs.Add(new Verb(new FormattedString("Inspect ", "the shelf".Magenta()), s => { if (!_hasBook) { Game.Instace.OutputPane.Write("There is nothing here."); return; } Game.Instace.OutputPane.Write(new FormattedString("There is a ", "Notebook".Cyan(), " on the ", "shelf.".Magenta())); _pickUpBookVerb.Enabled = true; })); }
public OnTheBox(TheCloset closet) : base("the Box") { _closet = closet; _unscrewVerb = new Verb("Unscrew the vent", UnscrewVerb); InternalVerbs.Add(new Verb("Climb down", ClimbDownVerb)); InternalVerbs.Add(_unscrewVerb); }
public TheCloset() : base("the Closet") { Instance = this; Props.Add(new Shelf(this)); Props.Add(new Toolbox(this)); Props.Add(new BlindFold(this)); Props.Add(new Rope(this)); Props.Add(new Box(this)); DoorToHallway = new Door(this, new Hallway(), "the door", 2, 3, lockMsg: "There is no handle. You could probably open it from the other side...") { Locked = true }; //DoorToHallway.DoorUsed += door => { if (!door.Locked) Player.Instance.ChangeLocation(Hallway.Instance); }; Props.Add(DoorToHallway); InternalVerbs.Add(new Verb("Look around", s => { var props = Props.Select(o => o.Name).ToArray(); if (props.Length > 0) { Game.Instace.OutputPane.Write("You are next to "); if (props.Length == 1) { Game.Instace.OutputPane.Write(props.First() + ". "); } else { Game.Instace.OutputPane.Write(FormattedString.Join(", ", props.WithoutLast())); Game.Instace.OutputPane.Write(new FormattedString(", and ") + props.Last() + ". "); } } })); }
public Rope(Location parent) : base(parent, "the Rope".Cyan(), 0, 0) { InternalVerbs.Add(new Verb(new FormattedString("Pick up the ", "Rope".Cyan()), s => { Parent.Props.Remove(this); Player.Instance.AddItem(new RopeItem()); })); }
public BlindFold(Location parent) : base(parent, "the Blindfold".Cyan(), 0, 0) { InternalVerbs.Add(new Verb(new FormattedString("Pick up the ", "Blindfold".Cyan()), s => { Parent.Props.Remove(this); Player.Instance.AddItem(new BlindFoldItem()); })); }
public Vent(Location from, Location to, string name, bool up, int x, int y, FormattedString post = null) : base(from, name, x, y) { _up = up; _to = to; _post = post; InternalVerbs.Add(new Verb(_up ? $"Enter the {Name}" : $"Exit the {Name}", EnterVentVerb)); }
private void BlindMethod(string s) { Game.PrintUserInterface(); var c = new TheCloset(); Game.Instace.OutputPane.Write("You reach up and remove your " + "blindfold".Cyan() + ". You are in " + c.Name + "."); InternalVerbs.Remove(_blind); Player.Instance.ChangeLocation(c); }
public DarkPlace() : base("a Dark Place") { _blind = new Verb(new FormattedString("Remove the ", "blindfold".Cyan()), BlindMethod); _escape = new Verb("Exert yourself!", EscapeMethod); _wiggle = new Verb("Wiggle my arms", WiggleMethod); InternalVerbs.Add(new Verb("Look around", LookMethod)); InternalVerbs.Add(_wiggle); }
public Box(TheCloset parent) : base(parent, "the box", 3, 2) { _onTheBox = new OnTheBox(parent); InternalVerbs.Add(new Verb(new FormattedString("Climb the ", "box".Magenta()), s => { Game.Instace.OutputPane.Write(new FormattedString("You can just barely reach a ", "ceiling vent".Magenta(), ".")); Player.Instance.ChangeLocation(_onTheBox); })); }
public Door(Location from, Location to, FormattedString name, int x, int y, FormattedString useMsg = null, string lockMsg = "The door is locked.") : base(from, name, x, y) { To = to; _useMsg = useMsg ?? "You use the door to " + To.Name + ".".Reset(); _lockMsg = lockMsg; InternalVerbs.Add(new Verb("Use", GetName, UseAction)); DoorUsed += DefaultDoorAction; }
private void UnscrewVerb(string s) { if (Player.Instance.Items.All(o => o.Name.ToString() != "Screwdriver")) { Game.Instace.OutputPane.Write(new FormattedString("You do not have a ", "Screwdriver".Cyan(), ".")); return; } Game.Instace.OutputPane.Write(new FormattedString("You use the ", "Screwdriver".Cyan(), " to open the ", "vent".Magenta(), ".")); InternalVerbs.Remove(_unscrewVerb); Props.Add(new TheVents.Vent(this, new TheVents(this), "vent", true, 3, 2)); }
public Desk(Location parent, OfficeType type, int x, int y) : base(parent, "the desk", x, y) { _item = null; switch (type) { case OfficeType.Mug: _item = new MugItem(); break; case OfficeType.Key: _item = new KeyItem(); break; } _hasItem = _item != null; InternalVerbs.Add(new Verb(new FormattedString("Inspect ", "the desk".Magenta()), s => { Game.Instace.OutputPane.Write( new FormattedString("There is nothing here but ", "a phone".Magenta(), " with no connection, ", "a computer".Magenta(), " with no power, and ", "various knick-knacks".Magenta(), " and ", "paperweights".Magenta(), ". ")); if (!_hasItem) { return; } Game.Instace.OutputPane.Write(new FormattedString("There is a ", _item.Name.Sections[0], " on ", "the desk.".Magenta())); _pickUpItemVerb.Enabled = true; })); if (_item == null) { return; } _pickUpItemVerb = new Verb("Pick up the " + _item.Name, s => { _hasItem = false; InternalVerbs.Remove(_pickUpItemVerb); Player.Instance.AddItem(_item); }) { Enabled = false }; InternalVerbs.Add(_pickUpItemVerb); }
public Toolbox(Location parent) : base(parent, "the toolbox", 0, 2) { _getScrewdriverVerb = new Verb(new FormattedString("Pick up the ", "Screwdriver".Cyan()), s => { Game.Instace.OutputPane.Write("You stash it in your inventory"); Player.Instance.AddItem(new ScrewDriver()); _getScrewdriverVerb.Enabled = false; _hasScrewdriver = false; }) { Enabled = false }; InternalVerbs.Add(new Verb(new FormattedString("Inspect ", "the toolbox".Magenta()), s => { Game.Instace.OutputPane.Write(_hasScrewdriver ? new FormattedString("There is a ", "Screwdriver".Cyan(), ".") : "It is empty."); _getScrewdriverVerb.Enabled = _hasScrewdriver; })); InternalVerbs.Add(_getScrewdriverVerb); }
private void WiggleMethod(string s) { Game.Instace.OutputPane.Write("You struggle against your bindings. They loosen a little."); InternalVerbs.Remove(_wiggle); InternalVerbs.Add(_escape); }
public Hallway() : base("the Hallway") { _instance = this; _sectionCommands = new[] { new CommandPart("first section of the hallway".Yellow()), new CommandPart("second section of the hallway".Yellow()), new CommandPart("third section of the hallway".Yellow()) }; var closetDoor = new Door(this, TheCloset.Instance, new FormattedString("door to the ", "Utility Closet".Yellow()), 2, 3); H1 = new[] { closetDoor, new Door(this, new Exit(), "Exit", 0, 4) { Locked = true } }; var mugO = Game.Random.Next(5); var keyO = mugO; while (keyO == mugO) { keyO = Game.Random.Next(5); } H2 = new Door[6]; for (var i = 0; i < H2.Length; i++) { var type = i == mugO ? OfficeType.Mug : (i == keyO ? OfficeType.Key : OfficeType.Empty); var x = new[] { 5, 5, 9, 9, 13, 13 }; var y = new[] { 3, 5, 3, 5, 3, 5 }; var l = new[] { "A1", "A2", "B1", "B2", "C1", "C2" }; H2[i] = new Door(this, new Office(l[i], type, i % 2 == 0, x[i], y[i]), new FormattedString("door to ", $"Office {l[i]}".Yellow()), x[i], y[i]); //H2[i].DoorUsed += door => Player.Instance.ChangeLocation(door.To); } H3 = new[] { new Door(this, new Bathroom(), new FormattedString("door to the ", "Bathroom".Yellow()), 17, 3), new Door(this, new Stairwell(), new FormattedString("door to the ", "Stairwell".Yellow()), 17, 5) { Locked = true }, new Door(this, new AdminOffice(), new FormattedString("door to the ", "Admin Office".Yellow()), 21, 3) { Locked = true }, new Door(this, new ElevatorShaft(), "Elevator".Yellow(), 21, 5) { Locked = true } }; closetDoor.DoorUsed -= closetDoor.DefaultDoorAction; closetDoor.DoorUsed += door => { if (TheCloset.Instance.DoorToHallway.Locked) { TheCloset.Instance.DoorToHallway.Locked = false; TheCloset.Instance.DoorToHallway.Name = new FormattedString("the door to ", "the Hallway".Yellow()); } Player.Instance.ChangeLocation(TheCloset.Instance); }; Props.AddRange(H1); InternalVerbs.Add(new Verb("Walk to the", GetSections, WalkToSection)); }