示例#1
0
        void _HandleRemoveQuestResponse(Dictionary <string, object> props)
        {
            int  index    = 1; // questLogSelectedIndex is 1 based.
            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))
                {
                    questLogEntries.Remove(entry);
                    break;
                }
                index++;
            }
            if (index == questLogSelectedIndex)
            {
                // we removed the selected entry. reset selection
                questLogSelectedIndex = 0;
            }
            else if (index < questLogSelectedIndex)
            {
                // removed an entry before our selection - decrement our selection
                questLogSelectedIndex--;
            }

            // 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
        /// <summary>
        /// Handles the updates of the Quest State and updates the objectives in the players Quest Log
        /// to match.
        /// </summary>
        /// <param name="props">Properties.</param>
        void _HandleQuestStateInfo(Dictionary <string, object> props)
        {
            long quest_id = (long)props["ext_msg_subject_oid"];
            OID  questID  = OID.fromLong(quest_id);

            // update our idea of the state
            foreach (QuestLogEntry entry in questLogEntries)
            {
                if (!entry.QuestId.Equals(questID))
                {
                    continue;
                }
                for (int j = 0; j < (entry.gradeCount + 1); j++)
                {
                    // 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);
                    }
                    entry.gradeInfo[j].objectives = objectives;
                }
            }

            // dispatch a ui event to tell the rest of the system
            string[] args = new string[1];
            AtavismEventSystem.DispatchEvent("QUEST_LOG_UPDATE", args);
        }
示例#3
0
        public void HandleInterruptHarvestTask(Dictionary <string, object> props)
        {
            string[] args = new string[2];
            args[0] = "";
            args[1] = OID.fromLong(ClientAPI.GetPlayerOid()).ToString();
            AtavismEventSystem.DispatchEvent("CASTING_CANCELLED", args);

            ClientAPI.GetPlayerObject().MobController.PlayAnimation("", 0);
        }
示例#4
0
        public void SendTradeOfferMessage(List <object> itemOids, Dictionary <string, object> currencies)
        {
            Dictionary <string, object> props = new Dictionary <string, object>();

            props.Add("requesterOid", OID.fromLong(ClientAPI.GetPlayerOid()));
            props.Add("partnerOid", tradePartnerOid);
            props.Add("offerItems", itemOids);
            props.Add("offerCurrencies", currencies);
            props.Add("accepted", acceptedByMe);
            props.Add("cancelled", cancelled);
            NetworkAPI.SendExtensionMessage(ClientAPI.GetPlayerOid(), false, "ao.TRADE_OFFER_REQ", props);
        }
示例#5
0
        public void BuyAuction(string itemGroupId, Dictionary <string, object> currencies, int count)
        {
            AtavismLogger.LogDebugMessage("BuyAuction Start");
            Dictionary <string, object> props = new Dictionary <string, object>();

            props.Add("startbid", 0);
            props.Add("buyout", currencies);
            props.Add("groupId", itemGroupId);
            props.Add("item_count", count);
            props.Add("auctioneer_oid", OID.fromLong(0));

            NetworkAPI.SendExtensionMessage(0, false, "auction.buy", props);
            AtavismLogger.LogDebugMessage("BuyAuction End");
        }
示例#6
0
 public void HandleInviteToGuild(string args_str)
 {
     if (args_str == "")
     {
         if (ClientAPI.GetTargetOid() > 0 && ClientAPI.GetPlayerOid() != ClientAPI.GetTargetOid())
         {
             AtavismGuild.Instance.SendGuildCommand("invite", OID.fromLong(ClientAPI.GetTargetOid()), null);
         }
     }
     else
     {
         AtavismGuild.Instance.SendGuildCommand("invite", null, args_str);
     }
 }
示例#7
0
        public void CreateAuction(AtavismInventoryItem item, Dictionary <string, object> currencies, int count, string itemGroupId)
        {
            AtavismLogger.LogDebugMessage("CreateAuction Start");
            Dictionary <string, object> props = new Dictionary <string, object>();

            props.Add("startbid", 0);
            props.Add("buyout", currencies);

            props.Add("item_oid", item.ItemId);
            props.Add("item_count", count);
            props.Add("itemgroup", itemGroupId);
            props.Add("auctioneer_oid", OID.fromLong(0));
            NetworkAPI.SendExtensionMessage(0, false, "auction.createSell", props);
            AtavismLogger.LogDebugMessage("CreateAuction End");
        }
