Beispiel #1
0
        public void ClearGrid()
        {
            int gridCount = gridSize * gridSize;

            for (int i = 0; i < gridCount; i++)
            {
                if (gridItems[i].item != null)
                {
                    gridItems[i].item.ResetUseCount();
                }
            }
            gridItems.Clear();
            for (int i = 0; i < gridCount; i++)
            {
                gridItems.Add(new CraftingComponent());
            }

            // Also clear special slots
            resultItems.Clear();
            dye          = null;
            essence      = null;
            recipeItem   = null;
            recipeItemID = -1;

            string[] args = new string[1];
            AtavismEventSystem.DispatchEvent("CRAFTING_GRID_UPDATE", args);
            AtavismEventSystem.DispatchEvent("INVENTORY_UPDATE", args);
        }
Beispiel #2
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();
        }
Beispiel #3
0
 public void HandleCraftingGridResponse(Dictionary <string, object> props)
 {
     try
     {
         AtavismLogger.LogInfoMessage("Got Message HandleCraftingGridResponse");
         recipeID     = (int)props["recipeID"];
         recipeName   = (string)props["recipeName"];
         recipeItemID = (int)props["recipeItem"];
         int numResults = (int)props["numResults"];
         resultItems.Clear();
         for (int i = 0; i < numResults; i++)
         {
             int itemID = (int)props["resultItem" + i];
             AtavismInventoryItem resultItem = GetComponent <Inventory>().GetItemByTemplateID(itemID);
             resultItem.Count = (int)props["resultItemCount" + i];
             resultItems.Add(resultItem);
         }
         if (recipeItemID != -1)
         {
             recipeItem = GetComponent <Inventory>().GetItemByTemplateID(recipeItemID);
         }
         else
         {
             recipeItem = null;
         }
         string[] args = new string[1];
         AtavismEventSystem.DispatchEvent("CRAFTING_GRID_UPDATE", args);
     }
     catch (System.Exception e)
     {
         AtavismLogger.LogError("Got Exeption " + e.Message);
     }
     AtavismLogger.LogInfoMessage("Got Message HandleCraftingGridResponse End");
 }
Beispiel #4
0
        public void HandleTradeOfferUpdate(Dictionary <string, object> props)
        {
            ConvertList(true, (List <object>)props["offer1"]);
            ConvertList(false, (List <object>)props["offer2"]);
            myCurrencyOffers.Clear();
            Dictionary <string, object> myCurrencies = (Dictionary <string, object>)props["currencyOffer1"];

            foreach (string currencyID in myCurrencies.Keys)
            {
                myCurrencyOffers.Add(currencyID, (int)myCurrencies[currencyID]);
            }
            theirCurrencyOffers.Clear();
            Dictionary <string, object> theirCurrencies = (Dictionary <string, object>)props["currencyOffer2"];

            foreach (string currencyID in theirCurrencies.Keys)
            {
                CurrencyDisplay currencyDisplay = Inventory.Instance.GenerateCurrencyDisplay(int.Parse(currencyID), (int)theirCurrencies[currencyID]);
                theirCurrencyOffers.Add(currencyDisplay);
            }
            acceptedByMe      = (bool)props["accepted1"];
            acceptedByPartner = (bool)props["accepted2"];
            cancelled         = false;

            // dispatch a ui event to tell the rest of the system
            string[] event_args = new string[1];
            AtavismEventSystem.DispatchEvent("TRADE_OFFER_UPDATE", event_args);
        }
Beispiel #5
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);
        }
