Images for weapons and potions
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.ComponentModel; | |
using System.Data; | |
using System.Drawing; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
using System.Windows.Forms; | |
using Engine; | |
using System.IO; | |
namespace MyLittleRPG | |
{ | |
public partial class MyLittleRPG : Form | |
{ | |
private Player _player; | |
private Monster _currentmonster; | |
private const string PLAYER_DATA_FILE_NAME = "PlayerData.xml"; | |
public MyLittleRPG() | |
{ | |
InitializeComponent(); | |
//Create new player + giving base stats | |
if (File.Exists(PLAYER_DATA_FILE_NAME)) | |
{ | |
_player = Player.CreatePlayerFromXmlString(File.ReadAllText(PLAYER_DATA_FILE_NAME)); | |
} | |
else | |
{ | |
_player = Player.CreateDefaultPlayer(); | |
} | |
lblHitPoints.DataBindings.Add("Text", _player, "CurrentHitPoints"); | |
lblGold.DataBindings.Add("Text", _player, "Gold"); | |
lblExperience.DataBindings.Add("Text", _player, "ExperiencePoints"); | |
lblLevel.DataBindings.Add("Text", _player, "Level"); | |
MoveTo(_player.CurrentLocation); | |
pctPlayer.Image = Properties.Resources.HumanWithSword; | |
} | |
private void btnNorth_Click(object sender, EventArgs e) | |
{ | |
MoveTo(_player.CurrentLocation.LocationToNorth); | |
ScrollToBottomMessages(); | |
} | |
private void btnEast_Click(object sender, EventArgs e) | |
{ | |
MoveTo(_player.CurrentLocation.LocationToEast); | |
ScrollToBottomMessages(); | |
} | |
private void btnSouth_Click(object sender, EventArgs e) | |
{ | |
MoveTo(_player.CurrentLocation.LocationToSouth); | |
ScrollToBottomMessages(); | |
} | |
private void btnWest_Click(object sender, EventArgs e) | |
{ | |
MoveTo(_player.CurrentLocation.LocationToWest); | |
ScrollToBottomMessages(); | |
} | |
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; | |
ScrollToBottomMessages(); | |
return; | |
} | |
//Update the player's current location | |
_player.CurrentLocation = newLocation; | |
//Show/hide available movement buttons | |
btnNorth.Enabled = (newLocation.LocationToNorth != null); | |
btnEast.Enabled = (newLocation.LocationToEast != null); | |
btnSouth.Enabled = (newLocation.LocationToSouth != null); | |
btnWest.Enabled = (newLocation.LocationToWest != null); | |
//Display current location name and description | |
rtbLocation.Text = newLocation.Name + Environment.NewLine; | |
rtbLocation.Text += newLocation.Description + Environment.NewLine; | |
//Completely heal player | |
_player.CurrentHitPoints = _player.MaximumHitPoints; | |
//Does location have quest | |
if (newLocation.QuestAvailableHere != null) | |
{ | |
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) | |
{ | |
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; | |
ScrollToBottomMessages(); | |
//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; | |
ScrollToBottomMessages(); | |
_player.AddExperiencePoints(newLocation.QuestAvailableHere.RewardExperiencePoints); | |
_player.Gold += newLocation.QuestAvailableHere.RewardGold; | |
//add the reward item in inventory | |
_player.AddItemToInventory(newLocation.QuestAvailableHere.RewardItem); | |
//mark quest as completed | |
_player.MarkQuestCompleted(newLocation.QuestAvailableHere); | |
} | |
} | |
} | |
else | |
{ | |
//player does not have quest | |
//display message | |
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 kk in newLocation.QuestAvailableHere.QuestCompletionItems) | |
{ | |
if (kk.Quantity == 1) | |
{ | |
rtbMessages.Text += kk.Quantity.ToString() + " " + kk.Details.Name + Environment.NewLine; | |
} | |
else | |
{ | |
rtbMessages.Text += kk.Quantity.ToString() + " " + kk.Details.NamePlural + Environment.NewLine; | |
} | |
} | |
rtbMessages.Text += Environment.NewLine; | |
ScrollToBottomMessages(); | |
//add the quest to the player's quest list | |
_player.Quests.Add(new PlayerQuest(newLocation.QuestAvailableHere)); | |
} | |
} | |
//does the location have monster | |
if (newLocation.MonsterLivingHere != null) | |
{ | |
rtbMessages.Text += "You see a " + newLocation.MonsterLivingHere.Name + Environment.NewLine; | |
//make new monster | |
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 item in standardMonster.LootTable) | |
{ | |
_currentmonster.LootTable.Add(item); | |
} | |
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 inventory list | |
UpdateInventoryListInUI(); | |
//refresh quest list on screen | |
UpdateQuestListInUI(); | |
//Refresh weapons | |
UpdateWeaponListInUI(); | |
//Refresh player's potion combobox | |
UpdatePotionListInUI(); | |
} | |
private void UpdateInventoryListInUI() | |
{ | |
dgvInventory.RowHeadersVisible = false; | |
dgvInventory.ColumnCount = 2; | |
dgvInventory.Columns[0].Name = "Name"; | |
dgvInventory.Columns[0].Width = 185; | |
dgvInventory.Columns[1].Name = "Quantity"; | |
dgvInventory.Rows.Clear(); | |
foreach (InventoryItem item in _player.Inventory) | |
{ | |
if (item.Quantity > 0) | |
{ | |
dgvInventory.Rows.Add(new[] { item.Details.Name, item.Quantity.ToString() }); | |
} | |
} | |
} | |
private void UpdateQuestListInUI() | |
{ | |
dgvQuests.RowHeadersVisible = false; | |
dgvQuests.ColumnCount = 2; | |
dgvQuests.Columns[0].Name = "Name"; | |
dgvQuests.Columns[0].Width = 185; | |
dgvQuests.Columns[1].Name = "Done?"; | |
dgvQuests.Rows.Clear(); | |
foreach (PlayerQuest item in _player.Quests) | |
{ | |
dgvQuests.Rows.Add(new[] { item.Details.Name, item.IsCompleted.ToString() }); | |
} | |
} | |
private void UpdateWeaponListInUI() | |
{ | |
List<Weapon> weapons = new List<Weapon>(); | |
foreach (InventoryItem item in _player.Inventory) | |
{ | |
if (item.Details is Weapon) | |
{ | |
if (item.Quantity>0) | |
{ | |
weapons.Add((Weapon)item.Details); | |
} | |
} | |
} | |
if (weapons.Count==0) | |
{ | |
//player doesn't have weapons | |
cboWeapons.Visible = false; | |
btnUseWeapon.Visible = false; | |
} | |
else | |
{ | |
cboWeapons.SelectedIndexChanged -= cboWeapons_SelectedIndexChanged; | |
cboWeapons.DataSource = weapons; | |
cboWeapons.SelectedIndexChanged += cboWeapons_SelectedIndexChanged; | |
cboWeapons.DisplayMember = "Name"; | |
cboWeapons.ValueMember = "ID"; | |
if (_player.CurrentWeapon!= null) | |
{ | |
cboWeapons.SelectedItem = _player.CurrentWeapon; | |
} | |
else | |
{ | |
cboWeapons.SelectedIndex = 0; | |
_player.CurrentWeapon = cboWeapons.SelectedItem as Weapon; | |
} | |
} | |
pctWeapon.Image = _player.CurrentWeapon?.Picture; | |
} | |
private void UpdatePotionListInUI() | |
{ | |
List<HealingPotion> healingPotions = new List<HealingPotion>(); | |
foreach (InventoryItem item in _player.Inventory) | |
{ | |
if (item.Details is HealingPotion) | |
{ | |
if (item.Quantity > 0) | |
{ | |
healingPotions.Add((HealingPotion)item.Details); | |
} | |
} | |
} | |
if (healingPotions.Count == 0) | |
{ | |
//player doesn't have weapons | |
cboPotions.Visible = false; | |
btnUsePotion.Visible = false; | |
pctHealing.Image = null; | |
} | |
else | |
{ | |
cboPotions.DataSource = healingPotions; | |
cboPotions.DisplayMember = "Name"; | |
cboWeapons.ValueMember = "ID"; | |
cboPotions.SelectedIndex = 0; | |
pctHealing.Image = (cboPotions.SelectedItem as HealingPotion)?.Picture; | |
} | |
} | |
private void btnUseWeapon_Click(object sender, EventArgs e) | |
{ | |
//get the currently selected weapon | |
Weapon currentWeapon = (Weapon)cboWeapons.SelectedItem; | |
//Determine the amount of damage to do to the monster | |
int damageToMonster = RandomNumberGenerator.NumberBetween(currentWeapon.MinimumDamage, currentWeapon.MaximumDamage); | |
//Apply the damage to the monster's CurrentHitPoints | |
_currentmonster.CurrentHitPoints -= damageToMonster; | |
//display message | |
rtbMessages.Text += "You hit the " + _currentmonster.Name + " for " + damageToMonster.ToString() + " points." + Environment.NewLine; | |
ScrollToBottomMessages(); | |
//Check if monster = dead | |
if (_currentmonster.CurrentHitPoints<=0) | |
{ | |
//monster is dead | |
rtbMessages.Text += Environment.NewLine; | |
rtbMessages.Text += "You defeated the " + _currentmonster.Name + Environment.NewLine; | |
//give exp | |
_player.AddExperiencePoints( _currentmonster.RewardExperiencePoints); | |
rtbMessages.Text += "You receive " + _currentmonster.RewardExperiencePoints.ToString() + " experience points" + Environment.NewLine; | |
//give gold | |
_player.Gold += _currentmonster.RewardGold; | |
rtbMessages.Text += "You receive " + _currentmonster.RewardGold.ToString() + " gold" + Environment.NewLine; | |
ScrollToBottomMessages(); | |
//get random loot | |
List<InventoryItem> lootedItems = new List<InventoryItem>(); | |
//add items to the lootedItems list, comparing a random number to get the drop % | |
foreach (LootItem item in _currentmonster.LootTable) | |
{ | |
if (RandomNumberGenerator.NumberBetween(1,100) <= item.DropPercentage) | |
{ | |
lootedItems.Add(new InventoryItem(item.Details, 1)); | |
} | |
} | |
//if no items were randomly selected, then add default | |
if (lootedItems.Count==0) | |
{ | |
foreach (LootItem ii in _currentmonster.LootTable) | |
{ | |
if (ii.IsDefaultItem) | |
{ | |
lootedItems.Add(new InventoryItem(ii.Details, 1)); | |
} | |
} | |
} | |
//add the looted items to the players inventory | |
foreach (InventoryItem ii in lootedItems) | |
{ | |
_player.AddItemToInventory(ii.Details); | |
if (ii.Quantity ==1) | |
{ | |
rtbMessages.Text += "You loot " + ii.Quantity.ToString() + " " + ii.Details.Name + Environment.NewLine; | |
} | |
else | |
{ | |
rtbMessages.Text += "You loot " + ii.Quantity.ToString() + " " + ii.Details.NamePlural + Environment.NewLine; | |
} | |
} | |
//refresh player info and inventory controls | |
UpdateInventoryListInUI(); | |
UpdateWeaponListInUI(); | |
UpdatePotionListInUI(); | |
//add a blank line to the message box for appearance | |
rtbMessages.Text += Environment.NewLine; | |
ScrollToBottomMessages(); | |
//Move player to current location to heal and create new monster | |
MoveTo(_player.CurrentLocation); | |
} | |
else | |
{ | |
//Monster is still alive | |
//Determine the amount of damage the monster does | |
int damageToPlayer = RandomNumberGenerator.NumberBetween(0, _currentmonster.MaximumDamage); | |
//Display message | |
rtbMessages.Text += "The " + _currentmonster.Name + " did " + damageToPlayer.ToString() + " points of damage." + | |
Environment.NewLine; | |
ScrollToBottomMessages(); | |
//subtract damage from player | |
_player.CurrentHitPoints -= damageToPlayer; | |
if (_player.CurrentHitPoints <= 0) | |
{ | |
//Display message | |
rtbMessages.Text += "The " + _currentmonster.Name + " killed you." + Environment.NewLine; | |
//move player to home | |
MoveTo(World.LocationByID(World.LOCATION_ID_HOME)); | |
ScrollToBottomMessages(); | |
} | |
} | |
} | |
private void btnUsePotion_Click(object sender, EventArgs e) | |
{ | |
//get the currently selected potion from the combobox | |
HealingPotion potion = (HealingPotion)cboPotions.SelectedItem; | |
//Add healing amount to the player's current hit points | |
_player.CurrentHitPoints = (_player.CurrentHitPoints + potion.AmountToHeal); | |
//CurrentHitPoints cannot exceed player's MaximumHitpoints | |
if (_player.CurrentHitPoints>_player.MaximumHitPoints) | |
{ | |
_player.CurrentHitPoints = _player.MaximumHitPoints; | |
} | |
//remove the potion | |
foreach (InventoryItem item in _player.Inventory) | |
{ | |
if (item.Details.ID == potion.ID) | |
{ | |
item.Quantity--; | |
break; | |
} | |
} | |
//display message | |
rtbMessages.Text += "You drink a " + potion.Name + Environment.NewLine; | |
//Determine the amount of damage the monster does | |
int damageToPlayer = RandomNumberGenerator.NumberBetween(0, _currentmonster.MaximumDamage); | |
//Display message | |
rtbMessages.Text += "The " + _currentmonster.Name + " did " + damageToPlayer.ToString() + " points of damage." + | |
Environment.NewLine; | |
ScrollToBottomMessages(); | |
//subtract damage from player | |
_player.CurrentHitPoints -= damageToPlayer; | |
//refresh player UI | |
if (_player.CurrentHitPoints <= 0) | |
{ | |
//Display message | |
rtbMessages.Text += "The " + _currentmonster.Name + " killed you." + Environment.NewLine; | |
//move player to home | |
MoveTo(World.LocationByID(World.LOCATION_ID_HOME)); | |
ScrollToBottomMessages(); | |
} | |
//Refresh player UI | |
UpdateInventoryListInUI(); | |
UpdatePotionListInUI(); | |
} | |
private void ScrollToBottomMessages() | |
{ | |
rtbMessages.SelectionStart = rtbMessages.Text.Length; | |
rtbMessages.ScrollToCaret(); | |
} | |
private void MyLittleRPG_FormClosing(object sender, FormClosingEventArgs e) | |
{ | |
File.WriteAllText(PLAYER_DATA_FILE_NAME, _player.ToXmlString()); | |
} | |
private void cboWeapons_SelectedIndexChanged(object sender, EventArgs e) | |
{ | |
_player.CurrentWeapon = (Weapon)cboWeapons.SelectedItem; | |
pctWeapon.Image = _player.CurrentWeapon?.Picture; | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
namespace Engine | |
{ | |
public class HealingPotion : Item | |
{ | |
public int AmountToHeal { get; set; } | |
public HealingPotion(int id,string name, string namePlural,int amountToHeal, System.Drawing.Image picture) : base(id,name,namePlural, picture) | |
{ | |
AmountToHeal = amountToHeal; | |
} | |
} | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using System; | |
using System.Collections.Generic; | |
using System.Linq; | |
using System.Text; | |
using System.Threading.Tasks; | |
namespace Engine | |
{ | |
public static class World | |
{ | |
public static readonly List<Item> Items = new List<Item>(); | |
public static readonly List<Monster> Monsters = new List<Monster>(); | |
public static readonly List<Quest> Quests = new List<Quest>(); | |
public static readonly List<Location> Locations = new List<Location>(); | |
public const int ITEM_ID_RUSTY_SWORD = 1; | |
public const int ITEM_ID_RAT_TAIL = 2; | |
public const int ITEM_ID_PIECE_OF_FUR = 3; | |
public const int ITEM_ID_SNAKE_FANG = 4; | |
public const int ITEM_ID_SNAKESKIN = 5; | |
public const int ITEM_ID_CLUB = 6; | |
public const int ITEM_ID_HEALING_POTION = 7; | |
public const int ITEM_ID_SPIDER_FANG = 8; | |
public const int ITEM_ID_SPIDER_SILK = 9; | |
public const int ITEM_ID_ADVENTURER_PASS = 10; | |
public const int MONSTER_ID_RAT = 1; | |
public const int MONSTER_ID_SNAKE = 2; | |
public const int MONSTER_ID_GIANT_SPIDER = 3; | |
public const int QUEST_ID_CLEAR_ALCHEMIST_GARDEN = 1; | |
public const int QUEST_ID_CLEAR_FARMERS_FIELD = 2; | |
public const int LOCATION_ID_HOME = 1; | |
public const int LOCATION_ID_TOWN_SQUARE = 2; | |
public const int LOCATION_ID_GUARD_POST = 3; | |
public const int LOCATION_ID_ALCHEMISTS_HUT = 4; | |
public const int LOCATION_ID_ALCHEMISTS_GARDEN = 5; | |
public const int LOCATION_ID_FARMHOUSE = 6; | |
public const int LOCATION_ID_FARM_FIELD = 7; | |
public const int LOCATION_ID_BRIDGE = 8; | |
public const int LOCATION_ID_SPIDER_FIELD = 9; | |
static World() | |
{ | |
PopulateItems(); | |
PopulateMonsters(); | |
PopulateQuests(); | |
PopulateLocations(); | |
} | |
public static Item ItemByID(int id) | |
{ | |
foreach (Item item in Items) | |
{ | |
if (item.ID==id) | |
{ | |
return item; | |
} | |
} | |
return null; | |
} | |
public static Monster MonsterByID(int id) | |
{ | |
foreach (Monster monster in Monsters) | |
{ | |
if (monster.ID==id) | |
{ | |
return monster; | |
} | |
} | |
return null; | |
} | |
public static Quest QuestByID(int id) | |
{ | |
foreach (Quest quest in Quests) | |
{ | |
if (quest.ID==id) | |
{ | |
return quest; | |
} | |
} | |
return null; | |
} | |
public static Location LocationByID(int id) | |
{ | |
foreach (Location location in Locations) | |
{ | |
if (location.ID ==id) | |
{ | |
return location; | |
} | |
} | |
return null; | |
} | |
private static void PopulateItems() | |
{ | |
//Weapons | |
Items.Add(new Weapon(ITEM_ID_RUSTY_SWORD, "Rusty sword", "Rusty swords", 0, 5, Properties.Resources.Rusty_Sword_WithBackground)); | |
Items.Add(new Weapon(ITEM_ID_CLUB, "Club", "Clubs", 3, 10,Properties.Resources.Club_WithBackGround)); | |
//Items | |
Items.Add(new Item(ITEM_ID_RAT_TAIL, "Rat tail", "Rat tails")); | |
Items.Add(new Item(ITEM_ID_PIECE_OF_FUR, "Piece of fur", "Pieces of fur")); | |
Items.Add(new Item(ITEM_ID_SNAKE_FANG, "Snake fang", "Snake fangs")); | |
Items.Add(new Item(ITEM_ID_SNAKESKIN, "Snakeskin", "Snakeskins")); | |
Items.Add(new Item(ITEM_ID_SPIDER_FANG, "Spider fang", "Spider fangs")); | |
Items.Add(new Item(ITEM_ID_SPIDER_SILK, "Spider silk", "Spider silks")); | |
Items.Add(new Item(ITEM_ID_ADVENTURER_PASS, "Adventurer pass", "Adventurer passes")); | |
//Healing | |
Items.Add(new HealingPotion(ITEM_ID_HEALING_POTION, "Healing potion", "Healing potions", 5, Properties.Resources.HealingPotion_WithBackGround2)); | |
} | |
private static void PopulateMonsters() | |
{ | |
Monster rat = new Monster(MONSTER_ID_RAT, "Rat", 5, 3, 10, 3, 3); | |
rat.LootTable.Add(new LootItem(ItemByID(ITEM_ID_RAT_TAIL), 75, false)); | |
rat.LootTable.Add(new LootItem(ItemByID(ITEM_ID_PIECE_OF_FUR), 75, true)); | |
Monster snake = new Monster(MONSTER_ID_SNAKE, "Snake", 5, 3, 10, 3, 3); | |
snake.LootTable.Add(new LootItem(ItemByID(ITEM_ID_SNAKE_FANG), 75, false)); | |
snake.LootTable.Add(new LootItem(ItemByID(ITEM_ID_SNAKESKIN), 75, true)); | |
Monster giantSpider = new Monster(MONSTER_ID_GIANT_SPIDER, "Giant spider", 20, 5, 40, 10, 10); | |
giantSpider.LootTable.Add(new LootItem(ItemByID(ITEM_ID_SPIDER_FANG), 75, true)); | |
giantSpider.LootTable.Add(new LootItem(ItemByID(ITEM_ID_SPIDER_SILK), 25, false)); | |
Monsters.Add(rat); | |
Monsters.Add(snake); | |
Monsters.Add(giantSpider); | |
} | |
private static void PopulateQuests() | |
{ | |
Quest clearAlchemistGarden = new Quest(QUEST_ID_CLEAR_ALCHEMIST_GARDEN, "Clear the alchemist's garden", | |
"Kill rats in the alchemist's garden and bring back 3 rat tails. " + | |
"You will receive a healing potion and 10 gold pieces.", 20, 10); | |
clearAlchemistGarden.QuestCompletionItems.Add(new QuestCompletionItem(ItemByID(ITEM_ID_RAT_TAIL), 3)); | |
clearAlchemistGarden.RewardItem = ItemByID(ITEM_ID_HEALING_POTION); | |
Quest clearFarmersField = new Quest(QUEST_ID_CLEAR_FARMERS_FIELD, "Clear the farmer's field", | |
"Kill snakes in the farmer's field and bring back 3 snake fangs. " + | |
"You will receive an adventurer's pass and 20 gold pieces.", 20, 20); | |
clearFarmersField.QuestCompletionItems.Add(new QuestCompletionItem(ItemByID(ITEM_ID_SNAKE_FANG), 3)); | |
clearFarmersField.RewardItem = ItemByID(ITEM_ID_ADVENTURER_PASS); | |
Quests.Add(clearAlchemistGarden); | |
Quests.Add(clearFarmersField); | |
} | |
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_ALCHEMISTS_HUT, "Alchemist's hut", "There are many strange plants on the shelves."); | |
Location alchemistGarden = new Location(LOCATION_ID_ALCHEMISTS_GARDEN, "Alchemist's garden", "Many plants are growing here."); | |
Location farmhouse = new Location(LOCATION_ID_FARMHOUSE, "Farmhouse", "There is a small farmhouse, with a farmer in front."); | |
Location farmersField = new Location(LOCATION_ID_FARM_FIELD, "Farmer's field", "You see rows of vegetables growing here."); | |
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 the trees in this forest."); | |
//Monsters living in locations | |
alchemistGarden.MonsterLivingHere = MonsterByID(MONSTER_ID_RAT); | |
farmersField.MonsterLivingHere = MonsterByID(MONSTER_ID_SNAKE); | |
spiderField.MonsterLivingHere = MonsterByID(MONSTER_ID_GIANT_SPIDER); | |
//Quests at locations | |
alchemistHut.QuestAvailableHere = QuestByID(QUEST_ID_CLEAR_ALCHEMIST_GARDEN); | |
farmhouse.QuestAvailableHere = QuestByID(QUEST_ID_CLEAR_FARMERS_FIELD); | |
//Linking the locations | |
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 = alchemistGarden; | |
alchemistGarden.LocationToSouth = alchemistHut; | |
guardPost.LocationToEast = bridge; | |
guardPost.LocationToWest = townSquare; | |
bridge.LocationToWest = guardPost; | |
bridge.LocationToEast = spiderField; | |
spiderField.LocationToWest = bridge; | |
// Add locations to static list | |
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); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment