Exemplo 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);
            bool         runThis      = (targetObject != null && targetObject.Length > 0);

            // get value from first game object in list
            if (runThis)
            {
                IntegerFieldValue.SetValueB(heroKitObject, 2, targetObject[0].layer);
            }

            // debug info
            if (heroKitObject.debugHeroObject)
            {
                string strLayer     = (targetObject != null && targetObject.Length > 0 && targetObject[0] != null) ? targetObject[0].layer.ToString() : "";
                string debugMessage = "Layer: " + strLayer;
                Debug.Log(HeroKitCommonRuntime.GetActionDebugInfo(heroKitObject, debugMessage));
            }

            return(-99);
        }
Exemplo 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);
        }
Exemplo n.º 3
0
        // Execute the action
        public int Execute(HeroKitObject hko)
        {
            heroKitObject = hko;
            int intValue = DropDownListValue.GetValue(heroKitObject, 0);

            IntegerFieldValue.SetValueB(heroKitObject, 1, intValue);

            // show debug message
            if (heroKitObject.debugHeroObject)
            {
                string debugMessage = "Result (C): " + intValue;
                Debug.Log(HeroKitCommonRuntime.GetActionDebugInfo(heroKitObject, debugMessage));
            }
            return(-99);
        }
Exemplo n.º 4
0
        // 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)
                {
                    IntegerFieldValue.SetValueB(heroKitObject, 3, listener.itemID);
                }

                // get item id
                bool getItem = BoolValue.GetValue(heroKitObject, 4);
                if (getItem)
                {
                    HeroObjectFieldValue.SetValueC(heroKitObject, 5, listener.item);
                }
            }

            //------------------------------------
            // debug message
            //------------------------------------
            if (heroKitObject.debugHeroObject)
            {
                string debugMessage = "Hero Kit Listener: " + listener;
                Debug.Log(HeroKitCommonRuntime.GetActionDebugInfo(heroKitObject, debugMessage));
            }

            return(-99);
        }
Exemplo n.º 5
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);
        }
Exemplo n.º 6
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);
        }
Exemplo n.º 7
0
        // Execute the action
        public int Execute(HeroKitObject hko)
        {
            heroKitObject = hko;
            HeroObject heroObject    = HeroObjectFieldValue.GetValueC(heroKitObject, 0);
            int        getThisObject = 0;
            bool       runThis       = (heroObject != null);

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

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

            return(-99);
        }
Exemplo n.º 8
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)
            {
                IntegerFieldValue.SetValueB(heroKitObject, 2, (int)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);
        }
Exemplo n.º 9
0
        /// <summary>
        /// Check for input from the player.
        /// </summary>
        private void CheckForInput()
        {
            // wait until there is a click in the scene (only when no options shown)
            if (Input.GetMouseButtonDown(0) || Input.GetKeyDown(KeyCode.Space) || Input.GetKeyDown(KeyCode.Return))
            {
                if (!chooseOption)
                {
                    updateIsDone = true;
                }
            }

            // if dialog has options, wait until a selection is made
            if (chooseOption)
            {
                // if a button was pressed, get the info from it
                if (heroKitObject.heroListenerData.active)
                {
                    heroKitObject.heroListenerData.active = false;
                    IntegerFieldValue.SetValueB(heroKitObject, eventID, actionID, selectedChoiceID, heroKitObject.heroListenerData.itemID);
                    updateIsDone = true;
                }
            }
        }
Exemplo n.º 10
0
        // Execute the action
        public int Execute(HeroKitObject hko)
        {
            // get values
            heroKitObject = hko;
            string   saveGameName = StringFieldValue.GetValueA(heroKitObject, 12, true);
            string   path         = Application.persistentDataPath + "/HeroSaves/" + saveGameName + ".json";
            DateTime date         = new DateTime();
            bool     runThis      = (File.Exists(path));

            // get the json data in the file
            if (runThis)
            {
                date = File.GetLastWriteTime(path);

                // set year
                if (BoolValue.GetValue(heroKitObject, 0))
                {
                    IntegerFieldValue.SetValueB(heroKitObject, 1, date.Year);
                }

                // set month
                if (BoolValue.GetValue(heroKitObject, 2))
                {
                    IntegerFieldValue.SetValueB(heroKitObject, 3, date.Month);
                }

                // set day
                if (BoolValue.GetValue(heroKitObject, 4))
                {
                    IntegerFieldValue.SetValueB(heroKitObject, 5, date.Day);
                }

                // set hour
                if (BoolValue.GetValue(heroKitObject, 6))
                {
                    IntegerFieldValue.SetValueB(heroKitObject, 7, date.Hour);
                }

                // set minute
                if (BoolValue.GetValue(heroKitObject, 8))
                {
                    IntegerFieldValue.SetValueB(heroKitObject, 9, date.Minute);
                }

                // set second
                if (BoolValue.GetValue(heroKitObject, 10))
                {
                    IntegerFieldValue.SetValueB(heroKitObject, 11, date.Second);
                }
            }

            // debug message
            if (heroKitObject.debugHeroObject)
            {
                string debugMessage = "Save Game Name: " + saveGameName + "\n" +
                                      "Save Date: " + date;
                Debug.Log(HeroKitCommonRuntime.GetActionDebugInfo(heroKitObject, debugMessage));
            }

            return(-99);
        }