Exemple #1
0
        public void OnEvent(AtavismEventData eData)
        {
            if (eData.eventType == "INVENTORY_UPDATE")
            {
                if (!removeEmptyItemsFromActionBar)
                {
                    return;
                }

                for (int i = 0; i < actions.Count; i++)
                {
                    for (int j = 0; j < actions[i].Count; j++)
                    {
                        AtavismAction action = actions[i][j];
                        if (action != null && action.actionObject != null && action.actionType == ActionType.Item)
                        {
                            // verify the item count is still > 0
                            AtavismInventoryItem actionItem = (AtavismInventoryItem)action.actionObject;
                            if (Inventory.Instance.GetCountOfItem(actionItem.templateId) < 1)
                            {
                                SetAction(i, j, null, false, 0, 0);
                            }
                        }
                    }
                }
            }
        }
 void UpdateButton(int abilityID)
 {
     if (abilityID > 0)
     {
         AtavismAbility ability = Abilities.Instance.GetAbility(abilityID);
         action = new AtavismAction();
         action.actionObject = ability;
         GetComponent <Button>().image.sprite = ability.icon;
         GetComponent <Button>().image.color  = new Color(1, 1, 1, 1);
     }
     else
     {
         GetComponent <Button>().image.color = new Color(0, 0, 0, 0);
     }
 }
Exemple #3
0
        public void HandleActionsUpdate(Dictionary <string, object> props)
        {
            AtavismLogger.LogInfoMessage("Got Actions Update");
            try
            {
                actions.Clear();
                mainActionBar = (int)props["currentBar"];
                int numBars = (int)props["numBars"];
                for (int i = 0; i < numBars; i++)
                {
                    List <AtavismAction> actionBar = new List <AtavismAction>();
                    int barActionCount             = (int)props["barActionCount" + i];
                    for (int j = 0; j < barActionCount; j++)
                    {
                        AtavismAction action       = new AtavismAction();
                        string        actionString = (string)props["bar" + i + "action" + j];
                        if (actionString.StartsWith("a"))
                        {
                            action.actionType = ActionType.Ability;
                            int abilityID = int.Parse(actionString.Substring(1));
                            action.actionObject = GetComponent <Abilities>().GetAbility(abilityID);
                        }
                        else if (actionString.StartsWith("i"))
                        {
                            action.actionType = ActionType.Item;
                            int itemID = int.Parse(actionString.Substring(1));
                            action.actionObject = Inventory.Instance.GetItemByTemplateID(itemID);
                        }
                        else
                        {
                            action.actionType = ActionType.None;
                        }
                        action.slot = j;
                        actionBar.Add(action);
                    }
                    actions.Add(actionBar);
                }

                // dispatch a ui event to tell the rest of the system
                string[] event_args = new string[1];
                AtavismEventSystem.DispatchEvent("ACTION_UPDATE", event_args);
            }
            catch (Exception e)
            {
                AtavismLogger.LogError("Auction.HandleActionsUpdate Exeption " + e.Message);
            }
            AtavismLogger.LogDebugMessage("HandleActionsUpdate End");
        }
Exemple #4
0
        void UpdateActions()
        {
            if (ClientAPI.GetPlayerObject() == null || !ClientAPI.GetPlayerObject().PropertyExists("actions"))
            {
                return;
            }
            actions.Clear();

            List <object> actions_prop = (List <object>)ClientAPI.GetPlayerObject().GetProperty("actions");

            AtavismLogger.LogDebugMessage("Got player actions property change: " + actions_prop);
            int pos = 0;
            //	int bar = 0;

            //foreach (List<object> actionList in actions_prop) {
            List <AtavismAction> actionBar = new List <AtavismAction>();

            foreach (string actionString in actions_prop)
            {
                AtavismAction action = new AtavismAction();
                if (actionString.StartsWith("a"))
                {
                    action.actionType = ActionType.Ability;
                    int abilityID = int.Parse(actionString.Substring(1));
                    action.actionObject = GetComponent <Abilities>().GetAbility(abilityID);
                }
                else if (actionString.StartsWith("i"))
                {
                    action.actionType = ActionType.Item;
                    int itemID = int.Parse(actionString.Substring(1));
                    action.actionObject = Inventory.Instance.GetItemByTemplateID(itemID);
                }
                else
                {
                    action.actionType = ActionType.None;
                }
                action.slot = pos;
                //if (actionBars[bar] != null)
                //	actionBars[bar].SendMessage("ActionUpdate", action);
                pos++;
                actionBar.Add(action);
            }
            actions.Add(actionBar);
            //}
            // dispatch a ui event to tell the rest of the system
            string[] event_args = new string[1];
            AtavismEventSystem.DispatchEvent("ACTION_UPDATE", event_args);
        }