Beispiel #1
0
        //--------------------------------------------------
        // SECTION C
        //--------------------------------------------------

        // Execute the action
        public int Execute(HeroKitObject hko)
        {
            // assign values (don't change)
            heroKitObject = hko;

            // replace this part with with your fields & code
            HeroKitObject[] targetObject = HeroObjectFieldValue.GetValueE(heroKitObject, 0, 1);
            bool            boolValue    = BoolFieldValue.GetValueA(heroKitObject, 3);

            // check to see if we can run this action on one or more hero game objects (don't change if this action can be used on more than one hero game object).
            bool runThis = (targetObject != null);

            // execute action for all objects in list (don't change if this action can be used on more than one hero game object).
            for (int i = 0; runThis && i < targetObject.Length; i++)
            {
                ExecuteOnTarget(targetObject[i], boolValue);
            }

            // show debug message for this action (add a custom message if desired or delete the custom message).
            if (hko.debugHeroObject)
            {
                Debug.Log(HeroKitCommonRuntime.GetActionDebugInfo(heroKitObject, "custom message"));
            }

            // the return code (don't change)
            return(-99);
        }
Beispiel #2
0
        // execute the action
        public int Execute(HeroKitObject hko)
        {
            heroKitObject = hko;

            // get the hero object where the parameters are stored
            HeroKitObject[]  targetObject    = HeroObjectFieldValue.GetValueE(heroKitObject, 0, 1);
            UnityObjectField objectData      = UnityObjectFieldValue.GetValueA(heroKitObject, 2);
            string           scriptName      = (objectData.value != null) ? objectData.value.name : "";
            bool             enableComponent = BoolFieldValue.GetValueA(heroKitObject, 3);
            bool             setProperties   = BoolValue.GetValue(heroKitObject, 4);

            bool runThis = (targetObject != null && scriptName != "");

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

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

            return(-99);
        }
Beispiel #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);
            bool value1     = BoolFieldValue.GetValueB(heroKitObject, 1);
            bool value2     = BoolFieldValue.GetValueA(heroKitObject, 3);
            bool evaluation = HeroActionCommonRuntime.CompareBools(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 = "Bool A: " + value1 + "\n" +
                                      "Bool 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);
        }
Beispiel #4
0
        // Execute the action
        public int Execute(HeroKitObject hko)
        {
            heroKitObject = hko;

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

            if (runThis)
            {
                // integer
                if (valueType == 1)
                {
                    int value = PlayerPrefs.GetInt(valueName);
                    IntegerFieldValue.SetValueB(heroKitObject, 1, value);
                }
                // float
                else if (valueType == 2)
                {
                    float value = PlayerPrefs.GetFloat(valueName);
                    FloatFieldValue.SetValueB(heroKitObject, 1, value);
                }
                // bool
                else if (valueType == 3)
                {
                    int  value    = PlayerPrefs.GetInt(valueName);
                    bool newValue = (value == 0) ? true : false;
                    BoolFieldValue.SetValueB(heroKitObject, 1, newValue);
                }
                // string
                else if (valueType == 4)
                {
                    string value = PlayerPrefs.GetString(valueName);
                    StringFieldValue.SetValueB(heroKitObject, 1, value);
                }
            }
            else
            {
                Debug.LogWarning(valueName + " was not found in player preferences.");
            }

            // 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);
        }
Beispiel #5
0
        // Execute the action
        public int Execute(HeroKitObject hko)
        {
            heroKitObject = hko;
            bool getThisBool = BoolFieldValue.GetValueA(heroKitObject, 1);

            BoolFieldValue.SetValueB(heroKitObject, 0, getThisBool);

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

            return(-99);
        }
Beispiel #6
0
        // Execute the action
        public int Execute(HeroKitObject hko)
        {
            heroKitObject = hko;
            bool result = HeroKitCommonRuntime.GetRandomBool();

            BoolFieldValue.SetValueB(heroKitObject, 0, result);

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

            return(-99);
        }
Beispiel #7
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);
        }
