示例#1
0
        // Execute the action
        public int Execute(HeroKitObject hko)
        {
            heroKitObject = hko;

            GameObject    prefab          = PrefabValue.GetValue(heroKitObject, 0);
            GameObject    parent          = GameObjectFieldValue.GetValueA(heroKitObject, 1);
            int           count           = IntegerFieldValue.GetValueA(heroKitObject, 2);
            bool          incrementItemID = BoolValue.GetValue(heroKitObject, 3);
            HeroKitObject notifications   = HeroObjectFieldValue.GetValueA(heroKitObject, 4)[0];
            int           stateID         = EventValue.GetStateID(heroKitObject, 5);
            int           eventID         = EventValue.GetEventID(heroKitObject, 5);
            bool          runThis         = (prefab != null && parent != null);

            if (runThis)
            {
                CreateUIObjects(prefab, parent, count, incrementItemID, notifications, stateID, eventID, false);
            }

            //------------------------------------
            // debug message
            //------------------------------------
            if (heroKitObject.debugHeroObject)
            {
                string debugMessage = "Parent Game Object: " + parent + "\n" +
                                      "Object to Duplicate: " + prefab + "\n" +
                                      "Number of Duplicates: " + count + "\n" +
                                      "Increment Item ID: " + incrementItemID + "\n" +
                                      "Send Notifications Here: " + notifications + "\n" +
                                      "Notification State ID: " + stateID + "\n" +
                                      "Notification Event ID: " + eventID;
                Debug.Log(HeroKitCommonRuntime.GetActionDebugInfo(heroKitObject, debugMessage));
            }

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

            // get field values
            GameObject targetObject = GameObjectFieldValue.GetValueA(heroKitObject, 0);
            bool       runThis      = (targetObject != null);

            if (runThis)
            {
                // turn game object off
                targetObject.SetActive(true);
            }

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

            return(-99);
        }
示例#3
0
        // Check to see if an integer meets certain conditions in an if statement
        // This is used by both If and Else If
        public int Execute(HeroKitObject hko)
        {
            // assign variables
            heroKitObject = hko;
            eventID       = heroKitObject.heroStateData.eventBlock;
            int actionID      = heroKitObject.heroStateData.action;
            int currentIndent = heroKitObject.heroState.heroEvent[eventID].actions[actionID].indent;

            // evaluate the if statement
            int        comparison = DropDownListValue.GetValue(heroKitObject, 2);
            GameObject value1     = GameObjectFieldValue.GetValueB(heroKitObject, 1);
            GameObject value2     = GameObjectFieldValue.GetValueA(heroKitObject, 3);
            bool       evaluation = HeroActionCommonRuntime.CompareValues(comparison, value1, value2);

            // next we need to get the action that we want the game loop to think just executed
            // this checks to see if the if statement should be run
            // if it should run, it disables the next conditional action if it is "Else" or "Else If"
            int thisAction = HeroActionCommonRuntime.RunConditionalIfAction(heroKitObject, eventID, actionID, currentIndent, evaluation);

            // debug message
            if (heroKitObject.debugHeroObject)
            {
                string debugMessage = "Game Object A: " + value1 + "\n" +
                                      "Game Object B: " + value2 + "\n" +
                                      "Result: " + evaluation;
                Debug.Log(HeroKitCommonRuntime.GetActionDebugInfo(heroKitObject, debugMessage));
            }

            // return the action that we want the game loop to think just executed
            return(thisAction);
        }
示例#4
0
        public GameObject ExecuteOnTarget(HeroKitObject targetObject, bool useName, string name, bool useTag, string tag, bool useLayer, int layer)
        {
            // go through children and search for match
            GameObject targetGameObject = null;
            int        children         = targetObject.transform.childCount;

            for (int i = 0; i < children; i++)
            {
                Transform childObject      = targetObject.transform.GetChild(i);
                bool      haveCorrectName  = false;
                bool      haveCorrectTag   = false;
                bool      haveCorrectLayer = false;
                bool      needName         = false;
                bool      needTag          = false;
                bool      needLayer        = false;

                if (useName)
                {
                    needName = true;
                    if (childObject.name == name)
                    {
                        haveCorrectName = true;
                    }
                }

                if (useTag)
                {
                    needTag = true;
                    if (childObject.tag == tag)
                    {
                        haveCorrectTag = true;
                    }
                }

                if (useLayer)
                {
                    needLayer = true;
                    if (childObject.gameObject.layer == layer)
                    {
                        haveCorrectLayer = true;
                    }
                }

                if (needName == haveCorrectName && needTag == haveCorrectTag && needLayer == haveCorrectLayer)
                {
                    targetGameObject = childObject.gameObject;
                    break;
                }
            }

            // save the game object
            GameObjectFieldValue.SetValueB(targetObject, 8, targetGameObject);

            return(targetGameObject);
        }
示例#5
0
        // Execute the action
        public int Execute(HeroKitObject hko)
        {
            heroKitObject = hko;
            GameObject gameObject = GameObjectFieldValue.GetValueA(heroKitObject, 1);

            GameObjectFieldValue.SetValueB(heroKitObject, 0, gameObject);

            // show debug message
            if (heroKitObject.debugHeroObject)
            {
                string debugMessage = "GameObject: " + gameObject;
                Debug.Log(HeroKitCommonRuntime.GetActionDebugInfo(heroKitObject, debugMessage));
            }

            return(-99);
        }
示例#6
0
        // 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);
        }
示例#7
0
        // Gets objects in a scene that match a certerin criteria
        public int Execute(HeroKitObject hko)
        {
            // Get variables
            heroKitObject = hko;
            eventID       = hko.heroStateData.eventBlock;

            // get the source object
            GameObject sourceGameObject = heroKitObject.heroState.heroEvent[eventID].messenger;

            GameObjectFieldValue.SetValueB(heroKitObject, 0, sourceGameObject);

            //-----------------------------------------
            // debugging stuff
            //-----------------------------------------
            if (heroKitObject.debugHeroObject)
            {
                string debugMessage = "Game Object: " + sourceGameObject;
                Debug.Log(HeroKitCommonRuntime.GetActionDebugInfo(heroKitObject, debugMessage));
            }

            return(-99);
        }
示例#8
0
        // Execute the action
        public int Execute(HeroKitObject hko)
        {
            heroKitObject = hko;
            GameObject gameObject = GameObjectFieldValue.GetValueA(heroKitObject, 0, true);
            bool       value      = BoolFieldValue.GetValueA(heroKitObject, 1);
            bool       runThis    = (gameObject != null);

            if (runThis)
            {
                gameObject.SetActive(value);
            }

            //-----------------------------------------
            // debugging stuff
            //-----------------------------------------
            if (heroKitObject.debugHeroObject)
            {
                string debugMessage = "Enabled: " + value;
                Debug.Log(HeroKitCommonRuntime.GetActionDebugInfo(heroKitObject, debugMessage));
            }

            return(-99);
        }
示例#9
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);
        }