Beispiel #6
0
        public void AbilitiesPropertyHandler(object sender, ObjectPropertyChangeEventArgs args)
        {
            if (args.Oid != ClientAPI.GetPlayerOid())
            {
                return;
            }
            List <object> abilities_prop = (List <object>)ClientAPI.GetPlayerObject().GetProperty("abilities");

            AtavismLogger.LogDebugMessage("Got player abilities property change: " + abilities_prop);
            playerAbilities.Clear();
            //int pos = 0;
            foreach (int abilityNum in abilities_prop)
            {
                if (!abilities.ContainsKey(abilityNum))
                {
                    AtavismLogger.LogWarning("Ability " + abilityNum + " does not exist");
                    continue;
                }
                AtavismAbility ability = abilities[abilityNum].Clone(tempCombatDataStorage);
                playerAbilities.Add(ability);
            }
            // dispatch a ui event to tell the rest of the system
            string[] event_args = new string[1];
            AtavismEventSystem.DispatchEvent("ABILITY_UPDATE", event_args);
        }
Beispiel #7
0
        public void HandleTradeComplete(Dictionary <string, object> props)
        {
            // dispatch a ui event to tell the rest of the system
            string[] event_args = new string[1];
            byte     status     = (byte)props["status"];

            if (status == 2 || status == 3)
            {
#if AT_I2LOC_PRESET
                event_args[0] = I2.Loc.LocalizationManager.GetTranslation("Trade Cancelled");
#else
                event_args[0] = "Trade Cancelled";
#endif
                UGUIConfirmationPanel.Instance.Hide();
                AtavismEventSystem.DispatchEvent("ERROR_MESSAGE", event_args);
                event_args = new string[1];
            }
            else if (status == 1)
            {
#if AT_I2LOC_PRESET
                event_args[0] = I2.Loc.LocalizationManager.GetTranslation("Trade Completed");
#else
                event_args[0] = "Trade Completed";
#endif
                AtavismEventSystem.DispatchEvent("ANNOUNCEMENT", event_args);
            }

            AtavismEventSystem.DispatchEvent("TRADE_COMPLETE", event_args);
        }
Beispiel #8
0
        void _HandleNpcDialogue(Dictionary <string, object> props)
        {
            // update our idea of the state
            //QuestLogEntry logEntry = null;
            NpcId               = (OID)props["npcOid"];
            dialogue            = new Dialogue();
            dialogue.dialogueID = (int)props["dialogueID"];
            dialogue.title      = (string)props["title"];
            dialogue.text       = (string)props["text"];
            dialogue.npcId      = NpcId;

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

            for (int i = 0; i < numOptions; i++)
            {
                DialogueAction action = new DialogueAction();
                action.interactionType  = (string)props["option" + i + "action"];
                action.interactionID    = (int)props["option" + i + "actionID"];
                action.interactionTitle = (string)props["option" + i + "text"];
                action.dialogueID       = dialogue.dialogueID;
                action.npcId            = NpcId;
                dialogue.actions.Add(action);
            }

            // dispatch a ui event to tell the rest of the system
            string[] args = new string[1];
            AtavismEventSystem.DispatchEvent("DIALOGUE_UPDATE", args);
        }
Beispiel #9
0
        public void _HandleQuestEvent(Dictionary <string, object> props)
        {
            string eventType = (string)props["event"];
            int    val1      = (int)props["val1"];
            int    val2      = (int)props["val2"];
            int    val3      = (int)props["val3"];
            string data      = (string)props["data"];

#if AT_I2LOC_PRESET
            if (data.IndexOf(" killed:") != -1)
            {
                string objectivesNames = I2.Loc.LocalizationManager.GetTranslation("Quests/" + data.Remove(data.IndexOf(" killed:")));
                //    string objectivesValues = data.Remove(0, data.LastIndexOf(':') < 0 ? 0 : data.LastIndexOf(':')+1);
                data = objectivesNames + " " + I2.Loc.LocalizationManager.GetTranslation("killed") + ": " + val2 + "/" + val3 + (val2 == val3 ? " (" + I2.Loc.LocalizationManager.GetTranslation("Complete") + ")" : "");
            }
            if (data.IndexOf(" collected:") != -1)
            {
                string objectivesNames = I2.Loc.LocalizationManager.GetTranslation("Quests/" + data.Remove(data.IndexOf(" collected:")));
                //    string objectivesValues = data.Remove(0, data.LastIndexOf(':') < 0 ? 0 : data.LastIndexOf(':')+1);
                data = objectivesNames + " " + I2.Loc.LocalizationManager.GetTranslation("collected") + ": " + val2 + "/" + val3 + (val2 == val3 ? " (" + I2.Loc.LocalizationManager.GetTranslation("Complete") + ")" : "");
            }
#endif
            //string errorMessage = eventType;
            if (eventType == "QuestProgress")
            {
                // dispatch a ui event to tell the rest of the system
                string[] args = new string[1];
                args[0] = data;
                AtavismEventSystem.DispatchEvent("ANNOUNCEMENT", args);
            }
        }
