/// <summary> /// Load the specified info. /// </summary> /// <param name='info'> /// Info. /// </param> public void Load(ViNoSaveInfo info) { VM vm = VM.Instance; if (vm == null) { ViNoDebugger.LogError("VM Not Found . Can't Load."); } switch (saveMethod) { case SaveMethods.COLLECT_VINO_SCENE_NODES: break; case SaveMethods.TRAVERSE_CHILDREN: if (destroyChildrenOnLoad) { if (theSavedPanel != null) { ViNoGOExtensions.DestroyImmediateChildren(theSavedPanel.name); } } break; } ViNoGameSaveLoad.Load(info); }
/// <summary> /// Save the specified info and fileName. /// </summary> /// <param name='info'> /// Info. /// </param> /// <param name='fileName'> /// File name. auto stub ".xml". /// If UNITY_EDITOR => Application.dataPath + fileName + ".xml". /// else => Application.persistentDataPath + fileName + ".xml". /// </param> static public void SaveToExternalFile(string fileName, ViNoSaveInfo info, FlagTable flagTable) { Save(info); /* * ViNoSaveData data = new ViNoSaveData(); * data.m_BgmName = info.m_BgmName; * data.m_CurrentScenarioName = info.m_CurrentScenarioName; * data.m_LoadedLevelIndex = info.m_LoadedLevelIndex; * data.m_LoadedLevelName = info.m_LoadedLevelName; * data.m_NodeName = info.m_NodeName; * data.m_SceneXmlData = info.m_SceneXmlData; * data.m_Date = info.m_Date; * data.m_ScenarioDescription = info.m_ScenarioDescription; * // data.m_ScenarioResourceFilePath = ScenarioNode.Instance.scenarioResourceFilePath; * //*/ string xmlStr = ViNoGameSaveLoad.SerializeObject <ViNoSaveData>(info.data); #if UNITY_WEBPLAYER PlayerPrefs.SetString(fileName + ".xml", xmlStr); #else ViNoGameSaveLoad.CreateXML(fileName + ".xml", xmlStr); #endif SaveFlagTable(fileName, flagTable); }
void Start() { if (info == null) { info = ScriptableObject.CreateInstance <ViNoSaveInfo>(); } m_FileExists = ExternalAccessor.IsSaveDataFileExists(fileName); if (m_FileExists) { // Load SaveInfo from Storage. ViNo.LoadDataFromStorage(fileName, ref info); UpdateText(info.data.m_Date, info.data.m_ScenarioDescription); } else { UpdateText("", "NO DATA"); } // NGUI Dependency... #if false // Load Mode. if (!SystemUIEvent.saveMode) { continueButton.isEnabled = m_FileExists; } #endif }
/// <summary> /// Load the specified info. /// </summary> /// <returns> /// If Load Succeed return true , Load Failed return false. /// </returns> static public bool Load(ViNoSaveInfo info) { bool levelNameNotMatchThisScene = !info.data.m_LoadedLevelName.Equals(Application.loadedLevelName); if (levelNameNotMatchThisScene) { ViNoDebugger.LogError("SaveData Level Name is : \"" + info.data.m_LoadedLevelName + "\" but this level is \"" + Application.loadedLevelName + "\""); return(false); } // Load Scene from XML. if (ViNoSceneManager.Instance != null) { ViNoSceneManager.Instance.Load(info); } bool haveLevelName = !string.IsNullOrEmpty(info.data.m_LoadedLevelName); bool haveNodeName = !string.IsNullOrEmpty(info.data.m_NodeName); bool isLoad = (haveLevelName && haveNodeName); if (isLoad) { // Deserialize VM. VM vm = VM.Instance; if (vm != null) { vm.ClearTextBuilder(); SystemUtility.ClearAllTextBoxMessage(); vm.Deserialize(info.data.m_NodeName); GameObject scenarioObj = GetScenarioObject(info); // Play from File ?. ScenarioNode scenario = scenarioObj.GetComponent <ScenarioNode>(); scenario.startFromSave = true; scenario.PlayFrom(info.data.m_NodeName); } // Load Sound. if (ISoundPlayer.Instance != null) { ISoundPlayer pl = ISoundPlayer.Instance; pl.OnLoad(info.data); } // Deactivate Selections. if (ISelectionsCtrl.Instance != null) { ISelectionsCtrl.Instance.ChangeActive(false); } } return(isLoad); }
public override void OnInspectorGUI() { ViNoSaveInfo info = target as ViNoSaveInfo; m_Edit = EditorGUILayout.BeginToggleGroup("", m_Edit); info.data.m_LoadedLevelIndex = EditorGUILayout.IntField("LevelIndex", info.data.m_LoadedLevelIndex); info.data.m_LoadedLevelName = EditorGUILayout.TextField("LevelName", info.data.m_LoadedLevelName); // string[] pop = { info.data.m_CurrentScenarioName }; // int sel = 0; // sel =EditorGUILayout.Popup( "ScenarioName" , sel , pop ); info.data.m_CurrentScenarioName = EditorGUILayout.TextField("ScenarioName", info.data.m_CurrentScenarioName); // string[] pop2 = { info.data.m_NodeName }; // int sel2 = 0; // sel2 =EditorGUILayout.Popup( "CurrentNode" , sel2 , pop2 ); info.data.m_NodeName = EditorGUILayout.TextField("CurrentNode", info.data.m_NodeName); info.data.m_BgmName = EditorGUILayout.TextField("BGM", info.data.m_BgmName); info.data.m_ScenarioResourceFilePath = EditorGUILayout.TextField("ScenarioFilePath", info.data.m_ScenarioResourceFilePath); EditorGUILayout.LabelField("SceneXml"); info.data.m_SceneXmlData = EditorGUILayout.TextArea(info.data.m_SceneXmlData); EditorGUILayout.LabelField("Saved Date"); EditorGUILayout.SelectableLabel(info.data.m_Date); EditorGUILayout.LabelField("Desc"); EditorGUILayout.SelectableLabel(info.data.m_ScenarioDescription); scenarioNode = EditorGUILayout.ObjectField(scenarioNode, typeof(ScenarioNode), true) as ScenarioNode; if (scenarioNode != null) { List <string> tagList = scenarioNode.GetNodeTagsUnderMe(); m_SelectedID = EditorGUILayout.Popup("NodeTagList", m_SelectedID, tagList.ToArray()); } if (GUILayout.Button("Clear Data")) { bool yes = EditorUtility.DisplayDialog(" ! ", "Are you sure you want to Clear Data", "yes", "no"); if (yes) { info.ClearData(); } } EditorGUILayout.EndToggleGroup(); if (GUI.changed) { EditorUtility.SetDirty(target); } }
static public void PlayScenario(ViNoSaveInfo info) { if (info.data == null) { Debug.LogWarning("ScenarioCtrl couldn't play because ViNoSaveInfo not attached."); return; } string levelName = info.data.m_LoadedLevelName; string scenarioName = info.data.m_CurrentScenarioName; PlayScenario(levelName, scenarioName); }
// if save Succeeded , then return true. static public bool DoQuickSave() { ViNoSaveInfo info = ScenarioCtrl.Instance.quickSaveSlot; //Info; if (info == null) { Debug.LogError("ScenarioCtrl not attached QuickSaveSlot. couldn't Save."); return(false); } else { return(ViNo.SaveData("QSaveData", info)); } }
/// <summary> /// Save the specified info. /// </summary> /// <param name='info'> /// Info. /// </param> static public void Save(ViNoSaveInfo info) { info.data.m_LoadedLevelIndex = Application.loadedLevel; info.data.m_LoadedLevelName = Application.loadedLevelName; // Serialization of Scene. if (ViNoSceneManager.Instance != null) { info.data.m_SceneXmlData = ViNoSceneManager.Instance.Save( ); } // Serialization of VM. if (VM.Instance != null) { VM.SerializationInfo vmSerInfo = VM.Instance.Serialize( ); info.data.m_NodeName = vmSerInfo.m_NodeName; info.data.m_CurrentScenarioName = vmSerInfo.m_ScenarioName; } else { ViNoDebugger.LogError("SaveInfo", "VM NOT Found. Can't serialize VM Info."); } // Serialization of BGM. if (ISoundPlayer.Instance != null) { ISoundPlayer pl = ISoundPlayer.Instance; // ViNoSoundPlayer pl = ISoundPlayer.Instance as ViNoSoundPlayer; pl.OnSave(info.data); } /* if( ScenarioNode.Instance != null ){ * info.data.m_ScenarioResourceFilePath = ScenarioNode.Instance.scenarioResourceFilePath; * } * //*/ // Set DateTime. info.data.m_Date = ViNoStringExtensions.GetDateTimeNowString(); // Set Message. SystemUIEvent sys = GameObject.FindObjectOfType(typeof(SystemUIEvent)) as SystemUIEvent; string str = sys.GetCurrentMessage(); if (str.Length >= 14) { str = str.Substring(0, 14) + "..."; } info.data.m_ScenarioDescription = str; }
static public bool DoQuickLoad() { SystemUtility.ClearAllTextBoxMessage(); ViNoSaveInfo info = ScenarioCtrl.Instance.quickSaveSlot; if (info != null) { return(ViNo.LoadData("QSaveData", ref info)); } else { Debug.LogError("ScenarioCtrl not attached QuickSaveSlot. couldn't Load."); return(false); } }
void OnLevelWasLoaded(int index) { Debug.Log("OnLevelWasLoaded" + index.ToString()); if (m_Instance == null) { Debug.LogWarning("ScenarioCtrl Instance Not Found."); return; } Debug.Log("Quick Save Data Cleared."); if (m_LoadLevelAndNewGame || m_LoadLevelAndStartScenario) { ViNoSaveInfo info = m_LoadLevelAndNewGame ? m_Instance.newGameInfo : m_Instance.saveInfo; PlayScenario(info); } }
public void DoContinue() { ViNoSaveInfo info = m_Instance.saveInfo; if (!string.IsNullOrEmpty(info.data.m_LoadedLevelName)) { m_LoadLevelAndStartScenario = true; // If this is the SaveInfo Level Name , Play Scenario at once. if (info.data.m_LoadedLevelName == Application.loadedLevelName) { PlayScenario(info); } // LoadLevel and Play Scenario. else { Application.LoadLevel(info.data.m_LoadedLevelName); } } }
static public GameObject GetScenarioObject(ViNoSaveInfo info) { string scenarioName = info.data.m_CurrentScenarioName; GameObject scenarioObj = GameObject.Find(scenarioName); if (scenarioObj == null) { Debug.LogWarning("ScenarioNode object NOT FOUND in scene. now Find in Resources."); scenarioObj = ViNoGOExtensions.InstantiateFromResource(scenarioName, null); if (scenarioObj == null) { Debug.LogError("ScenarioNode :" + scenarioName + " also Not Found in Resources."); } else { ViNoGOExtensions.StripGameObjectName(scenarioObj, "(Clone)", ""); } } return(scenarioObj); }
static public void LoadDataFromStorage(string fileName, ref ViNoSaveInfo reloadedInfo) { // Debug.Log( "FileName:" + fileName); #if UNITY_WEBPLAYER string xmlStr = PlayerPrefs.GetString(fileName + ".xml"); //ViNoGameSaveLoad.LoadXML( fileName + ".xml" ); #else string xmlStr = ViNoGameSaveLoad.LoadXML(fileName + ".xml"); #endif ViNoSaveData saveData = ViNoGameSaveLoad.DeserializeObject <ViNoSaveData>(xmlStr) as ViNoSaveData; reloadedInfo.data.m_BgmName = saveData.m_BgmName; reloadedInfo.data.m_CurrentScenarioName = saveData.m_CurrentScenarioName; reloadedInfo.data.m_LoadedLevelIndex = saveData.m_LoadedLevelIndex; reloadedInfo.data.m_LoadedLevelName = saveData.m_LoadedLevelName; reloadedInfo.data.m_NodeName = saveData.m_NodeName; reloadedInfo.data.m_SceneXmlData = saveData.m_SceneXmlData; reloadedInfo.data.m_ScenarioResourceFilePath = saveData.m_ScenarioResourceFilePath; reloadedInfo.data.m_Date = saveData.m_Date; reloadedInfo.data.m_ScenarioDescription = saveData.m_ScenarioDescription; }
/// <summary> /// Loads the data. /// </summary> static public bool LoadData(string fileName, ref ViNoSaveInfo info) { // IScriptEngine vino = IScriptEngine.Instance; ScenarioNode scenario = ScenarioNode.Instance; if (scenario != null) { // if( vino.saveToExternalFile ){ // Load Flag Data from Storage. // FlagTable.FlagUnit[] flags = LoadFlagTable( fileName ); FlagTableData flagData = LoadFlagTable(fileName); if (scenario.flagTable != null) { #if false // scenario.flagTable.flags = flags; #else scenario.flagTable.flags = flagData.flags; scenario.flagTable.stringValues = flagData.stringValues; #endif } else { Debug.LogWarning("ScenarioNode.Instance " + scenario.name + " flagTable Not attached."); } // Load SaveData from Storage. LoadDataFromStorage(fileName, ref info); return(ViNo.Load(info)); // } /* else{ * return ViNo.Load( info ); * } * //*/ } else { Debug.LogWarning("ScenarioNode instance NOT FOUND."); return(false); } }
public void LoadLevelAndNewGame() { ViNoSaveInfo info = m_Instance.newGameInfo; if (!string.IsNullOrEmpty(info.data.m_LoadedLevelName)) { m_LoadLevelAndNewGame = true; // If this is the SaveInfo Level Name , Play Scenario at once. if (info.data.m_LoadedLevelName == Application.loadedLevelName) { } else { Application.LoadLevel(info.data.m_LoadedLevelName); } } else { Debug.LogError("Level Name is Empty !"); } }
void Start(){ if( info == null ){ info = ScriptableObject.CreateInstance<ViNoSaveInfo>(); } m_FileExists = ExternalAccessor.IsSaveDataFileExists( fileName ); if( m_FileExists ){ // Load SaveInfo from Storage. ViNo.LoadDataFromStorage( fileName , ref info) ; UpdateText( info.data.m_Date , info.data.m_ScenarioDescription ); } else{ UpdateText( "" , "NO DATA" ); } // NGUI Dependency... #if false // Load Mode. if( ! SystemUIEvent.saveMode ){ continueButton.isEnabled = m_FileExists; } #endif }
/// <summary> /// Saves the data. if a Scenario is Played. /// </summary> static public bool SaveData(string fileName, ViNoSaveInfo info) { ScenarioNode scenario = ScenarioNode.Instance; if (scenario != null) { // if( vino.saveToExternalFile ){ // ScenarioNode has a ViNoSaveInfo. saveInfo is a ScriptableObject Data. ViNo.SaveToExternalFile(fileName, info, scenario.flagTable); /* } * else{ * ViNo.Save( info ); * } * //*/ return(true); } else { Debug.LogWarning("ScenarioNode instance NOT FOUND."); return(false); } }
static public bool SaveData(string fileName, ViNoSaveInfo info) { return(ViNo.SaveData(fileName, info)); }
public static bool SaveData( string fileName , ViNoSaveInfo info ) { return ViNo.SaveData( fileName , info ); }
// if info's ScenarioNode found in this Level, then play that. public static void PlayScenario( ViNoSaveInfo info ) { ScenarioCtrl.PlayScenario( info ); }
// if info's ScenarioNode found in this Level, then play that. static public void PlayScenario(ViNoSaveInfo info) { ScenarioCtrl.PlayScenario(info); }
public static void PlayScenario( ViNoSaveInfo info ) { if( info.data == null ){ Debug.LogWarning( "ScenarioCtrl couldn't play because ViNoSaveInfo not attached." ); return; } string levelName = info.data.m_LoadedLevelName; string scenarioName = info.data.m_CurrentScenarioName; PlayScenario( levelName , scenarioName ); }
static public void CreateConvScene(string templScenePath) { GameObject sceneRoot = CreateTemplScene(templScenePath); sceneRoot.name = "A Conversation Scene"; string scenarioName = "A_Conversation"; if (!System.IO.Directory.Exists("Assets/" + scenarioName)) { AssetDatabase.CreateFolder("Assets", scenarioName); } GameObject scenarioObj = ViNoToolUtil.CreateANewScenario(scenarioName, true); GameObject startObj = scenarioObj.transform.FindChild("START").gameObject; // scenarioObj.transform.parent.transform.parent = sceneRoot.transform; GameObject node0 = new GameObject("0_Scene"); LoadSceneNode loadSceneNode = node0.AddComponent <LoadSceneNode>(); loadSceneNode.sceneName = "Scene1"; loadSceneNode.method = LoadSceneNode.Methods.DESTROY_AND_LOAD; loadSceneNode.withFadeIn = true; loadSceneNode.transform.parent = startObj.transform; DialogPartNode dlgNode = ViNoToolUtil.AddDialogPartNode(startObj.transform); dlgNode.name = "1_Dialog"; DialogPartData data0 = dlgNode.AddData("", ""); DialogPartData data1 = dlgNode.AddData("Sachi", "Hello. I am Sachi."); DialogPartData data2 = dlgNode.AddData("", ""); DialogPartData data3 = dlgNode.AddData("Maiko", "Hi. Sachi."); DialogPartData data4 = dlgNode.AddData("Sachi", "Bye Bye !"); DialogPartData data5 = dlgNode.AddData("Maiko", "Bye Bye !"); DialogPartData data6 = dlgNode.AddData("", ""); data0.enterActorEntries = new DialogPartData.ActorEntry[1]; data0.enterActorEntries[0] = new DialogPartData.ActorEntry(); data0.enterActorEntries[0].actorName = "Sachi"; data0.actionID = DialogPartNodeActionType.EnterActor; data0.enterActorEntries[0].position = ViNoToolkit.SceneEvent.ActorPosition.middle_left; data1.isName = true; data2.enterActorEntries = new DialogPartData.ActorEntry[1]; data2.enterActorEntries[0] = new DialogPartData.ActorEntry(); data2.enterActorEntries[0].actorName = "Maiko"; data2.actionID = DialogPartNodeActionType.EnterActor; data2.enterActorEntries[0].position = ViNoToolkit.SceneEvent.ActorPosition.middle_right; data3.isName = true; data4.isName = true; data5.isName = true; data6.actionID = DialogPartNodeActionType.ExitActor; data6.exitActorEntries = new DialogPartData.ActorEntry[2]; data6.exitActorEntries[0] = new DialogPartData.ActorEntry(); data6.exitActorEntries[1] = new DialogPartData.ActorEntry(); data6.exitActorEntries[0].actorName = "Sachi"; data6.exitActorEntries[1].actorName = "Maiko"; #if false GameObject parentObj = GameObject.Find("Panels"); DrawObjectsTab.CreateBG("BG", parentObj); GameObject ch1 = DrawObjectsTab.Create2Layer("Ch1", parentObj); GameObject ch2 = DrawObjectsTab.Create2Layer("Ch2", parentObj); ch1.transform.localPosition = new Vector3(-120f, 0f, 0f); ch2.transform.localPosition = new Vector3(120f, 0f, 0f); AssetDatabase.MoveAsset("Assets/BG", "Assets/" + scenarioName + "/BG"); AssetDatabase.MoveAsset("Assets/Ch1", "Assets/" + scenarioName + "/Ch1"); AssetDatabase.MoveAsset("Assets/Ch2", "Assets/" + scenarioName + "/Ch2"); #endif string scenarioFlagDataPath = "Assets/" + scenarioName + "/" + scenarioName + "Flags.asset"; string scenarioSaveDataPath = "Assets/" + scenarioName + "/" + scenarioName + "SaveData.asset"; FlagTable flagTable = ScriptableObjectUtility.CreateScriptableObject("FlagTable", scenarioFlagDataPath) as FlagTable; ViNoSaveInfo saveInfo = ScriptableObjectUtility.CreateScriptableObject("ViNoSaveInfo", scenarioSaveDataPath) as ViNoSaveInfo; ScenarioNode scenarioNode = scenarioObj.GetComponent <ScenarioNode>(); scenarioNode.m_PlayAtStart = true; scenarioNode.flagTable = flagTable; // scenarioNode.saveInfo = saveInfo; ScenarioCtrl scenarioCtrl = GameObject.FindObjectOfType(typeof(ScenarioCtrl)) as ScenarioCtrl; scenarioCtrl.quickSaveSlot = saveInfo; scenarioCtrl.saveInfo = saveInfo; // Create an ActorLibrary and a SceneLibrary. string actorLibPrefabPath = "Assets/" + scenarioName + "/ActorLibrary.prefab"; string sceneLibPrefabPath = "Assets/" + scenarioName + "/SceneLibrary.prefab"; ViNoScenarioDataUtil.CreateActorLibrary(actorLibPrefabPath); ViNoScenarioDataUtil.CreateSceneLibrary(sceneLibPrefabPath); GameObject.DestroyImmediate(GameObject.Find("ActorLibrary")); GameObject.DestroyImmediate(GameObject.Find("SceneLibrary")); // ViNoToolkit.ActorInfo actor1 = ViNoScenarioDataUtil.CreateActorInfo() as ViNoToolkit.ActorInfo; ViNoToolkit.SceneEvent sceneEvt = GameObject.FindObjectOfType(typeof(ViNoToolkit.SceneEvent)) as ViNoToolkit.SceneEvent; ViNoToolkit.ActorLibrary actorLib = AssetDatabase.LoadAssetAtPath(actorLibPrefabPath, typeof(ViNoToolkit.ActorLibrary)) as ViNoToolkit.ActorLibrary; ViNoToolkit.SceneLibrary sceneLib = AssetDatabase.LoadAssetAtPath(sceneLibPrefabPath, typeof(ViNoToolkit.SceneLibrary)) as ViNoToolkit.SceneLibrary; /* actorLib.actorEntries = new ViNoToolkit.ActorInfo[ 1 ]; * actorLib.actorEntries[ 0 ] = actor1; * //*/ sceneEvt.actorLib = actorLib; sceneEvt.sceneLib = sceneLib; }
/// <summary> /// Load the specified info. /// </summary> /// <param name='info'> /// Info. /// </param> public void Load( ViNoSaveInfo info ) { VM vm = VM.Instance; if( vm == null ){ ViNoDebugger.LogError( "VM Not Found . Can't Load." ); } switch( saveMethod ){ case SaveMethods.COLLECT_VINO_SCENE_NODES: break; case SaveMethods.TRAVERSE_CHILDREN: if( destroyChildrenOnLoad ){ if( theSavedPanel != null ){ ViNoGOExtensions.DestroyImmediateChildren( theSavedPanel.name ); } } break; } ViNoGameSaveLoad.Load ( info ); }
static public void Load(ViNoSaveInfo info) { ViNoGameSaveLoad.LoadSceneFromXmlString(info.data.m_SceneXmlData); }
public void DoNewGame() { ViNoSaveInfo info = m_Instance.newGameInfo; PlayScenario(info); }