//--------------------------------------------------
        // SECTION C
        //--------------------------------------------------

        // Pauses an event for X amount of time before going on to the next action
        public int Execute(HeroKitObject hko)
        {
            // assign variables (don't change)
            heroKitObject = hko;

            // replace this part with with your fields & code
            int secondsToWait = IntegerFieldValue.GetValueA(heroKitObject, 0);

            timeToWait = secondsToWait + Time.time;

            // set up update for long action (don't change)
            eventID = heroKitObject.heroStateData.eventBlock;
            heroKitObject.heroState.heroEvent[eventID].waiting = true;
            updateIsDone = false;
            heroKitObject.longActions.Add(this); // if you want to update this action using FixedUpdate, change longActions to longActionsFixed

            // show debug message for this action (add a custom message if desired or delete the custom message).
            if (heroKitObject.debugHeroObject)
            {
                string customMessage = "Seconds to wait: " + secondsToWait;
                Debug.Log(HeroKitCommonRuntime.GetActionDebugInfo(heroKitObject, customMessage));
            }

            // the return code (don't change)
            return(-99);
        }
Example #2
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);
            int heroGuid       = IntegerFieldValue.GetValueA(heroKitObject, 3);

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

            // 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 GUID: " + heroGuid + "\n" +
                                      "Maximum number of objects to get: " + objectCount + "\n" +
                                      "Objects found: " + countStr;
                Debug.Log(HeroKitCommonRuntime.GetActionDebugInfo(heroKitObject, debugMessage));
            }

            return(-99);
        }
Example #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);
            List <HeroKitObject> targetObjects = HeroObjectFieldValue.GetValueB(heroKitObject, 1);
            int  value1     = (targetObjects == null) ? 0 : targetObjects.Count;
            int  value2     = IntegerFieldValue.GetValueA(heroKitObject, 3);
            bool evaluation = HeroActionCommonRuntime.CompareIntegers(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 = "Hero Object Count: " + value1 + "\n" +
                                      "Value to Compare Against: " + 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);
        }
Example #4
0
        // Execute the action
        public int Execute(HeroKitObject hko)
        {
            heroKitObject = hko;

            // get field values
            HeroKitObject[] targetObject = HeroObjectFieldValue.GetValueE(heroKitObject, 0, 1);
            Vector3         degrees      = new Vector3();

            degrees.z = DropDownListValue.GetValue(heroKitObject, 2);
            int  speed   = IntegerFieldValue.GetValueA(heroKitObject, 3);
            bool runThis = (targetObject != null);

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

            // set up update for long action
            eventID = heroKitObject.heroStateData.eventBlock;
            heroKitObject.heroState.heroEvent[eventID].waiting = false;
            updateIsDone = false;
            heroKitObject.longActions.Add(this);

            // debug message
            if (heroKitObject.debugHeroObject)
            {
                string debugMessage = "Speed: " + speed + "\n" +
                                      "Euler Angles: " + degrees;
                Debug.Log(HeroKitCommonRuntime.GetActionDebugInfo(heroKitObject, debugMessage));
            }

            return(-99);
        }
Example #5
0
        public void ExecuteOnTarget(HeroKitObject targetObject, string childName)
        {
            Transform transform = null;

            if (childName == "")
            {
                transform = targetObject.transform;
            }
            else
            {
                transform = targetObject.GetHeroChildComponent <Transform>("Transform", childName);
            }

            if (transform != null)
            {
                Vector3 degrees = new Vector3();

                // get the target rotation
                degrees.z         = IntegerFieldValue.GetValueA(heroKitObject, 4);
                degreesToChange.z = degrees.z;

                // change the rotation
                transform.localEulerAngles = transform.localEulerAngles + degrees;
            }
        }