Beispiel #10
0
        private void handleVipUpdate(Dictionary <string, object> props)
        {
            //    Debug.LogError("handleVipUpdate");
            bonuses.Clear();
            level      = (int)props["lev"];
            points     = (long)props["points"];
            max_points = (long)props["mpoints"];
            time       = (long)props["time"] / 1000;
            Name       = (string)props["name"];
            desc       = (string)props["desc"];
            int bNum = (int)props["bNum"];

            for (int i = 0; i < bNum; i++)
            {
                string   b     = (string)props["b" + i];
                string[] ba    = b.Split('|');
                Bonus    bonus = new Bonus();
                bonus.name       = ba[0];
                bonus.value      = int.Parse(ba[1]);
                bonus.percentage = float.Parse(ba[2]);
                bonuses.Add(bonus);
            }
            if (time > 0)
            {
                calculatedTime = Time.time + time;
            }
            string[] event_args = new string[1];
            AtavismEventSystem.DispatchEvent("VIP_UPDATE", event_args);
            //    Debug.LogError("handleVipUpdate END");
        }
Beispiel #11
0
 public void RequestMailList(Vector3 location)
 {
     RequestMailList();
     this.mailboxLocation = location;
     //dispatch an event to tell the rest of the system
     string[] args = new string[1];
     AtavismEventSystem.DispatchEvent("SHOW_MAIL", args);
 }
Beispiel #12
0
 void _HandleRepairComplete(Dictionary <string, object> props)
 {
     //   Debug.LogError("_HandleRepair");
     // dispatch a ui event to tell the rest of the system
     string[] args = new string[1];
     AtavismEventSystem.DispatchEvent("REPAIR_COMPLETE", args);
     //   Debug.LogError("_HandleRepair End");
 }
Beispiel #13
0
 public void HandleGuildMotd(Dictionary <string, object> props)
 {
     motd  = (string)props["motd"];
     omotd = (string)props["omotd"];
     // dispatch a ui event to tell the rest of the system
     string[] args = new string[1];
     AtavismEventSystem.DispatchEvent("GUILD_UPDATE", args);
 }
Beispiel #14
0
        // Update is called once per frame
        void Update()
        {
            if (activeClaim == null /*&& buildingState != WorldBuildingState.None*/)
            {
                // Check against claims to see if a region has been entered
                foreach (Claim claim in claims)
                {
                    //   Debug.LogWarning("WorldBuilder "+claim.id+" "+claim.name+ " "+claim.permissionlevel+" "+claim.permissions+" | scena="+UnityEngine.SceneManagement.SceneManager.GetActiveScene().name);
                    if (ClientAPI.GetPlayerObject() != null && InsideClaimArea(claim, ClientAPI.GetPlayerObject().Position))
                    {
                        //     Debug.LogWarning("WorldBuilder Selected ClaimId="+claim.id+" "+claim.name );
                        activeClaim = claim;
                        // dispatch a ui event to tell the rest of the system
                        string[] args = new string[1];
                        AtavismEventSystem.DispatchEvent("CLAIM_CHANGED", args);
                        break;
                    }
                }
            }
            else /*if (buildingState != WorldBuildingState.None) */
            {
                // Check if the player has left the claim
                if (ClientAPI.GetPlayerObject() != null && !InsideClaimArea(activeClaim, ClientAPI.GetPlayerObject().Position))
                {
                    activeClaim = null;
                    // dispatch a ui event to tell the rest of the system
                    string[] args = new string[1];
                    AtavismEventSystem.DispatchEvent("CLAIM_CHANGED", args);
                }
            }

            // Check distance for selected object - if too far away, unselect it
            if (selectedObject != null && buildingState != WorldBuildingState.MoveItem)
            {
                if (ClientAPI.GetPlayerObject() != null)
                {
                    if (Vector3.Distance(ClientAPI.GetPlayerObject().Position, selectedObject.transform.position) > deselectDistance)
                    {
                        SelectedObject = null;
                    }
                }
                else
                {
                    SelectedObject = null;
                }
            }

            if (frameCount == 3 && objectsToLoad.Count > 0)
            {
                SpawnClaimObject(objectsToLoad[0]);
                objectsToLoad.RemoveAt(0);
            }
            frameCount++;
            if (frameCount > 3)
            {
                frameCount = 0;
            }
        }