Beispiel #8
0
        // Execute the action
        public int Execute(HeroKitObject hko)
        {
            heroKitObject = hko;

            SceneObjectValueData objectData = SceneObjectValue.GetValue(heroKitObject, 0, 1, false);
            bool   showCanvas = BoolFieldValue.GetValueA(heroKitObject, 2);
            Canvas canvas     = null;

            // object is hero object
            if (objectData.heroKitObject != null)
            {
                canvas = objectData.heroKitObject[0].GetHeroComponent <Canvas>("Canvas");
            }

            // object is game object
            else if (objectData.gameObject != null)
            {
                canvas = heroKitObject.GetGameObjectComponent <Canvas>("Canvas", false, objectData.gameObject[0]);
            }

            if (canvas != null)
            {
                canvas.enabled = showCanvas;
            }
            else
            {
                Debug.LogError("Can't toggle canvas. There is no canvas attached to this game object.");
            }

            //------------------------------------
            // debug message
            //------------------------------------
            if (heroKitObject.debugHeroObject)
            {
                string strGO        = (canvas != null) ? canvas.gameObject.name : "";
                string debugMessage = "Game Object: " + strGO;
                Debug.Log(HeroKitCommonRuntime.GetActionDebugInfo(heroKitObject, debugMessage));
            }

            return(-99);
        }
        // Execute the action
        public int Execute(HeroKitObject hko)
        {
            heroKitObject = hko;
            HeroObject heroObject    = HeroObjectFieldValue.GetValueC(heroKitObject, 0);
            bool       getThisObject = false;
            bool       runThis       = (heroObject != null);

            if (runThis)
            {
                getThisObject = BoolFieldValue.GetValueC(heroKitObject, 1, heroObject);
                BoolFieldValue.SetValueB(heroKitObject, 2, getThisObject);
            }

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

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

            SceneObjectValueData objectData = SceneObjectValue.GetValue(heroKitObject, 0, 1, false);
            bool   value  = BoolFieldValue.GetValueA(heroKitObject, 2);
            Toggle toggle = null;

            // object is hero object
            if (objectData.heroKitObject != null)
            {
                toggle = objectData.heroKitObject[0].GetHeroComponent <Toggle>("Toggle");
            }

            // object is game object
            else if (objectData.gameObject != null)
            {
                toggle = heroKitObject.GetGameObjectComponent <Toggle>("Toggle", false, objectData.gameObject[0]);
            }

            if (toggle != null)
            {
                toggle.isOn = value;
            }

            //------------------------------------
            // debug message
            //------------------------------------
            if (heroKitObject.debugHeroObject)
            {
                string strGO        = (toggle != null) ? toggle.gameObject.name : "";
                string debugMessage = "Game Object: " + strGO + "\n" +
                                      "Value: " + value;
                Debug.Log(HeroKitCommonRuntime.GetActionDebugInfo(heroKitObject, debugMessage));
            }

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

            SceneObjectValueData objectData = SceneObjectValue.GetValue(heroKitObject, 0, 1, false);
            string stringForText            = BoolFieldValue.GetValueA(heroKitObject, 2).ToString();
            Text   text = null;

            // object is hero object
            if (objectData.heroKitObject != null)
            {
                text = objectData.heroKitObject[0].GetHeroComponent <Text>("Text");
            }

            // object is game object
            else if (objectData.gameObject != null)
            {
                text = heroKitObject.GetGameObjectComponent <Text>("Text", false, objectData.gameObject[0]);
            }

            if (text != null)
            {
                text.text = stringForText;
            }

            //------------------------------------
            // debug message
            //------------------------------------
            if (heroKitObject.debugHeroObject)
            {
                string strGO        = (text != null) ? text.gameObject.name : "";
                string debugMessage = "Game Object: " + strGO + "\n" +
                                      "Text: " + stringForText;
                Debug.Log(HeroKitCommonRuntime.GetActionDebugInfo(heroKitObject, debugMessage));
            }

            return(-99);
        }
Beispiel #12
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);
        }
Beispiel #13
0
 // Execute the action on a target hero game object
 public void ExecuteOnTarget(HeroKitObject targetObject, bool boolValue)
 {
     // replace this with your fields
     BoolFieldValue.SetValueB(targetObject, 2, boolValue);
 }