Пример #1
0
        /// <summary>
        /// Handles the Quest Log Update message, which has information about the current status
        /// of Quests that the player is on.
        /// </summary>
        /// <param name="props">Properties.</param>
        void _HandleQuestLogInfo(Dictionary <string, object> props)
        {
            // update our idea of the state
            QuestLogEntry logEntry = null;
            long          quest_id = (long)props["ext_msg_subject_oid"];
            OID           questID  = OID.fromLong(quest_id);

            foreach (QuestLogEntry entry in questLogEntries)
            {
                if (entry.QuestId.Equals(questID))
                {
                    logEntry = entry;
                    break;
                }
            }
            if (logEntry == null)
            {
                logEntry = new QuestLogEntry();
                questLogEntries.Add(logEntry);
            }
            logEntry.QuestId     = questID;
            logEntry.Title       = (string)props["title"];
            logEntry.Description = (string)props["description"];
            logEntry.Objective   = (string)props["objective"];
            logEntry.Complete    = (bool)props["complete"];
            logEntry.gradeCount  = (int)props["grades"];
            logEntry.gradeInfo   = new List <QuestGradeEntry>();
            for (int j = 0; j < (logEntry.gradeCount + 1); j++)
            {
                QuestGradeEntry gradeEntry = new QuestGradeEntry();
                // Objectives
                List <string> objectives    = new List <string>();
                int           numObjectives = (int)props["numObjectives" + j];
                for (int k = 0; k < numObjectives; k++)
                {
                    string objective = (string)props["objective" + j + "_" + k];
                    objectives.Add(objective);
                }
                gradeEntry.objectives = objectives;

                // Rewards
                List <QuestRewardEntry> gradeRewards = new List <QuestRewardEntry>();
                int numRewards = (int)props["rewards" + j];
                //           Debug.LogError("QuestLog " + logEntry.Title + " rewards count:" + numRewards);
                for (int k = 0; k < numRewards; k++)
                {
                    //id, name, icon, count = item;
                    QuestRewardEntry entry = new QuestRewardEntry();
                    entry.id = (int)props["rewards" + j + "_" + k];
                    AtavismInventoryItem item = gameObject.GetComponent <Inventory>().GetItemByTemplateID(entry.id);
                    entry.item       = item;
                    entry.item.Count = (int)props["rewards" + j + "_" + k + "Count"];
                    gradeRewards.Add(entry);
                    //ClientAPI.Write("Reward: %s" % entry)
                }
                gradeEntry.rewardItems = gradeRewards;
                // Items to choose from
                List <QuestRewardEntry> gradeRewardsToChoose = new List <QuestRewardEntry>();
                numRewards = (int)props["rewardsToChoose" + j];
                //          Debug.LogError("QuestLog " + logEntry.Title + " rewards Choose count:" + numRewards);
                for (int k = 0; k < numRewards; k++)
                {
                    //id, name, icon, count = item;
                    QuestRewardEntry entry = new QuestRewardEntry();
                    entry.id = (int)props["rewardsToChoose" + j + "_" + k];
                    AtavismInventoryItem item = gameObject.GetComponent <Inventory>().GetItemByTemplateID(entry.id);
                    entry.item       = item;
                    entry.item.Count = (int)props["rewardsToChoose" + j + "_" + k + "Count"];
                    gradeRewardsToChoose.Add(entry);
                    //ClientAPI.Write("Reward: %s" % entry)
                }
                gradeEntry.RewardItemsToChoose = gradeRewardsToChoose;
                List <QuestRepRewardEntry> gradeRepReward = new List <QuestRepRewardEntry>();
                numRewards = (int)props["rewardsRep" + j];
                //              Debug.LogError("Quest " + logEntry.Title + " rewards Choose count:" + numRewards);
                for (int k = 0; k < numRewards; k++)
                {
                    //id, name, icon, count = item;
                    QuestRepRewardEntry entry = new QuestRepRewardEntry();
                    entry.name  = (string)props["rewardsRep" + j + "_" + k];
                    entry.count = (int)props["rewardsRep" + j + "_" + k + "Count"];
                    gradeRepReward.Add(entry);
                    //ClientAPI.Write("Reward to choose: %s" % entry)
                }
                gradeEntry.rewardRep = gradeRepReward;


                gradeEntry.expReward = (int)props["xpReward" + j];
                // Currencies
                List <QuestRewardEntry> currencies = new List <QuestRewardEntry>();
                numRewards = (int)props["currencies" + j];
                for (int k = 0; k < numRewards; k++)
                {
                    //id, name, icon, count = item;
                    QuestRewardEntry entry = new QuestRewardEntry();
                    entry.id    = (int)props["currency" + j + "_" + k];
                    entry.count = (int)props["currency" + j + "_" + k + "Count"];
                    currencies.Add(entry);
                    //ClientAPI.Write("Reward: %s" % entry)
                }
                gradeEntry.currencies = currencies;
                logEntry.gradeInfo.Add(gradeEntry);
            }
            // dispatch a ui event to tell the rest of the system
            string[] args = new string[1];
            AtavismEventSystem.DispatchEvent("QUEST_LOG_UPDATE", args);
            UpdateQuestListSelected();
        }