示例#8
0
        public void HandleStartHarvestTask(Dictionary <string, object> props)
        {
            //ClientAPI.Write("Starting build task with length: " + (float)props["length"]);
            float length = (float)props["length"];

            string[] csArgs = new string[2];
            csArgs[0] = length.ToString();
            csArgs[1] = OID.fromLong(ClientAPI.GetPlayerOid()).ToString();
            AtavismEventSystem.DispatchEvent("CASTING_STARTED", csArgs);

            if (UGUICastingBar.Instance != null && UGUICastingBar.Instance.icon != null)
            {
                UGUICastingBar.Instance.icon.sprite = resourceNodes[currentResourceNode].selectedIcon;
            }
        }
示例#9
0
 /// <summary>
 ///
 /// </summary>
 /// <param name="inviter"></param>
 /// <param name="accepted"></param>
 public void TradeInviteResponse(object inviter, bool accepted)
 {
     if (accepted)
     {
         //   string[] event_args = new string[1];
         //  AtavismEventSystem.DispatchEvent("TRADE_START", event_args);
         Dictionary <string, object> props = new Dictionary <string, object>();
         props.Add("requesterOid", (OID)inviter);
         props.Add("partnerOid", OID.fromLong(ClientAPI.GetPlayerOid()));
         props.Add("response", "accept");
         NetworkAPI.SendExtensionMessage(ClientAPI.GetPlayerOid(), false, "ao.TRADE_START_REQ_RESPONSE", props);
     }
     else
     {
         CancelTrade();
     }
 }
示例#10
0
        public void HandleInterruptBuildTask(Dictionary <string, object> props)
        {
            int objectID = (int)props["id"];
            int claimID  = (int)props["claimID"];

            // What do we do now?
            string[] args = new string[2];
            args[0] = "";
            args[1] = OID.fromLong(ClientAPI.GetPlayerOid()).ToString();
            if (selectedObject == null || GetBuildObjectTemplate(selectedObject.TemplateID).buildTaskReqPlayer)
            {
                AtavismEventSystem.DispatchEvent("CASTING_CANCELLED", args);
            }
            else
            {
                AtavismEventSystem.DispatchEvent("GROWING_CANCELLED", args);
            }

            ClientAPI.GetPlayerObject().GameObject.GetComponent <AtavismMobController>().PlayAnimation("", 0);
        }
示例#11
0
        public void HandleStartBuildTask(Dictionary <string, object> props)
        {
            //ClientAPI.Write("Starting build task with length: " + (float)props["length"]);
            float length = (float)props["length"];

            string[] csArgs = new string[2];
            csArgs[0] = length.ToString();
            if (selectedObject == null || GetBuildObjectTemplate(selectedObject.TemplateID).buildTaskReqPlayer)
            {
                csArgs[1] = OID.fromLong(ClientAPI.GetPlayerOid()).ToString();
                AtavismEventSystem.DispatchEvent("CASTING_STARTED", csArgs);
            }
            else
            {
                csArgs    = new string[2];
                csArgs[0] = "0";
                csArgs[1] = length.ToString();
                AtavismEventSystem.DispatchEvent("GROWING_STARTED", csArgs);
            }
        }
示例#12
0
        /// <summary>
        /// Handles the Quest History Log Update message, which has information about the Historicaly Quests.
        /// </summary>
        /// <param name="props">Properties.</param>
        void _HandleQuestHistoryLogInfo(Dictionary <string, object> props)
        {
            questHistoryLogEntries.Clear();
            for (int ii = 0; ii < (int)props["numQuests"]; ii++)
            {
                QuestLogEntry logEntry = new QuestLogEntry();
                long          qId      = (long)props["questId" + ii];
                OID           questId  = OID.fromLong(qId);
                logEntry.QuestId      = questId;
                logEntry.Title        = (string)props["title" + ii];
                logEntry.Description  = (string)props["description" + ii];
                logEntry.Objective    = (string)props["objective" + ii];
                logEntry.CompleteText = (string)props["complete" + ii];
                logEntry.reqLeval     = (int)props["level" + ii];
                questHistoryLogEntries.Add(logEntry);
            }

            // dispatch a ui event to tell the rest of the system
            string[] args = new string[1];
            AtavismEventSystem.DispatchEvent("QUEST_HISTORY_LOG_UPDATE", args);
        }
