Exemple #1
0
        /// <summary>
        /// Get the name of a child object attached to a hero object.
        /// </summary>
        /// <param name="heroKitObject">The hero kit object that contains the data for this action.</param>
        /// <param name="actionFieldIDA">ID assigned to action field A.</param>
        /// <param name="actionFieldIDB">ID assigned to action field B.</param>
        /// <returns></returns>
        public static string GetValue(HeroKitObject heroKitObject, int actionFieldIDA, int actionFieldIDB)
        {
            bool   onChild   = BoolValue.GetValue(heroKitObject, actionFieldIDA);
            string childName = (onChild) ? StringFieldValue.GetValueA(heroKitObject, actionFieldIDB) : "";

            return(childName);
        }
Exemple #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    objectCount = IntegerFieldValue.GetValueA(heroKitObject, 2);
            string name        = StringFieldValue.GetValueA(heroKitObject, 3);

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

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

            //-----------------------------------------
            // debugging stuff
            //-----------------------------------------
            if (heroKitObject.debugHeroObject)
            {
                string countStr     = (filteredObjects != null) ? filteredObjects.Count.ToString() : 0.ToString();
                string debugMessage = "Get objects with this name: " + name + "\n" +
                                      "Maximum number of objects to get: " + objectCount + "\n" +
                                      "Objects found: " + countStr;
                Debug.Log(HeroKitCommonRuntime.GetActionDebugInfo(heroKitObject, debugMessage));
            }

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

            // save the current scene
            SaveScene saveScene = new SaveScene();

            saveScene.SaveSceneData(heroKitObject, false); // save scene objects
            saveScene.SaveSceneData(heroKitObject, true);  // save persistent objects

            // get the path where you want to put the save game file on the player's device
            string saveGameName = StringFieldValue.GetValueA(heroKitObject, 0, true);
            string path         = Application.persistentDataPath + "/HeroSaves/" + saveGameName + ".json";

            // if there is an existing save file, get the seconds played
            GameSaveData existingGame = HeroKitCommonRuntime.GetSaveGame(saveGameName);

            // convert game data to json data
            string jsonText = GetSaveGameData(existingGame);

            // save the json data to player's device
            File.WriteAllText(path, jsonText);

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

            return(-99);
        }
        // Execute the action
        public int Execute(HeroKitObject hko)
        {
            heroKitObject = hko;
            HeroKitObject[] targetObject = HeroObjectFieldValue.GetValueE(heroKitObject, 0, 1);
            bool            changeMove   = BoolValue.GetValue(heroKitObject, 2);
            bool            changeFace   = BoolValue.GetValue(heroKitObject, 3);

            string[] moveNames = new string[0];
            if (changeMove)
            {
                moveNames = new string[9];

                // movement
                moveNames[0] = StringFieldValue.GetValueA(heroKitObject, 5);
                moveNames[1] = StringFieldValue.GetValueA(heroKitObject, 6);
                moveNames[2] = StringFieldValue.GetValueA(heroKitObject, 7);
                moveNames[3] = StringFieldValue.GetValueA(heroKitObject, 8);
                moveNames[4] = StringFieldValue.GetValueA(heroKitObject, 9);
                moveNames[5] = StringFieldValue.GetValueA(heroKitObject, 10);
                moveNames[6] = StringFieldValue.GetValueA(heroKitObject, 11);
                moveNames[7] = StringFieldValue.GetValueA(heroKitObject, 12);
                moveNames[8] = StringFieldValue.GetValueA(heroKitObject, 13);
            }

            string[] faceNames = new string[0];
            if (changeFace)
            {
                faceNames = new string[9];

                // face
                faceNames[0] = StringFieldValue.GetValueA(heroKitObject, 14);
                faceNames[1] = StringFieldValue.GetValueA(heroKitObject, 15);
                faceNames[2] = StringFieldValue.GetValueA(heroKitObject, 16);
                faceNames[3] = StringFieldValue.GetValueA(heroKitObject, 17);
                faceNames[4] = StringFieldValue.GetValueA(heroKitObject, 18);
                faceNames[5] = StringFieldValue.GetValueA(heroKitObject, 19);
                faceNames[6] = StringFieldValue.GetValueA(heroKitObject, 20);
                faceNames[7] = StringFieldValue.GetValueA(heroKitObject, 21);
                faceNames[8] = StringFieldValue.GetValueA(heroKitObject, 22);
            }

            bool runThis = (targetObject != null);

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

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

            return(-99);
        }
