Beispiel #1
0
        // Gets objects in a scene that match a certerin criteria
        public int Execute(HeroKitObject hko)
        {
            // Get variables
            heroKitObject = hko;

            //-----------------------------------------
            // Get the game objects in the scene that match specific parameters
            //-----------------------------------------
            int    actionType     = DropDownListValue.GetValue(heroKitObject, 0);
            int    getHeroFieldID = 1;
            int    objectCount    = IntegerFieldValue.GetValueA(heroKitObject, 2);
            string tag            = TagValue.GetValue(heroKitObject, 3);

            // filter the hero kit objects in the scene
            List <HeroKitObject> filteredObjects = HeroActionCommonRuntime.GetHeroObjectsByTag(HeroActionCommonRuntime.GetHeroObjectsInScene(), objectCount, tag);

            // assign the hero kit objects to the list
            HeroActionCommonRuntime.AssignObjectsToList(heroKitObject, getHeroFieldID, filteredObjects, actionType);

            //-----------------------------------------
            // debugging stuff
            //-----------------------------------------
            if (heroKitObject.debugHeroObject)
            {
                string countStr     = (filteredObjects != null) ? filteredObjects.Count.ToString() : 0.ToString();
                string debugMessage = "Get objects with this tag: " + tag + "\n" +
                                      "Maximum number of objects to get: " + objectCount + "\n" +
                                      "Objects found: " + countStr;
                Debug.Log(HeroKitCommonRuntime.GetActionDebugInfo(heroKitObject, debugMessage));
            }

            return(-99);
        }
Beispiel #2
0
        // Execute the action
        public int Execute(HeroKitObject hko)
        {
            heroKitObject = hko;

            // get field values
            SceneObjectValueData data = SceneObjectValue.GetValue(heroKitObject, 0, 1, false);

            GameObject[] targetObject = HeroKitCommonRuntime.GetGameObjectsFromSceneObjects(data);
            string       tag          = TagValue.GetValue(heroKitObject, 2);
            bool         runThis      = (targetObject != null);

            // execute action for all objects in list
            for (int i = 0; runThis && i < targetObject.Length; i++)
            {
                ExecuteOnTarget(targetObject[i], tag);
            }

            // debug info
            if (heroKitObject.debugHeroObject)
            {
                string debugMessage = "Tag: " + tag;
                Debug.Log(HeroKitCommonRuntime.GetActionDebugInfo(heroKitObject, debugMessage));
            }

            return(-99);
        }
        // Gets objects in a scene that match a certerin criteria
        public int Execute(HeroKitObject hko)
        {
            // Get variables
            heroKitObject = hko;

            // Get values
            GameObject targetObject = GameObjectFieldValue.GetValueB(heroKitObject, 0);
            bool       useName      = BoolValue.GetValue(heroKitObject, 2);
            string     name         = (useName) ? StringFieldValue.GetValueA(heroKitObject, 3) : "";
            bool       useTag       = BoolValue.GetValue(heroKitObject, 4);
            string     tag          = (useTag) ? TagValue.GetValue(heroKitObject, 5) : "";
            bool       useLayer     = BoolValue.GetValue(heroKitObject, 6);
            int        layer        = (useLayer) ? DropDownListValue.GetValue(heroKitObject, 7) - 1 : 0;
            GameObject childObject  = null;
            bool       runThis      = (targetObject != null);

            if (runThis)
            {
                // get the child object
                childObject = GetChild(targetObject, useName, name, useTag, tag, useLayer, layer);

                // save the game object
                GameObjectFieldValue.SetValueB(heroKitObject, 8, childObject);
            }

            //-----------------------------------------
            // debugging stuff
            //-----------------------------------------
            if (heroKitObject.debugHeroObject)
            {
                string strLayer     = (useLayer) ? layer.ToString() : "";
                string debugMessage = "Child: " + childObject + "\n" +
                                      "With Tag: " + tag + "\n" +
                                      "On Layer: " + strLayer + "\n" +
                                      "With Name: " + name;
                Debug.Log(HeroKitCommonRuntime.GetActionDebugInfo(heroKitObject, debugMessage));
            }

            return(-99);
        }
Beispiel #4
0
        // Gets objects in a scene that match a certerin criteria
        public int Execute(HeroKitObject hko)
        {
            // Get variables
            heroKitObject = hko;

            // Get values
            HeroKitObject[] targetObject = HeroObjectFieldValue.GetValueE(heroKitObject, 0, 1);
            bool            useName      = BoolValue.GetValue(heroKitObject, 2);
            string          name         = (useName) ? StringFieldValue.GetValueA(heroKitObject, 3) : "";
            bool            useTag       = BoolValue.GetValue(heroKitObject, 4);
            string          tag          = (useTag) ? TagValue.GetValue(heroKitObject, 5) : "";
            bool            useLayer     = BoolValue.GetValue(heroKitObject, 6);
            int             layer        = (useLayer) ? DropDownListValue.GetValue(heroKitObject, 7) - 1 : 0;

            GameObject[] targetGameObject = new GameObject[targetObject.Length];
            bool         runThis          = (targetObject != null);

            // execute action for all objects in list
            for (int i = 0; runThis && i < targetObject.Length; i++)
            {
                targetGameObject[i] = ExecuteOnTarget(targetObject[i], useName, name, useTag, tag, useLayer, layer);
            }

            //-----------------------------------------
            // debugging stuff
            //-----------------------------------------
            if (heroKitObject.debugHeroObject)
            {
                string strLayer     = (useLayer) ? layer.ToString() : "";
                string strCount     = (targetGameObject != null) ? targetGameObject.Length.ToString() : "";
                string debugMessage = "Child With Tag: " + tag + "\n" +
                                      "Child On Layer: " + strLayer + "\n" +
                                      "Child With Name: " + name + "\n" +
                                      "Children Found: " + strCount;
                Debug.Log(HeroKitCommonRuntime.GetActionDebugInfo(heroKitObject, debugMessage));
            }

            return(-99);
        }
