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 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 FormattedString LevelString(bool showlevel = true, bool complete = true) { var b = new FormattedString(); var count = NextParts.Count(); b.Append(ThisPart); if (count == 1) { b.Append(" "); b.Append(NextParts.First().LevelString(showlevel)); return(b); } if (count != 0 && showlevel) { b.Append($"[ {FormattedString.Join("| ", NextParts.Select(o => o.LevelString(complete)))}] "); } else if (count != 0) { b.Append("..."); } return(b); }