Exemple #5
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);
        }
Exemple #6
0
        // Execute the action
        public int Execute(HeroKitObject hko)
        {
            heroKitObject = hko;
            string getThisString = StringFieldValue.GetValueA(heroKitObject, 1);

            StringFieldValue.SetValueB(heroKitObject, 0, getThisString);

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

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

            string productName = Application.productName;

            StringFieldValue.SetValueB(heroKitObject, 0, productName);

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

            return(-99);
        }
Exemple #9
0
        // Execute the action
        public int Execute(HeroKitObject hko)
        {
            // get values
            heroKitObject = hko;

            string sceneName = SceneManager.GetActiveScene().name;

            StringFieldValue.SetValueB(heroKitObject, 0, sceneName);

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

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

            string url = StringFieldValue.GetValueA(heroKitObject, 0);

            Application.OpenURL(url);

            //------------------------------------
            // debug message
            //------------------------------------
            if (heroKitObject.debugHeroObject)
            {
                string debugMessage = "URL: " + url;
                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;

            // 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);
        }
        // Execute the action
        public int Execute(HeroKitObject hko)
        {
            heroKitObject = hko;
            HeroObject heroObject    = HeroObjectFieldValue.GetValueC(heroKitObject, 0);
            string     getThisObject = "";
            bool       runThis       = (heroObject != null);

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

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

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

            string        title        = StringFieldValue.GetValueA(heroKitObject, 0);
            HeroKitObject targetObject = SetupSaveMenu(title, 1);
            bool          runThis      = (targetObject != null);

            if (runThis)
            {
                // enable the canvas
                Canvas canvas = targetObject.GetHeroComponent <Canvas>("Canvas");
                canvas.enabled = true;
            }

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

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

            // get the path where you want to load the save game file
            string saveDataName = StringFieldValue.GetValueA(heroKitObject, 0, true);

            // get the saved game
            GameSaveData savedGame = HeroKitCommonRuntime.GetSaveGame(saveDataName);

            // load the game
            LoadSaveGameData(savedGame);

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

            return(-99);
        }
Exemple #16
0
        // Gets objects in a scene that match a certerin criteria
        public int Execute(HeroKitObject hko)
        {
            // Get variables
            heroKitObject = hko;

            // Get values
            HeroKitObject[] targetObject = HeroObjectFieldValue.GetValueE(heroKitObject, 0, 1);
            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[] targetGameObject = new GameObject[targetObject.Length];
            bool         runThis          = (targetObject != null);

            // execute action for all objects in list
            for (int i = 0; runThis && i < targetObject.Length; i++)
            {
                targetGameObject[i] = ExecuteOnTarget(targetObject[i], useName, name, useTag, tag, useLayer, layer);
            }

            //-----------------------------------------
            // debugging stuff
            //-----------------------------------------
            if (heroKitObject.debugHeroObject)
            {
                string strLayer     = (useLayer) ? layer.ToString() : "";
                string strCount     = (targetGameObject != null) ? targetGameObject.Length.ToString() : "";
                string debugMessage = "Child With Tag: " + tag + "\n" +
                                      "Child On Layer: " + strLayer + "\n" +
                                      "Child With Name: " + name + "\n" +
                                      "Children Found: " + strCount;
                Debug.Log(HeroKitCommonRuntime.GetActionDebugInfo(heroKitObject, debugMessage));
            }

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

            SceneObjectValueData objectData = SceneObjectValue.GetValue(heroKitObject, 0, 1, false);
            string stringForText            = StringFieldValue.GetValueA(heroKitObject, 2, true);
            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);
        }
Exemple #18
0
        // 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);
            string name                      = StringFieldValue.GetValueA(heroKitObject, 3);
            List <HeroKitObject> listObjects = HeroObjectFieldValue.GetValueB(heroKitObject, 4);

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

            // filter the hero kit objects in the scene
            List <HeroKitObject> filteredObjects = HeroActionCommonRuntime.GetHeroObjectsByName(arrayObjects, objectCount, name);

            // 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 name: " + name + "\n" +
                                      "Objects found: " + countStr;
                Debug.Log(HeroKitCommonRuntime.GetActionDebugInfo(heroKitObject, debugMessage));
            }

            return(-99);
        }
