Example #1
0
        public void UpdateQuest(int questID, int state)
        {
            PlayerQuest playerQuest = Quests.SingleOrDefault(
                pq => pq.ID == questID);

            if (playerQuest == null)
            {
                Quests.Add(new PlayerQuest(World.GetQuest(questID), state, false));
            }
            else
            {
                playerQuest.State = state;
            }
        }
        private void GiveQuestToPlayer(Quest quest)
        {
            RaiseMessage("You receive the " + quest.Name + " quest.", false);
            RaiseMessage(quest.Description, false);
            RaiseMessage("To complete it, return with:", false);

            foreach (QuestCompletionItem qci in quest.QuestCompletionItems)
            {
                RaiseMessage(string.Format("{0} {1}", qci.Quantity,
                                           qci.Quantity == 1 ? qci.Details.Name : qci.Details.NamePlural));
            }
            RaiseMessage("", false);

            Quests.Add(new PlayerQuest(quest));
        }
Example #3
0
        private void GiveQuestToPlayer(Quest quest, TTS tts)
        {
            RaiseMessage("Tens uma missão nova: " + quest.Name + ".");
            RaiseMessage(quest.Description);
            RaiseMessage("Para completá-la, volta com:");
            string items = "";

            foreach (QuestCompletionItem qci in quest.QuestCompletionItems)
            {
                items += string.Format("{0} {1}", qci.Quantity,
                                       qci.Quantity == 1 ? qci.Details.Name : qci.Details.NamePlural);
                items += ",";
                RaiseMessage(string.Format("{0} {1}", qci.Quantity,
                                           qci.Quantity == 1 ? qci.Details.Name : qci.Details.NamePlural));
            }

            RaiseMessage("");

            Quests.Add(new PlayerQuest(quest));
            tts.Speak(text + " e tens uma missão nova: " + quest.Name + "." + " Para completá-la, volta com: " + items);
            text = "";
        }
Example #4
0
        private void GiveQuestToPlayer(Quest quest)
        {
            RaiseMessage("You receive the " + quest.Name + " quest.");
            RaiseMessage(quest.Description);
            RaiseMessage("To complete it, return with:");

            foreach (QuestCompletionItem qci in quest.QuestCompletionItems)
            {
                if (qci.Quantity == 1)
                {
                    RaiseMessage(qci.Quantity + " " + qci.Details.Name);
                }
                else
                {
                    RaiseMessage(qci.Quantity + " " + qci.Details.NamePlural);
                }
            }

            RaiseMessage("");

            Quests.Add(new PlayerQuest(quest));
        }
        private void GiveQuestToPlayer(Location newLocation)
        {
            // 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);
                }
            }

            // Add the quest to the player's quest list
            Quests.Add(new PlayerQuest(newLocation.QuestAvailableHere));
        }
Example #6
0
        private static void PopulateQuests()
        {
            Quest helpLibrarian = new Quest(
                QUEST_ID_HELP_LIBRARIAN,
                "Kill the bandits in the librarian's Zen garden (some of them can have a stolen Black pearl)",
                "Kill the bandits in the library and bring back 3 Bandits' heads to the librarian for proof that you're not one of them. You will receive a healing potion and 10 gold.",
                40, 20);

            helpLibrarian.QuestCompletionItems.Add(new QuestCompletionItem(ItemByID(ITEM_ID_BANDIT_HEAD), 3));
            helpLibrarian.RewardItem = ItemByID(ITEM_ID_HEALING_POTION);

            Quest clearFarmersField = new Quest(
                QUEST_ID_CLEAR_FARMERS_FIELD,
                "Clear the farmer's field",
                "Kill the serpents in the farmer's field and bring back 3 serpent fangs. You will receive an adventurer's pass and 20 gold pieces.",
                30, 10);

            clearFarmersField.QuestCompletionItems.Add(new QuestCompletionItem(ItemByID(ITEM_ID_SERPENT_FANG), 3));
            clearFarmersField.RewardItem = ItemByID(ITEM_ID_ADVENTURER_KEY);

            Quests.Add(helpLibrarian);
            Quests.Add(clearFarmersField);
        }
