Ejemplo n.º 1
0
 //construct the damn thing the way that i want
 public Location(int id, string name, string description, Item itemRequiredToEnter = null, Quest questAvailableHere = null, Monster monsterLivingHere = null) {
     ID = id;
     Name = name;
     Description = description;
     ItemRequiredToEnter = itemRequiredToEnter;
     QuestAvailableHere = questAvailableHere;
     MonsterLivingHere = monsterLivingHere;
 }
Ejemplo n.º 2
0
 public Location(int id, string name, string description, Item itemrequred = null, Quest questAvailHere = null, Monster monstersHere = null)
 {
     Index = id;
     Name = name;
     Description = description;
     ItemRequiredToEnter = itemrequred;
     QuestAvailableHere = questAvailHere;
     MonstersHere = monstersHere;
 }
Ejemplo n.º 3
0
 public Item(int id, string name, string namePlural, Item itemRequiredToEnter = null, Quest questAvailableHere = null,
     Monster monsterLivingHere = null)
 {
     ID = id;
     Name = name;
     NamePlural = namePlural;
     ItemRequiredToEnter = itemRequiredToEnter;
     QuestAvailableHere = questAvailableHere;
     MonsterLivingHere = monsterLivingHere;
 }
Ejemplo n.º 4
0
 public Location(int ID, string Name, string Description, Item ItemRequiredToEnter = null, Quest QuestAvailableHere = null,
     Monster MonsterLivingHere = null)
 {
     this.ID = ID;
     this.Name = Name;
     this.Description = Description;
     this.ItemRequiredToEnter = ItemRequiredToEnter;
     this.QuestAvailableHere = QuestAvailableHere;
     this.MonsterLivingHere = MonsterLivingHere;
 }
Ejemplo n.º 5
0
        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);
        }
Ejemplo n.º 6
0
        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, false));

            Monster snake = new Engine.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_SNAKESIN), 75, true));

            Monster giantSpider = new Engine.Monster(MONSTER_ID_GIANT_SPIDER, "Giant Spider", 5, 3, 10, 3, 3);

            giantSpider.LootTable.Add(new LootItem(ItemByID(ITEM_ID_SPIDER_FANG), 75, true));
            giantSpider.LootTable.Add(new LootItem(ItemByID(ITEM_ID_SPIDER_SILK), 75, false));

            Monsters.Add(rat);
            Monsters.Add(snake);
            Monsters.Add(giantSpider);
        }
Ejemplo n.º 7
0
        public void Start_Combat(Monster _mob, Character _char, Weapon _weap, RichTextBox myLabel)
        {
            this.mob = _mob;
            this.player = _char;
            this.Weapon_Min_Damage = _weap.Min_Damage;
            this.Weapon_Max_Damage = _weap.Max_Damage;
            rtBox = myLabel;

            //Player Attack Mob
            int tempIncDmg = 0;
            tempIncDmg = Damage_Dealt();
            mob.CurrentHP -= tempIncDmg;

            DamageOutPut("Damage Dealt : " + tempIncDmg.ToString() + "\r\n", 0);

            if (mob.CurrentHP > 0 && _roundNumber != MAX_ROUND)
            {
                _roundNumber++;
            }
            else if (mob.CurrentHP <= 0)
            {
                DamageOutPut("You killed : " + mob.Name + " in " + _roundNumber.ToString() + " round(s)" + "\r\n", 4);
                WinLose = true;
                InCombat = false;
                _roundNumber = 0;
                return;
            }

            //Mob Attack player
            int tempOutDmg = 0;
            tempOutDmg = Damage_Taken();
            player.Player_Current_Health -= tempOutDmg;

            DamageOutPut("Damage Taken : " + tempOutDmg.ToString() + "\r\n", 1);

            if (player.Player_Current_Health > 0 && _roundNumber != MAX_ROUND)
            {
                _roundNumber++;
            }
            else if (player.Player_Current_Health <= 0)
            {
                DamageOutPut("You were killed by " + mob.Name + "\r\n", 5);
                WinLose = false;
                InCombat = false;
                _roundNumber = 0;
                return;
            }
            DamageOutPut("Round : " + _roundNumber.ToString() + "\r\n", 2);
        }
Ejemplo n.º 8
0
 public Location(int id, string name, string description, Item itemRequiredToEnter = null, Quest questAvailableHere = null, Monster monsterLivingHere = null)
 {
     ID                  = id;
     Name                = name;
     Description         = description;
     ItemRequiredToEnter = itemRequiredToEnter;
     QuestAvailableHere  = questAvailableHere;
     MonsterLivingHere   = monsterLivingHere;
 }
