private static string?LoadSaveGame() { var saveGames = SaveGameHandler.GetSaveGameNames(); if (saveGames.Count == 0) { PrintMessage("No saved games found!"); return(null); } int count = 1; foreach (var tmp in from name in saveGames where name != null select new MenuItem { Title = name, CommandToExecute = () => { SetSaveGame(name); Run(Settings, SavedState); return(null); } }) { _loadSaveGamesMenu.MenuItemsDictionary.Add((count++).ToString(), tmp); } _loadSaveGamesMenu.Run(); _loadSaveGamesMenu = new Menu(2) { Title = "Load/save games", MenuItemsDictionary = new Dictionary <string, MenuItem>() }; return(null); }
static void SetupSaveGame() { SaveGameHandler handler = SaveGameHandler.Instance; if (handler != null) { Diagnostics.Stopwatch stopwatch = new Diagnostics.Stopwatch(); stopwatch.Reset(); stopwatch.Start(); var saveablesQuery = from Instance in UsefulTools.Tools.FindAllSceneObjects <MonoBehaviour>() where typeof(ISaveable).IsAssignableFrom(Instance.GetType()) && !Instance.GetType().IsInterface&& !Instance.GetType().IsAbstract let key = string.Format("{0}_{1}", Instance.GetType().Name, System.Guid.NewGuid().ToString("N")) select new SaveableDataPair(SaveableDataPair.DataBlockType.ISaveable, key, Instance, new string[0]); var attributesQuery = from Instance in UsefulTools.Tools.FindAllSceneObjects <MonoBehaviour>() let attr = Instance.GetType().GetFields().Where(field => field.GetCustomAttributes(typeof(SaveableField), false).Count() > 0 && !field.IsLiteral && field.IsPublic).Select(fls => fls.Name).ToArray() let key = string.Format("{0}_{1}", Instance.GetType().Name, System.Guid.NewGuid().ToString("N")) where attr.Count() > 0 select new SaveableDataPair(SaveableDataPair.DataBlockType.Attribute, key, Instance, attr); SaveableDataPair[] pairs = saveablesQuery.Union(attributesQuery).ToArray(); stopwatch.Stop(); handler.saveableDataPairs = pairs; EditorUtility.SetDirty(handler); Debug.Log("<color=green>[Setup SaveGame Successful]</color> Found Saveable Objects: " + pairs.Length + ", Time Elapsed: " + stopwatch.ElapsedMilliseconds + "ms"); } else { Debug.LogError("[Setup SaveGame Error] To Setup SaveGame you need to Setup your scene first."); } }
void Awake() { healthManager = Player.GetComponent <HealthManager>(); scriptManager = Player.gameObject.GetComponentInChildren <ScriptManager>(); if (scriptManager.ArmsCamera.GetComponent <PostProcessVolume>()) { postProcessing = scriptManager.ArmsCamera.GetComponent <PostProcessVolume>(); if (postProcessing.profile.HasSettings <ColorGrading>()) { colorGrading = postProcessing.profile.GetSetting <ColorGrading>(); } else if (useGreyscale) { Debug.LogError($"[PostProcessing] Please add ColorGrading Effect to a {postProcessing.profile.name} profile in order to use Greyscale."); } } else { Debug.LogError($"[PostProcessing] There is no PostProcessVolume script added to a {ScriptManager.Instance.ArmsCamera.gameObject.name}!"); } lightSlider = LightPercentagle.GetComponentInChildren <Slider>(); lightBackground = lightSlider.transform.GetChild(0).GetComponent <Image>(); defaultIcon = LightPercentagle.transform.GetChild(0).GetComponent <Image>().sprite; configHandler = GetComponent <ConfigHandler>(); saveHandler = GetComponent <SaveGameHandler>(); inputManager = GetComponent <InputController>(); inventoryScript = GetComponent <Inventory>(); uiInteractive = true; }
void OnEnable() { handler = target as SaveGameHandler; p_SaveLoadSettings = serializedObject.FindProperty("SaveLoadSettings"); p_dataBetweenScenes = serializedObject.FindProperty("dataBetweenScenes"); p_fadeControl = serializedObject.FindProperty("fadeControl"); p_saveableDataPairs = serializedObject.FindProperty("saveableDataPairs"); }
void Awake() { configHandler = GetComponent <ConfigHandler>(); healthManager = Camera.main.transform.root.gameObject.GetComponent <HealthManager>(); scriptManager = Player.transform.GetChild(0).transform.GetChild(0).GetComponent <ScriptManager>(); saveHandler = GetComponent <SaveGameHandler>(); uiInteractive = true; }
private void LoadGame(GameObject obj) { string slotIDStr = ""; slotIDStr = obj.transform.GetChild(1).GetComponent <Text>().text.Substring(6, 3); int slotID = 0; slotID = int.Parse(slotIDStr); SaveGameHandler.LoadGame(slotID); }
public void CreatePlayerBasedFilter(ScoutingRequest request, List <Func <Player, bool> > filters) { List <int> countryClubs = null; Func <Player, bool> filter = null; if (request.PlaysInDivision.HasValue) { Club_Comp comp = _savegame.ClubComps.Values.FirstOrDefault(x => x.Id == request.PlaysInDivision.Value); if (comp != null) { var compClubs = _savegame.Clubs.Where(x => x.Value.DivisionId == comp.Id).Select(x => x.Value).ToList(); filter = x => compClubs.Select(y => y.ClubId).Contains(x._staff.ClubId); filters.Add(filter); return; } } if (!string.IsNullOrWhiteSpace(request.PlaysInCountry)) { int?playsInNationId = _savegame.Nations.Values.FirstOrDefault(x => x.Name.Equals(request.PlaysInCountry, StringComparison.InvariantCultureIgnoreCase))?.Id; if (playsInNationId != null) { countryClubs = _savegame.Clubs.Where(x => x.Value.NationId == playsInNationId.Value).Select(x => x.Key).ToList(); if (countryClubs?.Count > 0) { filter = x => countryClubs.Contains(x._staff.ClubId) || (x._staff.ClubId == -1 && x._staff.NationId == playsInNationId.Value); filters.Add(filter); return; } } } if (!string.IsNullOrWhiteSpace(request.PlaysInRegion)) { List <int> regionCountryIds = SaveGameHandler.GetCountriesInRegion(_savegame.Nations, request.PlaysInRegion); if (regionCountryIds?.Count > 0) { countryClubs = _savegame.Clubs.Where(x => regionCountryIds.Contains(x.Value.NationId)).Select(x => x.Key).ToList(); filter = x => countryClubs.Contains(x._staff.ClubId) || (x._staff.ClubId == -1 && regionCountryIds.Contains(x._staff.NationId)); filters.Add(filter); return; } } }
void OnGUI() { SaveGameHandler handler = SaveGameHandler.Instance; SerializedObject serializedObject = new SerializedObject(handler); SerializedProperty list = serializedObject.FindProperty("saveableDataPairs"); GUIStyle boxStyle = GUI.skin.GetStyle("HelpBox"); boxStyle.fontSize = 10; boxStyle.alignment = TextAnchor.MiddleCenter; int count = handler.saveableDataPairs.Length; string warning = ""; MessageType messageType = MessageType.None; if (count > 0 && handler.saveableDataPairs.All(pair => pair.Instance != null)) { warning = "SaveGame Handler is set up successfully!"; messageType = MessageType.Info; } else if (count > 0 && handler.saveableDataPairs.Any(pair => pair.Instance == null)) { warning = "Some of saveable instances are missing! Please find scene saveables again!"; messageType = MessageType.Error; } else if (count < 1) { warning = "In order to use SaveGame feature in your scene, you must find saveables first!"; messageType = MessageType.Warning; } EditorGUI.HelpBox(new Rect(1, 0, EditorGUIUtility.currentViewWidth - 2, 40), warning, messageType); EditorGUI.HelpBox(new Rect(1, 40, EditorGUIUtility.currentViewWidth - 2, 30), "Found Saveables: " + count, MessageType.None); GUIContent btnTxt = new GUIContent("Find Saveables"); var rt = GUILayoutUtility.GetRect(btnTxt, GUI.skin.button, GUILayout.Width(150), GUILayout.Height(30)); rt.center = new Vector2(EditorGUIUtility.currentViewWidth / 2, rt.center.y); rt.y = 80; if (GUI.Button(rt, btnTxt, GUI.skin.button)) { SetupSaveGame(); } }
public void SaveGame() { SaveGameHandler.SaveGame(); }
void Awake() { gamemanager = GameObject.Find("GAMEMANAGER"); saveGame = gamemanager.GetComponent <SaveGameHandler>(); }
void Awake() { saveGame = SaveGameHandler.Instance; }
private static void SetSaveGame(string name) { SavedState = SaveGameHandler.LoadSaveGame(name); }
public static SaveGameData LoadSaveGameFile(string fileName) { return(SaveGameHandler.OpenSaveGameIntoMemory(fileName)); }