Beispiel #15
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);
        }
Beispiel #16
0
        public void ClaimIDMessage(Dictionary <string, object> props)
        {
            int claimID = (int)props["claimID"];
            //   Debug.LogWarning("WorldBuilder Got Cliam id="+claimID);
            Claim claim = new Claim();

            if (GetClaim(claimID) != null)
            {
                claim = GetClaim(claimID);
            }
            else
            {
                claim.id = claimID;
            }

            claim.name  = (string)props["claimName"];
            claim.sizeX = (int)props["claimSizeX"];
            claim.sizeZ = (int)props["claimSizeZ"];
            claim.loc   = (Vector3)props["claimLoc"];
            claim.GenerateBounds();
            claim.claimType       = (ClaimType)props["claimType"];
            claim.ownerName       = (string)props["ownerName"];
            claim.forSale         = (bool)props["forSale"];
            claim.permissionlevel = (int)props["permissionLevel"];
            if (claim.forSale)
            {
                claim.cost     = (int)props["cost"];
                claim.currency = (int)props["currency"];
            }
            claim.purchaseItemReq = (int)props["purchaseItemReq"];
            claim.playerOwned     = (bool)props["myClaim"];
            // Player permissions
            claim.permissions.Clear();
            int permissionCount = (int)props["permissionCount"];

            for (int i = 0; i < permissionCount; i++)
            {
                ClaimPermission per = new ClaimPermission();
                per.playerName      = (string)props["permission_" + i];
                per.permissionLevel = (int)props["permissionLevel_" + i];
                claim.permissions.Add(per);
            }

            if (GetClaim(claimID) == null)
            {
                // Debug.LogWarning("WorldBuilder add to Cliam list id=" + claim.id);
                claims.Add(claim);
            }

            if (claim == activeClaim)
            {
                string[] args = new string[1];
                AtavismEventSystem.DispatchEvent("CLAIM_CHANGED", args);
            }
            AtavismLogger.LogDebugMessage("Got new claim data: " + claim.id);
        }
Beispiel #17
0
 public void StartPlaceClaimObject(AtavismInventoryItem item)
 {
     if (activeClaim == null)
     {
         return;
     }
     string[] args = new string[1];
     args[0] = item.ItemId.ToString();
     AtavismEventSystem.DispatchEvent("PLACE_CLAIM_OBJECT", args);
 }
Beispiel #18
0
        private void HandleGroupDice(Dictionary <string, object> props)
        {
            int itemId = (int)props["itemId"];
            int count  = (int)props["time"];

            mob = (OID)props["mob"];
            string[] event_args = new string[2];
            event_args[0] = count.ToString();
            event_args[1] = itemId.ToString();
            AtavismEventSystem.DispatchEvent("GROUP_DICE", event_args);
        }
