Example #1
0
    void OnEnable()
    {
        OnLoad?.Invoke();
        if (debugMode)
        {
            Debug.LogError("Deleting player prefs");
            PlayerPrefs.DeleteAll();
        }
        if (!PlayerPrefs.HasKey("volume"))
        {
            PlayerPrefs.SetFloat("volume", 1);
            Debug.LogError("volume key not found");
        }
        if (!PlayerPrefs.HasKey("smoothmove"))
        {
            Debug.LogError("smoothmove key not found");
            PlayerPrefs.SetInt("smoothmove", 1);
        }

        if (!PlayerPrefs.HasKey("snapangle"))
        {
            PlayerPrefs.SetInt("snapangle", 15);
            Debug.LogError("snapangle key not found");
        }

        AudioListener.volume = PlayerPrefs.GetFloat("volume");
        MoveVolumeIndicator();

        filePath = Application.persistentDataPath + "/game_data.json";

        if (File.Exists(filePath))
        {
            Debug.Log("Save file located at " + filePath);
            resumeButton.SetActive(true);
        }
        else
        {
            Debug.LogWarning("No save file located");
        }

        smoothMoveCheck.enabled = PlayerPrefs.GetInt("smoothmove") == 1 ? false : true;

        OnFinishedLoad?.Invoke();
    }
Example #2
0
        public ManagerBase2()
        {
            HostContext.Current.OnInitialize += delegate(object sender, EventArgs a)
            {
                try
                {
                    Initialize();
                }
                catch
                {
                }
                if (OnInitialize != null)
                {
                    try
                    {
                        OnInitialize.Invoke(this, EventArgs.Empty);
                    }
                    catch (Exception)
                    {
                    }
                }
            };

            HostContext.Current.OnBeforeQuerySettings += delegate(object sender, EventArgs a)
            {
                if (OnBeforeQuerySettings != null)
                {
                    try
                    {
                        OnBeforeQuerySettings.Invoke(this, EventArgs.Empty);
                    }
                    catch (Exception)
                    {
                    }
                }
                try
                {
                    QuerySettings();
                }
                catch (Exception)
                {
                }
            };

            HostContext.Current.OnAfterQuerySettings += delegate(object sender, EventArgs a)
            {
                if (OnAfterQuerySettings != null)
                {
                    try
                    {
                        OnAfterQuerySettings.Invoke(this, EventArgs.Empty);
                    }
                    catch (Exception)
                    {
                    }
                }
            };

            HostContext.Current.OnLoad += delegate(object sender, EventArgs a)
            {
                if (OnLoad != null)
                {
                    try
                    {
                        OnLoad.Invoke(this, EventArgs.Empty);
                    }
                    catch (Exception)
                    {
                    }
                }
                try
                {
                    Load();
                }
                catch (Exception)
                {
                }
            };

            HostContext.Current.OnLoad += delegate(object sender, EventArgs a)
            {
                try
                {
                    FinishedLoading();
                }
                catch (Exception)
                {
                }
                if (OnFinishedLoad != null)
                {
                    try
                    {
                        OnFinishedLoad.Invoke(this, EventArgs.Empty);
                    }
                    catch (Exception)
                    {
                    }
                }
            };
        }