public static void LetPlayerEnterTownGate(Player p1, Player p2, Location destination) { GameEngine.SayToLocation(p1.Location, $"{p2.Name} stoically looks you up and down then signals the gatekeeper."); LocationConnector portcullis = p1.Location.GetConnector(destination); portcullis.Unlock(); GameEngine.SayToLocation(p1.Location, $"The massive portcullis rattles as it raises up."); portcullis.SetTickEvent(new ConnectorSelfEvent(ConnectorEventTemplates.ClosePortcullisOnCountdown, countdown: 2)); }
public static void ClosePortcullisOnCountdown(LocationConnector connector) { int timeLeft = connector.OnTickEvent.CountdownTick(); if (connector.OnTickEvent.TimesUp) { connector.Lock(); GameEngine.SayToLocation(connector.Parent, "The portcullis into the town comes crashing down!"); GameEngine.SayToLocation(connector.Destination, "The portcullis into the town comes crashing down!"); connector.ClearTickEvent(); } }
public static void TravelFromPointToPoint(Player player, Location startingPoint, Location destination, string exitText = "", string enterText = "") { if (player == null) { throw new ArgumentNullException($"{MethodBase.GetCurrentMethod().ReflectedType.Name}, null player"); } if (destination == null) { throw new ArgumentNullException($"{MethodBase.GetCurrentMethod().ReflectedType.Name}, null starting location"); } if (destination == null) { throw new ArgumentNullException($"{MethodBase.GetCurrentMethod().ReflectedType.Name}, null ending location"); } if (exitText == "") { exitText = $"{player.Name} leaves {startingPoint} and heads for {destination}."; } if (enterText == "") { enterText = $"{player.Name} enters {destination} from {startingPoint}."; } if (player.IsAlive && player.Location == startingPoint) { LocationConnector exitConnector = startingPoint.GetConnector(destination); if (exitConnector == null || (exitConnector.IsUnlocked)) { exitConnector.OnPlayerExit.PerformAction(player); GameEngine.SayToLocation(player.Location, exitText); player.Relocate(destination); GameEngine.SayToLocation(player.Location, enterText); LocationConnector enterConnector = destination.GetConnector(startingPoint); enterConnector.OnPlayerEnter.PerformAction(player); } else { GameEngine.SayToLocation(player.Location, $"{player.Name} tries to go to {destination.Name} but the way is locked."); } } else { GameEngine.SayToLocation(player.Location, $"{player.Name} was travelling but got interrupted."); } }
public static void DoNothing(LocationConnector connector) { }
public void PerformAction(LocationConnector connector) { this.PerformedAction(connector); }