Beispiel #19
0
        public void HandleGuildData(Dictionary <string, object> props)
        {
#if AT_I2LOC_PRESET
            //ClientAPI.Write(I2.Loc.LocalizationManager.GetTranslation("Got guild update"));
#else
            //   ClientAPI.Write("Got guild update");
#endif
            members = new List <AtavismGuildMember>();
            ranks   = new List <AtavismGuildRank>();

            guildName = (string)props["guildName"];
            if (guildName == null)
            {
                // dispatch a ui event to tell the rest of the system
                string[] args = new string[1];
                AtavismEventSystem.DispatchEvent("GUILD_UPDATE", args);
                return;
            }
            motd  = (string)props["motd"];
            omotd = (string)props["omotd"];

            int numMembers = (int)props["numMembers"];
            for (int i = 0; i < numMembers; i++)
            {
                AtavismGuildMember member = new AtavismGuildMember();
                member.oid    = (OID)props["memberOid" + i];
                member.name   = (string)props["memberName" + i];
                member.rank   = (int)props["memberRank" + i];
                member.level  = (int)props["memberLevel" + i];
                member.zone   = (string)props["memberZone" + i];
                member.note   = (string)props["memberNote" + i];
                member.status = (int)props["memberStatus" + i];
                members.Add(member);
            }

            int numRanks = (int)props["numRanks"];
            for (int i = 0; i < numRanks; i++)
            {
                AtavismGuildRank rank = new AtavismGuildRank();
                rank.rankLevel   = (int)props["rankLevel" + i];
                rank.rankName    = (string)props["rankName" + i];
                rank.permissions = new List <AtavismGuildRankPermission>();
                int rankNumPermissions = (int)props["rankNumPermissions" + i];
                for (int j = 0; j < rankNumPermissions; j++)
                {
                    string permission = (string)props["rankNum" + i + "Permission" + j];
                    rank.permissions.Add((AtavismGuildRankPermission)Enum.Parse(typeof(AtavismGuildRankPermission), permission));
                }
                ranks.Add(rank);
            }
            // dispatch a ui event to tell the rest of the system
            string[] event_args = new string[1];
            AtavismEventSystem.DispatchEvent("GUILD_UPDATE", event_args);
        }
Beispiel #20
0
        public virtual void HandleRequirementFailedEvent(Dictionary <string, object> props)
        {
            string eventType = (string)props["event"];
            int    val       = (int)props["val"];
            string data      = (string)props["data"];

            string errorMessage = eventType;

            if (eventType == "RequirementResultSkillTooLow")
            {
#if AT_I2LOC_PRESET
                errorMessage = I2.Loc.LocalizationManager.GetTranslation("You do not meet the requirements");
#else
                errorMessage = "You do not meet the requirements";
#endif
            }
            else if (eventType == "RequirementResultWrongRace")
            {
#if AT_I2LOC_PRESET
                errorMessage = I2.Loc.LocalizationManager.GetTranslation("You do not meet the requirements");
#else
                errorMessage = "You do not meet the requirements";
#endif
            }
            else if (eventType == "RequirementResultWrongClass")
            {
#if AT_I2LOC_PRESET
                errorMessage = I2.Loc.LocalizationManager.GetTranslation("You do not meet the requirements");
#else
                errorMessage = "You do not meet the requirements";
#endif
            }
            else if (eventType == "RequirementResultLevelTooLow")
            {
#if AT_I2LOC_PRESET
                errorMessage = I2.Loc.LocalizationManager.GetTranslation("You do not meet the requirements");
#else
                errorMessage = "You do not meet the requirements";
#endif
            }
            else if (eventType == "RequirementResultStatTooLow")
            {
#if AT_I2LOC_PRESET
                errorMessage = I2.Loc.LocalizationManager.GetTranslation("You do not meet the requirements");
#else
                errorMessage = "You do not meet the requirements";
#endif
            }

            // dispatch a ui event to tell the rest of the system
            string[] args = new string[1];
            args[0] = errorMessage;
            AtavismEventSystem.DispatchEvent("ERROR_MESSAGE", args);
        }
