コード例 #1
0
    /// <summary>
    /// will create a new scene and add it to scene list
    /// </summary>
    /// <param name="sceneName"></param>
    public SaveableScene addNewScene(string sceneName)
    {
        SaveableScene result = new SaveableScene(sceneName);

        addScene(result);
        return(result);
    }
コード例 #2
0
    public SaveableScene prepareNextScene(string sceneName, List <IRestorableGameObject> transferToNextScene, bool loadScene = true)
    {
        SaveableScene result = getScene(sceneName);

        FirstTimeSceneLoaded = !loadScene;
        ///check if the scene is loaded already
        if (result == null)
        {
            ///if the scene was not loaded, check if it is even existing as a file in the game folder
            if (sceneExists(sceneName))
            {
                ///if the scene exists in a file load it
                result = GameDataController.LoadSaveable <SaveableScene>(FolderSystem.getSceneSavePath(GameName, sceneName));
                /////create new Scene list. Since its marked as "NonSerialized" its null after loading
                //AllScenes = new List<SaveableScene>();
                addScene(result);
            }
            else
            {
                ///if the scene doesnt exist in file, create a new scene
                result = addNewScene(sceneName);
                ///since the scene was not existing already, "KeepExistingObjects"
                ///is set to true, as the scene objects
                ///should not be deleted when first entering a scene
                FirstTimeSceneLoaded = true;
            }
        }
        CurrentScene = result;
        CurrentScene.initiateLoadedScene();

        CurrentScene.TransferedObjectTree = transferToNextScene;
        return(result);
    }
コード例 #3
0
    /// <summary>
    /// creates the gameobject and scripts (which values are not loaded yet).
    /// this is called recursiv for all children of this game object
    /// </summary>
    public GameObject createObject(Transform parent, int siblingIndex = -1)
    {
        GameObject gameObject;

        gameObject = getSceneGameObject(parent);

        BaseSaveableGameObject saveableObject = gameObject.GetComponent <BaseSaveableGameObject>();

        inGameObject = gameObject;

        gameObject.SetActive(active);
        gameObject.tag = tag;
        gameObject.transform.parent = parent;
        gameObject.layer            = layer;
        gameObject.name             = gameObjectName;

        if (siblingIndex >= 0)
        {
            gameObject.transform.SetSiblingIndex(siblingIndex);
        }

        reconstructAttachedComponentList(saveableObject);

        foreach (TreeNode <IRestorableGameObject> node in childTree.getAllNodesWithValues())
        {
            node.Value.createObject(
                SaveableScene.getTransformFromPath(
                    gameObject.transform, node.getParentTreePath())
                , node.Key);
        }

        return(gameObject);
    }
コード例 #4
0
    public override void prepareGameObjectRestore(IList <Transform> nonPrefabs)
    {
        InGameObject = SaveableScene.getTransformFromPath(pathFromRoot).gameObject;
        SaveableNonPrefab saveableNonPrefab = InGameObject.GetComponent <SaveableNonPrefab>();

        saveableNonPrefab.PathFromRoot = pathFromRoot;
        nonPrefabs.Add(InGameObject.transform);
    }
コード例 #5
0
    //Ariel
    //This function ends the recording, and saves all of the movements the user has recorded with the "Next" function, and places them into a Scene.
    private void EndRecording_Click()
    {
        recordStarted = false;
        numRecordings++;
        endpositions = new List <Vector3>();
        GameObject.Find("StartRecord").GetComponent <Button>().interactable = true;

        /*When the user clicks "End Recording", the list of positions is placed
         * into a list of list of positions. The scene is over, and the user will now
         * build the next scene's starting positions.
         */
        foreach (GameObject variable in objectList)
        {
            endObjectList.Add(variable);
            endpositions.Add(variable.transform.position);
        }

        nextPositions.Add(endpositions);
        Dropdown dropdown = GameObject.Find("SceneDropdown").GetComponent <Dropdown>();
        List <Dropdown.OptionData> m_Messages = new List <Dropdown.OptionData>();
        string newOptionString = "Scene " + numRecordings;

        Dropdown.OptionData newOption = new Dropdown.OptionData();

        List <Dropdown.OptionData> newOptionList = new List <Dropdown.OptionData>();

        newOptionList.Add(newOption);
        newOption.text = newOptionString;
        dropdown.AddOptions(newOptionList);

        //The following creates an option in the Scene Dropdown Menu
        //The following is to keep track of the number of recordings and movements in the current
        //saved scene for debugging purposes.
        List <Dropdown.OptionData> m_messages = new List <Dropdown.OptionData>();
        Scene newScene = new Scene();

        newScene.CreateScene(nextPositions, startpositions);

        foreach (GameObject variable in startObjectList)
        {
            newScene.addToObjectsInScene(variable);
            newScene.setObjectsInScenetoInactive();
        }

        foreach (Quaternion anotherVar in objectRotationsForPlayback)
        {
            newScene.addQuaternion(anotherVar);
        }
        newScene.setSceneID(numRecordings);
        SceneList.Add(newScene);
        SaveableScene tempSaveableScene = new SaveableScene(newScene, this);

        SaveableSceneList.Add(tempSaveableScene);

        nextPositions = new List <List <Vector3> >();
        recordingIndex++;
        x = 0;
    }