Ejemplo n.º 9
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 new location have a quest?
            if (newLocation.QuestAvailableHere != null)
            {
                // Check if player already has quest, and if completed
                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 already completed quest
                    if (!playerAlreadyCompletedQuest)
                    {
                        // Check if player has all required items to complete quest
                        bool playerHasAllItemsToCompleteQuest = HasAllQuestCompletionItems(newLocation.QuestAvailableHere);

                        // Player has all items required to complete 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
                {
                    // Player does not already have 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;
            }
        }
Ejemplo n.º 10
0
        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();
        }
Ejemplo n.º 11
0
        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();
        }
Ejemplo n.º 12
0
 public Location(int id, string name, string description, Item entryItem = null, Quest questsHere = null, Monster monstersHere = null)
 {
     ID               = id;
     Name             = name;
     Description      = description;
     ItemsToEnterHere = entryItem;
     QuestsHere       = questsHere;
     MonstersHere     = monstersHere;
 }
Ejemplo n.º 13
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;
            }
        }
Ejemplo n.º 14
0
        private 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(Environment.NewLine);
                            RaiseMessage("You complete the '" + newLocation.QuestAvailableHere.Name + "' quest.");

                            // Remove quest items from inventory
                            RemoveQuestCompletionItems(newLocation.QuestAvailableHere);

                            // Give quest rewards (experience and gold)
                            RaiseMessage("You receive: ");
                            RaiseMessage(newLocation.QuestAvailableHere.RewardExperiencePoints.ToString() + " experience points");
                            RaiseMessage(newLocation.QuestAvailableHere.RewardGold.ToString() + " gold");
                            newLocation.QuestAvailableHere.RewardItems.ForEach(item => RaiseMessage(item.Name));
                            RaiseMessage(Environment.NewLine);

                            AddExperiencePoints(newLocation.QuestAvailableHere.RewardExperiencePoints);
                            Gold += newLocation.QuestAvailableHere.RewardGold;

                            // Add the reward item to the player's inventory
                            //AddItemToInventory(newLocation.QuestAvailableHere.RewardItem);
                            newLocation.QuestAvailableHere.RewardItems.ForEach(item => AddItemToInventory(item));

                            // 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.ToString() + " " + qci.Details.Name);
                        }
                        else
                        {
                            RaiseMessage(qci.Quantity.ToString() + " " + qci.Details.NamePlural, true);
                        }
                    }

                    // 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;
            }
            OnPropertyChanged("CurrentMonster");
            // Refresh UI
            //ScrollAndUpdateMonsterUI();
        }
Ejemplo n.º 15
0
        private static void PopulateMonsters()
        {
            Monster rat = new Monster(MonsterIdRat, "Rat", 5, 3, 10, 3, 3);
            rat.LootTable.Add(new LootItem(ItemById(ItemIdRatTail), 75, false));
            rat.LootTable.Add(new LootItem(ItemById(ItemIdPieceOfFur), 75, true));

            Monster snake = new Monster(MonsterIdSnake, "Snake", 5, 3, 10, 3, 3);
            snake.LootTable.Add(new LootItem(ItemById(ItemIdSnakeFang), 75, false));
            snake.LootTable.Add(new LootItem(ItemById(ItemIdSnakeSkin), 75, true));

            Monster giantSpider = new Monster(MonsterIdGiantSpider, "Giant spider", 20, 5, 40, 10, 10);
            giantSpider.LootTable.Add(new LootItem(ItemById(ItemIdSpiderFang), 75, true));
            giantSpider.LootTable.Add(new LootItem(ItemById(ItemIdSpiderSilk), 25, false));

            Monsters.Add(rat);
            Monsters.Add(snake);
            Monsters.Add(giantSpider);
        }