Beispiel #21
0
        public void ClaimObjectInfoMessage(Dictionary <string, object> props)
        {
            itemsPlacedToUpgrade.Clear();
            int  objectID  = (int)props["id"];
            int  claimID   = (int)props["claimID"];
            int  health    = (int)props["health"];
            int  maxHealth = (int)props["maxHealth"];
            int  itemCount = (int)props["itemCount"];
            bool complete  = (bool)props["complete"];

            Claim claim = GetClaim(claimID);

            if (claim != null)
            {
                if (!claim.claimObjects.ContainsKey(objectID))
                {
                    return;
                }
                claim.claimObjects[objectID].Health    = health;
                claim.claimObjects[objectID].MaxHealth = maxHealth;
                claim.claimObjects[objectID].Complete  = complete;
                Dictionary <int, int> itemReqs = new Dictionary <int, int>();
                for (int i = 0; i < itemCount; i++)
                {
                    itemReqs.Add((int)props["item" + i], (int)props["itemCount" + i]);
                }
                claim.claimObjects[objectID].ItemReqs = itemReqs;

                // Work out how much time is left in the current task
                long timeCompleted = (long)props["timeCompleted"];
                if (timeCompleted > 0)
                {
                    long     timeLeft         = (long)props["timeLeft"];
                    float    secondsCompleted = (float)timeCompleted / 1000f;
                    float    secondsLeft      = (float)timeLeft / 1000f;
                    string[] csArgs           = new string[2];
                    csArgs[0] = secondsCompleted.ToString();
                    csArgs[1] = secondsLeft.ToString();
                    AtavismEventSystem.DispatchEvent("GROWING_STARTED", csArgs);
                }
                else
                {
                    string[] csArgs = new string[2];
                    csArgs[0] = "0";
                    csArgs[1] = "0";
                    AtavismEventSystem.DispatchEvent("GROWING_STARTED", csArgs);
                }
            }

            // Dispatch event to be picked up by UI
            string[] args = new string[1];
            args[0] = "";
            AtavismEventSystem.DispatchEvent("CLAIM_OBJECT_UPDATED", args);
        }
Beispiel #22
0
 // Update is called once per frame
 void Update()
 {
     if (NpcId != null && ClientAPI.GetObjectNode(NpcId.ToLong()) != null)
     {
         if (Vector3.Distance(ClientAPI.GetPlayerObject().Position, ClientAPI.GetObjectNode(NpcId.ToLong()).GameObject.transform.position) > 5)
         {
             NpcId = null;
             string[] args = new string[1];
             AtavismEventSystem.DispatchEvent("CLOSE_NPC_DIALOGUE", args);
         }
     }
 }
Beispiel #23
0
 // Update is called once per frame
 void Update()
 {
     if (mailboxLocation != Vector3.zero)
     {
         if (Vector3.Distance(ClientAPI.GetPlayerObject().Position, mailboxLocation) > 5)
         {
             mailboxLocation = Vector3.zero;
             string[] args = new string[1];
             AtavismEventSystem.DispatchEvent("CLOSE_MAIL_WINDOW", args);
         }
     }
 }
