public void RemoveItemFromInventory() { if (_currentGameItem != null) { GameItemModelQuantity selectedGameItemModelQuantity = _currentGameItem as GameItemModelQuantity; switch (_currentGameItem.GameItemModel) { case LightSaberParts lightSaber: RemoveLightsaberPercent(lightSaber, selectedGameItemModelQuantity); _player.UpdateMissionStatus(); break; case KyberCrystals kybercrystal: RemoveLightsaberCrystalProgress(kybercrystal, selectedGameItemModelQuantity); _player.UpdateMissionStatus(); break; default: _currentLocation.AddGameItemModelToLocation(selectedGameItemModelQuantity); _player.RemoveGameItemModelToInventory(selectedGameItemModelQuantity); break; } } }
private string GenerateMissionLightsaberDetail(MissionLightsaberParts mission) { StringBuilder sb = new StringBuilder(); sb.Clear(); sb.AppendLine("All Required Lightsaber Parts"); foreach (var gameItemModelQuantity in mission.RequiredgameItemModelQuantities) { sb.Append(TAB + gameItemModelQuantity.GameItemModel.Name); sb.AppendLine($" ( {gameItemModelQuantity.Quantity} ) "); } if (mission.Status == Mission.MissionStatus.Incomplete) { sb.AppendLine("Lightsaber Parts To Gather"); foreach (var gameItemModelQuantity in mission.GameItemModelQuantityMissionToDo(_player.Inventory.ToList())) { int quantityInInventory = 0; GameItemModelQuantity gameItemModelQuantityGathered = _player.Inventory.FirstOrDefault(gi => gi.GameItemModel.Id == gameItemModelQuantity.GameItemModel.Id); if (gameItemModelQuantityGathered != null) { quantityInInventory = gameItemModelQuantityGathered.Quantity; } sb.Append(TAB + gameItemModelQuantity.GameItemModel.Name); sb.AppendLine($" ( {gameItemModelQuantity.Quantity - quantityInInventory} ) "); } } sb.Remove(sb.Length - 2, 2); return(sb.ToString()); }
public void AddItemToInventory() { if (_currentGameItem != null && _currentLocation.GameItems.Contains(_currentGameItem)) { GameItemModelQuantity selectedGameItemModelQuantity = _currentGameItem as GameItemModelQuantity; switch (_currentGameItem.GameItemModel) { case LightSaberParts lightSaber: AddLightsaberProgress(lightSaber, selectedGameItemModelQuantity); _player.UpdateMissionStatus(); break; case KyberCrystals kybercrystal: AddLightsaberCrystalProgress(kybercrystal, selectedGameItemModelQuantity); _player.UpdateMissionStatus(); _currentGameItem = _currentKyberCrystal; break; default: _currentLocation.RemoveGameItemModelFromLocation(selectedGameItemModelQuantity); _player.AddGameItemModelToInventory(selectedGameItemModelQuantity); break; } } }
private void AddLightsaberCrystalProgress(KyberCrystals kybercrystal, GameItemModelQuantity selectedGameItemModelQuantity) { if (_player.LightsaberProgress == 85) { _currentKyberCrystal = _currentGameItem; _player.LightsaberProgress += kybercrystal.LightsaberProgress; _currentLocation.RemoveGameItemModelFromLocation(selectedGameItemModelQuantity); _player.AddGameItemModelToInventory(selectedGameItemModelQuantity); } else if (_player.LightsaberProgress == 100) { MessageBoxResult result = MessageBox.Show("Error: You are already holding a Kyber Crystal"); } else { MessageBoxResult result = MessageBox.Show("Error: You need to gather all the lightsaber parts first."); } }
private void RemoveLightsaberPercent(LightSaberParts lightSaber, GameItemModelQuantity selectedGameItemModelQuantity) { _player.LightsaberProgress -= lightSaber.LightsaberProgress; _currentLocation.AddGameItemModelToLocation(selectedGameItemModelQuantity); _player.RemoveGameItemModelToInventory(selectedGameItemModelQuantity); }
private void RemoveLightsaberCrystalProgress(KyberCrystals kybercrystal, GameItemModelQuantity selectedGameItemModelQuantity) { _player.LightsaberProgress -= kybercrystal.LightsaberProgress; _currentLocation.AddGameItemModelToLocation(selectedGameItemModelQuantity); _player.RemoveGameItemModelToInventory(selectedGameItemModelQuantity); }
private void AddLightsaberProgress(LightSaberParts lightSaber, GameItemModelQuantity selectedGameItemModelQuantity) { _player.LightsaberProgress += lightSaber.LightsaberProgress; _currentLocation.RemoveGameItemModelFromLocation(selectedGameItemModelQuantity); _player.AddGameItemModelToInventory(selectedGameItemModelQuantity); }