Пример #2
0
        void _HandleQuestProgressInfo(Dictionary <string, object> props)
        {
            /// update the information about the quests in progress from this npc
            questsInProgress.Clear();
            int numQuests = (int)props["numQuests"];

            npcID = (OID)props["npcID"];
            for (int i = 0; i < numQuests; i++)
            {
                QuestLogEntry logEntry = new QuestLogEntry();
                questsInProgress.Add(logEntry);
                logEntry.Title   = (string)props["title" + i];
                logEntry.QuestId = (OID)props["questID" + i];
                logEntry.NpcId   = npcID;
                //logEntry.Description = (string)props ["description" + i];
                logEntry.ProgressText = (string)props["progress" + i];
                logEntry.Complete     = (bool)props["complete" + i];
                logEntry.Objective    = (string)props["objective" + i];
                logEntry.gradeCount   = (int)props["grades" + i];
                logEntry.gradeInfo    = new List <QuestGradeEntry>();
                //ClientAPI.Write("Quest grades: %s" % logEntry.grades)
                for (int j = 0; j < (logEntry.gradeCount + 1); j++)
                {
                    QuestGradeEntry         gradeEntry   = new QuestGradeEntry();
                    List <QuestRewardEntry> gradeRewards = new List <QuestRewardEntry>();
                    int numRewards = (int)props["rewards" + i + " " + j];
                    for (int k = 0; k < numRewards; k++)
                    {
                        //id, name, icon, count = item;
                        QuestRewardEntry entry = new QuestRewardEntry();
                        entry.id = (int)props["rewards" + i + "_" + j + "_" + k];
                        AtavismInventoryItem item = gameObject.GetComponent <Inventory>().GetItemByTemplateID(entry.id);
                        entry.item       = item;
                        entry.item.Count = (int)props["rewards" + i + "_" + j + "_" + k + "Count"];
                        gradeRewards.Add(entry);
                        //ClientAPI.Write("Reward: %s" % entry)
                    }
                    gradeEntry.rewardItems = gradeRewards;
                    // Items to choose from
                    List <QuestRewardEntry> gradeRewardsToChoose = new List <QuestRewardEntry>();
                    numRewards = (int)props["rewardsToChoose" + i + " " + j];
                    for (int k = 0; k < numRewards; k++)
                    {
                        //id, name, icon, count = item;
                        QuestRewardEntry entry = new QuestRewardEntry();
                        entry.id = (int)props["rewardsToChoose" + i + "_" + j + "_" + k];
                        AtavismInventoryItem item = gameObject.GetComponent <Inventory>().GetItemByTemplateID(entry.id);
                        entry.item       = item;
                        entry.item.Count = (int)props["rewardsToChoose" + i + "_" + j + "_" + k + "Count"];
                        gradeRewardsToChoose.Add(entry);
                        //ClientAPI.Write("Reward to choose: %s" % entry)
                    }
                    gradeEntry.RewardItemsToChoose = gradeRewardsToChoose;
                    List <QuestRepRewardEntry> gradeRepReward = new List <QuestRepRewardEntry>();
                    numRewards = (int)props["rewardsRep" + i + " " + j];
                    //              Debug.LogError("Quest " + logEntry.Title + " rewards Choose count:" + numRewards);
                    for (int k = 0; k < numRewards; k++)
                    {
                        //id, name, icon, count = item;
                        QuestRepRewardEntry entry = new QuestRepRewardEntry();
                        entry.name  = (string)props["rewardsRep" + i + "_" + j + "_" + k];
                        entry.count = (int)props["rewardsRep" + i + "_" + j + "_" + k + "Count"];
                        gradeRepReward.Add(entry);
                        //ClientAPI.Write("Reward to choose: %s" % entry)
                    }
                    gradeEntry.rewardRep = gradeRepReward;

                    if (props.ContainsKey("xpReward" + i + " " + j))
                    {
                        //                  Debug.LogError("Quest Progress xpReward" + i + " " + j + " ->" + props["xpReward" + i + " " + j]);
                        gradeEntry.expReward = (int)props["xpReward" + i + " " + j];
                    }
                    else
                    {
                        Debug.LogWarning("Quest Progress no xpReward");
                    }

                    // Currencies
                    List <QuestRewardEntry> currencies = new List <QuestRewardEntry>();
                    numRewards = (int)props["currencies" + i + " " + j];
                    for (int k = 0; k < numRewards; k++)
                    {
                        QuestRewardEntry entry = new QuestRewardEntry();
                        entry.id    = (int)props["currency" + i + "_" + j + "_" + k];
                        entry.count = (int)props["currency" + i + "_" + j + "_" + k + "Count"];
                        currencies.Add(entry);
                        //ClientAPI.Write("Reward to choose: %s" % entry)
                    }
                    gradeEntry.currencies     = currencies;
                    gradeEntry.completionText = (string)props["completion" + i + "_" + j];
                    logEntry.gradeInfo.Add(gradeEntry);
                }
            }
            //
            // dispatch a ui event to tell the rest of the system
            //
            if (gameObject.GetComponent <NpcInteraction>().NpcId != npcID)
            {
                gameObject.GetComponent <NpcInteraction>().InteractionOptions.Clear();
            }

            gameObject.GetComponent <NpcInteraction>().NpcId = npcID;
            string[] args = new string[1];
            AtavismEventSystem.DispatchEvent("QUEST_PROGRESS_UPDATE", args);
            UpdateQuestListSelected();
        }