Exemple #19
0
        // Execute the action
        public int Execute(HeroKitObject hko)
        {
            // get values
            heroKitObject = hko;
            string       saveGameName = StringFieldValue.GetValueA(heroKitObject, 0, true);
            GameSaveData savedGame    = HeroKitCommonRuntime.GetSaveGame(saveGameName);
            bool         runThis      = (savedGame != null);

            // save the name of the scene
            if (runThis)
            {
                StringFieldValue.SetValueB(heroKitObject, 1, savedGame.lastScene);
            }

            // debug message
            if (heroKitObject.debugHeroObject)
            {
                string lastScene    = (savedGame != null) ? savedGame.lastScene : "";
                string debugMessage = "Scene: " + lastScene;
                Debug.Log(HeroKitCommonRuntime.GetActionDebugInfo(heroKitObject, debugMessage));
            }

            return(-99);
        }
Exemple #20
0
        // Execute the action
        public int Execute(HeroKitObject hko)
        {
            // get values
            heroKitObject = hko;

            // get common values
            HeroKitObject targetObject = HeroKitCommonRuntime.GetPrefabFromAssets(HeroKitCommonRuntime.settingsInfo.dialogBox, true);
            bool          runThis      = (targetObject != null);

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

                // get the dialog script
                uiDialog                = targetObject.GetHeroComponent <UIDialog>("UIDialog", true);
                uiDialog.textAction     = UIDialog.TextAction.showDialog;
                uiDialog.heroKitObject  = heroKitObject;
                uiDialog.dontHideCanvas = BoolValue.GetValue(heroKitObject, 30);
                uiDialog.eventID        = heroKitObject.heroStateData.eventBlock;
                uiDialog.actionID       = heroKitObject.heroStateData.action;

                // get values for title
                uiDialog.setTitle = BoolValue.GetValue(heroKitObject, 0);
                if (uiDialog.setTitle)
                {
                    uiDialog.title = StringFieldValue.GetValueA(heroKitObject, 1, true);
                    uiDialog.changeTitleAlignment = BoolValue.GetValue(heroKitObject, 26);
                    if (uiDialog.changeTitleAlignment)
                    {
                        uiDialog.titleAlignmentType = DropDownListValue.GetValue(heroKitObject, 27);
                    }
                }

                // get values for message
                uiDialog.message = StringFieldValue.GetValueA(heroKitObject, 2, true);

                // get values for audio
                UnityObjectField unityObjectAudio = UnityObjectFieldValue.GetValueA(heroKitObject, 28, false);
                uiDialog.audioClip = (unityObjectAudio.value != null) ? (AudioClip)unityObjectAudio.value : null;

                // get values for message choices
                uiDialog.addChoices = BoolValue.GetValue(heroKitObject, 21);
                if (uiDialog.addChoices)
                {
                    uiDialog.selectedChoiceID = 29;
                    uiDialog.numberOfChoices  = DropDownListValue.GetValue(heroKitObject, 22);
                    uiDialog.choiceText       = new UnityEngine.UI.Text[3];
                    uiDialog.choice           = new string[uiDialog.numberOfChoices];

                    if (uiDialog.numberOfChoices >= 1)
                    {
                        uiDialog.choice[0] = StringFieldValue.GetValueA(heroKitObject, 23, true);
                    }
                    if (uiDialog.numberOfChoices >= 2)
                    {
                        uiDialog.choice[1] = StringFieldValue.GetValueA(heroKitObject, 24, true);
                    }
                    if (uiDialog.numberOfChoices >= 3)
                    {
                        uiDialog.choice[2] = StringFieldValue.GetValueA(heroKitObject, 25, true);
                    }
                }

                // get values for left portrait
                SetPortraitInfo(0, 3, 4, 5, 6, 7, 8, 9, 10, 11, 31, 32);

                // get values for right portrait
                SetPortraitInfo(1, 12, 13, 14, 15, 16, 17, 18, 19, 20, 33, 34);

                // enable the dialog script
                uiDialog.enabled = true;
                uiDialog.Initialize();

                eventID = heroKitObject.heroStateData.eventBlock;
                heroKitObject.heroState.heroEvent[eventID].waiting = true;
                updateIsDone = false;
                heroKitObject.longActions.Add(this);
            }

            // show debug message
            if (heroKitObject.debugHeroObject)
            {
                string dialogText   = (uiDialog != null) ? uiDialog.message : "";
                string debugMessage = "Message: " + dialogText;
                Debug.Log(HeroKitCommonRuntime.GetActionDebugInfo(heroKitObject, debugMessage));
            }

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

            // get the type of object to spawn
            int spawnType = DropDownListValue.GetValue(heroKitObject, 0);

            // where are we spawning item? from pool or in scene?
            bool   usePool  = BoolValue.GetValue(heroKitObject, 1);
            string poolName = (usePool) ? StringFieldValue.GetValueA(heroKitObject, 2) : "";

            // debug string
            string debugSpawn = "";

            // get the object to spawn (1=hero object, 2=prefab)
            if (spawnType == 1)
            {
                HeroObject heroSpawn      = HeroObjectFieldValue.GetValueC(heroKitObject, 3);
                bool       debugHeroSpawn = BoolValue.GetValue(heroKitObject, 4);
                bool       dontSave       = BoolValue.GetValue(heroKitObject, 5);
                Vector3    position       = GetPosition();
                Quaternion rotation       = GetRotation();
                HeroKitDatabase.SpawnHeroKitObject(usePool, poolName, position, rotation, heroSpawn, debugHeroSpawn, dontSave);
                if (heroKitObject.debugHeroObject)
                {
                    debugSpawn = "Hero Object: " + heroSpawn + "\n" +
                                 "Debug: " + debugHeroSpawn + "\n" +
                                 "Can Save: " + !dontSave + "\n" +
                                 "Position: " + position + "\n" +
                                 "Rotation: " + rotation + "\n" +
                                 "Use Pool: " + usePool + "\n" +
                                 "Pool Name: " + poolName;
                }
            }
            else if (spawnType == 2)
            {
                GameObject prefabSpawn = (!usePool) ? PrefabValue.GetValue(heroKitObject, 5) : null;
                Vector3    position    = GetPosition();
                Quaternion rotation    = GetRotation();
                HeroKitDatabase.SpawnPrefab(usePool, poolName, position, rotation, prefabSpawn);
                if (heroKitObject.debugHeroObject)
                {
                    debugSpawn = "Game Object: " + prefabSpawn + "\n" +
                                 "Position: " + position + "\n" +
                                 "Rotation: " + rotation + "\n" +
                                 "Use Pool: " + usePool + "\n" +
                                 "Pool Name: " + poolName;
                }
            }

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

            return(-99);
        }