Ejemplo n.º 16
0
 public List<Monster> LoadMonsters()
 {
     int tempItemIdx = 0;
     logging.Logging(String.Format("DBManager : Loading Monster Database...."));
     string sql = "SELECT * FROM dev_mob";
     if(Monsters.Count == 0)
     {
         command = new MySqlCommand(sql, connection);
         reader = command.ExecuteReader();
         if (reader != null)
         {
             while (reader.Read())
             {
                 Mob_Index = Convert.ToInt32(reader["a_index"]);
                 Mob_Name = reader["a_name"].ToString();
                 Mob_Str = Convert.ToInt32(reader["a_str"]);
                 Mob_Vit = Convert.ToInt32(reader["a_vit"]);
                 Mob_Int = Convert.ToInt32(reader["a_int"]);
                 Mob_Wis = Convert.ToInt32(reader["a_wis"]);
                 Mob_Dex = Convert.ToInt32(reader["a_dex"]);
                 Mob_Char = Convert.ToInt32(reader["a_char"]);
                 Mob_Exp = Convert.ToInt32(reader["a_exp"]);
                 Mob_Gold = Convert.ToInt32(reader["a_gold"]);
                 Mob_CurrentHP = Convert.ToInt32(reader["a_maxHP"]);
                 Mob_Max_HP = Mob_CurrentHP;
                 Monster tempMob = new Monster(Mob_Index, Mob_Name, Mob_Str, Mob_Vit, Mob_Int, Mob_Wis, Mob_Dex, Mob_Char, Mob_Exp, Mob_Gold, Mob_CurrentHP, Mob_Max_HP);
                 //drop table load = Item ID, Chance, Default? yes:no, if Item ID = 0 stop adding
                 for (int i = 0; i < 10; i++)
                 {
                     tempItemIdx = Convert.ToInt32(reader["a_item" + i]);
                     if (tempItemIdx != 0)
                     {
                         tempMob.LootTable.Add(new LootItem(World.ItemByID(
                             tempItemIdx),
                             Convert.ToInt32(reader["a_item_ch" + i]),
                             Convert.ToBoolean(reader["a_item_d" + i])));
                     }
                 }
                 Monsters.Add(tempMob);
                 //rat.LootTable.Add(new LootItem(ItemByID(ITEM_INDEX001), 75, false));
             }
         }
         reader.Close();
         return Monsters;
     }
     return null;
 }
Ejemplo n.º 17
0
        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;
            }
        }
Ejemplo n.º 18
0
        private void MoveTo(Location newLocation)
        {
            if (!HasRequiredItemToEnterThisLocation(newLocation))
            {
                RaiseMessage("You must have a " + newLocation.ItemRequiredToEnter.Name + " to enter this location.");
                return;
            }

            CurrentLocation = newLocation;

            CurrentHitPoints = MaximumHitPoints;

            if (newLocation.QuestAvailableHere != null)
            {
                bool playerAlreadyHasQuest       = HasThisQuest(newLocation.QuestAvailableHere);
                bool playerAlreadyCompletedQuest = CompletedThisQuest(newLocation.QuestAvailableHere);

                if (playerAlreadyHasQuest)
                {
                    if (!playerAlreadyCompletedQuest)
                    {
                        bool playerHasAllItemsToCompleteQuest = HasAllQuestCompletionItems(newLocation.QuestAvailableHere);

                        if (playerHasAllItemsToCompleteQuest)
                        {
                            RaiseMessage("");
                            RaiseMessage("You complete the '" + newLocation.QuestAvailableHere.Name + "' quest.");

                            RemoveQuestCompletionItems(newLocation.QuestAvailableHere);

                            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;

                            AddItemToInventory(newLocation.QuestAvailableHere.RewardItem);

                            MarkQuestCompleted(newLocation.QuestAvailableHere);
                        }
                    }
                }
                else
                {
                    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("");

                    Quests.Add(new PlayerQuest(newLocation.QuestAvailableHere));
                }
            }

            if (newLocation.MonsterLivingHere != null)
            {
                RaiseMessage("You see a " + newLocation.MonsterLivingHere.Name);

                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;
            }
        }
Ejemplo n.º 19
0
        private static void PopulateMonsters()
        {
            Monster rat = new Monster(MONSTER_ID_RAT, Resources.Text.resRat, 5, 3, 10, 3, 3, 0);
            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, Resources.Text.resSnake, 5, 3, 10, 3, 3, 60);
            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, Resources.Text.resGiantSpider, 20, 5, 40, 10, 10, 0);
            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);
        }
        public void MoveTo(Location newLocation)
        {
            // Make sure _player has any required item for the new location
            if (!HasRequiredItemToEnterThisLocation(newLocation))
            {
                RaiseMessage("You must have a " + newLocation.ItemRequiredToEnter.Name +
                             " to enter this location.");
                return;  // return without moving to the new location
            }

            // We have any required item, or there wasn't an item required,
            // so update the player's current location
            CurrentLocation = newLocation;

            CompletelyHeal();

            #region QuestInNewLocation
            if (newLocation.HasAQuest)
            {
                if (PlayerDoesNotHaveThisQuest(newLocation.QuestAvailableHere))
                {
                    GiveQuestToPlayer(newLocation);
                }
                else // Player doesn't have the quest yet - so add it to his quest list
                {
                    if (PlayerHasNotCompleted(newLocation.QuestAvailableHere) &&
                        PlayerHasAllQuestCompletionItems(newLocation.QuestAvailableHere))
                    {
                        // Quest is completed!!
                        CompleteQuestAndGiveRewards(newLocation);
                    }
                } // end player has this quest / or not
            }     // end quest is available here
            #endregion

            #region MonsterLivingHere
            // 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 // There is not a MonsterLivingHere
            {
                _currentMonster = null;
            }
            #endregion
        }