Example #6
0
        // Execute the action
        public int Execute(HeroKitObject hko)
        {
            // get values
            heroKitObject = hko;
            String imageGroupPrefabName = "HeroKit Image Canvas";
            String imagePrefabName      = "HeroKit Image Sprite";
            int    imageID = IntegerFieldValue.GetValueA(heroKitObject, 0);

            // get the game object that contains the images
            GameObject imageGroup = GetImageGroup(imageGroupPrefabName);

            if (imageGroup != null)
            {
                // get the game object that contains the image
                GameObject targetObject = GetImage(imagePrefabName, imageID, imageGroup);
                if (targetObject != null)
                {
                    // disable the targetObject
                    targetObject.SetActive(false);
                }
            }

            // debug message
            if (heroKitObject.debugHeroObject)
            {
                string debugMessage = "Image ID: " + imageID;
                Debug.Log(HeroKitCommonRuntime.GetActionDebugInfo(heroKitObject, debugMessage));
            }

            return(-99);
        }
        // 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);
        }
Example #8
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);
            int heroGuid       = HeroObjectFieldValue.GetValueD(heroKitObject, 3);

            // filter the hero kit objects in the scene
            List <HeroKitObject> heroKitObjects = HeroActionCommonRuntime.GetHeroObjectsByGUID(HeroActionCommonRuntime.GetHeroObjectsInScene(), objectCount, heroGuid);

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

            //-----------------------------------------
            // debugging stuff
            //-----------------------------------------
            if (heroKitObject.debugHeroObject)
            {
                string debugMessage = "Hero Object GUID: " + heroGuid + "\n" +
                                      "Max number to return: " + objectCount;
                Debug.Log(HeroKitCommonRuntime.GetActionDebugInfo(heroKitObject, debugMessage));
            }

            return(-99);
        }
Example #9
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.name = HeroKitCommonRuntime.settingsInfo.inventoryMenu.name;
                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 remove
                    item = HeroObjectFieldValue.GetValueC(heroKitObject, 0);
                    if (item != null)
                    {
                        // get the number of items to remove
                        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, false);
                        HeroKitObject heroObject = null;

                        // if the item exists, remove it
                        if (gameObject != null)
                        {
                            // 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 2 in the hero kit object attached to this prefab
                            heroObject.PlayEvent(2);
                        }
                    }
                }
            }

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

            return(-99);
        }
Example #10
0
        // Execute the action
        public int Execute(HeroKitObject hko)
        {
            heroKitObject = hko;
            HeroKitObject[] targetObject   = HeroObjectFieldValue.GetValueE(heroKitObject, 0, 1);
            float           jumpHeight     = FloatFieldValue.GetValueA(heroKitObject, 2);
            int             jumpDirection  = DropDownListValue.GetValue(heroKitObject, 3);
            int             directionForce = (jumpDirection > 1) ? IntegerFieldValue.GetValueA(heroKitObject, 4) : 0;

            wait = !BoolValue.GetValue(heroKitObject, 5);
            bool runThis = (targetObject != null);

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

            // set up the long action
            eventID = heroKitObject.heroStateData.eventBlock;
            heroKitObject.heroState.heroEvent[eventID].waiting = wait;
            updateIsDone = false;
            heroKitObject.longActions.Add(this);

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

            return(-99);
        }
Example #11
0
        // Execute the action
        public int Execute(HeroKitObject hko)
        {
            heroKitObject = hko;
            HeroKitObject[] targetObject  = HeroObjectFieldValue.GetValueE(heroKitObject, 0, 1);
            int             speed         = IntegerFieldValue.GetValueA(heroKitObject, 2);
            int             moveType      = DropDownListValue.GetValue(heroKitObject, 3); // 4-way or 8-way?
            int             animationType = DropDownListValue.GetValue(heroKitObject, 4); // 4-way or 8-way?
            bool            changeSpeed   = BoolValue.GetValue(heroKitObject, 5);
            bool            changeMove    = BoolValue.GetValue(heroKitObject, 6);
            bool            changeAnim    = BoolValue.GetValue(heroKitObject, 7);
            bool            runThis       = (targetObject != null);

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

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

            return(-99);
        }
