Beispiel #1
0
    public void CmdSaveState()
    {
        Debug.Log("Saving state");
        GameObject[] words  = GameObject.FindGameObjectsWithTag("Word");
        GameObject[] sounds = GameObject.FindGameObjectsWithTag("Sound");

        WordActs        wordscript;
        List <WordInfo> stateList = new List <WordInfo>();

        foreach (GameObject obj in words)
        {
            wordscript = obj.GetComponent <WordActs> ();
            stateList.Add(new WordInfo(wordscript.m_wordstr, wordscript.m_serverFileName, wordscript.m_scale,
                                       obj.transform.position, obj.transform.rotation, wordscript.m_looping, wordscript.m_sequencer.playtriggers, wordscript.m_sequencer.path, wordscript.m_sequencer.scrubs));
        }
        NonVerbalActs soundscript;

        foreach (GameObject obj in sounds)
        {
            soundscript = obj.GetComponent <NonVerbalActs> ();
            stateList.Add(new WordInfo("", soundscript.m_serverFileName, 1.0f,
                                       obj.transform.position, obj.transform.rotation, soundscript.m_looping, soundscript.m_sequencer.playtriggers, soundscript.m_sequencer.path, null));
        }

        /*
         * string filename = Application.persistentDataPath + "/" + Webserver.GenerateFileName ("state") + ".json";
         * Debug.Log ("Saving state to " + filename);
         */

        IAAScene scene = new IAAScene();

        scene.wordInfoList = stateList;
        LocalPlayerOptions.SceneFile sceneFile = LocalPlayerOptions.singleton.PreloadFile;
        if (sceneFile != null)
        {
            string oriTitle = sceneFile.title;
            int    pos      = sceneFile.title.LastIndexOf(sepString);
            if (pos != -1)
            {
                oriTitle = sceneFile.title.Substring(0, pos);
            }
            scene.title = Webserver.GenerateSceneName(oriTitle);
            scene.name  = Webserver.GenerateSceneName(sceneFile.sceneName);
        }
        else
        {
            scene.title = Webserver.GenerateSceneName("New Scene");
            scene.name  = Webserver.GenerateSceneName("NewScene");
        }
        Webserver.singleton.UploadNewScene(scene);
    }