Ejemplo n.º 1
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);
            Vector3      position     = new Vector3();
            bool         changeX      = false;
            bool         changeY      = false;
            bool         changeZ      = false;
            bool         runThis      = (targetObject != null && targetObject.Length > 0);

            // get value from first game object in list
            if (runThis)
            {
                position = targetObject[0].transform.localEulerAngles;

                changeX = BoolValue.GetValue(heroKitObject, 2);
                if (changeX)
                {
                    FloatFieldValue.SetValueB(heroKitObject, 3, position.x);
                }

                changeY = BoolValue.GetValue(heroKitObject, 4);
                if (changeY)
                {
                    FloatFieldValue.SetValueB(heroKitObject, 5, position.y);
                }

                changeZ = BoolValue.GetValue(heroKitObject, 6);
                if (changeZ)
                {
                    FloatFieldValue.SetValueB(heroKitObject, 7, position.z);
                }
            }

            //-----------------------------------------
            // debugging stuff
            //-----------------------------------------
            if (heroKitObject.debugHeroObject)
            {
                string xStr         = (changeX) ? "X: " + position.x + " " : "";
                string yStr         = (changeY) ? "Y: " + position.y + " " : "";
                string zStr         = (changeZ) ? "Z: " + position.z + " " : "";
                string debugMessage = "Rotation coordinates: " + xStr + yStr + zStr;
                Debug.Log(HeroKitCommonRuntime.GetActionDebugInfo(heroKitObject, debugMessage));
            }

            return(-99);
        }
Ejemplo n.º 2
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);
        }
Ejemplo n.º 3
0
        // Execute the action
        public int Execute(HeroKitObject hko)
        {
            heroKitObject = hko;
            float bottom = FloatFieldValue.GetValueA(heroKitObject, 0);
            float top    = FloatFieldValue.GetValueA(heroKitObject, 1);
            float result = HeroKitCommonRuntime.GetRandomFloat(bottom, top);

            FloatFieldValue.SetValueB(heroKitObject, 2, result);

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

            return(-99);
        }
Ejemplo n.º 4
0
        // Execute the action
        public int Execute(HeroKitObject hko)
        {
            heroKitObject = hko;
            float intA      = FloatFieldValue.GetValueB(heroKitObject, 0);
            float intB      = FloatFieldValue.GetValueA(heroKitObject, 2);
            int   operation = DropDownListValue.GetValue(heroKitObject, 1);
            float result    = HeroActionCommonRuntime.PerformMathOnFloats(operation, intA, intB);

            FloatFieldValue.SetValueB(heroKitObject, 0, result);

            // show debug message
            if (heroKitObject.debugHeroObject)
            {
                string debugMessage = "A: " + intA + "\n" +
                                      "B: " + intB + "\n" +
                                      "Result (A): " + result;
                Debug.Log(HeroKitCommonRuntime.GetActionDebugInfo(heroKitObject, debugMessage));
            }

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

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

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

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

            SceneObjectValueData objectData = SceneObjectValue.GetValue(heroKitObject, 0, 1, false);
            Slider slider = null;

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

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

            if (slider != null)
            {
                FloatFieldValue.SetValueB(heroKitObject, 2, slider.value);
            }

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

            return(-99);
        }