Beispiel #5
0
        // Gets objects in a scene that match a certerin criteria
        public int Execute(HeroKitObject hko)
        {
            // Get variables
            heroKitObject = hko;
            eventID       = heroKitObject.heroStateData.eventBlock;

            //-----------------------------------------
            // Get the game objects in the scene that match specific parameters
            //-----------------------------------------
            int    actionType                = DropDownListValue.GetValue(heroKitObject, 0);
            int    getHeroFieldID            = 1;
            int    objectCount               = IntegerFieldValue.GetValueA(heroKitObject, 2);
            string tag                       = TagValue.GetValue(heroKitObject, 3);
            List <HeroKitObject> listObjects = HeroObjectFieldValue.GetValueB(heroKitObject, 4);

            // convert list objects to array
            HeroKitObject[] arrayObjects = (listObjects != null) ? listObjects.ToArray() : null;

            // filter the hero kit objects in the list
            List <HeroKitObject> filteredObjects = HeroActionCommonRuntime.GetHeroObjectsByTag(arrayObjects, objectCount, tag);

            // assign the hero kit objects to the list
            HeroActionCommonRuntime.AssignObjectsToList(heroKitObject, getHeroFieldID, filteredObjects, actionType);

            //-----------------------------------------
            // debugging stuff
            //-----------------------------------------
            if (heroKitObject.debugHeroObject)
            {
                string countStr     = (filteredObjects != null) ? filteredObjects.Count.ToString() : 0.ToString();
                string debugMessage = "Get objects with this tag: " + tag + "\n" +
                                      "Objects found: " + countStr;
                Debug.Log(HeroKitCommonRuntime.GetActionDebugInfo(heroKitObject, debugMessage));
            }

            return(-99);
        }
Beispiel #6
0
        // Gets objects in a scene that match a certerin criteria
        public int Execute(HeroKitObject hko)
        {
            // Get variables
            heroKitObject = hko;

            bool   useName  = BoolValue.GetValue(heroKitObject, 0);
            bool   useTag   = BoolValue.GetValue(heroKitObject, 2);
            bool   useLayer = BoolValue.GetValue(heroKitObject, 4);
            string name     = "";
            string tag      = "";
            int    layer    = 0;

            if (useName)
            {
                name = StringFieldValue.GetValueA(heroKitObject, 1);
            }
            if (useTag)
            {
                tag = TagValue.GetValue(heroKitObject, 3);
            }
            if (useLayer)
            {
                layer = DropDownListValue.GetValue(heroKitObject, 5) - 1;
            }

            GameObject targetGameObject = null;

            GameObject[] gameObjects = UnityEngine.Object.FindObjectsOfType <GameObject>();

            if (useName && useTag && useLayer)
            {
                for (int i = 0; i < gameObjects.Length; i++)
                {
                    if (gameObjects[i].name == name && gameObjects[i].layer == layer && gameObjects[i].tag == tag)
                    {
                        targetGameObject = gameObjects[i];
                        break;
                    }
                }
            }

            else if (useName && useTag && !useLayer)
            {
                for (int i = 0; i < gameObjects.Length; i++)
                {
                    if (gameObjects[i].name == name && gameObjects[i].tag == tag)
                    {
                        targetGameObject = gameObjects[i];
                        break;
                    }
                }
            }

            else if (useName && !useTag && useLayer)
            {
                for (int i = 0; i < gameObjects.Length; i++)
                {
                    if (gameObjects[i].name == name && gameObjects[i].layer == layer)
                    {
                        targetGameObject = gameObjects[i];
                        break;
                    }
                }
            }

            else if (!useName && useTag && useLayer)
            {
                for (int i = 0; i < gameObjects.Length; i++)
                {
                    if (gameObjects[i].tag == tag && gameObjects[i].layer == layer)
                    {
                        targetGameObject = gameObjects[i];
                        break;
                    }
                }
            }

            else if (!useName && !useTag && useLayer)
            {
                for (int i = 0; i < gameObjects.Length; i++)
                {
                    if (gameObjects[i].layer == layer)
                    {
                        targetGameObject = gameObjects[i];
                        break;
                    }
                }
            }

            else if (!useName && useTag && !useLayer)
            {
                for (int i = 0; i < gameObjects.Length; i++)
                {
                    if (gameObjects[i].tag == tag)
                    {
                        targetGameObject = gameObjects[i];
                        break;
                    }
                }
            }

            else if (useName && !useTag && !useLayer)
            {
                for (int i = 0; i < gameObjects.Length; i++)
                {
                    if (gameObjects[i].name == name)
                    {
                        targetGameObject = gameObjects[i];
                        break;
                    }
                }
            }

            GameObjectFieldValue.SetValueB(heroKitObject, 6, targetGameObject);

            //-----------------------------------------
            // debugging stuff
            //-----------------------------------------
            if (heroKitObject.debugHeroObject)
            {
                string strLayer     = (useLayer) ? layer.ToString() : "";
                string debugMessage = "Game Object With Tag: " + tag + "\n" +
                                      "Game Object On Layer: " + strLayer + "\n" +
                                      "Game Object With Name: " + name + "\n" +
                                      "Game Object Found: " + targetGameObject;
                Debug.Log(HeroKitCommonRuntime.GetActionDebugInfo(heroKitObject, debugMessage));
            }

            return(-99);
        }