Ejemplo n.º 21
0
        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();
        }
Ejemplo n.º 22
0
        /**
         * This method takes the Mob, player and weapon then runs a battle until one of them is dead.
         */
        public void Fight(Monster enemy, Player player)
        {
            // Create the Dice objects
            DiceRoll attack    = new DiceRoll(1, 20);   //Repersents 1D20 die
            DiceRoll pDamage   = new DiceRoll(player.Equipt.Damage);
            DiceRoll mobDamage = new DiceRoll(enemy.Damage);

            if (enemy.CanBeAttacked == false)
            {
                Console.WriteLine("Can't be attacked for whatever reason");
                return;
            }

            while (enemy.IsDead != true && player.IsDead != true)
            {
                _attackResult = attack.Roll();

                Console.WriteLine("Your attack with your " + player.Equipt.Name.ToString() + ": " + AttackResults);

                if (AttackResults >= enemy.AC)
                {
                    Console.WriteLine("You hit the " + enemy.Name);

                    _damageResult = pDamage.Roll();
                    Console.WriteLine("You did " + DamageResults + " points of damage.");

                    enemy.CurrentHitPoints -= DamageResults;
                    Console.WriteLine(enemy.Name + " has " + enemy.CurrentHitPoints + " hitpoints left");

                    if (enemy.CurrentHitPoints <= 0)
                    {
                        Console.WriteLine("The " + enemy.Name + " is dead!");
                        enemy.IsDead = true;
                        Console.WriteLine("The fight took " + Round + " rounds to finish.");
                        Player.CurrentLocation.RoomMob.Remove(enemy);
                        player.ExperiencePoints += enemy.Experiance;
                        player.Gold             += enemy.Gold;
                        if (enemy.Factions == Factions.Evil)
                        {
                            player.Alignment++;
                        }
                        else if (enemy.Factions == Factions.Good)
                        {
                            player.Alignment--;
                        }


                        break;
                    }
                }
                else
                {
                    Console.WriteLine("You Missed your attack!");
                }

                _attackResult = attack.Roll();
                Console.WriteLine(enemy.Name + " attacks you: " + AttackResults);

                if (AttackResults > player.AC)
                {
                    Console.WriteLine("The " + enemy.Name + " hits you!");

                    _damageResult = mobDamage.Roll();
                    Console.WriteLine("The " + enemy.Name + " did " + DamageResults + " points of damage.");

                    player.CurrentHitPoints -= DamageResults;

                    if (player.CurrentHitPoints <= 0)
                    {
                        Console.WriteLine("You are dead!");
                        player.IsDead = true;
                        Console.WriteLine("The fight took " + Round + " rounds to finish.\n");
                        Load.LoadGameData(player.PlayerName);
                        CurrentLocationClass.DisplayCurrentLocation();
                    }
                }
                else
                {
                    Console.WriteLine("The " + enemy.Name + " missed you!");
                }

                Round++;
            }

            //Console.WriteLine("The fight took " + Round + " rounds to finish.");
            if (player.IsDead == true)
            {
                player.PlayerName += "-Dead";
            }
        }
Ejemplo n.º 23
0
        private static void PopulateMonsters()
        {
            Monster rat = new Monster(MONSTER_INDEX_RAT, "Rat", 1, 5, 0, 0, 0, 0, 3, 10, 3, 3);
            rat.LootTable.Add(new LootItem(ItemByID(ITEM_INDEX001), 75, false));
            rat.LootTable.Add(new LootItem(ItemByID(ITEM_INDEX002), 75, false));

            Monster snake = new Monster(MONSTER_INDEX_SNAKE, "Snake", 5, 10, 0, 0, 0, 0, 5, 10, 10, 10);
            snake.LootTable.Add(new LootItem(ItemByID(ITEM_INDEX003), 75, false));
            snake.LootTable.Add(new LootItem(ItemByID(ITEM_INDEX004), 25, true));

            Monster spider = new Monster(MONSTER_INDEX_GIANT_SPIDER, "Giant Spider", 10, 20, 0, 0, 0, 0, 10, 20, 30, 30);
            spider.LootTable.Add(new LootItem(ItemByID(ITEM_INDEX007), 75, true));
            spider.LootTable.Add(new LootItem(ItemByID(ITEM_INDEX008), 25, false));

            Monsters.Add(rat);
            Monsters.Add(snake);
            Monsters.Add(spider);
        }
Ejemplo n.º 24
0
        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();
        }