/////// <summary> /////// Allows the player class to call the PlayerFlee Method; /////// </summary> ////public static void OnPlayerFlee() ////{ //// PlayerFlee(); ////} /// <summary> /// Withdraws the player from combat. /// </summary> public void PlayerFlee() { if (_currentLocation != null) { // Set New Current Location: if (_currentLocation.LocationId == 1) { Location newLocation = AccessibleLocations.FirstOrDefault(l => l.LocationId == (CurrentLocation.LocationId + 1)); CurrentLocation = newLocation; } else { Location newLocation = AccessibleLocations.FirstOrDefault(l => l.LocationId == (CurrentLocation.LocationId + 1)); CurrentLocation = newLocation; } //Hurt the player for fleeing if they are above 10 hitpoints: if (Player.Health > 10) { Player.Health = Player.Health - 10; } // Message: need to remove backingfield... _messages.Add("You flee the fight!"); OnPropertyChanged(nameof(MessageDisplay)); // Update Location List: UpdateAccessibleLocations(); } }
/// <summary> /// Adjusts data based on player moving: /// </summary> private void OnPlayerMove() { // Set New Current Location: _currentLocation = AccessibleLocations.FirstOrDefault(l => l.Name == _currentLocationName); if (!_player.LocationsVisited.Contains(_currentLocation)) { _player.LocationsVisited.Add(_currentLocation); // XP Modifier _player.ExperiencePoints += _currentLocation.XPModifier; } // Health if (_player.Health < 100 && _currentLocation.HealthModifier > 0) { _player.CheckPlayerHealthByLocation(_currentLocation); _messages.Add("\n\tSomething in this area has restored some of your health."); } if (_currentLocation.HealthModifier != 0 && _currentLocation.HealthModifier < 0) { _player.CheckPlayerHealthByLocation(_currentLocation); _messages.Add("\n\tSomething in this area has sapped some of your vitality."); } // chance of spawning the Monger: if (!_currentLocation.LocationNPCs.Contains(GameData.GetNPCById(1)) && _currentLocation.LocationId < 13 && _currentLocation.LocationId != 4) { switch (r.Next(1, 11)) { case 10: _messages.Add("Something is lurking in the trees... You hear a horrible shriek as the Monger reveals itself!"); _currentLocation.LocationNPCs.Add(GameData.GetNPCById(1)); break; default: break; } } // Message: OnPropertyChanged(nameof(MessageDisplay)); // Update Location List: UpdateAccessibleLocations(); }
/// <summary> /// Adjusts data based on player moving: /// </summary> private void OnPlayerMove() { // Set New Current Location: _currentLocation = AccessibleLocations.FirstOrDefault(l => l.Name == _currentLocationName); if (!_player.LocationsVisited.Contains(_currentLocation)) { _player.LocationsVisited.Add(_currentLocation); // XP Modifier _player.ExperiencePoints += _currentLocation.XPModifier; // todo Impliment Live Modifiers: // Lives | NOT IMPLIMENTED // if (_currentLocation.ModifyLives != 0) _player.Lives += _currentLocation.LivesModifier; //} } //todo move this to the player class // Health if (_player.Health < 100 && _currentLocation.HealthModifier > 0) { _player.CheckPlayerHealthByLocation(_currentLocation); _messages.Add("\n\tSomething in this area has restored some of your health."); } if (_currentLocation.HealthModifier != 0 && _currentLocation.HealthModifier < 0) { _player.CheckPlayerHealthByLocation(_currentLocation); _messages.Add("\n\tSomething in this area has sapped some of your vitality."); } // Message: OnPropertyChanged(nameof(MessageDisplay)); // Update Location List: UpdateAccessibleLocations(); }
/// <summary> /// updates areas that are accessible from current area /// </summary> private void UpdateAccessibleLocations() { ////clear accessible locations AccessibleLocations.Clear(); //start with no accessible locations foreach (Location location in MasterGameMap.Locations) { location.IsAccessible = false; } //update available locations based on current location foreach (int locationId in CurrentLocation.CurrentAvailableLocations) { foreach (Location location in _masterGameMap.Locations) { if (location.Id == locationId) { location.IsAccessible = true; _accessibleLocations.Add(location); } } } }