Beispiel #1
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];
             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);
                 if (item != null) {
                     entry.name = item.name;
                     entry.icon = item.icon;
                 }
                 entry.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);
                 if (item != null) {
                     entry.name = item.name;
                     entry.icon = item.icon;
                 }
                 entry.count = (int)props ["rewardsToChoose" + i + "_" + j + "_" + k + "Count"];
                 gradeRewardsToChoose.Add (entry);
                 //ClientAPI.Write("Reward to choose: %s" % entry)
             }
             gradeEntry.RewardItemsToChoose = gradeRewardsToChoose;
             logEntry.gradeInfo.Add (gradeEntry);
         }
     }
     // dispatch a ui event to tell the rest of the system
     gameObject.GetComponent<NpcInteraction> ().NpcId = npcID;
     string[] args = new string[1];
     AtavismEventSystem.DispatchEvent ("QUEST_OFFERED_UPDATE", args);
 }
Beispiel #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.name = item.name;
                 entry.icon = item.icon;
                 entry.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.name = item.name;
                 entry.icon = item.icon;
                 entry.count = (int)props ["rewardsToChoose" + i + "_" + j + "_" + k + "Count"];
                 gradeRewardsToChoose.Add (entry);
                 //ClientAPI.Write("Reward to choose: %s" % entry)
             }
             gradeEntry.RewardItemsToChoose = gradeRewardsToChoose;
             gradeEntry.completionText = (string)props ["completion" + i + "_" + j];
             logEntry.gradeInfo.Add (gradeEntry);
         }
     }
     //
     // dispatch a ui event to tell the rest of the system
     //
     gameObject.GetComponent<NpcInteraction> ().NpcId = npcID;
     string[] args = new string[1];
     AtavismEventSystem.DispatchEvent ("QUEST_PROGRESS_UPDATE", args);
 }
Beispiel #3
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.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];
            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);
                if (item != null) {
                    entry.name = item.name;
                    entry.icon = item.icon;
                }
                entry.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];
            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);
                if (item != null) {
                    entry.name = item.name;
                    entry.icon = item.icon;
                }
                entry.count = (int)props ["rewardsToChoose" + j + "_" + k + "Count"];
                gradeRewardsToChoose.Add (entry);
                //ClientAPI.Write("Reward: %s" % entry)
            }
            gradeEntry.RewardItemsToChoose = gradeRewardsToChoose;
            gradeEntry.expReward = (int)props ["xpReward" + j];
            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);
    }