Example #7
0
        /* Function to move the player to a new location */
        public void MoveTo(Location newLocation)
        {
            //Does the location have any required items
            if (!HasRequiredItemToEnterThisLocation(newLocation))
            {
                // rtbMessages.Text += "You must have a " + newLocation.ItemRequiredToEnter.Name + " to enter this location." + Environment.NewLine;
                return;
            }

            // Update the player's current location
            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
            CurrentHitPoints = MaximumHitPoints;

            // Update Hit Points in UI
            // lblHitPoints.Text = _player.CurrentHitPoints.ToString(); // data binding takes care of this

            // 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)
                        {
                            completeQuest(newLocation);
                        }
                    }
                }
                else
                {
                    // The player does not already have the quest

                    // Display the messages

                    /* rtbMessages.Text += "You received the " + newLocation.QuestAvailableHere.Name + " quest." + Environment.NewLine;
                     * rtbMessages.Text += newLocation.QuestAvailableHere.Description + Environment.NewLine;
                     * rtbMessages.Text += "To complete this, come back with:" + Environment.NewLine; */
                    foreach (QuestCompletionItem qci in newLocation.QuestAvailableHere.QuestCompletionItems)
                    {
                        if (qci.Quantity == 1)
                        {
                            RaiseMessage(qci.Quantity.ToString() + " " + qci.Details.Name + Environment.NewLine);
                        }
                        else
                        {
                            RaiseMessage(qci.Quantity.ToString() + " " + qci.Details.NamePlural + Environment.NewLine);
                        }
                    }
                    // rtbMessages.Text += Environment.NewLine;

                    // 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 + "!" + Environment.NewLine);

                // Make a new monster and add its loot table, 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);
                }

                // Prepare UI for combat

                /* cboWeapons.Visible = Weapons.Any();
                 * cboPotions.Visible = Potions.Any();
                 * btnUseWeapon.Visible = Weapons.Any();
                 * btnUsePotion.Visible = Potions.Any();*/
            }
            else
            {
                _currentMonster = null;

                /*cboWeapons.Visible = false;
                 * cboPotions.Visible = false;
                 * btnUseWeapon.Visible = false;
                 * btnUsePotion.Visible = false;*/
            }
        }
Example #8
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.");
                RaiseMessage("");
                return;
            }

            // Update 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 complete it
                bool playerAlreadyHasQuest       = HasThisQuest(newLocation.QuestAvailableHere);
                bool playerAlreadyCompletedQuest = CompletedThisQuest(newLocation.QuestAvailableHere);

                // See if the player already has the quest
                if (playerAlreadyHasQuest)
                {
                    // If player has not completed the quest
                    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.RewardGold.ToString() + " gold");
                            RaiseMessage(newLocation.QuestAvailableHere.RewardExperiencePoints.ToString() + " experience points");
                            RaiseMessage(newLocation.QuestAvailableHere.RewardItem.Name);
                            //RaiseMessage("");

                            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("");
                    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);
                        }
                    }
                    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 values from the standard monster in the Worls.Moster 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;
            }
        }
