Esempio n. 1
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);
        }
Esempio n. 2
0
 // Use this for initialization
 void Start()
 {
     AtavismEventSystem.RegisterEvent("LOADING_SCENE_START", this);
     AtavismEventSystem.RegisterEvent("LOADING_SCENE_END", this);
     AtavismEventSystem.RegisterEvent("PLAYER_TELEPORTED", this);
     SceneManager.sceneLoaded += LevelWasLoaded;
 }
Esempio n. 3
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);
        }
Esempio n. 4
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");
 }
Esempio n. 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);
        }
Esempio n. 6
0
        void Start()
        {
            if (instance != null)
            {
                return;
            }
            instance = this;

            int gridCount = gridSize * gridSize;

            for (int i = 0; i < gridCount; i++)
            {
                gridItems.Add(new CraftingComponent());
            }

            // Listen for messages from the server
            NetworkAPI.RegisterExtensionMessageHandler("CraftingGridMsg", HandleCraftingGridResponse);
            NetworkAPI.RegisterExtensionMessageHandler("CraftingMsg", HandleCraftingMessage);
            NetworkAPI.RegisterExtensionMessageHandler("BlueprintMsg", HandleBlueprintMessage);
            NetworkAPI.RegisterExtensionMessageHandler("resource_drops", HandleResourceDropsMessage);
            NetworkAPI.RegisterExtensionMessageHandler("resource_state", HandleResourceStateMessage);

            NetworkAPI.RegisterExtensionMessageHandler("start_harvest_task", HandleStartHarvestTask);
            NetworkAPI.RegisterExtensionMessageHandler("harvest_task_interrupted", HandleInterruptHarvestTask);

            // Listen for inventory changes
            AtavismEventSystem.RegisterEvent("INVENTORY_UPDATE", this);
        }
Esempio n. 7
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);
            }
        }
Esempio n. 8
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);
        }
Esempio n. 9
0
 private void OnDestroy()
 {
     AtavismEventSystem.UnregisterEvent("PLACE_CLAIM_OBJECT", this);
     AtavismEventSystem.UnregisterEvent("CLAIM_OBJECT_CLICKED", this);
     AtavismEventSystem.UnregisterEvent("START_BUILD_CLAIM_OBJECT", this);
     AtavismEventSystem.UnregisterEvent("CLAIM_CHANGED", this);
 }
Esempio n. 10
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);
        }
Esempio n. 11
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);
        }
Esempio n. 12
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");
        }
Esempio n. 13
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();
        }
Esempio n. 14
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);
 }
Esempio n. 15
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);
 }
Esempio n. 16
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");
 }
Esempio n. 17
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;
            }
        }
Esempio n. 18
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);
        }
Esempio n. 19
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);
        }
Esempio n. 20
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);
 }
Esempio n. 21
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);
        }
Esempio n. 22
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);
        }
Esempio n. 23
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);
        }
Esempio n. 24
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);
        }
Esempio n. 25
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);
         }
     }
 }
Esempio n. 26
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);
         }
     }
 }
Esempio n. 27
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);
        }
Esempio n. 28
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);
        }
Esempio n. 29
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);
        }
Esempio n. 30
0
 // Use this for initialization
 void Start()
 {
     loginState = LoginState.Login;
     AtavismEventSystem.RegisterEvent("LOGIN_RESPONSE", this);
     AtavismEventSystem.RegisterEvent("REGISTER_RESPONSE", this);
     AtavismEventSystem.RegisterEvent("SETTINGS_LOADED", this);
     // Play music
     SoundSystem.LoadSoundSettings();
     if (musicObject != null)
     {
         SoundSystem.PlayMusic(musicObject.GetComponent <AudioSource>());
     }
 }