Example #12
0
        /// <summary>
        /// Get a slider value from the slider field.
        /// </summary>
        /// <param name="heroKitObject">The hero kit object that contains the data for this action.</param>
        /// <param name="actionFieldID">ID assigned to action field A.</param>
        /// <returns>The value of the slider.</returns>
        public static int GetValue(HeroKitObject heroKitObject, int actionFieldID)
        {
            // Get the value
            int value = IntegerFieldValue.GetValueA(heroKitObject, actionFieldID);

            // Return the value
            return(value);
        }
        // Gets objects in a scene that match a certerin criteria
        public int Execute(HeroKitObject hko)
        {
            // Get variables
            heroKitObject = hko;
            eventID       = heroKitObject.heroStateData.eventBlock;
            int actionCount = heroKitObject.heroState.heroEvent[eventID].actions.Count;

            //-----------------------------------------
            // 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);
            HeroKitObject        originHKO        = HeroObjectFieldValue.GetValueA(heroKitObject, 3)[0];
            List <HeroKitObject> listObjects      = HeroObjectFieldValue.GetValueB(heroKitObject, 4);
            string               childName        = ChildObjectValue.GetValue(heroKitObject, 5, 6);
            int                  rayDirectionType = DropDownListValue.GetValue(heroKitObject, 7);
            int                  fieldOfView      = IntegerFieldValue.GetValueA(heroKitObject, 8);

            // get origin object
            GameObject originObject = null;
            Transform  transform    = null;

            if (childName == "")
            {
                transform = originHKO.transform;
            }
            else
            {
                transform = originHKO.GetHeroChildComponent <Transform>("Transform", childName);
            }

            originObject = transform.gameObject;

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

            // filter the hero kit objects in the scene
            List <HeroKitObject> filteredObjects = HeroActionCommonRuntime.GetHeroObjectsFOV(arrayObjects, objectCount, originObject, fieldOfView, rayDirectionType);

            // 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 name         = (originObject != null) ? originObject.name : "";
                string debugMessage = "Get objects in field of view of this object: " + name + "\n" +
                                      "Objects found: " + countStr;
                Debug.Log(HeroKitCommonRuntime.GetActionDebugInfo(heroKitObject, debugMessage));
            }

            return(-99);
        }
Example #14
0
        // Execute the action
        public int Execute(HeroKitObject hko)
        {
            // get values
            heroKitObject = hko;
            String imageGroupPrefabName = "HeroKit Image Canvas";
            String imagePrefabName      = "HeroKit Image Sprite";
            int    imageID = IntegerFieldValue.GetValueA(heroKitObject, 0);
            int    speed   = IntegerFieldValue.GetValueA(heroKitObject, 1);
            float  scale   = IntegerFieldValue.GetValueA(heroKitObject, 2) * 0.01f;

            wait = BoolValue.GetValue(heroKitObject, 3);
            HeroKitObject targetObject = null;
            Vector3       currentScale = new Vector3();
            Vector3       targetScale  = new Vector3();

            // get the game object that contains the images
            GameObject imageGroup = GetImageGroup(imageGroupPrefabName);

            if (imageGroup != null)
            {
                // get the game object that contains the image
                GameObject imageObject = GetImage(imagePrefabName, imageID, imageGroup);
                if (imageObject != null)
                {
                    // get the hero kit object
                    targetObject = heroKitObject.GetGameObjectComponent <HeroKitObject>("HeroKitObject", false, imageObject);

                    // get the current position
                    currentScale = targetObject.transform.localScale;
                    targetScale  = new Vector3(scale, scale, targetObject.transform.localScale.z);
                }
            }

            // pan the camera
            uiScale             = targetObject.GetHeroComponent <UIScale>("UIScale", true);
            uiScale.targetScale = targetScale;
            uiScale.speed       = speed;
            uiScale.Initialize();

            // set up update for long action
            eventID = heroKitObject.heroStateData.eventBlock;
            heroKitObject.heroState.heroEvent[eventID].waiting = wait;
            updateIsDone = false;
            heroKitObject.longActions.Add(this);

            // debug message
            if (heroKitObject.debugHeroObject)
            {
                string debugMessage = "Image ID: " + imageID + "\n" +
                                      "Scale: " + scale * 100 + "\n" +
                                      "Speed: " + speed;
                Debug.Log(HeroKitCommonRuntime.GetActionDebugInfo(heroKitObject, debugMessage));
            }

            return(-99);
        }