示例#13
0
        public void HandleTradeStart(Dictionary <string, object> props)
        {
            myOffers.Clear();
            for (int i = 0; i < tradeSlotCount; i++)
            {
                myOffers.Add(null);
            }
            theirOffers.Clear();
            for (int i = 0; i < tradeSlotCount; i++)
            {
                theirOffers.Add(null);
            }
            acceptedByMe      = false;
            acceptedByPartner = false;
            cancelled         = false;
            long partnerOid = (long)props["ext_msg_subject_oid"];

            tradePartnerOid = OID.fromLong(partnerOid);
            myCurrencyOffers.Clear();
            theirCurrencyOffers.Clear();
            // dispatch a ui event to tell the rest of the system
            string[] event_args = new string[1];
            AtavismEventSystem.DispatchEvent("TRADE_START", event_args);
        }
示例#14
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();
        }
示例#15
0
        public void _HandleComm(BaseWorldMessage message)
        {
            CommMessage commMessage = (CommMessage)message;

            AtavismLogger.LogDebugMessage("Got comm message with channel: " + commMessage.ChannelId);
            if (commMessage.ChannelId == 0)
            {
                // Server channel (0)
                //ClientAPI.Interface.DispatchEvent("CHAT_MSG_SAY", [message.Message, nodeName, ""]);
                string[] args = new string[1];
                args[0] = commMessage.Message;
                AtavismEventSystem.DispatchEvent("CHAT_MSG_SERVER", args);
            }
            else if (commMessage.ChannelId == 2)
            {
                // ServerInfo channel (2)
                //ClientAPI.Interface.DispatchEvent("CHAT_MSG_SYSTEM", [message.Message, ""]);
                string[] args = new string[3];
                args[0] = commMessage.Message;
                args[1] = "System";
                args[2] = "";
                AtavismEventSystem.DispatchEvent("CHAT_MSG_SYSTEM", args);
            }
            else if (commMessage.ChannelId == -2)
            {
                string[] args = new string[3];
                args[0] = commMessage.Message;
                args[1] = "Admin";
                args[2] = "";
                AtavismEventSystem.DispatchEvent("ADMIN_MESSAGE", args);
            }
            else
            {
                // Say channel (1)
                //ClientAPI.Interface.DispatchEvent("CHAT_MSG_SAY", [message.Message, nodeName, ""]);
                string[] args = new string[4];
                string   msg  = commMessage.Message;
#if AT_I2LOC_PRESET
                if (msg.IndexOf("has joined the group") != -1)
                {
                    msg = msg.Remove(msg.IndexOf("has joined the group")) + I2.Loc.LocalizationManager.GetTranslation("has joined the group") + ".";
                }
                if (msg.IndexOf("has left the group") != -1)
                {
                    msg = msg.Remove(msg.IndexOf("has left the group")) + I2.Loc.LocalizationManager.GetTranslation("has left the group") + ".";
                }
                if (msg.IndexOf("has disbanded the group") != -1)
                {
                    msg = msg.Remove(msg.IndexOf("has disbanded the group")) + I2.Loc.LocalizationManager.GetTranslation("has disbanded the group") + ".";
                }
                if (msg.IndexOf("is now the group leader") != -1)
                {
                    msg = msg.Remove(msg.IndexOf("is now the group leader")) + I2.Loc.LocalizationManager.GetTranslation("is now the group leader") + ".";
                }
                if (msg.IndexOf("has muted the group") != -1)
                {
                    msg = msg.Remove(msg.IndexOf("has muted the group")) + I2.Loc.LocalizationManager.GetTranslation("has muted the group") + ".";
                }
                if (msg.IndexOf("has un-muted the group") != -1)
                {
                    msg = msg.Remove(msg.IndexOf("has un-muted the group")) + I2.Loc.LocalizationManager.GetTranslation("has un-muted the group") + ".";
                }
                if (msg.IndexOf("Only the group leader can invite new members") != -1)
                {
                    msg = I2.Loc.LocalizationManager.GetTranslation("Only the group leader can invite new members") + ".";
                }
                if (msg.IndexOf("Your group is full") != -1)
                {
                    msg = I2.Loc.LocalizationManager.GetTranslation("Your group is full") + ".";
                }
                if (msg.IndexOf("is already grouped") != -1)
                {
                    msg = msg.Remove(msg.IndexOf("is already grouped")) + I2.Loc.LocalizationManager.GetTranslation("is already grouped") + ".";
                }
                if (msg.IndexOf("is already considering a group invite") != -1)
                {
                    msg = msg.Remove(msg.IndexOf("is already considering a group invite")) + I2.Loc.LocalizationManager.GetTranslation("is already considering a group invite") + ".";
                }
                if (msg.IndexOf("You have invited") != -1)
                {
                    msg = msg.Remove(msg.IndexOf("to your group"));
                    msg = I2.Loc.LocalizationManager.GetTranslation("You have invited") + msg.Remove(0, 16) + I2.Loc.LocalizationManager.GetTranslation("to your group") + ".";
                }
                if (msg.IndexOf("Invitation for") != -1)
                {
                    msg = msg.Remove(msg.IndexOf("was cancelled"));
                    msg = I2.Loc.LocalizationManager.GetTranslation("Invitation for") + msg.Remove(0, 14) + I2.Loc.LocalizationManager.GetTranslation("was cancelled") + ".";
                }
                if (msg.IndexOf("Invitation from") != -1)
                {
                    msg = msg.Remove(msg.IndexOf("was cancelled"));
                    msg = I2.Loc.LocalizationManager.GetTranslation("Invitation from") + msg.Remove(0, 15) + I2.Loc.LocalizationManager.GetTranslation("was cancelled") + ".";
                }
#endif
                args[0] = msg;
                args[1] = commMessage.SenderName;
                args[2] = commMessage.ChannelId.ToString();
                if (commMessage.Oid > 0)
                {
                    args[3] = OID.fromLong(commMessage.Oid).ToString();
                }
                else
                {
                    args[3] = "";
                }
                AtavismEventSystem.DispatchEvent("CHAT_MSG_SAY", args);
            }
        }
