/// <summary> /// Checks all conditions from Settings Window and determines it they are met or not /// </summary> /// <returns></returns> private bool CanShowRate() { bool sessionCountReached; bool customEventsReached; bool timeSinceStartReached; bool timeSinceOpenReached; int fisrtShow = SaveValues.IsFirstShow(); if (fisrtShow > 1) { return(false); } if (fisrtShow == 0) { sessionCountReached = IsSessionCountReached(RateGameSettings.firstShowSettings); customEventsReached = IsCustomEventReached(RateGameSettings.firstShowSettings); timeSinceStartReached = IsTimeSinceStartReached(RateGameSettings.firstShowSettings); timeSinceOpenReached = IsTimeSinceOpenReached(RateGameSettings.firstShowSettings); } else { sessionCountReached = IsSessionCountReached(RateGameSettings.postponeSettings); customEventsReached = IsCustomEventReached(RateGameSettings.postponeSettings); timeSinceStartReached = IsTimeSinceStartReached(RateGameSettings.postponeSettings); timeSinceOpenReached = IsTimeSinceOpenReached(RateGameSettings.postponeSettings); } if (sessionCountReached && customEventsReached && timeSinceStartReached && timeSinceOpenReached) { return(true); } return(false); }
public static SaveValues getInstance() { if (instance == null) { instance = new SaveValues(); } return(instance); }
private IEnumerator continuousSave() { while (true) { yield return(new WaitForSeconds(20)); SaveValues.getInstance().SaveGame(); } }
private IEnumerator startUp() { yield return(new WaitForSeconds(0)); SaveValues.getInstance().LoadGame(); //Get the path of the Game data folder string m_Path = Application.dataPath; //Output the Game data path to the console StartCoroutine(continuousSave()); // Dont destroy this object when a new scene is loaded }
//Load game to a file public void LoadGame() { Debug.Log("Serialising" + Application.persistentDataPath + "/gamesave.save"); // 1 if (File.Exists(Application.persistentDataPath + "/gamesave.save")) { BinaryFormatter bf = new BinaryFormatter(); FileStream file = File.Open(Application.persistentDataPath + "/gamesave.save", FileMode.Open); SaveValues.setInstance((SaveValues)bf.Deserialize(file)); file.Close(); } }
//Save game to a file public void SaveGame() { BinaryFormatter bf = new BinaryFormatter(); FileStream file = File.Create(Application.persistentDataPath + "/gamesave.save"); SaveValues.getInstance().UpdateValues(); bf.Serialize(file, SaveValues.getInstance()); Debug.Log("Serialising " + Application.persistentDataPath + "/gamesave.save"); file.Close(); Debug.Log("Game Saved"); }
/// <summary> /// Checks time since start /// </summary> /// <param name="displayConditions">first time conditions or postpone conditions</param> /// <returns></returns> private bool IsTimeSinceStartReached(DisplayConditions displayConditions) { if (displayConditions.useInGameTime) { if (SaveValues.GetTimeSinceStart() + Time.time >= displayConditions.gamePlayTime * 60) { return(true); } } else { return(true); } return(false); }
/// <summary> /// Checks time since opening /// </summary> /// <param name="displayConditions">first time conditions or postpone conditions</param> /// <returns></returns> private bool IsTimeSinceOpenReached(DisplayConditions displayConditions) { if (displayConditions.useRealTime) { if (SaveValues.GetTimeSinceOpen() >= displayConditions.realTime) { return(true); } } else { return(true); } return(false); }
/// <summary> /// Checks custom events /// </summary> /// <param name="displayConditions">first time conditions or postpone conditions</param> /// <returns></returns> private bool IsCustomEventReached(DisplayConditions displayConditions) { if (displayConditions.useCustomEvents) { if (SaveValues.GetNumberOfCustomEvents() >= displayConditions.minCustomEvents) { return(true); } } else { return(true); } return(false); }
/// <summary> /// Checks sessions count /// </summary> /// <param name="displayConditions">first time conditions or postpone conditions</param> /// <returns></returns> private bool IsSessionCountReached(DisplayConditions displayConditions) { if (displayConditions.useSessionsCount) { if (SaveValues.GetNumberOfSessions() >= displayConditions.minSessiosnCount) { return(true); } } else { return(true); } return(false); }
public void Load() { if (File.Exists(savePath)) { BinaryFormatter bf = new BinaryFormatter(); FileStream file = File.Open(savePath, FileMode.Open); savedValues = (SaveValues)bf.Deserialize(file); file.Close(); Debug.Log("musicMuted : " + savedValues.musicMuted); Debug.Log("Plants saved " + savedValues.availablePlants.Count); } else { CreateNewGame(); } }
//Load game to a file public void LoadGame() { // 1 if (File.Exists(Application.persistentDataPath + "/gamesave.save")) { BinaryFormatter bf = new BinaryFormatter(); FileStream file = File.Open(Application.persistentDataPath + "/gamesave.save", FileMode.Open); Debug.Log("Loading " + Application.persistentDataPath + "/gamesave.save"); SaveValues sv = (SaveValues)bf.Deserialize(file); AchievementManager.instance.achievementsMap = sv.achievementsMap; GlobalGameManager.instance.highScoreDict = sv.highScoreDict; GlobalGameManager.instance.forestUnlocked = sv.forestUnlocked; GlobalGameManager.instance.oceanUnlocked = sv.oceanUnlocked; GlobalGameManager.instance.firstPlay = sv.firstPlay; file.Close(); } AchievementManager.instance.IncrementAchievement(AchievementType.Plays); }
/// <summary> /// saves the game play time /// </summary> private void OnApplicationQuit() { SaveValues.AddTimeFromStart(Time.time); }
protected override void Start() { base.Start(); saveValues = GameObject.FindGameObjectWithTag(Tags.saveManager).GetComponent <SaveValues> (); loadValues = GameObject.FindGameObjectWithTag(Tags.saveManager).GetComponent <LoadValues> (); }
/// <summary> /// Really loads the popup /// </summary> private void DisplayPopup() { SaveValues.MarkAsSeen(); LoadCPopup(RateGameSettings.ratePopupCanvas, RateGameSettings.popupGameObject); }
/// <summary> /// Called to increase a custom event /// </summary> public void IncreaseCustomEvents() { SaveValues.IncreaseNumberOfCustomEvents(); }
/// <summary> /// Called to stop showing Rate Popup /// </summary> public void NeverShowPopup() { SaveValues.NeverShowPopup(); }
//Save game to a file public void SaveGame() { SaveValues.getInstance().SaveGame(); }
internal static void setInstance(SaveValues saveValues) { instance = saveValues; }