Example #15
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;
            int actionCount   = heroKitObject.heroState.heroEvent[eventID].actions.Count;
            int nextAction    = -99;

            // get the conditional action that follows this action in the if / if else / else / end sequence
            int nextConditionalAction = HeroActionCommonRuntime.GetNextConditionAction(heroKitObject, eventID, actionID, currentIndent);

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

            // if there are no actions inside a do while loop, show error message and break out of loop
            if (actionID == nextConditionalAction)
            {
                Debug.LogWarning("Loop has no actions! Breaking out of loop early.");
                heroKitObject.heroState.heroEvent[eventID].actions[nextConditionalAction + 1].actionFields[0].bools[0] = false;
                return(-99);
            }

            // if the conditional action that follows is an End Do While, we need to set a value.
            if (nextConditionalAction != -99)
            {
                if (heroKitObject.heroState.heroEvent[eventID].actions[nextConditionalAction + 1].actionTemplate.name == "End Do While")
                {
                    // Was beginning of do while a success? Assign this to the End Do While action.
                    heroKitObject.heroState.heroEvent[eventID].actions[nextConditionalAction + 1].actionFields[0].bools[0] = evaluation;

                    // if sucess was true, what is the id assigned to beginning of do while?
                    heroKitObject.heroState.heroEvent[eventID].actions[nextConditionalAction + 1].actionFields[0].ints[0] = actionID;
                }
            }

            // if evaluation is false, go to end of loop.
            if (!evaluation)
            {
                nextAction = nextConditionalAction;
            }

            // show debug message
            if (heroKitObject.debugHeroObject)
            {
                string debugMessage = heroKitObject.heroState.heroEvent[eventID].actions[actionID].name + " = " + evaluation;
                Debug.Log(HeroKitCommonRuntime.GetActionDebugInfo(heroKitObject, debugMessage));
            }

            // return the action that we want the game loop to think just executed
            return(nextAction);
        }
        // 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);
        }
        // Gets objects in a scene that match a certerin criteria
        public int Execute(HeroKitObject hko)
        {
            // Get variables
            heroKitObject = hko;
            eventID       = heroKitObject.heroStateData.eventBlock;
            int actionCount = heroKitObject.heroState.heroEvent[eventID].actions.Count;

            //-----------------------------------------
            // 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);
            GameObject           targetObject   = HeroObjectFieldValue.GetValueA(heroKitObject, 3)[0].gameObject;
            List <HeroKitObject> listObjects    = HeroObjectFieldValue.GetValueB(heroKitObject, 10);

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

            bool getX = BoolValue.GetValue(heroKitObject, 4);
            bool getY = BoolValue.GetValue(heroKitObject, 5);
            bool getZ = BoolValue.GetValue(heroKitObject, 6);

            float x = (getX) ? FloatFieldValue.GetValueA(heroKitObject, 7) : 0;
            float y = (getY) ? FloatFieldValue.GetValueA(heroKitObject, 8) : 0;
            float z = (getZ) ? FloatFieldValue.GetValueA(heroKitObject, 9) : 0;

            Vector3 radius = new Vector3(x, y, z);

            // filter the hero kit objects in the scene
            List <HeroKitObject> filteredObjects = HeroActionCommonRuntime.GetHeroObjectsDistance(heroKitObject, arrayObjects, objectCount, radius, getX, getY, getZ, targetObject);

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

            //-----------------------------------------
            // debugging stuff
            //-----------------------------------------
            if (heroKitObject.debugHeroObject)
            {
                string xStr         = (getX) ? "X: " + x + " " : "";
                string yStr         = (getY) ? "Y: " + y + " " : "";
                string zStr         = (getZ) ? "Z: " + z + " " : "";
                string countStr     = (filteredObjects != null) ? filteredObjects.Count.ToString() : 0.ToString();
                string debugMessage = "Get objects in this radius: " + xStr + yStr + zStr + "\n" +
                                      "Objects found: " + countStr;
                Debug.Log(HeroKitCommonRuntime.GetActionDebugInfo(heroKitObject, debugMessage));
            }

            return(-99);
        }
