public override void Run_Node() { switch (stat_type) { case Stat_Type.Set_Number: StatsManager.Set_Numbered_Stat(stat_name, set_number_to); break; case Stat_Type.Modify_Number: StatsManager.Add_To_Numbered_Stat(stat_name, modify_number_amount); break; case Stat_Type.Set_Boolean: StatsManager.Set_Boolean_Stat(stat_name, set_bool_to); break; case Stat_Type.Toggle_Boolean: StatsManager.Toggle_Boolean_Stat(stat_name); break; case Stat_Type.Set_String: StatsManager.Set_String_Stat(stat_name, set_string_to); break; } if (print_all_stats_to_console) { StatsManager.Print_All_Stats(); } Finish_Node(); }
// Loads a scene and sets the settings of this save file to the game // Must be called with a monobehaviour with StartCoroutine(Load()) // Modify this method to add in your own custom loading code public IEnumerator Load() { Debug.Log("Loading..." + current_conv_node); StatsManager.Clear_All_Stats(); string active_scene = UnityEngine.SceneManagement.SceneManager.GetActiveScene().name; // UI is unresponsive if there are 2 event systems if (UnityEngine.EventSystems.EventSystem.current.gameObject) { GameObject.Destroy(UnityEngine.EventSystems.EventSystem.current.gameObject); } // Load items StatsManager.items = saved_items; VNSceneManager.scene_manager = null; // Load the scene that was saved UnityEngine.SceneManagement.SceneManager.LoadScene(current_scene, UnityEngine.SceneManagement.LoadSceneMode.Additive); // Must wait 1 frame before initializing the new scene yield return(null); // Unpause in case the game was paused before loading Pause.pause.ResumeGame(); // Stop the default things from happening VNSceneManager.scene_manager.starting_conversation = null; ConversationManager cur_conv = GameObject.Find(current_conv).GetComponent <ConversationManager>(); // Set log VNSceneManager.scene_manager.Add_To_Log("", log_text); // Set play time VNSceneManager.scene_manager.play_time += time_played; ActorManager.actors_on_scene = new List <Actor>(); ActorManager.exiting_actors = new List <Actor>(); ActorManager.left_actors = new List <Actor>(); ActorManager.right_actors = new List <Actor>(); ActorManager.center_actors = new List <Actor>(); /* * // Load the actors on the scene * foreach (string a in left_actors) * { * ActorManager.Instantiate_Actor(a, Actor_Positions.LEFT); * } * foreach (string a in right_actors) * { * ActorManager.Instantiate_Actor(a, Actor_Positions.RIGHT); * } * foreach (string a in center_actors) * { * ActorManager.Instantiate_Actor(a, Actor_Positions.CENTER); * } */ // Execute any Nodes that need to executed to create the scene (StaticImageNodes, SetBackground, SetMusicNode, ChangeActorImage, etc) foreach (string node_path in Nodes_to_Execute_on_Load) { // Figure out what type of Node we're dealing with string[] node_parts = node_path.Split(new string[] { feature_save_separation_character }, StringSplitOptions.None); // We can figure out which node is executed by the Node component embedded in the string if (node_parts.Length == 2) { GameObject go = GameObject.Find(node_parts[1]); if (go == null) { Debug.LogError("Load: Could not find node to execute; " + node_path); continue; } Node n = (Node)go.GetComponent(node_parts[0]); if (n != null) { n.executed_from_load = true; n.Run_Node(); } else { Debug.LogError("Load: Gameobject did not have attached node to execute; " + node_path); } } // Can't figure out which node type this is, simply execute the first node on the found gameobject else if (node_parts.Length == 1) { GameObject go = GameObject.Find(node_path); if (go == null) { Debug.LogError("Load: Could not find node to execute; " + node_path); continue; } Node n = go.GetComponent <Node>(); if (n != null) { n.executed_from_load = true; n.Run_Node(); } else { Debug.LogError("Load: Gameobject did not have attached node to execute; " + node_path); } } } // Delete conversations not present in our saved conversations ConversationManager[] convs = (ConversationManager[])UnityEngine.Object.FindObjectsOfType(typeof(ConversationManager)) as ConversationManager[]; foreach (ConversationManager c in convs) { // Find all conversations in our freshly loaded scene, check if we should keep or delete these conversations string name = (c.name); // Record the full name of the object (including its parents) Transform parent = c.transform.parent; while (parent != null) { name = name.Insert(0, parent.name + "/"); parent = parent.parent; } bool delete_conv = true; // Check against saved conversations foreach (string s in remaining_conversations) { if (name == s) { delete_conv = false; break; } } if (delete_conv) { GameObject.Destroy(c.gameObject); } } // Load stats StatsManager.boolean_stats = saved_boolean_stats; StatsManager.numbered_stats = saved_numbered_stats; StatsManager.string_stats = saved_string_stats; StatsManager.items = saved_items; StatsManager.Print_All_Stats(); // Load log text VNSceneManager.text_logs = log_categories; VNSceneManager.scene_manager.Conversation_log = log_text; //<< MODIFY THIS SECTION TO LOAD THINGS SPECIFIC TO YOUR GAME >>// //<< MODIFY THE ABOVE SECTION TO LOAD THINGS SPECIFIC TO YOUR GAME >>// // Start the conversation cur_conv.Start_Conversation_Partway_Through(current_conv_node); yield return(0); // Flip any actors that are meant to be flipped foreach (string a in flipped_actors) { Actor actor = ActorManager.Get_Actor(a); if (a != null) { actor.transform.localScale = new Vector3(-actor.transform.localScale.x, actor.transform.localScale.y, actor.transform.localScale.z); } } UnityEngine.SceneManagement.SceneManager.SetActiveScene(UnityEngine.SceneManagement.SceneManager.GetSceneByName(current_scene)); UnityEngine.SceneManagement.SceneManager.UnloadSceneAsync(active_scene); AudioListener.pause = false; yield return(0); }