Esempio n. 1
0
    /// <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);
    }
Esempio n. 2
0
 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
    }
Esempio n. 5
0
    //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();
        }
    }
Esempio n. 6
0
    //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");
    }
Esempio n. 7
0
 /// <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);
 }
Esempio n. 8
0
 /// <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);
 }
Esempio n. 9
0
    /// <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);
    }
Esempio n. 10
0
    /// <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);
    }
Esempio n. 11
0
 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();
     }
 }
Esempio n. 12
0
    //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);
    }
Esempio n. 13
0
 /// <summary>
 /// saves the game play time
 /// </summary>
 private void OnApplicationQuit()
 {
     SaveValues.AddTimeFromStart(Time.time);
 }
Esempio n. 14
0
 protected override void Start()
 {
     base.Start();
     saveValues = GameObject.FindGameObjectWithTag(Tags.saveManager).GetComponent <SaveValues> ();
     loadValues = GameObject.FindGameObjectWithTag(Tags.saveManager).GetComponent <LoadValues> ();
 }
Esempio n. 15
0
 /// <summary>
 /// Really loads the popup
 /// </summary>
 private void DisplayPopup()
 {
     SaveValues.MarkAsSeen();
     LoadCPopup(RateGameSettings.ratePopupCanvas, RateGameSettings.popupGameObject);
 }
Esempio n. 16
0
 /// <summary>
 /// Called to increase a custom event
 /// </summary>
 public void IncreaseCustomEvents()
 {
     SaveValues.IncreaseNumberOfCustomEvents();
 }
Esempio n. 17
0
 /// <summary>
 /// Called to stop showing Rate Popup
 /// </summary>
 public void NeverShowPopup()
 {
     SaveValues.NeverShowPopup();
 }
Esempio n. 18
0
 //Save game to a file
 public void SaveGame()
 {
     SaveValues.getInstance().SaveGame();
 }
Esempio n. 19
0
 internal static void setInstance(SaveValues saveValues)
 {
     instance = saveValues;
 }