Beispiel #24
0
        public void HandleMailList(Dictionary <string, object> props)
        {
            mailList = new List <MailEntry>();
            int numMail = (int)props["numMail"];

            for (int i = 0; i < numMail; i++)
            {
                MailEntry entry = new MailEntry();
                entry.mailId     = (int)props["mail_" + i + "ID"];
                entry.senderOid  = (OID)props["mail_" + i + "SenderOid"];
                entry.senderName = (string)props["mail_" + i + "SenderName"];
                entry.subject    = (string)props["mail_" + i + "Subject"];
                entry.message    = (string)props["mail_" + i + "Message"];
                List <MailItem> items = new List <MailItem>();
                //TODO: put item reading code here
                int numItems = (int)props["mail_" + i + "NumItems"];
                for (int j = 0; j < numItems; j++)
                {
                    MailItem mailItem     = new MailItem();
                    int      itemTemplate = (int)props["mail_" + i + "ItemTemplate" + j];
                    if (itemTemplate > 0)
                    {
                        mailItem.item  = Inventory.Instance.GetItemByTemplateID(itemTemplate);
                        mailItem.count = (int)props["mail_" + i + "ItemCount" + j];
                    }
                    items.Add(mailItem);
                }
                entry.items = items;

                // Currency
                int currencyType   = (int)props["mail_" + i + "CurrencyType"];
                int currencyAmount = (int)props["mail_" + i + "CurrencyAmount"];
                if (currencyType > 0)
                {
                    entry.currencies.Add(Inventory.Instance.GetCurrency(currencyType), currencyAmount);
                }
                entry.cashOnDelivery = (bool)props["mail_" + i + "CoD"];
                entry.read           = (bool)props["mail_" + i + "Read"];
                mailList.Add(entry);

                // Update the mail being read
                if (selectedMail != null && selectedMail.mailId == entry.mailId)
                {
                    selectedMail = entry;
                }
            }


            //dispatch an event to tell the rest of the system
            string[] args = new string[1];
            AtavismEventSystem.DispatchEvent("MAIL_UPDATE", args);
        }
Beispiel #25
0
        public void HandleGuildChat(Dictionary <string, object> props)
        {
            OID    senderOid  = (OID)props["senderOid"];
            string senderName = (string)props["senderName"];
            string message    = (string)props["message"];

            string[] args = new string[4];
            args[0] = message;
            args[1] = senderName;
            args[2] = "5";
            args[3] = senderOid.ToString();
            AtavismEventSystem.DispatchEvent("CHAT_MSG_SAY", args);
        }
Beispiel #26
0
        public void StartPlaceBuildObject(int buildObjectTemplateID)
        {
            // Make sure player is in a claim they own
            if (activeClaim == null)
            {
                return;
            }

            // dispatch a ui event to tell the rest of the system
            string[] args = new string[1];
            args[0] = "" + buildObjectTemplateID;
            AtavismEventSystem.DispatchEvent("START_BUILD_CLAIM_OBJECT", args);
        }
Beispiel #27
0
        private void _HandleArenaStatUpdate(Dictionary <string, object> props)
        {
            AtavismLogger.LogDebugMessage("_HandleArenaStatUpdate START");
            try
            {
                string stat   = (string)props["stat"];
                OID    plyOid = (OID)props["player"];
                int    team   = (int)props["team"];
                int    score  = (int)props["score"];
                if (activeArenaTeams[team] != null)
                {
                    foreach (ArenaTeamPlayerEntry ply in activeArenaTeams[team].players)
                    {
                        if (ply.playerOid.Equals(plyOid))
                        {
                            switch (stat)
                            {
                            case "score":
                                ply.score = score;
                                break;

                            case "kill":
                                ply.kills = score;
                                break;

                            case "death":
                                ply.deaths = score;
                                break;

                            case "damageTaken":
                                ply.damageTaken = score;
                                break;

                            case "damageDealt":
                                ply.damageDealt = score;
                                break;
                            }
                        }
                    }
                }
                string[] args = new string[1];
                AtavismEventSystem.DispatchEvent("ARENA_SCORE_UPDATE", args);
            }
            catch (Exception e)
            {
                AtavismLogger.LogError("Arena._HandleArenaStatUpdate Exeption " + e.Message);
            }
            AtavismLogger.LogDebugMessage("_HandleArenaStatUpdate END");
        }