Example #18
0
        // Execute the action
        public int Execute(HeroKitObject hko)
        {
            // assign variables
            heroKitObject = hko;
            eventID       = heroKitObject.heroStateData.eventBlock;
            int actionCount = heroKitObject.heroState.heroEvent[eventID].actions.Count;

            // the action to skip to
            int nextActionID = IntegerFieldValue.GetValueA(heroKitObject, 0);

            if (hko.debugHeroObject)
            {
                Debug.Log(HeroKitCommonRuntime.GetActionDebugInfo(heroKitObject, nextActionID.ToString()));
            }
            return(nextActionID + 1);
        }
        // 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);

            bool getX = BoolValue.GetValue(heroKitObject, 3);
            bool getY = BoolValue.GetValue(heroKitObject, 4);
            bool getZ = BoolValue.GetValue(heroKitObject, 5);

            float x = (getX) ? FloatFieldValue.GetValueA(heroKitObject, 6) : 0;
            float y = (getY) ? FloatFieldValue.GetValueA(heroKitObject, 7) : 0;
            float z = (getZ) ? FloatFieldValue.GetValueA(heroKitObject, 8) : 0;

            float radius = FloatFieldValue.GetValueA(heroKitObject, 9);

            Vector3 pos = new Vector3(x, y, z);

            // filter the hero kit objects in the scene
            List <HeroKitObject> filteredObjects = HeroActionCommonRuntime.GetHeroObjectsPosition(heroKitObject, HeroActionCommonRuntime.GetHeroObjectsInScene(), objectCount, pos, getX, getY, getZ, radius);

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

            //-----------------------------------------
            // debugging stuff
            //-----------------------------------------
            if (heroKitObject.debugHeroObject)
            {
                string xStr         = (getX) ? "X: " + x + " " : "";
                string yStr         = (getY) ? "Y: " + y + " " : "";
                string zStr         = (getZ) ? "Z: " + z + " " : "";
                string countStr     = (filteredObjects != null) ? filteredObjects.Count.ToString() : 0.ToString();
                string debugMessage = "Get objects at this position: " + xStr + yStr + zStr + "\n" +
                                      "Maximum number of objects to get: " + objectCount + "\n" +
                                      "Objects found: " + countStr;
                Debug.Log(HeroKitCommonRuntime.GetActionDebugInfo(heroKitObject, debugMessage));
            }

            return(-99);
        }
Example #20
0
        // Execute the action
        public int Execute(HeroKitObject hko)
        {
            heroKitObject = hko;
            string poolName   = StringFieldValue.GetValueA(heroKitObject, 0);
            int    itemCount  = IntegerFieldValue.GetValueA(heroKitObject, 1);
            int    objectType = DropDownListValue.GetValue(heroKitObject, 2);

            // ------------------------------------------------
            // Get the prefab that will populate the pool
            // ------------------------------------------------

            GameObject prefab          = null;
            bool       isHeroKitObject = false;

            // hero object
            if (objectType == 1)
            {
                prefab          = Resources.Load <GameObject>("Hero Templates/Components/HeroKit Default Object");
                isHeroKitObject = true;
            }

            // prefab
            else if (objectType == 2)
            {
                prefab = PrefabValue.GetValue(heroKitObject, 3);
            }

            // ------------------------------------------------
            // Create the pool
            // ------------------------------------------------
            HeroKitDatabase.AddPool(poolName, prefab, itemCount, isHeroKitObject);

            //------------------------------------
            // debug message
            //------------------------------------
            if (heroKitObject.debugHeroObject)
            {
                string debugMessage = "Pool Name: " + poolName + "\n" +
                                      "Items to add: " + itemCount + "\n" +
                                      "Item: " + prefab;
                Debug.Log(HeroKitCommonRuntime.GetActionDebugInfo(heroKitObject, debugMessage));
            }

            // normal return
            return(-99);
        }
