public void ResetDefaultSound()
    {
        if (BackGroundAudioSource != null && defaultAudio != null && BackGroundAudioSource.clip != defaultAudio)
        {
            BackGroundAudioSource.clip = defaultAudio;

            if (SoundEnabled())
            {
                BackGroundAudioSource.Play();
            }
        }
    }
    public void ResetGame()
    {
        int oldCoins  = Player.Coins;
        int oldPoints = Player.Score;

        GameSetup();

        Player.SendCoinsChangedMessage(Player.Coins, oldCoins);
        Player.SendScoreChangedMessage(Player.Score, oldPoints);

        string newLanguage = PreferencesFactory.GetString("Language", useSecurePrefs: false);

        if (newLanguage != null)
        {
            LocaliseText.Language = newLanguage;
        }

        if (SoundEnabled())
        {
            BackGroundAudioSource.Play();
        }

        GameManager.SafeQueueMessage(new GameResetedMessage());
    }
    protected override void GameSetup()
    {
        // secure preferences
        PreferencesFactory.UseSecurePrefs = SecurePreferences;
        if (SecurePreferences)
        {
            if (string.IsNullOrEmpty(PreferencesPassPhrase))
            {
                Debug.LogWarning("You have not set a custom pass phrase in GameManager | Player Preferences. Please correct for improved security.");
            }
            else
            {
                PreferencesFactory.PassPhrase = PreferencesPassPhrase;
            }
            PreferencesFactory.AutoConvertUnsecurePrefs = AutoConvertUnsecurePrefs;
        }

        StartupLevels = NumberOfAutoCreatedLevels;

        int NumberOfAdditionalCreatedLevels = PreferencesFactory.GetInt(Constants.KeyNumberOfAdditionalCreatedLevels);

        NumberOfAutoCreatedLevels += NumberOfAdditionalCreatedLevels;

        string FirstAppStartDate = PreferencesFactory.GetString(Constants.KeyFirstAppStartDate, null);

        if (FirstAppStartDate == null)
        {
            PreferencesFactory.SetString(Constants.KeyFirstAppStartDate, UnbiasedTime.Instance.Now().ToString(CultureInfo.InvariantCulture));
        }

        PreferencesFactory.SetString(Constants.KeyLastAppStartDate, UnbiasedTime.Instance.Now().ToString(CultureInfo.InvariantCulture));

        int TimesAppStarted = PreferencesFactory.GetInt(Constants.KeyTimesAppStarted, 0);

        PreferencesFactory.SetInt(Constants.KeyTimesAppStarted, TimesAppStarted + 1);

        base.GameSetup();

        if (PlayerPrefs.GetInt("ManualChangedLanguage", 0) == 0)
        {
#if UNITY_ANDROID || UNITY_EDITOR
            string savedLanguage  = PreferencesFactory.GetString("Language", useSecurePrefs: false);
            string systemLanguage = DeviceLanguage();

            // user does not changed his language manual
            // and system language is different from previous auto-detected
            if (systemLanguage != savedLanguage)
            {
                LanguageController.ChangeLanguage(systemLanguage);
            }
#endif

#if UNITY_IOS
            IOSNativeUtility.OnLocaleLoaded += GetLocale;
            IOSNativeUtility.Instance.GetLocale();
#endif
        }

        Packs = new PackGameItemManager();

        if (LevelSetupMode == GameItemSetupMode.FromResources)
        {
            Packs.Load(1, NumberOfAutoCreatedPacks);
        }

        Ranks = new RankGameItemManager();

        if (LevelSetupMode == GameItemSetupMode.FromResources)
        {
            Ranks.Load(1, NumberOfAutoCreatedRanks);
        }

        Rank rank = Ranks.GetItem(1);

        if (!rank.IsUnlocked)
        {
            rank.IsUnlocked = true; // first rank is unlocked by default
            rank.UpdatePlayerPrefs();
        }

        Pack pack = Packs.GetItem(1);

        if (!pack.IsUnlocked)
        {
            pack.IsUnlocked = true; // first pack is unlocked by default
            pack.UpdatePlayerPrefs();
        }

        Level level = Levels.GetItem(1);

        if (!level.IsUnlocked)
        {
            level.IsUnlocked = true; // first level is unlocked by default
            level.UpdatePlayerPrefs();
        }

        GameManager.SafeAddListener <UserNotificationsChangedMessage>(UserNotificationsChangedHandler);
        GameManager.SafeAddListener <LocalisationChangedMessage>(LocalisationHandler);

        // bug fix in gameframework when user loose all his lives and start game again and Lives back to full
        if (FirstAppStartDate != null)
        { // but only after first start ever
            Player.Lives = Player.GetSettingInt("Lives", 0);
        }

        if (FirstAppStartDate == null)
        { // first start
            PreferencesFactory.SetInt(Constants.KeyNotificationsAllowed, 1);
        }

        //

        Advertisement.Initialize(Constants.UnityAdsGameId);

        if (BackGroundAudioVolume > Constants.DefaultAudioVolume)
        {
            BackGroundAudioVolume = Constants.DefaultAudioVolume;
        }

        if (EffectAudioVolume > Constants.DefaultAudioVolume)
        {
            EffectAudioVolume = Constants.DefaultAudioVolume;
        }

        _currentBackgroundSoundVolume = BackGroundAudioVolume;

        if (!SoundEnabled())
        {
            BackGroundAudioSource.Stop();
        }

#if UNITY_IPHONE
        SA.IOSNative.Core.AppController.Subscribe();

        SA.IOSNative.Core.AppController.OnApplicationDidReceiveMemoryWarning += OnApplicationDidReceiveMemoryWarning;
#endif

#if !UNITY_EDITOR
        CancelLocalNotifications();
        RegisterLocalNotifications();
#endif
    }