Ejemplo n.º 1
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);
        }
Ejemplo n.º 2
0
        // Execute the action
        public int Execute(HeroKitObject hko)
        {
            heroKitObject = hko;

            // Get the scene object
            string  sceneName      = UnityObjectFieldValue.GetValueA(heroKitObject, 0).sceneName;
            Vector3 cameraPosition = new Vector3();
            Vector3 cameraRotation = new Vector3();
            bool    runThis        = (sceneName != "");

            if (runThis)
            {
                bool useDefaultScene     = BoolValue.GetValue(heroKitObject, 1);
                bool removeNonPersistent = BoolValue.GetValue(heroKitObject, 2);
                bool saveCurrentScene    = !BoolValue.GetValue(heroKitObject, 3);

                // get position
                bool    getPosition     = BoolValue.GetValue(heroKitObject, 4);
                Vector3 defaultPosition = new Vector3(-999999, -999999, -999999);
                cameraPosition = (getPosition) ? CoordinatesValue.GetValue(heroKitObject, 5, 6, 7, 8, 9, 10, defaultPosition) : defaultPosition;

                // get rotation
                bool    getRotation     = BoolValue.GetValue(heroKitObject, 11);
                Vector3 defaultRotation = new Vector3(-999999, -999999, -999999);
                cameraRotation = (getRotation) ? CoordinatesValue.GetValue(heroKitObject, 12, 13, 14, 15, 16, 17, defaultRotation) : defaultRotation;

                // Save the current scene
                if (saveCurrentScene)
                {
                    SaveScene saveScene = new SaveScene();
                    saveScene.SaveSceneData(heroKitObject, false); // save scene objects
                    saveScene.SaveSceneData(heroKitObject, true);  // save persistent objects
                }

                // Load the scene. Load any cached data for the scene.
                HeroKitCommonScene.LoadScene(sceneName, useDefaultScene, removeNonPersistent, cameraPosition, cameraRotation);

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

            // debug message
            if (heroKitObject.debugHeroObject)
            {
                string debugMessage = "Scene ID: " + sceneName + "\n" +
                                      "Camera Position: " + cameraPosition + "\n" +
                                      "Camera Rotation: " + cameraRotation;
                Debug.Log(HeroKitCommonRuntime.GetActionDebugInfo(heroKitObject, debugMessage));
            }

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

            // save the data in the current scene in a temporary directory
            SaveScene saveScene = new SaveScene();

            saveScene.SaveSceneData(heroKitObject, true);

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

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

            // Get the hero kit object to move
            HeroKitObject targetObject = HeroObjectFieldValue.GetValueE(heroKitObject, 0, 1, false)[0];

            // Get the scene object
            string sceneName = UnityObjectFieldValue.GetValueA(heroKitObject, 2).sceneName;

            // get new position for target object
            Vector3 defaultPosition = new Vector3(-999999, -999999, -999999);
            Vector3 targetPosition  = CoordinatesValue.GetValue(heroKitObject, 3, 4, 5, 6, 7, 8, defaultPosition);

            // get new rotation for target object
            Vector3 targetDirection = defaultPosition;
            int     directionType   = DropDownListValue.GetValue(heroKitObject, 9);

            switch (directionType)
            {
            case 1:     // retain
                break;

            case 2:     // left
                targetDirection.y = -90f;
                break;

            case 3:     // right
                targetDirection.y = 90f;
                break;

            case 4:     // up
                targetDirection.y = 0f;
                break;

            case 5:     // down
                targetDirection.y = 180f;
                break;

            case 6:     // custom
                targetDirection = CoordinatesValue.GetValue(heroKitObject, 10, 11, 12, 13, 14, 15, defaultPosition);
                break;
            }

            // move camera to object's position?
            bool moveCameraPos = BoolValue.GetValue(heroKitObject, 16);

            // move camera to object's rotation?
            bool moveCameraRotation = BoolValue.GetValue(heroKitObject, 17);

            // scene transition settings
            bool useDefaultScene     = BoolValue.GetValue(heroKitObject, 18);
            bool removeNonPersistent = BoolValue.GetValue(heroKitObject, 19);
            bool saveCurrentScene    = !BoolValue.GetValue(heroKitObject, 20);

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

            // NEXT STEP:
            // save current scene,
            // check if object is persistant. if it is, load next scene, change direction and rotation of object.
            // if it isn't see what we can do to physically move it from one scene to another. Keep in mind that object could exist in two scenes after this (if it is saved in scene data)
            // maybe disable it in current scene and create a new verison in the next scene.

            if (runThis)
            {
                // Save the current scene
                if (saveCurrentScene)
                {
                    SaveScene saveScene = new SaveScene();
                    saveScene.SaveSceneData(heroKitObject, false); // save scene objects
                    saveScene.SaveSceneData(heroKitObject, true);  // save persistent objects
                }

                // Load the scene. Load any cached data for the scene.
                HeroKitCommonScene.LoadSceneWithObject(sceneName, useDefaultScene, removeNonPersistent,
                                                       targetPosition, targetDirection, targetObject, moveCameraPos, moveCameraRotation);
            }

            if (targetObject == null)
            {
                Debug.LogError("There is no object to move to the next scene! Terminating action early.");
            }

            // debug message
            if (heroKitObject.debugHeroObject)
            {
                string debugMessage = "Scene: " + sceneName + "\n" +
                                      "Move this object: " + targetObject + "\n" +
                                      "To this position: " + targetPosition;
                Debug.Log(HeroKitCommonRuntime.GetActionDebugInfo(heroKitObject, debugMessage));
            }

            // Return value
            return(-99);
        }
Ejemplo n.º 5
0
        // This is used by HeroKitCommon.GetAction() to add this action to the ActionDictionary. Don't delete!
        public static SaveScene Create()
        {
            SaveScene action = new SaveScene();

            return(action);
        }