コード例 #6
0
ファイル: EnemyHealth.cs プロジェクト: flofe104/SpackJerrow
    public override void Die()
    {
        Rigidbody r = this.GetOrAddComponent <Rigidbody>();

        r.isKinematic = false;
        r.AddForce((transform.position - GameManager.Player.transform.position).normalized * pushForce, ForceMode.Impulse);
        SaveableScene.SetAsRootTransform(transform);
        CannonShooter c = GetComponent <CannonShooter>();

        c.StopAllCoroutines();
        c.enabled = false;
    }
コード例 #7
0
 public override void BoatChange(Boat newBoat)
 {
     if (newBoat == null)
     {
         SaveableScene.SetAsRootTransform(transform);
     }
     else
     {
         if (canEnterBoat)
         {
             transform.parent = newBoat.PassengerSeat;
         }
     }
 }
コード例 #8
0
    public void loadGame(GamePersistence gameDataController)
    {
        SaveableGame.GameDataController = gameDataController;

        SaveableScene loadedScene = GameDataController.LoadSaveable <SaveableScene>
                                        (FolderSystem.getSceneSavePath(GameName,
                                                                       CurrentSceneName));

        ///reset scene list so no changes made before loading are interfering
        AllScenes = new List <SaveableScene>();

        addScene(loadedScene);
        CurrentScene = loadedScene;
        CurrentScene.initiateLoadedScene();

        ///load new scene
        SceneManager.LoadScene(CurrentSceneName);
    }
コード例 #9
0
    public static void removeObjectFromSavedList(ISaveableGameObject gameObject)
    {
        SaveableScene currentScene = GetCurrentGame().CurrentScene;

        currentScene.AllInGameObjects.Remove(gameObject);
    }
コード例 #10
0
    public static void addObjectToCurrentScene(ISaveableGameObject gameObject)
    {
        SaveableScene currentScene = GetCurrentGame().CurrentScene;

        currentScene.AllInGameObjects.Add(gameObject);
    }
コード例 #11
0
    /// <summary>
    /// adds the given slot to the garabe heap, which will get the object removed
    /// after the saved objects are restored
    /// </summary>
    /// <param name="gameObject"></param>
    public static void addObjectToGarbageHeap(GameObject gameObject)
    {
        SaveableScene currentScene = GetCurrentGame().CurrentScene;

        currentScene.GarbageHeap.Push(gameObject);
    }
コード例 #12
0
 /// <summary>
 /// will add the scene
 /// </summary>
 /// <param name="sceneName"></param>
 /// <param name="current">scene will be set as the current scene of the game</param>
 /// <returns>return true when the scene was added</returns>
 public void addScene(SaveableScene scene)
 {
     allScenes.Add(scene);
 }
コード例 #13
0
    //This is used in the Load function, it takes the list of SaveableScenes from the JSON file,
    //and repurposes the serialized data to refill the SceneList in the program.
    public void saveableScenesIntoScenes(SaveableScene scene, MenuFunctions current)
    {
        //getID
        SceneID = scene.saveSceneID;

        //get the start positions
        int start = 0;

        foreach (float[,] floatVec3s in scene.saveStartPositions)
        {
            Vector3 tempVec3 = new Vector3(floatVec3s[start, 0], floatVec3s[start, 1], floatVec3s[start, 1]);
            startPos.Add(tempVec3);
            start++;
        }


        //get the positions

        foreach (List <float[, ]> floatVec3Nexts in scene.savePositions)
        {
            List <Vector3> tempListToPutInNextPos = new List <Vector3>();
            //Debug to check the positions of the saveable Scene
            int objectIndex = 0;
            foreach (float[,] pos2 in floatVec3Nexts)
            {
                Debug.Log("[SCENE CLASS] Actor " + objectIndex + " Saveable Scene Pos: (" + pos2[0, 0] + ", " + pos2[0, 1] + ", " + pos2[0, 2] + ")");

                Vector3 tempVec = new Vector3(pos2[objectIndex, 0], pos2[objectIndex, 1], pos2[objectIndex, 2]);
                Debug.Log("[SCENE CLASS] Actor " + objectIndex + " Scene Pos: " + tempVec);


                tempListToPutInNextPos.Add(tempVec);
                if (objectIndex > objects.Count)
                {
                    objectIndex = 0;
                }
                else
                {
                    objectIndex++;
                }
            }

            positions.Add(tempListToPutInNextPos);
        }

        Debug.Log("positions.Count" + positions.Count);

        //get the objects
        int tempPrefabCheck = 0;

        foreach (string tagString in scene.tagsForObjects)
        {
            if (tagString.Equals("Player"))
            {
                GameObject buildObject = Instantiate(current.actorDrop.prefabList[scene.prefabIndexesForObjects[tempPrefabCheck]], startPos[tempPrefabCheck], Quaternion.identity);
                objects.Add(buildObject);
                buildObject.SetActive(false);
            }
            else if (tagString.Equals("Props"))
            {
                GameObject buildObject = Instantiate(current.propDrop.prefabList[scene.prefabIndexesForObjects[tempPrefabCheck]], startPos[tempPrefabCheck], Quaternion.identity);
                objects.Add(buildObject);
                buildObject.SetActive(false);
            }


            tempPrefabCheck++;
        }
    }