示例#16
0
        void HandleCraftingMessage(Dictionary <string, object> props)
        {
            string msgType = (string)props["PluginMessageType"];

            switch (msgType)
            {
            case "CraftingStarted":
            {
                int creationTime = (int)props["creationTime"];
                if (creationTime > 0)
                {
                    // dispatch a ui event to tell the rest of the system
                    string[] args = new string[2];
                    args[0] = creationTime.ToString();
                    args[1] = OID.fromLong(ClientAPI.GetPlayerOid()).ToString();
                    AtavismEventSystem.DispatchEvent("CASTING_STARTED", args);
                }
                //ClearGrid();
                //ui.GetComponent<CraftingUI>().StartProgressBar();
                break;
            }

            case "CraftingCompleted":
            {
                // Go through each item in the grid and set the item back to 0, reducing the count in the grid instead
                //  int num = int.Parse((string)props["num"]);

                int num = (int)props["num"];

                for (int i = 0; i < num; i++)
                {
                    //   int itemId = int.Parse((string)props["item" + i + "Id"]);
                    //  int itemCount = int.Parse((string)props["item" + i + "Count"]);

                    int                  itemId    = (int)props["item" + i + "Id"];
                    int                  itemCount = (int)props["item" + i + "Count"];
                    string[]             args      = new string[1];
                    AtavismInventoryItem it        = Inventory.Instance.GetItemByTemplateID(itemId);
                    if (it != null)
                    {
                        args[0] = "Item Created " + it.BaseName + " x" + itemCount;
                        AtavismEventSystem.DispatchEvent("ANNOUNCEMENT", args);
                    }
                }
                //	string[] args = new string[1];
                //	AtavismEventSystem.DispatchEvent("CRAFTING_GRID_UPDATE", args);*/
                //AtavismNGUIManager.Instance.craftingUI.StopCraftingTimer();
                break;
            }

            case "CraftingFailed":
            {
                /*Dictionary<string, object> errors = new Dictionary<string,object>();
                 * errors.Add("ErrorText", (string)props["ErrorMsg"]);
                 * GameObject ui = GameObject.Find("UI");
                 * ui.GetComponent<ErrorMessage>().HandleErrorMessage(errors);
                 */
                string[] args = new string[1];
                args[0] = (string)props["ErrorMsg"];
                AtavismEventSystem.DispatchEvent("ERROR_MESSAGE", args);

                break;
            }

            case "CraftingInterrupted":
            {
                Debug.LogWarning("Crafting was interrupted");
                // dispatch a ui event to tell the rest of the system
                string[] args = new string[2];
                args[1] = OID.fromLong(ClientAPI.GetPlayerOid()).ToString();
                AtavismEventSystem.DispatchEvent("CASTING_CANCELLED", args);
                ClientAPI.GetPlayerObject().GameObject.GetComponent <AtavismMobController>().PlayAnimation("", 0);
                break;
            }
            }

            AtavismLogger.LogDebugMessage("Got A Crafting Message!");
        }