Exemple #24
0
        // Execute the action
        public int Execute(HeroKitObject hko)
        {
            // get values
            heroKitObject = hko;

            TextAsset csv     = ObjectValue.GetValue <TextAsset>(heroKitObject, 0);
            bool      runThis = (csv != null);

            if (runThis)
            {
                string text = csv.text;

                // save name of the localization file (used to play localized audio for messages)
                bool localizeAudio = BoolValue.GetValue(heroKitObject, 1);
                HeroKitCommonRuntime.localizatonDirectory = (localizeAudio) ? StringFieldValue.GetValueA(heroKitObject, 2) : "";

                // get each line in the file
                string[] delimitersA = { "\r\n" };
                string[] lines       = text.Split(delimitersA, StringSplitOptions.RemoveEmptyEntries);

                // get key and value from each line
                List <KeyValuePair <string, string> > localizationList = new List <KeyValuePair <string, string> >();
                char[] delimitersB = { ',' };
                for (int i = 0; i < lines.Length; i++)
                {
                    string[] textLine = lines[i].Split(delimitersB, 2);

                    if (textLine.Length >= 2)
                    {
                        string key   = textLine[0];
                        string value = textLine[1];

                        // if value is more than one word, remove quotes
                        bool removeQuotes = value.Contains(" ");
                        if (removeQuotes)
                        {
                            string trimmedValue = value.Trim('\"');
                            value = trimmedValue;
                        }

                        // add the key and value to the localization list
                        localizationList.Add(new KeyValuePair <string, string>(key, value));
                    }
                }

                // add the key value pairs to the dictionary
                if (localizationList.Count > 0)
                {
                    HeroKitDatabase.LocalizationDictionary = new Dictionary <string, string>();
                    HeroKitDatabase.AddLocalization(localizationList);
                }
            }

            // show debug message
            if (heroKitObject.debugHeroObject)
            {
                string fileName     = (csv != null) ? csv.name : "";
                string debugMessage = "CSV File: " + fileName;
                Debug.Log(HeroKitCommonRuntime.GetActionDebugInfo(heroKitObject, debugMessage));
            }

            return(-99);
        }