public SuperAdventure() { InitializeComponent(); location = new Location(1, "Home", "This is your house"); player = new Player(10, 10, 20, 0, 1); lblHitPoints.Text = player.CurrentHitPoints.ToString(); lblGold.Text = player.Gold.ToString(); lblExperience.Text = player.ExperiencePoints.ToString(); lblLevel.Text = player.Level.ToString(); }
public Rpg() { Location location = new Location(1, "Home" , "Home Sweet Home"); InitializeComponent(); _player = new Player(100,100,125,0,1); RolfHp.Text = _player.CurrentHP.ToString(); RolfOrich.Text = _player.Orich.ToString(); RolfXP.Text = _player.XP.ToString(); RolfLevel.Text = _player.Level.ToString(); }
public SuperAdventure() { InitializeComponent(); Engine.Location location = new Engine.Location(1, "home", "This Is Your House", null); _player = new Engine.Player(10, 10, 20, 0, 1); Location test1 = new Engine.Location(1, "your house", "where you live", null); Item item = new Item(1, "key", "first key"); Quest quest1 = new Quest(1, "", "", 100, 100); Location test3 = new Engine.Location(1, "", "", item, quest1, null); }
//Application Load Method public Form1() { Location location = new Location(1, "Home", "This is your home."); InitializeComponent(); this.MouseWheel += new MouseEventHandler(Inven_MouseWheel); tabControl1.TabPages.Remove(mainUIPage); tabControl1.TabPages.Remove(selcrePage); _combat = new Combat(); newChar1.Visible = false; newChar2.Visible = false; newChar3.Visible = false; newChar4.Visible = false; warLinkLbl.Visible = false; wizLinkLbl.Visible = false; preLinkLbl.Visible = false; ranLinkLbl.Visible = false; }
public Exrain() { InitializeComponent(); Location location = new Engine.Location(1, "Home", "This is your house."); location.ID = 1; location.Name = "Home"; location.Description = "This is your house"; _player = new Player(10, 10, 20, 0, 1); lblHitPoints.Text = _player.CurrentHitPoints.ToString(); lblMonero.Text = _player.Currency.ToString(); lblExperience.Text = _player.ExperiencePoints.ToString(); lblLevel.Text = _player.Level.ToString(); }
public SuperAdventure() { InitializeComponent(); Location location = new Engine.Location(1, "Home", "This is your house."); _player = new Player(); _player.CurrentHitPoints = 10; _player.MaximumHitPoints = 10; _player.Gold = 20; _player.ExperiencePoints = 0; _player.Level = 1; lblHitPoints.Text = _player.CurrentHitPoints.ToString(); lblGold.Text = _player.Gold.ToString(); lblExperience.Text = _player.ExperiencePoints.ToString(); lblLevel.Text = _player.Level.ToString(); }
public bool HasRequiredItemToEnterThisLocation(Location location) { if(location.ItemRequiredToEnter == null) { // There is no required item for this location, so return "true" return true; } // See if the player has the required item in their inventory foreach(InventoryItem ii in Inventory) { if(ii.Details.ID == location.ItemRequiredToEnter.ID) { // We found the required item, so return "true" return true; } } // We didn't find the required item in their inventory, so return "false" return false; }
public SuperAdventure() { InitializeComponent(); Location location = new Location(1, "Home", "This is your house"); /* * location.ID = 1; * location.Name = "Home"; * location.Description = "This is your house"; */ _player = new Player(10, 10, 20, 0, 1); /* * _player.CurrentHitPoints = 10; * _player.MaximumHitPoints = 10; * _player.Gold = 20; * _player.ExperiencePoints = 0; * _player.Level = 1; */ lblHitPoints.Text = _player.CurrentHitPoints.ToString(); lblGold.Text = _player.Gold.ToString(); lblExperience.Text = _player.ExperiencePoints.ToString(); lblLevel.Text = _player.Level.ToString(); Location test1 = new Engine.Location(1, "Your House", "This is your house."); Location test2 = new Engine.Location(1, "Your House", "This is your house", null, null, null); //Demo Purposes Item item = new Item(1, "key", "first key"); Quest quest1 = new Quest(1, "", "", 100, 100); Location test3 = new Engine.Location(1, "", "", item, quest1, null); }
public void GenerateLocationLinks(Location[,] dungeonFloor, int row, int col, int maxX, int maxY) { if(row != 0) { locationToNorth = dungeonFloor[row - 1, col]; } else { locationToNorth = null; } if(row != maxX) { locationToSouth = dungeonFloor[row + 1, col]; } else { locationToSouth = null; } if(col != 0) { locationToWest = dungeonFloor[row, col - 1]; } else { locationToWest = null; } if(col != maxY) { locationToEast = dungeonFloor[row, col + 1]; } else { locationToEast = null; } }
private void Moveto(Location newLocation) { if (newLocation.ItemRequiredToEnter != null) { bool playerHasRequiredItem = false; foreach (Inventory ii in _player.Inventory) { if (ii.Details.Index == newLocation.ItemRequiredToEnter.Index) { playerHasRequiredItem = true; break; } } if (!playerHasRequiredItem) { AppendOutPut(String.Format("You must have a {0} to enter this are", newLocation.ItemRequiredToEnter.Name)); return; } } _player.Character_Location = newLocation; btnNorth.Visible = (newLocation.LocationToNorth != null); btnEast.Visible = (newLocation.LocationToEast != null); btnSouth.Visible = (newLocation.LocationToSouth != null); btnWest.Visible = (newLocation.LocationToWest != null); AppendOutPut(newLocation.Name); AppendOutPut(newLocation.Description); _player.Player_Current_Health = _player.Player_Max_Health; hpLbl.Text = _player.Player_Current_Health.ToString(); if (newLocation.QuestAvailableHere != null) { bool playerAlreadyHasQuest = false; bool playerAlreadyCompletedQuest = false; foreach (PlayerQuest playerQuest in _player.Quests) { if (playerQuest.Details.Index == newLocation.QuestAvailableHere.Index) { playerAlreadyHasQuest = true; if (playerQuest.IsComplete) { playerAlreadyCompletedQuest = true; } } } if (playerAlreadyHasQuest) { if (!playerAlreadyCompletedQuest) { bool playerHasItemsToCompleteQuest = true; foreach (QuestCompleted qci in newLocation.QuestAvailableHere.QuestCompleted) { bool foundItemInPlayersInventory = false; foreach (Inventory ii in _player.Inventory) { if (ii.Details.Index == qci.Details.Index) { foundItemInPlayersInventory = true; if (ii.Quantity < qci.Quantity) { playerHasItemsToCompleteQuest = false; break; } break; } } if (!foundItemInPlayersInventory) { playerHasItemsToCompleteQuest = false; break; } } if (playerHasItemsToCompleteQuest) { AppendOutPut(String.Format("You completed the '{0}' quest", newLocation.QuestAvailableHere.Name)); foreach (QuestCompleted qci in newLocation.QuestAvailableHere.QuestCompleted) { foreach (Inventory ii in _player.Inventory) { if (ii.Details.Index == qci.Details.Index) { ii.Quantity -= qci.Quantity; break; } } } AppendOutPut(String.Format("You receive : {0} exp \r\n{1} gold\r\n{2}", newLocation.QuestAvailableHere.Reward_EXP.ToString(), newLocation.QuestAvailableHere.Reward_GOLD.ToString(), newLocation.QuestAvailableHere.Reward_ITEM.Name)); _player.Player_Exp += newLocation.QuestAvailableHere.Reward_EXP; _player.Gold += newLocation.QuestAvailableHere.Reward_GOLD; bool addedItemToPlayerInventory = false; foreach (Inventory ii in _player.Inventory) { if (ii.Details.Index == newLocation.QuestAvailableHere.Reward_ITEM.Index) { ii.Quantity++; addedItemToPlayerInventory = true; break; } } if (!addedItemToPlayerInventory) { _player.Inventory.Add(new Inventory(newLocation.QuestAvailableHere.Reward_ITEM, 1)); } foreach (PlayerQuest pq in _player.Quests) { if (pq.Details.Index == newLocation.QuestAvailableHere.Index) { pq.IsComplete = true; break; } } } } } else { AppendOutPut(String.Format("You receive the {0} quest\r\n{1}\r\nTo complete it return with :", newLocation.QuestAvailableHere.Name, newLocation.QuestAvailableHere.Description )); foreach (QuestCompleted qci in newLocation.QuestAvailableHere.QuestCompleted) { if (qci.Quantity == 1) { AppendOutPut(String.Format("{0} {1}", qci.Quantity.ToString(), qci.Details.Name)); } else { AppendOutPut(String.Format("{0} {1}", qci.Quantity.ToString(), qci.Details.NamePlurel)); } } _player.Quests.Add(new PlayerQuest(newLocation.QuestAvailableHere)); } } if (newLocation.MonstersHere != null) { AppendOutPut(String.Format("You see a {0}", newLocation.MonstersHere.Name)); Monster standardMonster = World.MonsterById(newLocation.MonstersHere.Index); _currentMonster = new Monster(standardMonster.Index, standardMonster.Name, standardMonster.STR, standardMonster.VIT, standardMonster.INTEL, standardMonster.WIS, standardMonster.DEX, standardMonster.CHARISMA, standardMonster.RewardEXP, standardMonster.RewardGold, standardMonster.CurrentHP, standardMonster.MaxHP); foreach (LootItem lootitem in standardMonster.LootTable) { _currentMonster.LootTable.Add(lootitem); } cboWeaponBox.Visible = true; cboPotionBox.Visible = true; btnUseWeapon.Visible = true; btnUsePotion.Visible = true; } else { _currentMonster = null; cboPotionBox.Visible = false; cboWeaponBox.Visible = false; btnUsePotion.Visible = false; btnUseWeapon.Visible = false; } questDGrid.RowHeadersVisible = false; questDGrid.ColumnCount = 2; questDGrid.Columns[0].Name = "Name"; questDGrid.Columns[0].Width = 192; questDGrid.Columns[1].Name = "Done?"; questDGrid.ClearSelection(); UpdateInventoryListInUI(); UpdateQuestListInUI(); UpdateWeaponListInUI(); UpdatePotionListInUI(); }
private void MoveTo(Location newLocation) { //Does the location have any required items if (newLocation.ItemRequiredToEnter != null) { // See if the player has the required item in their inventory bool playerHasRequiredItem = false; foreach (InventoryItem ii in _player.Inventory) { if (ii.Details.ID == newLocation.ItemRequiredToEnter.ID) { // We found the required item playerHasRequiredItem = true; break; // Exit out of the foreach loop } } if (!playerHasRequiredItem) { // We didn't find the required item in their inventory, so display a message and stop trying to move rtbMessages.Text += "You must have a " + newLocation.ItemRequiredToEnter.Name + " to enter this location." + Environment.NewLine; return; } } // Update the player's current location _player.CurrentLocation = newLocation; // Show/hide available movement buttons btnNorth.Visible = (newLocation.LocationToNorth != null); btnEast.Visible = (newLocation.LocationToEast != null); btnSouth.Visible = (newLocation.LocationToSouth != null); btnWest.Visible = (newLocation.LocationToWest != null); // Display current location name and description rtbLocation.Text = newLocation.Name + Environment.NewLine; rtbLocation.Text += newLocation.Description + Environment.NewLine; // Completely heal the player _player.CurrentHitPoints = _player.MaximumHitPoints; // Update Hit Points in UI lblHitPoints.Text = _player.CurrentHitPoints.ToString(); // Does the location have a quest? if (newLocation.QuestAvailableHere != null) { // See if the player already has the quest, and if they've completed it bool playerAlreadyHasQuest = false; bool playerAlreadyCompletedQuest = false; foreach (PlayerQuest playerQuest in _player.Quests) { if (playerQuest.Details.ID == newLocation.QuestAvailableHere.ID) { playerAlreadyHasQuest = true; if (playerQuest.IsCompleted) { playerAlreadyCompletedQuest = true; } } } // See if the player already has the quest if (playerAlreadyHasQuest) { // If the player has not completed the quest yet if (!playerAlreadyCompletedQuest) { // See if the player has all the items needed to complete the quest bool playerHasAllItemsToCompleteQuest = true; foreach (QuestCompletionItem qci in newLocation.QuestAvailableHere.QuestCompletionItems) { bool foundItemInPlayersInventory = false; // Check each item in the player's inventory, to see if they have it, and enough of it foreach (InventoryItem ii in _player.Inventory) { // The player has this item in their inventory if (ii.Details.ID == qci.Details.ID) { foundItemInPlayersInventory = true; if (ii.Quantity < qci.Quantity) { // The player does not have enough of this item to complete the quest playerHasAllItemsToCompleteQuest = false; // There is no reason to continue checking for the other quest completion items break; } // We found the item, so don't check the rest of the player's inventory break; } } // If we didn't find the required item, set our variable and stop looking for other items if (!foundItemInPlayersInventory) { // The player does not have this item in their inventory playerHasAllItemsToCompleteQuest = false; // There is no reason to continue checking for the other quest completion items break; } } // The player has all items required to complete the quest if (playerHasAllItemsToCompleteQuest) { // Display message rtbMessages.Text += Environment.NewLine; rtbMessages.Text += "You complete the '" + newLocation.QuestAvailableHere.Name + "' quest." + Environment.NewLine; // Remove quest items from inventory foreach (QuestCompletionItem qci in newLocation.QuestAvailableHere.QuestCompletionItems) { foreach (InventoryItem ii in _player.Inventory) { if (ii.Details.ID == qci.Details.ID) { // Subtract the quantity from the player's inventory that was needed to complete the quest ii.Quantity -= qci.Quantity; break; } } } // Give quest rewards rtbMessages.Text += "You receive: " + Environment.NewLine; rtbMessages.Text += newLocation.QuestAvailableHere.RewardExperiencePoints.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.ExperiencePoints += newLocation.QuestAvailableHere.RewardExperiencePoints; _player.Gold += newLocation.QuestAvailableHere.RewardGold; // Add the reward item to the player's inventory bool addedItemToPlayerInventory = false; foreach (InventoryItem ii in _player.Inventory) { if (ii.Details.ID == newLocation.QuestAvailableHere.RewardItem.ID) { // They have the item in their inventory, so increase the quantity by one ii.Quantity++; addedItemToPlayerInventory = true; break; } } // They didn't have the item, so add it to their inventory, with a quantity of 1 if (!addedItemToPlayerInventory) { _player.Inventory.Add(new InventoryItem(newLocation.QuestAvailableHere.RewardItem, 1)); } // Mark the quest as completed // Find the quest in the player's quest list foreach (PlayerQuest pq in _player.Quests) { if (pq.Details.ID == newLocation.QuestAvailableHere.ID) { // Mark it as completed pq.IsCompleted = true; break; } } } } } else { // The player does not already have the quest // Display the messages 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; // Add the quest to the player's quest list _player.Quests.Add(new PlayerQuest(newLocation.QuestAvailableHere)); } } // Does the location have a monster? if (newLocation.MonsterLivingHere != null) { rtbMessages.Text += "You see a " + newLocation.MonsterLivingHere.Name + Environment.NewLine; // Make a new monster, using the values from the standard monster in the World.Monster list Monster standardMonster = World.MonsterByID(newLocation.MonsterLivingHere.ID); _currentMonster = new Monster(standardMonster.ID, standardMonster.Name, standardMonster.MaximumDamage, standardMonster.RewardExperiencePoints, standardMonster.RewardGold, standardMonster.CurrentHitPoints, standardMonster.MaximumHitPoints); foreach (LootItem lootItem in standardMonster.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; } // Refresh player's inventory list dgvInventory.RowHeadersVisible = false; dgvInventory.ColumnCount = 2; dgvInventory.Columns[0].Name = "Name"; dgvInventory.Columns[0].Width = 197; dgvInventory.Columns[1].Name = "Quantity"; dgvInventory.Rows.Clear(); foreach (InventoryItem inventoryItem in _player.Inventory) { if (inventoryItem.Quantity > 0) { dgvInventory.Rows.Add(new[] { inventoryItem.Details.Name, inventoryItem.Quantity.ToString() }); } } // Refresh player's quest list dgvQuests.RowHeadersVisible = false; dgvQuests.ColumnCount = 2; dgvQuests.Columns[0].Name = "Name"; dgvQuests.Columns[0].Width = 197; dgvQuests.Columns[1].Name = "Done?"; dgvQuests.Rows.Clear(); foreach (PlayerQuest playerQuest in _player.Quests) { dgvQuests.Rows.Add(new[] { playerQuest.Details.Name, playerQuest.IsCompleted.ToString() }); } // Refresh player's weapons combobox List<Weapon> weapons = new List<Weapon>(); foreach (InventoryItem inventoryItem in _player.Inventory) { if (inventoryItem.Details is Weapon) { if (inventoryItem.Quantity > 0) { weapons.Add((Weapon)inventoryItem.Details); } } } if (weapons.Count == 0) { // The player doesn't have any weapons, so hide the weapon combobox and "Use" button cboWeapons.Visible = false; btnUseWeapon.Visible = false; } else { cboWeapons.DataSource = weapons; cboWeapons.DisplayMember = "Name"; cboWeapons.ValueMember = "ID"; cboWeapons.SelectedIndex = 0; } // Refresh player's potions combobox List<HealingPotion> healingPotions = new List<HealingPotion>(); foreach (InventoryItem inventoryItem in _player.Inventory) { if (inventoryItem.Details is HealingPotion) { if (inventoryItem.Quantity > 0) { healingPotions.Add((HealingPotion)inventoryItem.Details); } } } if (healingPotions.Count == 0) { // The player doesn't have any potions, so hide the potion combobox and "Use" button cboPotions.Visible = false; btnUsePotion.Visible = false; } else { cboPotions.DataSource = healingPotions; cboPotions.DisplayMember = "Name"; cboPotions.ValueMember = "ID"; cboPotions.SelectedIndex = 0; } }
public void MoveTo(Location newLocation) { //Does the location have any required items if (!HasRequiredItemToEnterThisLocation(newLocation)) { RaiseMessage("You must have a " + newLocation.ItemRequiredToEnter.Name + " to enter this location."); return; } // Update the player's current location CurrentLocation = newLocation; // Completely heal the player CurrentHitPoints = MaximumHitPoints; // Does the location have a quest? if (newLocation.QuestAvailableHere != null) { // See if the player already has the quest, and if they've completed it bool playerAlreadyHasQuest = HasThisQuest(newLocation.QuestAvailableHere); bool playerAlreadyCompletedQuest = CompletedThisQuest(newLocation.QuestAvailableHere); // See if the player already has the quest if (playerAlreadyHasQuest) { // If the player has not completed the quest yet if (!playerAlreadyCompletedQuest) { // See if the player has all the items needed to complete the quest bool playerHasAllItemsToCompleteQuest = HasAllQuestCompletionItems(newLocation.QuestAvailableHere); // The player has all items required to complete the quest if (playerHasAllItemsToCompleteQuest) { // Display message RaiseMessage(""); RaiseMessage("You complete the '" + newLocation.QuestAvailableHere.Name + "' quest."); // Remove quest items from inventory RemoveQuestCompletionItems(newLocation.QuestAvailableHere); // Give quest rewards RaiseMessage("You receive: "); RaiseMessage(newLocation.QuestAvailableHere.RewardExperiencePoints + " experience points"); RaiseMessage(newLocation.QuestAvailableHere.RewardGold + " gold"); RaiseMessage(newLocation.QuestAvailableHere.RewardItem.Name, true); AddExperiencePoints(newLocation.QuestAvailableHere.RewardExperiencePoints); Gold += newLocation.QuestAvailableHere.RewardGold; // Add the reward item to the player's inventory AddItemToInventory(newLocation.QuestAvailableHere.RewardItem); // Mark the quest as completed MarkQuestCompleted(newLocation.QuestAvailableHere); } } } else { // The player does not already have the quest // Display the messages RaiseMessage("You receive the " + newLocation.QuestAvailableHere.Name + " quest."); RaiseMessage(newLocation.QuestAvailableHere.Description); RaiseMessage("To complete it, return with:"); foreach (QuestCompletionItem qci in newLocation.QuestAvailableHere.QuestCompletionItems) { if (qci.Quantity == 1) { RaiseMessage(qci.Quantity + " " + qci.Details.Name); } else { RaiseMessage(qci.Quantity + " " + qci.Details.NamePlural); } } RaiseMessage(""); // Add the quest to the player's quest list Quests.Add(new PlayerQuest(newLocation.QuestAvailableHere)); } } // Does the location have a monster? if (newLocation.MonsterLivingHere != null) { RaiseMessage("You see a " + newLocation.MonsterLivingHere.Name); // Make a new monster, using the values from the standard monster in the World.Monster list Monster standardMonster = World.MonsterByID(newLocation.MonsterLivingHere.ID); _currentMonster = new Monster(standardMonster.ID, standardMonster.Name, standardMonster.MaximumDamage, standardMonster.RewardExperiencePoints, standardMonster.RewardGold, standardMonster.CurrentHitPoints, standardMonster.MaximumHitPoints); foreach (LootItem lootItem in standardMonster.LootTable) { _currentMonster.LootTable.Add(lootItem); } } else { _currentMonster = null; } }
private static void PopulateLocations() { Location home = new Location(LOCATION_ID_HOME, "Home", "Your house."); Location dragonsreach = new Location(LOCATION_ID_DRAGONSREACH, "Town square", "You see a fountain."); Location collegeofwinterhold = new Location(LOCATION_ID_COLLEGE_OF_WINTERHOLD, "Alchemist's hut", "There are many strange plants on the shelves."); collegeofwinterhold.AvailableMission = MissionByID(MISSION_ID_CLEAR_ELYSIUM); Location herasgarden = new Location(LOCATION_ID_HERA_GARDEN, "Alchemist's garden", "Many plants are growing here."); herasgarden.CreaturePresent = CreatureByID(CREATURE_ID_SKEEVER); Location templeofdibella = new Location(LOCATION_ID_TEMPLE_OF_DIBELLA, "Farmhouse", "There is a small farmhouse, with a farmer in front."); templeofdibella.AvailableMission = MissionByID(MISSION_ID_CLEAR_ELYSIUM); Location elysium = new Location(LOCATION_ID_ELYSIUM, "Farmer's field", "You see rows of vegetables growing here."); elysium.CreaturePresent = CreatureByID(CREATURE_ID_DEATH_HOUND); Location labyrinth = new Location(LOCATION_ID_LABYRINTH, "Guard post", "There is a large, tough-looking guard here.", ItemByID(ITEM_ID_ADVENTURER_PASS)); Location bridge = new Location(LOCATION_ID_BRIDGE, "Bridge", "A stone bridge crosses a wide river."); Location dragonvaleforest = new Location(LOCATION_ID_DRAGONVALE_FOREST, "Forest", "You see spider webs covering covering the trees in this forest."); dragonvaleforest.CreaturePresent = CreatureByID(CREATURE_ID_DRAGON); home.ToNorth = dragonsreach; dragonsreach.ToNorth = collegeofwinterhold; dragonsreach.ToSouth = home; dragonsreach.ToEast = labyrinth; dragonsreach.ToWest = templeofdibella; templeofdibella.ToEast = dragonsreach; templeofdibella.ToWest = elysium; elysium.ToEast = templeofdibella; collegeofwinterhold.ToSouth = dragonsreach; collegeofwinterhold.ToNorth = herasgarden; herasgarden.ToSouth = collegeofwinterhold; labyrinth.ToEast = bridge; labyrinth.ToWest = dragonsreach; bridge.ToWest = labyrinth; bridge.ToEast = dragonvaleforest; dragonvaleforest.ToWest = bridge; Locations.Add(home); Locations.Add(dragonsreach); Locations.Add(labyrinth); Locations.Add(collegeofwinterhold); Locations.Add(herasgarden); Locations.Add(templeofdibella); Locations.Add(bridge); Locations.Add(dragonvaleforest); }
public bool HasRequiredItemToEnterThisLocation(Location location) { if(location.ItemRequiredToEnter== null) { return true; } return Inventory.Any(ii => ii.Details.ID == location.ItemRequiredToEnter.ID); }
public bool HasRequiredItemToEnterThisLocation(Location location) { if (location.ItemRequiredToEnter == null) { // There is no required item for this location, so return "true" return true; } // See if the player has the required item in their inventory return Inventory.Exists(ii => ii.Details.ID == location.ItemRequiredToEnter.ID); }
private static void PopulateLocations() { // Create each location Location home = new Location(LOCATION_ID_HOME, "Home", "Your house. You really need to clean up the place."); Location townSquare = new Location(LOCATION_ID_TOWN_SQUARE, "Town square", "You see a fountain."); Location alchemistHut = new Location(LOCATION_ID_ALCHEMIST_HUT, "Alchemist's hut", "There are many strange plants on the shelves."); alchemistHut.QuestAvailableHere = QuestByID(QUEST_ID_CLEAR_ALCHEMIST_GARDEN); Location alchemistsGarden = new Location(LOCATION_ID_ALCHEMISTS_GARDEN, "Alchemist's garden", "Many plants are growing here."); alchemistsGarden.MonsterLivingHere = MonsterByID(MONSTER_ID_RAT); Location farmhouse = new Location(LOCATION_ID_FARMHOUSE, "Farmhouse", "There is a small farmhouse, with a farmer in front."); farmhouse.QuestAvailableHere = QuestByID(QUEST_ID_CLEAR_FARMERS_FIELD); Location farmersField = new Location(LOCATION_ID_FARM_FIELD, "Farmer's field", "You see rows of vegetables growing here."); farmersField.MonsterLivingHere = MonsterByID(MONSTER_ID_SNAKE); Location guardPost = new Location(LOCATION_ID_GUARD_POST, "Guard post", "There is a large, tough-looking guard here.", ItemByID(ITEM_ID_ADVENTURER_PASS)); guardPost.MonsterLivingHere = MonsterByID(MONSTER_ID_MAGICAN); Location bridge = new Location(LOCATION_ID_BRIDGE, "Bridge", "A stone bridge crosses a wide river."); bridge.QuestAvailableHere = QuestByID(QUEST_ID_HIDDEN_TREASURE); Location spiderField = new Location(LOCATION_ID_SPIDER_FIELD, "Forest", "You see spider webs covering covering the trees in this forest."); spiderField.MonsterLivingHere = MonsterByID(MONSTER_ID_GIANT_SPIDER); spiderField.LevelRequirement = 5; // Link the locations together home.LocationToNorth = townSquare; townSquare.LocationToNorth = alchemistHut; townSquare.LocationToSouth = home; townSquare.LocationToEast = guardPost; townSquare.LocationToWest = farmhouse; farmhouse.LocationToEast = townSquare; farmhouse.LocationToWest = farmersField; farmersField.LocationToEast = farmhouse; alchemistHut.LocationToSouth = townSquare; alchemistHut.LocationToNorth = alchemistsGarden; alchemistsGarden.LocationToSouth = alchemistHut; guardPost.LocationToEast = bridge; guardPost.LocationToWest = townSquare; bridge.LocationToWest = guardPost; bridge.LocationToEast = spiderField; spiderField.LocationToWest = bridge; // Add the locations to the static list Locations.Add(home); Locations.Add(townSquare); Locations.Add(guardPost); Locations.Add(alchemistHut); Locations.Add(alchemistsGarden); Locations.Add(farmhouse); Locations.Add(farmersField); Locations.Add(bridge); Locations.Add(spiderField); }
private static void PopulateLocations() { //Creating each location Location home = new Location(LocationIdHome,"Home","Your House You really need to clean up the place."); Location townSquare = new Location(LocationIdTownSquare, "Town square", "You see a fountain."); Location alchemistHut = new Location(LocationIdAlchemistHut, "Alchemist's hut", "There are so many strange plants on the shelves."); alchemistHut.QuestAvailableHere = QuestById(QuestIdClearAlchemistGarden); Location alchemistGarden = new Location(LocationIdAlchemistGarden, "Alchemist's hut", "Many plants are growing here."); alchemistGarden.QuestAvailableHere = QuestById(QuestIdClearFarmersField); Location farmHouse = new Location(LocationIdFarmHouse, "Farmhouse", "There is a small farmhouse, with a farmer in the front."); farmHouse.QuestAvailableHere = QuestById(QuestIdClearFarmersField); Location farmersField = new Location(LocationIdFarmField, "Farmer's field", "You see rows of vegtables growing here."); farmersField.MonsterLivingHere = MonsterById(MonsterIdSnake); Location guardPost = new Location(LocationIdGuardPost, "Guard Post", "There is a large tough-looking guard here", ItemById(ItemIdAdventurePass)); Location bridge = new Location(LocationIdBridge, "Bridge", "A stone bridge crosses a wide river."); Location spiderField = new Location(LocationIdSpiderField, "Forest", "You see spider webs covering the trees in this forest."); spiderField.MonsterLivingHere = MonsterById(MonsterIdGiantSpider); //Linking the locations together home.LocationToNorth = townSquare; townSquare.LocationToNorth = alchemistHut; townSquare.LocationToSouth = home; townSquare.LocationToEast = guardPost; townSquare.LocationToWest = farmHouse; farmHouse.LocationToEast = townSquare; farmHouse.LocationToWest = farmersField; farmersField.LocationToEast = farmHouse; alchemistHut.LocationToNorth = alchemistGarden; alchemistHut.LocationToSouth = townSquare; alchemistGarden.LocationToSouth = alchemistHut; guardPost.LocationToEast = bridge; guardPost.LocationToWest = townSquare; bridge.LocationToEast = spiderField; bridge.LocationToWest = guardPost; spiderField.LocationToWest = bridge; //Add the locations to the static list //todo use object initilaization syntax Locations.Add(home); Locations.Add(townSquare); Locations.Add(guardPost); Locations.Add(alchemistHut); Locations.Add(alchemistGarden); Locations.Add(farmHouse); Locations.Add(farmersField); Locations.Add(bridge); Locations.Add(spiderField); }
private static void PopulateLocations() { // Create each location Location home = new Location(LOCATION_ID_HOME, "Home", "Your house. You really need to clean up the place."); Location townSquare = new Location(LOCATION_ID_TOWN_SQUARE, "Town square", "You see a fountain."); Location alchemistHut = new Location(LOCATION_ID_ALCHEMIST_HUT, "Alchemist's hut", "There are many strange plants on the shelves."); alchemistHut.QuestAvailableHere = QuestByID(QUEST_ID_CLEAR_ALCHEMIST_GARDEN); Location alchemistsGarden = new Location(LOCATION_ID_ALCHEMISTS_GARDEN, "Alchemist's garden", "Many plants are growing here."); alchemistsGarden.MonsterLivingHere = MonsterByID(MONSTER_ID_RAT); Location farmhouse = new Location(LOCATION_ID_FARMHOUSE, "Farmhouse", "There is a small farmhouse, with a farmer in front."); farmhouse.QuestAvailableHere = QuestByID(QUEST_ID_CLEAR_FARMERS_FIELD); Location farmersField = new Location(LOCATION_ID_FARM_FIELD, "Farmer's field", "You see rows of vegetables growing here."); farmersField.MonsterLivingHere = MonsterByID(MONSTER_ID_SNAKE); Location guardPost = new Location(LOCATION_ID_GUARD_POST, "Guard post", "There is a large, tough-looking guard here.", ItemByID(ITEM_ID_ADVENTURER_PASS)); Location bridge = new Location(LOCATION_ID_BRIDGE, "Bridge", "A stone bridge crosses a wide river."); Location spiderField = new Location(LOCATION_ID_SPIDER_FIELD, "Forest", "You see spider webs covering covering the trees in this forest."); spiderField.MonsterLivingHere = MonsterByID(MONSTER_ID_GIANT_SPIDER); // Link the locations together home.LocationToNorth = townSquare; townSquare.LocationToNorth = alchemistHut; townSquare.LocationToSouth = home; townSquare.LocationToEast = guardPost; townSquare.LocationToWest = farmhouse; farmhouse.LocationToEast = townSquare; farmhouse.LocationToWest = farmersField; farmersField.LocationToEast = farmhouse; alchemistHut.LocationToSouth = townSquare; alchemistHut.LocationToNorth = alchemistsGarden; alchemistsGarden.LocationToSouth = alchemistHut; guardPost.LocationToEast = bridge; guardPost.LocationToWest = townSquare; bridge.LocationToWest = guardPost; bridge.LocationToEast = spiderField; spiderField.LocationToWest = bridge; // Add the locations to the static list Locations.Add(home); Locations.Add(townSquare); Locations.Add(guardPost); Locations.Add(alchemistHut); Locations.Add(alchemistsGarden); Locations.Add(farmhouse); Locations.Add(farmersField); Locations.Add(bridge); Locations.Add(spiderField); }
private void MoveTo(Location newLocation) { //Does the location have any required items if (!_player.HasRequiredItemToEnterThisLocation(newLocation)) { rtbMessages.Text += string.Format("You must have a {0} to enter this location.{1}", newLocation.ItemRequiredToEnterHere.Name, Environment.NewLine); return; } //Update the player's current location _player.CurrentLocation = newLocation; //Show/hide available movement buttons btnNorth.Visible = (newLocation.LocationToNorth != null); btnEast.Visible = (newLocation.LocationToEast != null); btnSouth.Visible = (newLocation.LocationToSouth != null); btnWest.Visible = (newLocation.LocationToWest != null); //Dispaly current location name description rtbLocation.Text = newLocation.Name + Environment.NewLine; rtbLocation.Text = newLocation.Description + Environment.NewLine; //Completly heal the player _player.CurrentHitPoints = _player.MaximumHitPoints; //Update hit points in the UI lblHitPoints.Text = _player.MaximumHitPoints.ToString(); //Does the location have a quest? if (newLocation.QuestAvailableHere != null) { //Variables to hold if the player already has the quest, and if they've completed it bool playerAlreadyHasQuest = _player.HasThisQuest(newLocation.QuestAvailableHere); bool playerAlreadyCompletedQuest = _player.CompletedThisQuest(newLocation.QuestAvailableHere); //See if the playeralready has the quest if (playerAlreadyHasQuest) { //if player has all items needed to complete the quest if (!playerAlreadyCompletedQuest) { //See if the player has all the items needed to complete the quest bool playerHasAllItemsToCompleteQuest = _player.HasAllQuestCompletionItems(newLocation.QuestAvailableHere); //The player has alll items required to complete the quest if (playerHasAllItemsToCompleteQuest) { //Display message rtbMessages.Text += Environment.NewLine; rtbMessages.Text += string.Format("You complete the {0} ' quest.{1}", newLocation.QuestAvailableHere.Name, Environment.NewLine); //Remove quest items from inventory _player.RemoveQuestCompletionItems(newLocation.QuestAvailableHere); //Give quest rewards rtbMessages.Text += string.Format("You recieve: {0}", Environment.NewLine); rtbMessages.Text += string.Format("{0} experience points{1}", newLocation.QuestAvailableHere.RewardExperiencePoints, Environment.NewLine); rtbMessages.Text += string.Format("{0} gold{1}", newLocation.QuestAvailableHere.RewardGold, Environment.NewLine); rtbMessages.Text += string.Format("{0}{1}", newLocation.QuestAvailableHere.RewardItem.Name, Environment.NewLine); rtbMessages.Text += Environment.NewLine; _player.ExperiencePoints += newLocation.QuestAvailableHere.RewardExperiencePoints; _player.Gold += newLocation.QuestAvailableHere.RewardGold; //Add the reward item to the players's inventory _player.AddItemToInventory(newLocation.QuestAvailableHere.RewardItem); //Mark the quest as completed _player.MarkQuestCompleted(newLocation.QuestAvailableHere); } } } else { //The player does not already have the quest //Display the messages rtbMessages.Text += string.Format("You recieve the {0} quest.{1}", newLocation.QuestAvailableHere, Environment.NewLine); rtbMessages.Text += string.Format(newLocation.QuestAvailableHere.Description + Environment.NewLine); rtbMessages.Text += string.Format("To complete it, return with:{0}", Environment.NewLine); foreach (QuestCompletionItem qCi in newLocation.QuestAvailableHere.QuestCompletionItems) { if (qCi.Quantity == 1) { rtbMessages.Text += string.Format("{0} {1} {2}", qCi.Quantity, qCi.Details.Name, Environment.NewLine); } else { rtbMessages.Text += string.Format("{0} {1} {2}", qCi.Quantity, qCi.Details.NamePlural, Environment.NewLine); } } rtbMessages.Text += Environment.NewLine; //Add the quest to the player's quest list _player.Quests.Add(new PlayerQuest(newLocation.QuestAvailableHere, true)); } } //Does the location have a monster? if (newLocation.MonsterLivingHere != null) { rtbMessages.Text += string.Format("You see a {0} {1}", newLocation.MonsterLivingHere.Name, Environment.NewLine); //Make a new Monster, using the new values from the standard monster in the World.Monster list Monster standardMonster = World.MonsterById(newLocation.MonsterLivingHere.ID); _currentMonster = new Monster(standardMonster.ID, standardMonster.Name, standardMonster.MaximumDamage, standardMonster.RewardExperiencePoints, standardMonster.RewardExperiencePoints, standardMonster.CurrentHitPoints, standardMonster.MaximumHitPoints); foreach (LootItem lootItem in standardMonster.LootTable) { _currentMonster.LootTable.Add(lootItem); } cboWeapons.Visible = true; cboPotions.Visible = true; btnUsePotion.Visible = true; btnUsePotion.Visible = true; } else { _currentMonster = null; cboWeapons.Visible = false; cboPotions.Visible = false; btnUsePotion.Visible = false; btnUsePotion.Visible = false; } //Refresh player's inventory list UpdateInventoryListInUI(); //Refresh players quest list UpdateQuestListInUI(); //Refresh player's weapons combobox UpdateWeaponListInUI(); //Refresh player's potions combobox UpdatePotionListInUI(); }
public bool HasRequiredItemToEnterLocation(Location location) { if (location.ItemRequiredToEnter == null) return true; foreach(Inventory ii in Inventory) if (ii.Details.Index == location.ItemRequiredToEnter.Index) return true; return false; }
private static void PopulateLocations() { // New Locations Location home = new Location(LOCATION_ID_HOME, "Home", "Your house. You really need to clean up the place."); Location townSquare = new Location(LOCATION_ID_TOWN_SQUARE, "Town square", "You see a fountain."); townSquare.QuestAvailableHere = QuestByID(QUEST_ID_GO_TO_MORRIS); Location alchemistHut = new Location(LOCATION_ID_ALCHEMIST_HUT, "Alchemist's hut", "There are many strange plants on the shelves."); alchemistHut.QuestAvailableHere = QuestByID(QUEST_ID_CLEAR_ALCHEMIST_GARDEN); Location alchemistsGarden = new Location(LOCATION_ID_ALCHEMISTS_GARDEN, "Alchemist's garden", "Many plants are growing here."); alchemistsGarden.MonsterLivingHere = MonsterByID(MONSTER_ID_RAT); Location farmhouse = new Location(LOCATION_ID_FARMHOUSE, "Farmhouse", "There is a small farmhouse, with a farmer in front."); farmhouse.QuestAvailableHere = QuestByID(QUEST_ID_CLEAR_FARMERS_FIELD); Location farmersField = new Location(LOCATION_ID_FARM_FIELD, "Farmer's field", "You see rows of vegetables growing here."); farmersField.MonsterLivingHere = MonsterByID(MONSTER_ID_SNAKE); Location guardPost = new Location(LOCATION_ID_GUARD_POST, "Guard post", "There is a large, tough-looking guard here.", ItemByID(ITEM_ID_ADVENTURER_PASS)); guardPost.QuestAvailableHere = QuestByID(QUEST_ID_CLEAR_SPIDERFIELD); Location bridge = new Location(LOCATION_ID_BRIDGE, "Bridge", "A stone bridge crosses a wide river."); Location spiderField = new Location(LOCATION_ID_SPIDER_FIELD, "Spider Field", "You see spider webs covering the ground in the field."); spiderField.MonsterLivingHere = MonsterByID(MONSTER_ID_GIANT_SPIDER); Location forestEntrance = new Location(LOCATION_ID_FOREST_ENTRANCE, "Forest Opening", "You see a path leading into a forest.", ItemByID(ITEM_ID_EXPLORER_PASS)); Location midForest = new Location(LOCATION_ID_MIDFOREST, "Forest", "There are a lot of trees and goo everywhere."); midForest.MonsterLivingHere = MonsterByID(MONSTER_ID_SLIME); // How locations connect to each other home.LocationToNorth = townSquare; home.LocationToSouth = forestEntrance; townSquare.LocationToNorth = alchemistHut; townSquare.LocationToSouth = home; townSquare.LocationToEast = guardPost; townSquare.LocationToWest = farmhouse; farmhouse.LocationToEast = townSquare; farmhouse.LocationToWest = farmersField; farmersField.LocationToEast = farmhouse; alchemistHut.LocationToSouth = townSquare; alchemistHut.LocationToNorth = alchemistsGarden; alchemistsGarden.LocationToSouth = alchemistHut; guardPost.LocationToEast = bridge; guardPost.LocationToWest = townSquare; bridge.LocationToWest = guardPost; bridge.LocationToEast = spiderField; spiderField.LocationToWest = bridge; forestEntrance.LocationToNorth = home; forestEntrance.LocationToSouth = midForest; midForest.LocationToNorth = forestEntrance; // Locations added to map Locations.Add(home); Locations.Add(townSquare); Locations.Add(guardPost); Locations.Add(alchemistHut); Locations.Add(alchemistsGarden); Locations.Add(farmhouse); Locations.Add(farmersField); Locations.Add(bridge); Locations.Add(spiderField); Locations.Add(forestEntrance); Locations.Add(midForest); }
private static void PopulateLocations() { // Create each location Location home = new Location(LOCATION_ID_HOME, Resources.Text.strHome, Resources.Text.strHomeDesc); Location townSquare = new Location(LOCATION_ID_TOWN_SQUARE, Resources.Text.strTownSquare, Resources.Text.strTownSquareDesc); townSquare.BankAvailableHere = BankByID(BANK_ID_TOWN_SQUARE); Location alchemistHut = new Location(LOCATION_ID_ALCHEMIST_HUT, Resources.Text.strAlchemistHut, Resources.Text.strAlchemistHutDesc); alchemistHut.QuestAvailableHere = QuestByID(QUEST_ID_CLEAR_ALCHEMIST_GARDEN); Location alchemistsGarden = new Location(LOCATION_ID_ALCHEMISTS_GARDEN, Resources.Text.strAlchemistGarden, Resources.Text.strAlchemistGardenDesc); alchemistsGarden.MonsterLivingHere = MonsterByID(MONSTER_ID_RAT); Location farmhouse = new Location(LOCATION_ID_FARMHOUSE, Resources.Text.strFarmhouse, Resources.Text.strFarmhouseDesc); farmhouse.QuestAvailableHere = QuestByID(QUEST_ID_CLEAR_FARMERS_FIELD); Location farmersField = new Location(LOCATION_ID_FARM_FIELD, Resources.Text.strFarmerField, Resources.Text.strFarmerFieldDesc); farmersField.MonsterLivingHere = MonsterByID(MONSTER_ID_SNAKE); Location guardPost = new Location(LOCATION_ID_GUARD_POST, Resources.Text.strGuardPost,Resources.Text.strGuardPostDesc, ItemByID(ITEM_ID_ADVENTURER_PASS)); Location bridge = new Location(LOCATION_ID_BRIDGE, Resources.Text.strBridge, Resources.Text.strBridgeDesc); Location spiderField = new Location(LOCATION_ID_SPIDER_FIELD, Resources.Text.strForest, Resources.Text.strForestDesc); spiderField.MonsterLivingHere = MonsterByID(MONSTER_ID_GIANT_SPIDER); // Link the locations together home.LocationToNorth = townSquare; townSquare.LocationToNorth = alchemistHut; townSquare.LocationToSouth = home; townSquare.LocationToEast = guardPost; townSquare.LocationToWest = farmhouse; farmhouse.LocationToEast = townSquare; farmhouse.LocationToWest = farmersField; farmersField.LocationToEast = farmhouse; alchemistHut.LocationToSouth = townSquare; alchemistHut.LocationToNorth = alchemistsGarden; alchemistsGarden.LocationToSouth = alchemistHut; guardPost.LocationToEast = bridge; guardPost.LocationToWest = townSquare; bridge.LocationToWest = guardPost; bridge.LocationToEast = spiderField; spiderField.LocationToWest = bridge; // Add the locations to the static list Locations.Add(home); Locations.Add(townSquare); Locations.Add(guardPost); Locations.Add(alchemistHut); Locations.Add(alchemistsGarden); Locations.Add(farmhouse); Locations.Add(farmersField); Locations.Add(bridge); Locations.Add(spiderField); }
public List<Contact> GetContactsByLocation(Location location) { List<Contact> contacts = new List<Contact>(); var conn = OpenConnection; lock (conn) { using (var cmd = conn.CreateCommand()) { cmd.CommandText = "SELECT * FROM log WHERE location=?location"; cmd.Parameters.AddWithValue("?location", (location == null) ? 0 : location.ID); using (var reader = cmd.ExecuteReader()) { while (reader.Read()) contacts.Add(LoadContact(reader)); } } } return contacts; }
private void MoveTo(Location newLocation) { //Does the location have any required items if(!_player.HasRequiredItemToEnterThisLocation(newLocation)) { rtbMessages.Text += "You must have a " + newLocation.ItemRequiredToEnter.Name + " to enter this location." + Environment.NewLine; return; } // Update the player's current location _player.CurrentLocation = newLocation; // Show/hide available movement buttons btnNorth.Visible = (newLocation.LocationToNorth != null); btnEast.Visible = (newLocation.LocationToEast != null); btnSouth.Visible = (newLocation.LocationToSouth != null); btnWest.Visible = (newLocation.LocationToWest != null); // Display current location name and description rtbLocation.Text = newLocation.Name + Environment.NewLine; rtbLocation.Text += newLocation.Description + Environment.NewLine; // Completely heal the player _player.CurrentHitPoints = _player.MaximumHitPoints; // Update Hit Points in UI lblHitPoints.Text = _player.CurrentHitPoints.ToString(); // Does the location have a quest? if(newLocation.QuestAvailableHere != null) { // See if the player already has the quest, and if they've completed it bool playerAlreadyHasQuest = _player.HasThisQuest(newLocation.QuestAvailableHere); bool playerAlreadyCompletedQuest = _player.CompletedThisQuest(newLocation.QuestAvailableHere); // See if the player already has the quest if(playerAlreadyHasQuest) { // If the player has not completed the quest yet if(!playerAlreadyCompletedQuest) { // See if the player has all the items needed to complete the quest bool playerHasAllItemsToCompleteQuest = _player.HasAllQuestCompletionItems(newLocation.QuestAvailableHere); // The player has all items required to complete the quest if(playerHasAllItemsToCompleteQuest) { // Display message rtbMessages.Text += Environment.NewLine; rtbMessages.Text += "You complete the '" + newLocation.QuestAvailableHere.Name + "' quest." + Environment.NewLine; // Remove quest items from inventory _player.RemoveQuestCompletionItems(newLocation.QuestAvailableHere); // Give quest rewards rtbMessages.Text += "You receive: " + Environment.NewLine; rtbMessages.Text += newLocation.QuestAvailableHere.RewardExperiencePoints.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.AddExperiencePoints(newLocation.QuestAvailableHere.RewardExperiencePoints); _player.Gold += newLocation.QuestAvailableHere.RewardGold; // Add the reward item to the player's inventory _player.AddItemToInventory(newLocation.QuestAvailableHere.RewardItem); // Mark the quest as completed _player.MarkQuestCompleted(newLocation.QuestAvailableHere); } } } else { // The player does not already have the quest // Display the messages 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; // Add the quest to the player's quest list _player.Quests.Add(new PlayerQuest(newLocation.QuestAvailableHere)); } } // Does the location have a monster? if(newLocation.MonsterLivingHere != null) { rtbMessages.Text += "You see a " + newLocation.MonsterLivingHere.Name + Environment.NewLine; // Make a new monster, using the values from the standard monster in the World.Monster list Monster standardMonster = World.MonsterByID(newLocation.MonsterLivingHere.ID); _currentMonster = new Monster(standardMonster.ID, standardMonster.Name, standardMonster.MaximumDamage, standardMonster.RewardExperiencePoints, standardMonster.RewardGold, standardMonster.CurrentHitPoints, standardMonster.MaximumHitPoints); foreach(LootItem lootItem in standardMonster.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; } // Refresh player's stats UpdatePlayerStats(); // Refresh player's inventory list UpdateInventoryListInUI(); // Refresh player's quest list UpdateQuestListInUI(); // Refresh player's weapons combobox UpdateWeaponListInUI(); // Refresh player's potions combobox UpdatePotionListInUI(); ScrollToBottomOfMessages(); }
public Location LoadLocation(int id) { MySqlConnection conn = OpenConnection; lock (conn) { using (MySqlCommand cmd = conn.CreateCommand()) { cmd.CommandText = "SELECT * FROM locations WHERE id=?id;"; cmd.Parameters.AddWithValue("?id", id); using (MySqlDataReader reader = cmd.ExecuteReader()) { if (!reader.Read()) return null; Location l = new Location { ID = id, Club = reader.GetString("club"), IotaName = reader.GetString("iotaname"), IotaRef = reader.GetString("iotaref"), Locator = reader.GetString("locator"), Wab = reader.GetString("wab"), }; return l; } } } }
private static void PopulateLocations() { Location home = new Location(LOCATION_INDEX_HOME, "Home", "Your house. What a mess"); Location townSquare = new Location(LOCATION_INDEX_TOWN_SQUARE, "Town Square", "You see a fountain"); Location alchemistHut = new Location(LOCATION_INDEX_ALCHEMIST_HUT, "Alchemists Hut", "There are many strange plants on the shelves"); alchemistHut.QuestAvailableHere = QuestByID(QUEST_INDEX_CLEAR_ALCHEMIST_GARDEN); Location alchemistGard = new Location(LOCATION_INDEX_ALCHEMIST_GARDEN, "Alchemist Garden", "Many plants are growing here"); alchemistGard.MonstersHere = MonsterById(MONSTER_INDEX_RAT); Location farmhouse = new Location(LOCATION_INDEX_FARMHOUSE, "Farmhouse", "There is a small farmhouse, with a farmer in front"); farmhouse.QuestAvailableHere = QuestByID(QUEST_INDEX_CLEAR_FARMERS_FIELD); Location farmersField = new Location(LOCATION_INDEX_FARMFIELD, "Farm Field", "You see rows of Vegatables growing here"); farmersField.MonstersHere = MonsterById(MONSTER_INDEX_SNAKE); Location guardPost = new Location(LOCATION_INDEX_GUARD_POST, "Guard post", "There is a large, tough looking guard here.", ItemByID(ITEM_INDEX009)); guardPost.QuestAvailableHere = QuestByID(QUEST_INDEX_CLEAR_SPIDERS); Location bridge = new Location(LOCATION_INDEX_BRIDGE, "Bridge", "A stone bridge crosses the wide river"); Location spiderField = new Location(LOCATION_INDEX_SPIDERFIELD, "Forest", "You see spider webs covering the trees in the forest"); spiderField.MonstersHere = MonsterById(MONSTER_INDEX_GIANT_SPIDER); home.LocationToNorth = townSquare; townSquare.LocationToNorth = alchemistHut; townSquare.LocationToSouth = home; townSquare.LocationToEast = guardPost; townSquare.LocationToWest = farmhouse; farmhouse.LocationToEast = townSquare; farmhouse.LocationToWest = farmersField; farmersField.LocationToEast = farmhouse; alchemistHut.LocationToSouth = townSquare; alchemistHut.LocationToNorth = alchemistGard; alchemistGard.LocationToSouth = alchemistHut; guardPost.LocationToEast = bridge; guardPost.LocationToWest = townSquare; bridge.LocationToWest = guardPost; bridge.LocationToEast = spiderField; spiderField.LocationToWest = bridge; Locations.Add(home); Locations.Add(townSquare); Locations.Add(guardPost); Locations.Add(alchemistHut); Locations.Add(alchemistGard); Locations.Add(farmersField); Locations.Add(farmhouse); Locations.Add(bridge); Locations.Add(spiderField); }
private void MoveTo(Location newLocation) { //Does the location have any required items if (!_player.HasRequiredItemToEnterThisLocation(newLocation)) { rtbMessages.Text += RmLoc.GetString("strPlayerMustHave") + newLocation.ItemRequiredToEnter.Name + RmLoc.GetString("strPlayerToEnter") + Environment.NewLine; ScrollToBottomOfMessages(); return; } // Update the player's current location _player.CurrentLocation = newLocation; // Show/hide available movement buttons btnNorth.Visible = (newLocation.LocationToNorth != null); btnEast.Visible = (newLocation.LocationToEast != null); btnSouth.Visible = (newLocation.LocationToSouth != null); btnWest.Visible = (newLocation.LocationToWest != null); // Display current location name and description rtbLocation.Text = newLocation.Name + Environment.NewLine; rtbLocation.Text += newLocation.Description + Environment.NewLine; pnBank.Visible = (newLocation.BankAvailableHere != null); if (newLocation.BankAvailableHere != null) { Bank bank = World.BankByID( newLocation.BankAvailableHere.ID); if(bank.AvailableGold != 0) { txtAvailableGold.Text = bank.AvailableGold.ToString(); } else { txtAvailableGold.Text = "0"; } rtbLocation.Text += RmLoc.GetString("strPlayerSeeA") + bank.Name+ Environment.NewLine; ScrollToBottomOfMessages(); } // Completely heal the player _player.CurrentHitPoints = _player.MaximumHitPoints; // Update Hit Points in UI lblHitPoints.Text = _player.CurrentHitPoints.ToString(); // Does the location have a quest? if (newLocation.QuestAvailableHere != null) { // See if the player already has the quest, and if they've completed it bool playerAlreadyHasQuest = _player.HasThisQuest(newLocation.QuestAvailableHere); bool playerAlreadyCompletedQuest = _player.CompletedThisQuest(newLocation.QuestAvailableHere); // See if the player already has the quest if (playerAlreadyHasQuest) { // If the player has not completed the quest yet if (!playerAlreadyCompletedQuest) { // See if the player has all the items needed to complete the quest bool playerHasAllItemsToCompleteQuest = _player.HasAllQuestCompletionItems(newLocation.QuestAvailableHere); // The player has all items required to complete the quest if (playerHasAllItemsToCompleteQuest) { // Display message rtbMessages.Text += Environment.NewLine; rtbMessages.Text += RmLoc.GetString("strQuestComplete")+ newLocation.QuestAvailableHere.Name + Environment.NewLine; ScrollToBottomOfMessages(); // Remove quest items from inventory _player.RemoveQuestCompletionItems(newLocation.QuestAvailableHere); // Give quest rewards rtbMessages.Text += RmLoc.GetString("strRewardReceive") + Environment.NewLine; rtbMessages.Text += newLocation.QuestAvailableHere.RewardExperiencePoints.ToString() + RmLoc.GetString("strRewardExperience") + Environment.NewLine; rtbMessages.Text += newLocation.QuestAvailableHere.RewardGold.ToString() + RmLoc.GetString("strRewardGold") + Environment.NewLine; rtbMessages.Text += newLocation.QuestAvailableHere.RewardItem.Name + Environment.NewLine; rtbMessages.Text += Environment.NewLine; ScrollToBottomOfMessages(); _player.ExperiencePoints += newLocation.QuestAvailableHere.RewardExperiencePoints; _player.Gold += newLocation.QuestAvailableHere.RewardGold; // Add the reward item to the player's inventory _player.AddItemToInventory(newLocation.QuestAvailableHere.RewardItem); // Mark the quest as completed _player.MarkQuestCompleted(newLocation.QuestAvailableHere); lblExperience.Text = _player.ExperiencePoints.ToString(); } } } else { // The player does not already have the quest // Display the messages rtbMessages.Text += RmLoc.GetString("strQuestReceive") + newLocation.QuestAvailableHere.Name + Environment.NewLine; rtbMessages.Text += newLocation.QuestAvailableHere.Description + Environment.NewLine; rtbMessages.Text += RmLoc.GetString("strQuestToComplete") + 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; ScrollToBottomOfMessages(); // Add the quest to the player's quest list _player.Quests.Add(new PlayerQuest(newLocation.QuestAvailableHere)); } } // Does the location have a monster? if (newLocation.MonsterLivingHere != null) { rtbMessages.Text += RmLoc.GetString("strPlayerSeeA") + newLocation.MonsterLivingHere.Name + Environment.NewLine; ScrollToBottomOfMessages(); // Make a new monster, using the values from the standard monster in the World.Monster list Monster standardMonster = World.MonsterByID(newLocation.MonsterLivingHere.ID); _currentMonster = new Monster(standardMonster.ID, standardMonster.Name, standardMonster.MaximumDamage, standardMonster.RewardExperiencePoints, standardMonster.RewardGold, standardMonster.CurrentHitPoints, standardMonster.MaximumHitPoints, standardMonster.AggroProbability); if(_currentMonster.AggroProbability == 0) { rtbMessages.Text += RmLoc.GetString("strNotAggro") + Environment.NewLine; } else { if (RandomNumberGenerator.NumberBetween(1, 100) >= _currentMonster.AggroProbability) { rtbMessages.Text += RmLoc.GetString("strAggroTrue") + Environment.NewLine; int damageToPlayer = RandomNumberGenerator.NumberBetween(0, _currentMonster.MaximumDamage); // Display message rtbMessages.Text += RmLoc.GetString("strThe") + _currentMonster.Name + RmLoc.GetString("strDid") + damageToPlayer.ToString() + RmLoc.GetString("strDamagePoints") + Environment.NewLine; ScrollToBottomOfMessages(); // Subtract damage from player _player.CurrentHitPoints -= damageToPlayer; // Refresh player data in UI lblHitPoints.Text = _player.CurrentHitPoints.ToString(); if (_player.CurrentHitPoints <= 0) { // Display message rtbMessages.Text += RmLoc.GetString("strThe") + _currentMonster.Name + RmLoc.GetString("strKilledYou") + Environment.NewLine; ScrollToBottomOfMessages(); // Move player to "Home" MoveTo(World.LocationByID(World.LOCATION_ID_HOME)); } } else { rtbMessages.Text += RmLoc.GetString("strAggroFalse") + Environment.NewLine; ScrollToBottomOfMessages(); } } foreach (LootItem lootItem in standardMonster.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; } // Refresh player's inventory list UpdateInventoryListInUI(); // Refresh player's quest list UpdateQuestListInUI(); // Refresh player's weapons combobox UpdateWeaponListInUI(); // Refresh player's potions combobox UpdatePotionListInUI(); }