Example #21
0
        // Execute the action
        public int Execute(HeroKitObject hko)
        {
            // get values
            heroKitObject = hko;
            SceneObjectValueData objectData = SceneObjectValue.GetValue(heroKitObject, 0, 1, false);
            Color endColor = ColorValue.GetValue(heroKitObject, 2);
            float duration = (float)(IntegerFieldValue.GetValueA(heroKitObject, 3) * 0.10);

            wait = BoolValue.GetValue(heroKitObject, 4);

            // get the text component
            if (objectData.heroKitObject != null)
            {
                // execute action for all objects in list
                for (int i = 0; i < objectData.heroKitObject.Length; i++)
                {
                    ExecuteOnHeroObject(objectData.heroKitObject[i], endColor, duration);
                }
            }
            else if (objectData.gameObject != null)
            {
                // execute action for all objects in list
                for (int i = 0; i < objectData.gameObject.Length; i++)
                {
                    ExecuteOnGameObject(objectData.gameObject[i], endColor, duration);
                }
            }

            // set up update for long action
            eventID = heroKitObject.heroStateData.eventBlock;
            heroKitObject.heroState.heroEvent[eventID].waiting = wait;
            updateIsDone = false;
            heroKitObject.longActionsFixed.Add(this);

            //------------------------------------
            // debug message
            //------------------------------------
            if (heroKitObject.debugHeroObject)
            {
                string debugMessage = "Color: " + endColor + "\n" +
                                      "Duration: " + duration;
                Debug.Log(HeroKitCommonRuntime.GetActionDebugInfo(heroKitObject, debugMessage));
            }

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

            string valueName = StringFieldValue.GetValueA(heroKitObject, 2);
            int    valueType = DropDownListValue.GetValue(heroKitObject, 0);

            // integer
            if (valueType == 1)
            {
                int value = IntegerFieldValue.GetValueA(heroKitObject, 1);
                PlayerPrefs.SetInt(valueName, value);
            }
            // float
            else if (valueType == 2)
            {
                float value = FloatFieldValue.GetValueA(heroKitObject, 1);
                PlayerPrefs.SetFloat(valueName, value);
            }
            // bool
            else if (valueType == 3)
            {
                bool value    = BoolFieldValue.GetValueA(heroKitObject, 1);
                int  newValue = (value) ? 1 : 0;
                PlayerPrefs.SetInt(valueName, newValue);
            }
            // string
            else if (valueType == 4)
            {
                string value = StringFieldValue.GetValueA(heroKitObject, 1);
                PlayerPrefs.SetString(valueName, value);
            }

            // debug message
            if (heroKitObject.debugHeroObject)
            {
                string debugMessage = "Value Type (1=int, 2=float, 3=bool, 4=string): " + valueType + "\n" +
                                      "Value Name: " + valueName;
                Debug.Log(HeroKitCommonRuntime.GetActionDebugInfo(heroKitObject, debugMessage));
            }

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

            // get field values
            startColor = ColorValue.GetValue(heroKitObject, 0);
            speed      = IntegerFieldValue.GetValueA(heroKitObject, 1) * 0.01f;

            // get the fade UI
            HeroKitObject targetObject = HeroKitCommonRuntime.GetPrefabFromAssets(HeroKitCommonRuntime.settingsInfo.fadeInOutScreen, true);
            bool          runThis      = (targetObject != null);

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

                // fade out the scene
                uiColor             = targetObject.GetHeroComponent <UIColor>("UIColor", true);
                uiColor.targetImage = targetObject.GetComponentInChildren <Image>(true);
                uiColor.targetColor = startColor;
                uiColor.startColor  = new Color(0, 0, 0, 0);
                uiColor.speed       = speed;
                uiColor.Initialize();

                // set up update for long action
                eventID = heroKitObject.heroStateData.eventBlock;
                heroKitObject.heroState.heroEvent[eventID].waiting = true;
                updateIsDone = false;
                heroKitObject.longActionsFixed.Add(this);
            }

            // show debug message
            if (heroKitObject.debugHeroObject)
            {
                string debugMessage = "Speed: " + speed + "\n" +
                                      "Start Color:" + startColor;
                Debug.Log(HeroKitCommonRuntime.GetActionDebugInfo(heroKitObject, debugMessage));
            }

            // return value
            return(-99);
        }
        // Gets objects in a scene that match a certerin criteria
        public int Execute(HeroKitObject hko)
        {
            // Get variables
            heroKitObject = hko;
            eventID       = heroKitObject.heroStateData.eventBlock;
            int actionCount = heroKitObject.heroState.heroEvent[eventID].actions.Count;

            //-----------------------------------------
            // 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);
            HeroKitProperty      heroProperty    = HeroPropertyValue.GetValue(heroKitObject, 3);
            List <HeroKitObject> list            = HeroObjectFieldValue.GetValueB(heroKitObject, 4);
            List <HeroKitObject> filteredObjects = null;

            if (list != null)
            {
                HeroKitObject[] listObjects = list.ToArray();

                // filter the hero kit objects in the scene
                filteredObjects = HeroActionCommonRuntime.GetHeroObjectsByProperty(listObjects, objectCount, heroProperty);

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

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

            return(-99);
        }
Example #25
0
        // Execute the action
        public int Execute(HeroKitObject hko)
        {
            heroKitObject = hko;
            int bottom = IntegerFieldValue.GetValueA(heroKitObject, 0);
            int top    = IntegerFieldValue.GetValueA(heroKitObject, 1);
            int result = HeroKitCommonRuntime.GetRandomInt(bottom, top);

            IntegerFieldValue.SetValueB(heroKitObject, 2, result);

            // show debug message
            if (heroKitObject.debugHeroObject)
            {
                string debugMessage = "Integer: " + result + "\n" +
                                      "Bottom: " + bottom + "\n" +
                                      "Top: " + top;
                Debug.Log(HeroKitCommonRuntime.GetActionDebugInfo(heroKitObject, debugMessage));
            }

            return(-99);
        }
Example #26
0
        // Execute the action
        public int Execute(HeroKitObject hko)
        {
            heroKitObject = hko;
            int intA      = IntegerFieldValue.GetValueA(heroKitObject, 1);
            int intB      = IntegerFieldValue.GetValueA(heroKitObject, 3);
            int operation = DropDownListValue.GetValue(heroKitObject, 2);
            int result    = HeroActionCommonRuntime.PerformMathOnIntegers(operation, intA, intB);

            IntegerFieldValue.SetValueB(heroKitObject, 0, result);

            // show debug message
            if (heroKitObject.debugHeroObject)
            {
                string debugMessage = "A: " + intA + "\n" +
                                      "B: " + intB + "\n" +
                                      "Result (C): " + result;
                Debug.Log(HeroKitCommonRuntime.GetActionDebugInfo(heroKitObject, debugMessage));
            }
            return(-99);
        }
Example #27
0
        // Execute the action
        public int Execute(HeroKitObject hko)
        {
            heroKitObject = hko;

            // get field values
            Camera camera    = CameraFieldValue.GetValue(heroKitObject, 0, 4);
            int    speed     = IntegerFieldValue.GetValueA(heroKitObject, 1);
            int    magnitude = IntegerFieldValue.GetValueA(heroKitObject, 2);
            int    time      = IntegerFieldValue.GetValueA(heroKitObject, 3);
            bool   runThis   = (camera != null);

            // make sure object is a camera
            if (runThis)
            {
                // shake the camera
                cameraShake           = heroKitObject.GetGameObjectComponent <CameraShake>("CameraShake", true, camera.gameObject);
                cameraShake.speed     = speed;
                cameraShake.magnitude = magnitude;
                cameraShake.time      = time;
                cameraShake.Initialize();

                // set up update for long action
                eventID = heroKitObject.heroStateData.eventBlock;
                heroKitObject.heroState.heroEvent[eventID].waiting = true;
                updateIsDone = false;
                heroKitObject.longActions.Add(this);
            }

            // show debug message
            if (heroKitObject.debugHeroObject)
            {
                string debugMessage = "Camera: " + camera + "\n" +
                                      "Magnitude: " + magnitude + "\n" +
                                      "Speed: " + speed + "\n" +
                                      "Speed: " + speed;
                Debug.Log(HeroKitCommonRuntime.GetActionDebugInfo(heroKitObject, debugMessage));
            }

            // return value
            return(-99);
        }
Example #28
0
        public void ExecuteOnTarget(HeroKitObject targetObject, string childName)
        {
            Transform transform = null;

            if (childName == "")
            {
                transform = targetObject.transform;
            }
            else
            {
                transform = targetObject.GetHeroChildComponent <Transform>("Transform", childName);
            }

            if (transform != null)
            {
                Vector3 degrees = new Vector3();

                // get the target rotation
                bool changeX = BoolValue.GetValue(heroKitObject, 4);
                if (changeX)
                {
                    degrees.x         = IntegerFieldValue.GetValueA(heroKitObject, 5);
                    degreesToChange.x = degrees.x;
                }
                bool changeY = BoolValue.GetValue(heroKitObject, 6);
                if (changeY)
                {
                    degrees.y         = IntegerFieldValue.GetValueA(heroKitObject, 7);
                    degreesToChange.y = degrees.y;
                }
                bool changeZ = BoolValue.GetValue(heroKitObject, 8);
                if (changeZ)
                {
                    degrees.z         = IntegerFieldValue.GetValueA(heroKitObject, 9);
                    degreesToChange.z = degrees.z;
                }

                // change the rotation
                transform.localEulerAngles = transform.localEulerAngles + degrees;
            }
        }
Example #29
0
        public void ExecuteOnTarget(HeroKitObject targetObject, int speed)
        {
            // set some values
            Transform transform = targetObject.GetHeroComponent <Transform>("transform");

            if (transform != null)
            {
                Vector3 degrees = transform.localEulerAngles;

                // get the target rotation
                // note: z and x are swapped on purpose
                degrees.x         = IntegerFieldValue.GetValueA(heroKitObject, 2);
                degreesToChange.z = degrees.x;

                // rotate the image
                rotateObject         = targetObject.GetHeroComponent <HeroObjectRotateToDegrees>("HeroObjectRotateToDegrees", true);
                rotateObject.speed   = speed;
                rotateObject.degrees = degrees;
                rotateObject.Initialize();
            }
        }
        // Execute the action
        public int Execute(HeroKitObject hko)
        {
            heroKitObject = hko;
            HeroKitObject[] targetObject = HeroObjectFieldValue.GetValueE(heroKitObject, 0, 1);
            int             speed        = IntegerFieldValue.GetValueA(heroKitObject, 2);
            int             jump         = IntegerFieldValue.GetValueA(heroKitObject, 3);
            bool            runThis      = (targetObject != null);

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

            if (heroKitObject.debugHeroObject)
            {
                Debug.Log(HeroKitCommonRuntime.GetActionDebugInfo(heroKitObject));
            }

            return(-99);
        }