// Tries to move the player back to previous location and if possible, sets potential location to the new location. Returns the outcome of the movement public CommandOutcome TryBack() { // Get intended destination (use previous old loc if travel was forced from old loc) string destination = locationController.TravelIsForced(OldLocations[0]) ? OldLocations[1] : OldLocations[0]; // Keep track of where player avatar is coming from UpdateOldLocations(); string backMsg = null; // Check to see if we actually moved from this location if (destination == CurrentLocation) { // We didn't, so claim a memory lapse backMsg = "91MemoryLapse"; } // Check to see if moving back is allowed from this location else if (!locationController.CanMoveBack(CurrentLocation)) { // It isn't so let player no there's no way back backMsg = "274NoWayBack"; } // Check to see if the destination can be reached from the current location else if (!locationController.DestinationCanBeReached(CurrentLocation, destination)) { // It can't, so let the player know backMsg = "140NoWayThere"; } if (backMsg == null) { // Destination can be reached, so mark that as potential location PotentialLocation = destination; } else { textDisplayController.AddTextToLog(playerMessageController.GetMessage(backMsg)); } return(CommandOutcome.FULL); }
private void FirstEncounter() { string location = playerController.CurrentLocation; // Determine if the player will encounter the first dwarf on this turn and return if not if (!(locationController.LocType(location) == LocationType.DEEP) || (Random.value < .95 && (!locationController.CanMoveBack(location) || Random.value < .85))) { return; } // Indicate player has met the first dwarf ActivationLevel = 2; // On first encountering the dwarves, randomly kill up to two of them (there's a 50% chance a dwarf will die - note it's possible the same dwarf could be killed twice - not a bug) for (int i = 0; i < 2; i++) { if (Random.value < .5) { KillDwarf(Random.Range(0, 4)); } } // If any of the dwarves is at the player avatar's current location, move them to the alternative location for (int i = 0; i < NUM_DWARVES; i++) { if (Dwarves[i].DwarfLocation == location) { Dwarves[i].DwarfLocation = dwarfStartLocations[6]; Dwarves[i].OldDwarfLocation = dwarfStartLocations[6]; } } // Tell the player about the encounter textDisplayController.AddTextToLog(playerMessageController.GetMessage("3DwarfThrow")); // Drop the axe here itemController.DropItemAt("28Axe", location); }