Beispiel #28
0
        public void HandleAuctionListForGroupUpdate(Dictionary <string, object> props)
        {
            AtavismLogger.LogDebugMessage("HandleAuctionListForGroupUpdate");

            /*  string keys = " [ ";
             * foreach (var it in props.Keys)
             * {
             *    keys += " ; " + it + " => " + props[it];
             * }
             * Debug.LogWarning("HandleAuctionOwnerListUpdate: keys:" + keys);
             */
            try
            {
                auctionsForGroupSell.Clear();
                auctionsForGroupOrder.Clear();
                costStartValue = (long)props["sPriceVal"];
                costStartPer   = (float)props["SPricePerc"];
                costEndValue   = (long)props["cPriceVal"];
                costEndPer     = (float)props["cPricePerc"];
                currecnyType   = (int)props["currency"];
                int numItemsSell  = (int)props["numItemsSell"];
                int numItemsOrder = (int)props["numItemsOrder"];
                for (int i = 0; i < numItemsSell; i++)
                {
                    AuctionCountPrice auctionInfo = new AuctionCountPrice();

                    auctionInfo.count    = (int)props["auctionSell_" + i + "Count"];
                    auctionInfo.price    = (long)props["auctionSell_" + i + "Price"];
                    auctionInfo.currency = (int)props["auctionSell_" + i + "Currency"];
                    auctionsForGroupSell.Add(auctionInfo.price, auctionInfo);
                }
                for (int i = 0; i < numItemsOrder; i++)
                {
                    AuctionCountPrice auctionInfo = new AuctionCountPrice();

                    auctionInfo.count    = (int)props["auctionOrder_" + i + "Count"];
                    auctionInfo.price    = (long)props["auctionOrder_" + i + "Price"];
                    auctionInfo.currency = (int)props["auctionOrder_" + i + "Currency"];
                    auctionsForGroupOrder.Add(auctionInfo.price, auctionInfo);
                }
                string[] args = new string[1];
                AtavismEventSystem.DispatchEvent("AUCTION_LIST_FOR_GROUP_UPDATE", args);
            }
            catch (Exception e)
            {
                AtavismLogger.LogError("AtavismAuction.HandleAuctionOwnerListUpdate Exeption " + e.Message);
            }
            AtavismLogger.LogDebugMessage("HandleAuctionOwnerListUpdate End");
        }
Beispiel #29
0
        void _HandleNpcInteractionOptionsResponse(Dictionary <string, object> props)
        {
            // update the information about the interaction options on offer from this npc
            interactionOptions.Clear();
            int numInteractions = (int)props["numInteractions"];

            NpcId = (OID)props["npcOid"];
            for (int i = 0; i < numInteractions; i++)
            {
                NpcInteractionEntry entry = new NpcInteractionEntry();
                entry.interactionType = (string)props["interactionType_" + i];
                //entry.interactionTitle = (string)props ["interactionTitle_" + i];
                string sComplete = "";

                if (props["interactionValue_" + i] != null && (bool)props["interactionValue_" + i])
#if AT_I2LOC_PRESET
                { sComplete = string.Concat(" (", I2.Loc.LocalizationManager.GetTranslation("Complete"), ")"); }
#else
                { sComplete = " (Complete)"; }
#endif

                entry.interactionTitle = (string)props["interactionTitle_" + i] + sComplete;

                entry.interactionID = (int)props["interactionID_" + i];
                entry.npcId         = NpcId;

                interactionOptions.Add(entry);

                //ClientAPI.Write("Quest grades: %s" % logEntry.grades)
            }

            string dialogueText = (string)props["dialogue_text"];
            if (dialogueText != "")
            {
                dialogue      = new Dialogue();
                dialogue.text = dialogueText;
            }
            else
            {
                dialogue = null;
            }

            //
            // dispatch a ui event to tell the rest of the system
            //
            string[] args = new string[1];
            // args [0] = npcID.ToString ();
            AtavismEventSystem.DispatchEvent("NPC_INTERACTIONS_UPDATE", args);
        }
Beispiel #30
0
        public void HandleBuildingResources(Dictionary <string, object> props)
        {
            buildingResources.Clear();
            int numResources = (int)props["numResources"];

            for (int i = 0; i < numResources; i++)
            {
                string resourceID    = (string)props["resource" + i + "ID"];
                int    resourceCount = (int)props["resource" + i + "Count"];
                buildingResources.Add(int.Parse(resourceID), resourceCount);
            }
            // dispatch a ui event to tell the rest of the system
            string[] args = new string[1];
            AtavismEventSystem.DispatchEvent("RESOURCE_UPDATE", args);
        }