Ejemplo n.º 1
0
        // Gets objects in a scene that match a certerin criteria
        public int Execute(HeroKitObject hko)
        {
            // Get variables
            heroKitObject = hko;
            SceneObjectValueData objectData = SceneObjectValue.GetValue(heroKitObject, 0, 1, false);
            HeroKitListenerUI    listener   = null;

            if (objectData.heroKitObject != null)
            {
                listener = objectData.heroKitObject[0].GetHeroComponent <HeroKitListenerUI>("HeroKitListenerUI");
            }
            else if (objectData.gameObject != null)
            {
                listener = heroKitObject.GetGameObjectComponent <HeroKitListenerUI>("HeroKitListenerUI", false, objectData.gameObject[0]);
            }

            if (listener != null)
            {
                // get item id
                bool getItemID = BoolValue.GetValue(heroKitObject, 2);
                if (getItemID)
                {
                    listener.itemID = IntegerFieldValue.GetValueA(heroKitObject, 3);
                }

                // get item
                bool getItem = BoolValue.GetValue(heroKitObject, 9);
                if (getItem)
                {
                    listener.item = HeroObjectFieldValue.GetValueC(heroKitObject, 10);
                }

                // get hero kit object, state, and event to play
                bool getEvent = BoolValue.GetValue(heroKitObject, 6);
                if (getEvent)
                {
                    listener.sendNotificationsHere = HeroObjectFieldValue.GetValueA(heroKitObject, 7)[0];
                    listener.stateID = EventValue.GetStateID(heroKitObject, 8);
                    listener.eventID = EventValue.GetEventID(heroKitObject, 8);
                }
            }

            //------------------------------------
            // debug message
            //------------------------------------
            if (heroKitObject.debugHeroObject)
            {
                string debugMessage = "Listener: " + listener;
                Debug.Log(HeroKitCommonRuntime.GetActionDebugInfo(heroKitObject, debugMessage));
            }

            return(-99);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Show an option button.
        /// </summary>
        /// <param name="choiceText">The text for the button.</param>
        /// <param name="choiceID">The ID for the button.</param>
        private void ShowChoice(Text choiceText, int choiceID)
        {
            choiceText.transform.parent.gameObject.SetActive(true);
            choiceText.text = choice[choiceID];

            HeroKitListenerUI listener = choiceText.transform.parent.gameObject.GetComponent <HeroKitListenerUI>();

            // set the target hero kit object
            listener.sendNotificationsHere = heroKitObject;

            // set action type as "Send Values"
            listener.actionType = 2;
        }
Ejemplo n.º 3
0
        public void CreateUIObjects(GameObject prefabObject, GameObject contentObject, int objectCount, bool incrementID,
                                    HeroKitObject notificationObject, int stateID, int eventID, bool selfNotify)
        {
            GameObject prefab = prefabObject;
            GameObject parent = contentObject;
            int        count  = objectCount;

            for (int i = 0; i < count; i++)
            {
                // create the game object
                GameObject gameObject = UnityEngine.Object.Instantiate(prefab, parent.transform);
                gameObject.name = prefab.name + " " + (i + 1);
                HeroKitObject hko = gameObject.GetComponent <HeroKitObject>();

                // get the hero kit listener component
                HeroKitListenerUI heroListener = hko.GetGameObjectComponent <HeroKitListenerUI>("HeroKitListenerUI", false, gameObject);
                if (heroListener != null)
                {
                    // increment item id?
                    if (incrementID)
                    {
                        heroListener.itemID = (i + 1);
                    }

                    // setup notifications
                    HeroKitObject notifications = (selfNotify) ? hko : notificationObject;
                    if (notifications != null)
                    {
                        heroListener.sendNotificationsHere = notifications;
                        heroListener.actionType            = 1;
                        heroListener.stateID = stateID;
                        heroListener.eventID = eventID;
                    }
                }

                // get the hero object component
                HeroKitObject heroObject = hko.GetGameObjectComponent <HeroKitObject>("HeroKitObject", false, gameObject);
                if (heroObject != null)
                {
                    heroObject.doNotSave = true;
                    heroObject.heroGUID  = HeroKitCommonRuntime.GetHeroGUID();
                }

                gameObject.SetActive(true);
            }
        }
Ejemplo n.º 4
0
        // Gets objects in a scene that match a certerin criteria
        public int Execute(HeroKitObject hko)
        {
            // Get variables
            heroKitObject = hko;
            SceneObjectValueData objectData = SceneObjectValue.GetValue(heroKitObject, 0, 1, false);
            HeroKitListenerUI    listener   = null;

            if (objectData.heroKitObject != null)
            {
                listener = objectData.heroKitObject[0].GetHeroComponent <HeroKitListenerUI>("HeroKitListenerUI");
            }
            else if (objectData.gameObject != null)
            {
                listener = heroKitObject.GetGameObjectComponent <HeroKitListenerUI>("HeroKitListenerUI", false, objectData.gameObject[0]);
            }

            if (listener != null)
            {
                // get item id
                bool getItemID = BoolValue.GetValue(heroKitObject, 2);
                if (getItemID)
                {
                    IntegerFieldValue.SetValueB(heroKitObject, 3, listener.itemID);
                }

                // get item id
                bool getItem = BoolValue.GetValue(heroKitObject, 4);
                if (getItem)
                {
                    HeroObjectFieldValue.SetValueC(heroKitObject, 5, listener.item);
                }
            }

            //------------------------------------
            // debug message
            //------------------------------------
            if (heroKitObject.debugHeroObject)
            {
                string debugMessage = "Hero Kit Listener: " + listener;
                Debug.Log(HeroKitCommonRuntime.GetActionDebugInfo(heroKitObject, debugMessage));
            }

            return(-99);
        }
Ejemplo n.º 5
0
        // Execute the action
        public int Execute(HeroKitObject hko)
        {
            heroKitObject = hko;

            // add menu to scene if it doesn't exist
            HeroKitObject targetObject = HeroKitCommonRuntime.GetPrefabFromAssets(HeroKitCommonRuntime.settingsInfo.inventoryMenu, true);
            HeroObject    item         = null;
            int           count        = 0;
            bool          runThis      = (targetObject != null);

            if (runThis)
            {
                targetObject.gameObject.SetActive(true);

                // get the container for the inventory slots
                GameObject parent = HeroKitCommonRuntime.GetChildGameObject(targetObject.gameObject, "Inventory Menu Content");
                if (parent != null)
                {
                    // get the item we want to add
                    item = HeroObjectFieldValue.GetValueC(heroKitObject, 0);
                    if (item != null)
                    {
                        // get the number of items to add
                        bool addMultiple = BoolValue.GetValue(heroKitObject, 1);
                        count = (addMultiple) ? IntegerFieldValue.GetValueA(heroKitObject, 2) : 1;

                        // check to see if the inventory slot already exists in the menu
                        GameObject    gameObject = HeroKitCommonRuntime.GetChildGameObject(parent, item.name, true);
                        HeroKitObject heroObject = null;

                        // add item if it doesn't exist
                        if (gameObject == null)
                        {
                            // get the inventory slot
                            GameObject prefab = HeroKitCommonRuntime.settingsInfo.inventorySlot;
                            if (prefab == null)
                            {
                                Debug.LogError("Can't add prefab because it can't be found. (Inventory Slot)");
                            }

                            // add prefab to parent
                            if (parent != null && prefab != null)
                            {
                                // create the game object
                                gameObject = UnityEngine.Object.Instantiate(prefab, parent.transform);

                                // get the hero kit listener component
                                HeroKitListenerUI heroListener = heroKitObject.GetGameObjectComponent <HeroKitListenerUI>("HeroKitListenerUI", false, gameObject);
                                if (heroListener != null)
                                {
                                    // add item
                                    heroListener.item = item;

                                    // setup notifications
                                    HeroKitObject notifications = HeroObjectFieldValue.GetValueA(heroKitObject, 3)[0];
                                    if (notifications != null)
                                    {
                                        heroListener.sendNotificationsHere = notifications;
                                        heroListener.actionType            = 1;
                                        heroListener.stateID = EventValue.GetStateID(heroKitObject, 4);
                                        heroListener.eventID = EventValue.GetEventID(heroKitObject, 4);
                                    }

                                    // rename the object
                                    gameObject.name = heroListener.item.name;
                                }

                                // get the hero object component
                                heroObject = heroKitObject.GetGameObjectComponent <HeroKitObject>("HeroKitObject", false, gameObject);
                                if (heroObject != null)
                                {
                                    heroObject.doNotSave = true;
                                    heroObject.heroGUID  = HeroKitCommonRuntime.GetHeroGUID();
                                }

                                // enable the game object
                                gameObject.SetActive(true);
                            }
                        }

                        // if prefab is not active, make it active
                        if (!gameObject.activeSelf)
                        {
                            gameObject.SetActive(true);
                        }

                        // get hero kit object
                        if (heroObject == null)
                        {
                            heroObject = heroKitObject.GetGameObjectComponent <HeroKitObject>("HeroKitObject", false, gameObject);
                        }

                        // add the # of items to add to integer variable list, slot 1
                        heroObject.heroList.ints.items[1].value = count;

                        // play event 1 in the hero kit object attached to this prefab
                        heroObject.PlayEvent(1);
                    }
                }
            }

            // debug message
            if (heroKitObject.debugHeroObject)
            {
                string debugMessage = "Item: " + item + "\n" +
                                      "Count: " + count;
                Debug.Log(HeroKitCommonRuntime.GetActionDebugInfo(heroKitObject, debugMessage));
            }

            return(-99);
        }
Ejemplo n.º 6
0
 /// <summary>
 /// Actions to perform when the hero kit listener is enabled.
 /// </summary>
 private void OnEnable()
 {
     heroKitListener = (HeroKitListenerUI)target;
 }
Ejemplo n.º 7
0
        // Execute the action
        public int Execute(HeroKitObject hko)
        {
            heroKitObject = hko;

            // add menu to scene if it doesn't exist
            HeroKitObject targetObject = HeroKitCommonRuntime.GetPrefabFromAssets(HeroKitCommonRuntime.settingsInfo.journalMenu, true);
            HeroObject    item         = null;
            bool          runThis      = (targetObject != null);

            if (runThis)
            {
                targetObject.gameObject.SetActive(true);

                // get the container for the inventory slots
                GameObject parent = HeroKitCommonRuntime.GetChildGameObject(targetObject.gameObject, "Journal Menu Content");
                if (parent != null)
                {
                    // get the item we want to add
                    item = HeroObjectFieldValue.GetValueC(heroKitObject, 0);
                    if (item != null)
                    {
                        // check to see if the inventory slot already exists in the menu
                        GameObject    gameObject = HeroKitCommonRuntime.GetChildGameObject(parent, item.name, true);
                        HeroKitObject heroObject = null;

                        // add item if it doesn't exist
                        if (gameObject == null)
                        {
                            // get the inventory slot
                            GameObject prefab = HeroKitCommonRuntime.settingsInfo.journalSlot;
                            if (prefab == null)
                            {
                                Debug.LogError("Prefab for journal slot is missing. (Journal Slot)");
                            }

                            // add prefab to parent
                            if (parent != null && prefab != null)
                            {
                                // create the game object
                                gameObject = UnityEngine.Object.Instantiate(prefab, parent.transform);

                                // get the hero kit listener component
                                HeroKitListenerUI heroListener = heroKitObject.GetGameObjectComponent <HeroKitListenerUI>("HeroKitListenerUI", false, gameObject);
                                if (heroListener != null)
                                {
                                    // add item
                                    heroListener.item = item;

                                    // rename the object
                                    gameObject.name = heroListener.item.name;
                                }

                                // get the hero object component
                                heroObject = heroKitObject.GetGameObjectComponent <HeroKitObject>("HeroKitObject", false, gameObject);
                                if (heroObject != null)
                                {
                                    heroObject.doNotSave = true;
                                    heroObject.heroGUID  = HeroKitCommonRuntime.GetHeroGUID();
                                }

                                // enable the game object
                                gameObject.SetActive(true);
                            }

                            // if prefab is not active, make it active
                            if (!gameObject.activeSelf)
                            {
                                gameObject.SetActive(true);
                            }

                            // get hero kit object
                            if (heroObject == null)
                            {
                                heroObject = heroKitObject.GetGameObjectComponent <HeroKitObject>("HeroKitObject", false, gameObject);
                            }

                            // play event 1 in the hero kit object attached to this prefab
                            heroObject.PlayEvent(1);
                        }
                        else
                        {
                            gameObject.SetActive(true);
                        }
                    }
                }
            }

            // debug message
            if (heroKitObject.debugHeroObject)
            {
                string debugMessage = "Journal Entry: " + item;
                Debug.Log(HeroKitCommonRuntime.GetActionDebugInfo(heroKitObject, debugMessage));
            }

            return(-99);
        }