Example #9
0
        public void MoveTo(Location newLocation)
        {
            if (!HasRequiredItemToEnterThisLocation(newLocation))
            {
                RaiseMessage("你必須" + newLocation.ItemRequiredToEnter.Name + "才能進入此區域");
                return;
            }



            CurrentLocation  = newLocation;
            CurrentHitPoints = MaxHitPoints;

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

                if (playerAlreadyHasQuest)
                {
                    if (!playerAlreadyCompleteQuest)
                    {
                        bool playerHasAllItemsToCompleteQuest =
                            HasAllQuestCompletedItem(newLocation.QuestAvailableHere);

                        if (playerHasAllItemsToCompleteQuest)
                        {
                            RaiseMessage("");
                            RaiseMessage("你完成了" + newLocation.QuestAvailableHere.Name + "任務");
                            RemoveQuestCompletionItems(newLocation.QuestAvailableHere);

                            RaiseMessage("妳得到了: " + newLocation.QuestAvailableHere.RewardEXP.ToString() + "經驗值");
                            RaiseMessage("以及" + newLocation.QuestAvailableHere.RewardGold + "黃金");
                            RaiseMessage(newLocation.QuestAvailableHere.RewardItem.Name, true);

                            AddEXPPoints(newLocation.QuestAvailableHere.RewardEXP);
                            Gold += newLocation.QuestAvailableHere.RewardGold;

                            AddItemToInventory(newLocation.QuestAvailableHere.RewardItem);

                            MarkQuestCompleted(newLocation.QuestAvailableHere);
                        }
                    }
                }
                else
                {
                    RaiseMessage("你得到了" + newLocation.QuestAvailableHere.Name + "任務");
                    RaiseMessage(newLocation.QuestAvailableHere.Description);
                    RaiseMessage("為了完成任務,需要物品:");

                    foreach (QuestCompletionItem qui in newLocation.QuestAvailableHere.QuestCompletionItems)
                    {
                        if (qui.Quantity == 1)
                        {
                            RaiseMessage(qui.Quantity + " " + qui.Details.Name);
                        }

                        else
                        {
                            RaiseMessage(qui.Quantity + " " + qui.Details.NamePlural);
                        }
                    }

                    RaiseMessage(" ");

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

            if (newLocation.MonsterLivingHere != null)
            {
                RaiseMessage("你看到了" + newLocation.MonsterLivingHere.Name);
                Monster standardMonster = World.MonsterByID(newLocation.MonsterLivingHere.ID);

                _currentMonster = new Monster(standardMonster.ID, "standardMonster.Name", standardMonster.MaxDamage,
                                              standardMonster.RewardEXP, standardMonster.RewardGold, standardMonster.CurrentHitPoints,
                                              standardMonster.MaxHitPoints);

                foreach (LootItem lootItem in standardMonster.LootTable)
                {
                    _currentMonster.LootTable.Add(lootItem);
                }
            }
            else
            {
                _currentMonster = null;
            }
        }
Example #10
0
        public void MoveTo(Location newLocation)
        {
            if (!HasRequiredItemToEnterThisLocation(newLocation))
            {
                RaiseMessage("You must have a " + newLocation.ItemRequeredToEnter.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.RewardExperiancePoints.ToString() + " experience points");
                            RaiseMessage(newLocation.QuestAvailableHere.RewardGold.ToString() + " gold");
                            RaiseMessage(newLocation.QuestAvailableHere.RewardItem.Name, true);

                            AddExperiancePoint(newLocation.QuestAvailableHere.RewardExperiancePoints);
                            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:" + Environment.NewLine);

                    foreach (QuestCompetionItem questCompetionItem in newLocation.QuestAvailableHere.QuestCompetionItems)
                    {
                        if (questCompetionItem.Quantity == 1)
                        {
                            RaiseMessage(questCompetionItem.Quantity.ToString() + " " + questCompetionItem.Details.Name);
                        }
                        else
                        {
                            RaiseMessage(questCompetionItem.Quantity.ToString() + " " + questCompetionItem.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.RewardExperiancePoints,
                                              standardMonster.RewardGold, standardMonster.CurrentHitPoints, standardMonster.MaximumHitPoints);

                foreach (LootItem lootItem in standardMonster.LootTable)
                {
                    _currentMonster.LootTable.Add(lootItem);
                }
            }
            else
            {
                _currentMonster = null;
            }
        }
Example #11
0
        public void MoveTo(Location newLocation)
        {
            // 1.1) Новото място има ли критерии (required items)?
            if (!HasRequiredItemToEnterThisLocation(newLocation))
            {
                // 1.1.1) Играчът няма нужният предмет за преминаване, следователно извежда съобщение и прекъсва Moving процеса (излиза от MoveTo функцията)
                //rtbMessages.Text += "You must have a " + newLocation.ItemRequiredToEnter.Name + " to enter this location." + Environment.NewLine;
                RaiseMessage("You must have a " + newLocation.ItemRequiredToEnter.Name + " to enter this location.");
                return;
            }
            // 1.1.2) Играчът има нужният предмет за преминаване щом не е минал през горния return

            // Обнови местоположението на играча
            CurrentLocation = newLocation;

            // 100% heal повреме на транспорта (героят се чувства отпочинал и зареден)
            CurrentHitPoints = MaximumHitPoints;

            // Отбележи промяната на HP на героя на екрана
            //lblHitPoints.Text = player.CurrentHitPoints.ToString();

            // 1.2) Тази нова локация има ли quest?
            if (newLocation.QuestAvailableHere != null)
            {
                // 1.2.1) Играчът притежава ли този quest

                //флаг дали играчът притежава quest-а
                bool playerAlreadyHasQuest = HasThisQuest(newLocation.QuestAvailableHere);
                //флаг дали играчът е завършил quest-a
                bool playerAlreadyCompletedQuest = CompletedThisQuest(newLocation.QuestAvailableHere);

                // Ако играчът притежава quest-a
                if (playerAlreadyHasQuest)
                {
                    // Играчът не е проверявал дали quest-a е завършен и все още е маркиран като незавършен
                    if (!playerAlreadyCompletedQuest)
                    {
                        // Флаг дали играчът притежава ВСИЧКИ (като бройка) quest items, нужни като критерии за завършването на quest-a
                        bool playerHasAllItemsToCompleteQuest = HasAllQuestCompletionItems(newLocation.QuestAvailableHere);

                        // 1.2.1.1.1.1) Играчът е изпълнил критериите за завършване на quest
                        if (playerHasAllItemsToCompleteQuest)
                        {
                            // 1.2.1.1.1.1.1) Изведи съобщение
                            RaiseMessage(""); // за да добави нов ред
                            RaiseMessage("You complete the '" + newLocation.QuestAvailableHere.Name + "' quest.");

                            // 1.2.1.1.1.1.2) Премахни quest items от Inventory на играча
                            RemoveQuestCompletionItems(newLocation.QuestAvailableHere);

                            // 1.2.1.1.1.1.3) Дай награда (увеличи gold, xp и евентуално добави Item/s в Inventory)
                            // Съобщение
                            RaiseMessage("You receive: ");
                            RaiseMessage(newLocation.QuestAvailableHere.RewardExperiencePoints + " experience points");
                            RaiseMessage(newLocation.QuestAvailableHere.RewardGold + " gold");
                            RaiseMessage(newLocation.QuestAvailableHere.RewardItem.Name, true); // addExtraNewLine=true, за да добави допълнителен празен ред накрая

                            //xp/gold награда
                            AddExperiencePoints(newLocation.QuestAvailableHere.RewardExperiencePoints);
                            Gold += newLocation.QuestAvailableHere.RewardGold;
                            //UpdatePlayerStats();

                            // Добави Item награда, ако има такава (засега правя реализация със задължителен Item reward, примерно potion)
                            AddItemToInventory(newLocation.QuestAvailableHere.RewardItem);

                            // 1.2.1.1.1.1.3) Маркирай quest-a като завършен (completed)
                            MarkQuestCompleted(newLocation.QuestAvailableHere);
                        }
                    }
                }
                else
                {
                    // 1.2.2) Играчът няма в quest log-a дадения quest

                    // 1.2.2.1) Изведи съобщение
                    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("");

                    // 1.2.2.2) Добави го в quest log-a
                    Quests.Add(new PlayerQuest(newLocation.QuestAvailableHere));
                }
            }

            // 1.3) Тази нова локация има ли enemy (enemies)?
            if (newLocation.EnemyLivingHere != null)
            {
                // 1.3.1.1) Съобщение
                RaiseMessage("You see a " + newLocation.EnemyLivingHere.Name);

                // 1.3.1.2) Създай противник, използвайки стойностите на стандартен противник от списъка с противници World.Enemies
                Enemy standardEnemy = World.EnemyByID(newLocation.EnemyLivingHere.ID);

                currentEnemy = new Enemy(standardEnemy.ID, standardEnemy.Name, standardEnemy.MaximumDamage, standardEnemy.RewardExperiencePoints, standardEnemy.RewardGold, standardEnemy.CurrentHitPoints, standardEnemy.MaximumHitPoints);

                foreach (LootItem lootItem in standardEnemy.LootTable)
                {
                    currentEnemy.LootTable.Add(lootItem);
                }

                // 1.3.1.3) Обнови потребителския интерфейс
                // автоматично с propertychanged event
            }
            else
            {
                // 1.3.2) Ако няма enemy
                currentEnemy = null;

                // 1.3.2.1) Скрий опциите за атака
                // автоматично
            }

            // 1.4) Обнови Inventory
            //UpdateInventoryListInUI();

            // 1.5) Oбнови quest log
            //UpdateQuestListInUI();

            // 1.6) Oбнови списъка с оръжията и в момента equipped (weapons' combobox)
            //UpdateWeaponListInUI();

            // 1.7) Oбнови списъка с Potions
            //UpdatePotionListInUI();
        }
        public void MoveTo(Location location)
        {
            //Does the location have any required items
            if (!PlayerDoesNotHaveTheItemRequiredToEnter(location))
            {
                RaiseMessage($"You must have a {location.ItemRequiredToEnter.Name} to enter this location." +
                             Environment.NewLine);
                return;
            }

            //Update the player's current location
            CurrentLocation = location;

            //Completely heal the player
            CurrentHitPoints = MaximumHitPoints;

            if (location.HasAQuest)
            {
                //See if the player already has the quest
                if (HasThisQuest(location.QuestAvailableHere))
                {
                    //If the player has not completed quest
                    if (!CompletedThisQuest(location.QuestAvailableHere))
                    {
                        //The player has all required items to complete the quest
                        if (HasAllQuestCompletionItems(location.QuestAvailableHere))
                        {
                            //Display message
                            RaiseMessage(Environment.NewLine);
                            RaiseMessage($"You completed the {location.QuestAvailableHere.Name} quest." + Environment.NewLine);

                            RemoveQuestCompletionItems(location.QuestAvailableHere);

                            //Give quest rewards
                            RaiseMessage("You receive " + Environment.NewLine);
                            RaiseMessage($"{location.QuestAvailableHere.RewardExperiencePoints} experience points" + Environment.NewLine);
                            RaiseMessage($"{location.QuestAvailableHere.RewardGold} gold" + Environment.NewLine);
                            RaiseMessage(location.QuestAvailableHere.RewardItem.Name + Environment.NewLine);
                            RaiseMessage(Environment.NewLine);

                            AddExperiencePoints(location.QuestAvailableHere.RewardExperiencePoints);

                            Gold += location.QuestAvailableHere.RewardGold;

                            //Add reward item to player inventory
                            AddItemToInventory(location.QuestAvailableHere.RewardItem);

                            //Mark the quest as completed
                            MarkQuestCompleted(location.QuestAvailableHere);
                        }
                    }
                }
                else
                {
                    //The player does not have the quest

                    //Display the messages
                    RaiseMessage($"You received the {location.QuestAvailableHere.Name} quest." + Environment.NewLine);
                    RaiseMessage(location.QuestAvailableHere.Description + Environment.NewLine);
                    RaiseMessage("To complete it, return with " + Environment.NewLine);

                    foreach (QuestCompletionItem qci in location.QuestAvailableHere.QuestCompletionItems)
                    {
                        if (qci.Quantity == 1)
                        {
                            RaiseMessage($"{qci.Quantity} {qci.Details.Name}" + Environment.NewLine);
                        }
                        else
                        {
                            RaiseMessage($"{qci.Quantity} {qci.Details.NamePlural}" + Environment.NewLine);
                        }
                    }

                    RaiseMessage(Environment.NewLine);

                    //Add the quest to the player's quest list
                    Quests.Add(new PlayerQuest(location.QuestAvailableHere));
                }
            }
            //Does the location have a monster?
            if (location.MonsterLivingHere != null)
            {
                RaiseMessage($"You see a {location.MonsterLivingHere.Name}" + Environment.NewLine);

                //Make a new monster, using the values from the standard monster in the World.Monster list
                Monster standardMonster = World.MonsterByID(location.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;
            }
        }
Example #13
0
        public void MoveTo(Location location)
        {
            if (PlayerDoesNotHaveTheRequiredItemToEnter(location))
            {
                RaiseMessage("You must have a " + location.ItemRequiredToEnter.Name + " to enter this location.");
                return;
            }

            CurrentLocation = location;

            FullHeal();

            if (location.HasAQuest)
            {
                bool playerAlreadyHasQuest       = HasThisQuest(location.QuestAvailableHere);
                bool playerAlreadyCompletedQuest = CompletedThisQuest(location.QuestAvailableHere);

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

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

                            RemoveQuestCompletionItems(location.QuestAvailableHere);

                            RaiseMessage("You receive: ");
                            RaiseMessage(location.QuestAvailableHere.RewardExperiencePoints + " experience points");
                            RaiseMessage(location.QuestAvailableHere.RewardGold + " gold");
                            RaiseMessage(location.QuestAvailableHere.RewardItem.Name, true);

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

                            AddItemToInventory(location.QuestAvailableHere.RewardItem);

                            MarkQuestCompleted(location.QuestAvailableHere);
                        }
                    }
                }
                else
                {
                    RaiseMessage("You receive the " + location.QuestAvailableHere.Name + " quest.");
                    RaiseMessage(location.QuestAvailableHere.Description);
                    RaiseMessage("To complete it, return with:");
                    foreach (QuestCompletionItem qci in location.QuestAvailableHere.QuestCompletionItems)
                    {
                        if (qci.Quantity == 1)
                        {
                            RaiseMessage(qci.Quantity + " " + qci.Details.Name);
                        }
                        else
                        {
                            RaiseMessage(qci.Quantity + " " + qci.Details.NamePlural);
                        }
                    }
                    RaiseMessage("");

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

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

                Monster standardMonster = World.MonsterByID(location.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;
            }
        }
Example #14
0
        private void MoveTo(Location newLocation)
        {
            //Does the location have required items
            if (!HasRequiredItemToEnterThisLocation(newLocation))
            {
                RaiseMessage("You must have a " + newLocation.ItemRequiredToEnter.Name + " to enter this place.");
                return;
            }

            //update player's current location
            CurrentLocation = newLocation;

            //heal player
            CurrentHP = MaxHP;

            //does location have quest?
            if (newLocation.QuestAvailableHere != null)
            {
                //See if player already has quest and if completed
                bool playerHasQuest       = HasThisQuest(newLocation.QuestAvailableHere);
                bool playerCompletedQuest = CompletedThisQuest(newLocation.QuestAvailableHere);

                //see if player already has quest
                if (playerHasQuest)
                {
                    //if player has not completed quest
                    if (!playerCompletedQuest)
                    {
                        //see if player has all items to complete quest
                        bool playerHasItemsForQuest = HasItemsForQuest(newLocation.QuestAvailableHere);

                        //player has all items to complete quest
                        if (playerHasItemsForQuest)
                        {
                            //display message
                            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.RewardEXP.ToString() + " EXP");
                            RaiseMessage(newLocation.QuestAvailableHere.RewardGold.ToString() + " Gold");
                            RaiseMessage(newLocation.QuestAvailableHere.RewardItem.Name);

                            AddEXP(newLocation.QuestAvailableHere.RewardEXP);
                            Gold += newLocation.QuestAvailableHere.RewardGold;

                            //add reward item to inventory
                            AddItemToInventory(newLocation.QuestAvailableHere.RewardItem);

                            //mark quest as completed
                            MarkQuestCompleted(newLocation.QuestAvailableHere);
                        }
                    }
                }
                else
                {
                    //player does not already have quest

                    //display 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);
                        }
                    }

                    //add quest to quest list
                    Quests.Add(new PlayerQuest(newLocation.QuestAvailableHere));
                }
            }

            //Does location have enemy?
            if (newLocation.EnemyLivingHere != null)
            {
                RaiseMessage("You see a " + newLocation.EnemyLivingHere.Name);

                //make new enemy using values from std enemy in World.Enemy list
                Enemy standardEnemy = World.EnemyById(newLocation.EnemyLivingHere.ID);

                _currentEnemy = new Enemy(standardEnemy.ID, standardEnemy.Name,
                                          standardEnemy.MaxDamage, standardEnemy.RewardEXP, standardEnemy.RewardGold, standardEnemy.CurrentHP, standardEnemy.MaxHP);

                foreach (LootItem lootItem in standardEnemy.LootTable)
                {
                    _currentEnemy.LootTable.Add(lootItem);
                }
            }
            else
            {
                _currentEnemy = null;
            }
        }