private void MoveTo(Location newLocation) { if (!_player.HasRequiredItemToEnterThisLocation(newLocation)) { rtbMessages.Text += "You must have a " + newLocation.ItemRequiredToEnter.Name + " to enter this location." + Environment.NewLine; return; } _player.CurrentLocation = newLocation; btnNorth.Visible = (newLocation.LocationToNorth != null); btnEast.Visible = (newLocation.LocationToEast != null); btnSouth.Visible = (newLocation.LocationToSouth != null); btnWest.Visible = (newLocation.LocationToWest != null); rtbLocation.Text = newLocation.Name + Environment.NewLine; rtbLocation.Text += newLocation.Description + Environment.NewLine; _player.CurrentMeatLeft = _player.MaximumMeatLeft; lblMeatLeft.Text = _player.CurrentMeatLeft.ToString(); if (newLocation.QuestAvailableHere != null) { bool playerAlreadyHasQuest = _player.HasThisQuest(newLocation.QuestAvailableHere); bool playerAlreadyCompletedQuest = _player.CompletedThisQuest(newLocation.QuestAvailableHere); if (playerAlreadyHasQuest) { if (!playerAlreadyCompletedQuest) { bool playerHasAllItemsToCompleteQuest = _player.HasAllQuestCompletionItems(newLocation.QuestAvailableHere); if (playerHasAllItemsToCompleteQuest) { rtbMessages.Text += Environment.NewLine; rtbMessages.Text += "You complete the '" + newLocation.QuestAvailableHere.Name + "'quest." + Environment.NewLine; _player.RemoveQuestCompletionItems(newLocation.QuestAvailableHere); rtbMessages.Text += "You receive: " + Environment.NewLine; rtbMessages.Text += newLocation.QuestAvailableHere.RewardEXPPoints.ToString() + " experience points" + Environment.NewLine; rtbMessages.Text += newLocation.QuestAvailableHere.RewardCoins.ToString() + " coins" + Environment.NewLine; rtbMessages.Text += newLocation.QuestAvailableHere.RewardItem.Name + Environment.NewLine; rtbMessages.Text += Environment.NewLine; _player.EXPPoints += newLocation.QuestAvailableHere.RewardEXPPoints; _player.Coins += newLocation.QuestAvailableHere.RewardCoins; _player.AddItemToInventory(newLocation.QuestAvailableHere.RewardItem); _player.MarkQuestCompleted(newLocation.QuestAvailableHere); } } } else { rtbMessages.Text += "You receive the '" + newLocation.QuestAvailableHere.Name + "' quest." + Environment.NewLine; rtbMessages.Text += newLocation.QuestAvailableHere.Description + Environment.NewLine; rtbMessages.Text += "To complete it, return with:" + Environment.NewLine; foreach (QuestCompletionItem qci in newLocation.QuestAvailableHere.QuestCompletionItems) { if (qci.Quantity == 1) { rtbMessages.Text += qci.Quantity.ToString() + " " + qci.Details.Name + Environment.NewLine; } else { rtbMessages.Text += qci.Quantity.ToString() + " " + qci.Details.NamePlural + Environment.NewLine; } } rtbMessages.Text += Environment.NewLine; _player.Quests.Add(new PlayerQuest(newLocation.QuestAvailableHere)); } } if (newLocation.MonsterLivingHere != null) { rtbMessages.Text += "You see a " + newLocation.MonsterLivingHere.Name + Environment.NewLine; Monster standartMonster = World.MonsterByID(newLocation.MonsterLivingHere.ID); _currentMonster = new Monster(standartMonster.ID, standartMonster.Name, standartMonster.MaximumDamage, standartMonster.RewardEXPPoints, standartMonster.RewardCoins, standartMonster.CurrentMeatLeft, standartMonster.MaximumMeatLeft); foreach (LootItem lootItem in standartMonster.LootTable) { _currentMonster.LootTable.Add(lootItem); } cboWeapons.Visible = true; cboPotions.Visible = true; btnUseWeapon.Visible = true; btnUsePotion.Visible = true; } else { _currentMonster = null; cboWeapons.Visible = false; cboPotions.Visible = false; btnUseWeapon.Visible = false; btnUsePotion.Visible = false; } UpdateInventoryListUI(); UpdateQuestListUI(); UpdateWeaponListUI(); UpdatePotionListUI(); }
private void MoveTo(Location newLocation) { if (!_player.HasRequiredItemToEnterThisLocation(newLocation)) { rtbMessages.Text += "You must have a " + newLocation.ItemRequiredtoEnter.Name + " to enter this location." + Environment.NewLine; return; } _player.CurrentLocation = newLocation; btnNorth.Visible = (newLocation.LocationToNorth != null); btnEast.Visible = (newLocation.LocationToEast != null); btnSouth.Visible = (newLocation.LocationToSouth != null); btnWest.Visible = (newLocation.LocationToWest != null); rtbLocation.Text = newLocation.Name + Environment.NewLine; rtbLocation.Text += newLocation.Description + Environment.NewLine; _player.CurrHitPoints = _player.MaxHitPoints; lblHitPoints.Text = _player.CurrHitPoints.ToString(); if (newLocation.QuestAvailableHere != null) { bool playerAlreadyHasQuest = _player.HasThisQuest(newLocation.QuestAvailableHere); bool playerAlreadyHasCompletedQuest = _player.CompletedThisQuest(newLocation.QuestAvailableHere); if (playerAlreadyHasQuest) { if (!playerAlreadyHasCompletedQuest) { bool playerHasAllItemsToCompleteQuest = _player.HasAllQuestCompletionItems(newLocation.QuestAvailableHere); if (playerHasAllItemsToCompleteQuest) { rtbMessages.Text += Environment.NewLine; rtbMessages.Text += "You complete the " + newLocation.QuestAvailableHere.Name + " quest." + Environment.NewLine; _player.RemoveQuestCompletionItems(newLocation.QuestAvailableHere); rtbMessages.Text += "You receive: " + Environment.NewLine; rtbMessages.Text += newLocation.QuestAvailableHere.RewardXp.ToString() + " experience points" + Environment.NewLine; rtbMessages.Text += newLocation.QuestAvailableHere.RewardGold.ToString() + " gold" + Environment.NewLine; rtbMessages.Text += newLocation.QuestAvailableHere.RewardItem.Name + Environment.NewLine; rtbMessages.Text += Environment.NewLine; _player.XpPoints += newLocation.QuestAvailableHere.RewardXp; _player.Gold += newLocation.QuestAvailableHere.RewardGold; _player.AddItemToInventory(newLocation.QuestAvailableHere.RewardItem); _player.MarkQuestCompleted(newLocation.QuestAvailableHere); } } } else { rtbMessages.Text += "You receive the " + newLocation.QuestAvailableHere.Name + " quest." + Environment.NewLine; rtbMessages.Text += newLocation.QuestAvailableHere.Description + Environment.NewLine; rtbMessages.Text += "To complete it, return with: " + Environment.NewLine; foreach (QuestCompletionItem questCompletionItem in newLocation.QuestAvailableHere .QuestCompletionItems) { if (questCompletionItem.Amount == 1) { rtbMessages.Text += questCompletionItem.Amount.ToString() + " " + questCompletionItem.Details.Name + Environment.NewLine; } else { rtbMessages.Text += questCompletionItem.Amount.ToString() + " " + questCompletionItem.Details.NamePlural + Environment.NewLine; } } rtbMessages.Text += Environment.NewLine; _player.Quests.Add(new PlayerQuest(newLocation.QuestAvailableHere)); } } if (newLocation.MonsterLivingHere != null) { rtbMessages.Text += "You see a " + newLocation.MonsterLivingHere.Name + Environment.NewLine; Monster monster = World.MonsterByID(newLocation.MonsterLivingHere.ID); _currentMonster = new Monster(monster.MaxDamage, monster.RewardXp, monster.ID, monster.Name, monster.RewardGold, monster.CurrHitPoints, monster.MaxHitPoints); foreach (LootItem lootItem in monster.LootTable) { _currentMonster.LootTable.Add(lootItem); } cbWeapons.Visible = true; cbPotions.Visible = true; btnUseWeapon.Visible = true; btnUsePotion.Visible = true; } else { _currentMonster = null; cbWeapons.Visible = false; cbPotions.Visible = false; btnUseWeapon.Visible = false; btnUsePotion.Visible = false; } UpdateInventoryListInUI(); UpdateQuestListInUI(); UpdateWeaponListInUI(); UpdatePotionListInUI(); }