Пример #3
0
        void _HandleQuestOfferResponse(Dictionary <string, object> props)
        {
            // update the information about the quests on offer from this npc
            questsOffered.Clear();
            int numQuests = (int)props["numQuests"];

            npcID = (OID)props["npcID"];
            for (int i = 0; i < numQuests; i++)
            {
                QuestLogEntry logEntry = new QuestLogEntry();
                questsOffered.Add(logEntry);
                logEntry.Title       = (string)props["title" + i];
                logEntry.QuestId     = (OID)props["questID" + i];
                logEntry.NpcId       = npcID;
                logEntry.Description = (string)props["description" + i];
                logEntry.Objective   = (string)props["objective" + i];
                //logEntry.Objectives.Clear ();
                //LinkedList<string> objectives = (LinkedList<string>)props ["objectives"];
                //foreach (string objective in objectives)
                //	logEntry.Objectives.Add (objective);
                logEntry.gradeCount = (int)props["grades" + i];
                logEntry.gradeInfo  = new List <QuestGradeEntry>();
                //ClientAPI.Write("Quest grades: %s" % logEntry.grades)
                for (int j = 0; j < (logEntry.gradeCount + 1); j++)
                {
                    QuestGradeEntry         gradeEntry   = new QuestGradeEntry();
                    List <QuestRewardEntry> gradeRewards = new List <QuestRewardEntry>();

                    int numRewards = (int)props["rewards" + i + " " + j];
                    //               Debug.LogError("Quest " + logEntry.Title + " rewards count:" + numRewards);
                    for (int k = 0; k < numRewards; k++)
                    {
                        //id, name, icon, count = item;
                        QuestRewardEntry entry = new QuestRewardEntry();
                        entry.id = (int)props["rewards" + i + "_" + j + "_" + k];
                        AtavismInventoryItem item = gameObject.GetComponent <Inventory>().GetItemByTemplateID(entry.id);
                        entry.item       = item;
                        entry.item.Count = (int)props["rewards" + i + "_" + j + "_" + k + "Count"];
                        gradeRewards.Add(entry);
                        //ClientAPI.Write("Reward: %s" % entry)
                    }
                    gradeEntry.rewardItems = gradeRewards;
                    // Items to choose from
                    List <QuestRewardEntry> gradeRewardsToChoose = new List <QuestRewardEntry>();
                    numRewards = (int)props["rewardsToChoose" + i + " " + j];
                    //              Debug.LogError("Quest " + logEntry.Title + " rewards Choose count:" + numRewards);
                    for (int k = 0; k < numRewards; k++)
                    {
                        //id, name, icon, count = item;
                        QuestRewardEntry entry = new QuestRewardEntry();
                        entry.id = (int)props["rewardsToChoose" + i + "_" + j + "_" + k];
                        AtavismInventoryItem item = gameObject.GetComponent <Inventory>().GetItemByTemplateID(entry.id);
                        entry.item       = item;
                        entry.item.Count = (int)props["rewardsToChoose" + i + "_" + j + "_" + k + "Count"];
                        gradeRewardsToChoose.Add(entry);
                        //ClientAPI.Write("Reward to choose: %s" % entry)
                    }
                    gradeEntry.RewardItemsToChoose = gradeRewardsToChoose;

                    List <QuestRepRewardEntry> gradeRepReward = new List <QuestRepRewardEntry>();
                    numRewards = (int)props["rewardsRep" + i + " " + j];
                    //              Debug.LogError("Quest " + logEntry.Title + " rewards Choose count:" + numRewards);
                    for (int k = 0; k < numRewards; k++)
                    {
                        //id, name, icon, count = item;
                        QuestRepRewardEntry entry = new QuestRepRewardEntry();
                        entry.name  = (string)props["rewardsRep" + i + "_" + j + "_" + k];
                        entry.count = (int)props["rewardsRep" + i + "_" + j + "_" + k + "Count"];
                        gradeRepReward.Add(entry);
                        //ClientAPI.Write("Reward to choose: %s" % entry)
                    }
                    gradeEntry.rewardRep = gradeRepReward;



                    // Quest Exp
                    gradeEntry.expReward = (int)props["xpReward" + i + " " + j];
                    // Currencies
                    List <QuestRewardEntry> currencies = new List <QuestRewardEntry>();
                    numRewards = (int)props["currencies" + i + " " + j];
                    for (int k = 0; k < numRewards; k++)
                    {
                        QuestRewardEntry entry = new QuestRewardEntry();
                        entry.id    = (int)props["currency" + i + "_" + j + "_" + k];
                        entry.count = (int)props["currency" + i + "_" + j + "_" + k + "Count"];
                        currencies.Add(entry);
                        //ClientAPI.Write("Reward to choose: %s" % entry)
                    }
                    gradeEntry.currencies = currencies;
                    logEntry.gradeInfo.Add(gradeEntry);
                }
            }
            // dispatch a ui event to tell the rest of the system
            if (gameObject.GetComponent <NpcInteraction>().NpcId != npcID)
            {
                gameObject.GetComponent <NpcInteraction>().InteractionOptions.Clear();
            }
            gameObject.GetComponent <NpcInteraction>().NpcId = npcID;
            string[] args = new string[1];
            AtavismEventSystem.DispatchEvent("QUEST_OFFERED_UPDATE", args);
        }