Exemplo n.º 1
0
    private static void BuyProductID(string productId)
    {
        if (!IsInitialized)
        {
            MyDebug.LogWarning("BuyProductID FAIL. Not initialized.");
            return;
        }
        if (string.IsNullOrEmpty(productId))
        {
            MyDebug.LogError("BuyProductID FAIL. Empty productId");
            return;
        }

        IAPProduct product = storeController.products.WithID(productId);

        if (product != null && product.availableToPurchase)
        {
            MyDebug.Log($"Purchasing product asychronously: {product.definition.id}");

            currentProductId = productId;

            storeController.InitiatePurchase(product);
        }
        else
        {
            MyDebug.LogError("BuyProductID: FAIL. Not purchasing product, either is not found or is not available for purchase");
        }
    }
Exemplo n.º 2
0
    //结构体转字节数组
    //public static byte[] StructToBytes(object structObj, int size = 0)
    //{
    //    if (size == 0)
    //    {
    //        size = Marshal.SizeOf(structObj);
    //    }
    //    IntPtr buffer = Marshal.AllocHGlobal(size);
    //    try
    //    {
    //        Marshal.StructureToPtr(structObj, buffer, false);
    //        byte[] bytes = new byte[size];
    //        Marshal.Copy(buffer, bytes, 0, size);
    //        return bytes;
    //    }
    //    catch (Exception ex)
    //    {
    //        MyDebug.LogWarning("struct to bytes error:" + ex);
    //        return null;
    //    }
    //    finally
    //    {
    //        Marshal.FreeHGlobal(buffer);
    //    }
    //}
    //字节数组转结构体
    public static object BytesToStruct(byte[] bytes, Type strcutType, int nSize, int index = 0)
    {
        if (bytes == null)
        {
            MyDebug.LogWarning("null bytes!!!!!!!!!!!!!");
        }

        var size   = Marshal.SizeOf(strcutType);
        var buffer = Marshal.AllocHGlobal(nSize);

        try
        {
            Marshal.Copy(bytes, index, buffer, nSize);
            return(Marshal.PtrToStructure(buffer, strcutType));
        }
        catch (Exception ex)
        {
            MyDebug.LogWarning("Type: " + strcutType.ToString() + "---TypeSize:" + size + "----packetSize:" + nSize);
            return(null);
        }
        finally
        {
            Marshal.FreeHGlobal(buffer);
        }
    }
 /// <summary>
 /// Setup
 /// </summary>
 protected override void Start()
 {
     MyDebug.LogWarning(
         "EnableBasedUponXxxUnlocked Components are deprecated and will be removed. Please replace with the more generic EnableBasedUponXxx components instead.");
     base.Start();
     GetGameItemManager().Unlocked += Unlocked;
 }
        /// <summary>
        /// Get a Vector3 value from PlayerPrefs.
        /// </summary>
        public static Vector3?GetVector3(string key, Vector3?defaultValue = null, bool?useSecurePrefs = null)
        {
            var result = GetString(key, null, useSecurePrefs); //, ItemType.Vector3);

            if (result == null)
            {
                return(defaultValue);
            }
            var parts = result.Split(':');

            if (parts.Length != 3)
            {
                MyDebug.LogWarning(
                    "GetVector3 found an invalid value and will return the default. Please check you are accessing the correct prefs item.");
                return(defaultValue);
            }
            float x, y, z;

            if (float.TryParse(parts[0], NumberStyles.Any, CultureInfo.InvariantCulture, out x) &&
                float.TryParse(parts[1], NumberStyles.Any, CultureInfo.InvariantCulture, out y) &&
                float.TryParse(parts[2], NumberStyles.Any, CultureInfo.InvariantCulture, out z))
            {
                return(new Vector3(x, y, z));
            }
            MyDebug.LogWarning(
                "GetVector3 found an invalid number value and will return the default. Please check you are accessing the correct prefs item.");
            return(defaultValue);
        }
Exemplo n.º 5
0
	// The V4VCResult Delegate assigned in Start, AdColony calls this after confirming V4VC transactions with your server
	// success - true: transaction completed, virtual currency awarded by your server - false: transaction failed, no virtual currency awarded
	// name - The name of your virtual currency, defined in your AdColony account
	// amount - The amount of virtual currency awarded for watching the video, defined in your AdColony account
	private void OnV4VCResult (bool success, string currencyName, int amount)
	{
		if (success) {
			MyDebug.Log (false,"AdsMCG::OnV4VCResult ==> V4VC SUCCESS: name = " + currencyName + ", amount = " + amount);
			GUtility.Me.PProgress.Cash += amount;
			GUtility.Me.SavePProgres ();
		} else {
			MyDebug.LogWarning (false,"AdsMCG::OnV4VCResult ==> V4VC FAILED!");
		}
	}
 /// <summary>
 /// Setup
 /// </summary>
 protected override void Start()
 {
     MyDebug.LogWarning(
         "EnableBasedUponXxxSelected Components are deprecated and will be removed. Please replace with the more generic EnableBasedUponXxx components instead.");
     base.Start();
     // add selection changed handler always, but not multiple times.
     if (Context.GetReferencedContextMode() != ObjectModel.GameItemContext.ContextModeType.Selected)
     {
         GetGameItemManager().SelectedChanged += SelectedChanged;
     }
 }
Exemplo n.º 7
0
        /// <summary>
        /// Evaluate the current condition
        /// </summary>
        /// <returns></returns>
        public override bool EvaluateCondition(GameItem gameItem)
        {
            if (_errorShown)
            {
                return(false);
            }
            _errorShown = true;
            MyDebug.LogWarning("TheCustomExample condition is for demonstration purposes only to show how to add your own custom conditions. Do not use this in custom code.");

            // Here you would have your own custom condition test.

            return(false);
        }
Exemplo n.º 8
0
    public static void AddObj(MovingObj obj)
    {
        if (movingObjs == null)
        {
            movingObjs = new Dictionary <string, MovingObj>();
        }

        if (movingObjs.ContainsKey(obj.name))
        {
            MyDebug.LogWarning($"Object with key {obj.name} already exists in list");
            return;
        }
        movingObjs.Add(obj.name, obj);
    }
Exemplo n.º 9
0
 public void OnUnityAdsDidFinish(string placementId, ShowResult showResult)
 {
     if (showResult == ShowResult.Finished)
     {
         EventManager.eventManager.FinishAd(RewardedButtons[placementId].rewardBonus);
     }
     else if (showResult == ShowResult.Skipped)
     {
         MyDebug.Log("Skipped");
     }
     else if (showResult == ShowResult.Failed)
     {
         MyDebug.LogWarning("The ad did not finish due to an error.");
     }
 }
Exemplo n.º 10
0
        IEnumerator WWWload(string key, string url)
        {
            //MyDebug.Log("WWWLoad:" + url);
            WWW www = null;

            try
            {
                www = new WWW(url);
            }
            catch (System.Exception ex)
            {
                MyDebug.LogWarning("url:" + url + "exception:" + ex.ToString());
            }
            dictWWW[key] = www;
            yield return(www);
        }
Exemplo n.º 11
0
 /// <summary>
 /// Fetches a localized string with the given key
 /// </summary>
 /// <param name="key"></param>
 /// <returns></returns>
 public static string GetString(string key)
 {
     if (null == mLocales)
     {
         SetLocale("zh_CN");
     }
     if (null != mLocales[mCurrentLocale])
     {
         string ret = (string)(mLocales[mCurrentLocale] as Hashtable)[key];
         if (ret == null)
         {
             MyDebug.LogWarning("本地化失败:" + key);
         }
         return(ret != null ? ret : "L:" + key);
     }
     return("L." + key);
 }
Exemplo n.º 12
0
        public void ShareLink(Uri contentURL, string contentTitle = "",
                              string contentDescription           = "", Uri photoURL = null)
        {
            if (!IsLoggedIn)
            {
                MyDebug.LogWarning("Authorise user before posting, fail event generated");

                IShareResult res = new ShareResult("User isn't authorised");
                OnPostingCompleteAction(FacebookHelperResultType.ERROR, res);
                return;
            }

            FB.ShareLink(
                contentURL: contentURL,
                contentTitle: contentTitle,
                contentDescription: contentDescription,
                photoURL: photoURL,
                callback: PostCallBack
                );
        }
Exemplo n.º 13
0
        //本地推送 你可以传入一个固定的推送时间
        public static void NotificationMessage(string message, System.DateTime newDate, bool isRepeatDay)
        {
#if UNITY_IPHONE
            CleanNotification();
            LocalNotification localNotification = new LocalNotification();
            localNotification.fireDate  = newDate;
            localNotification.alertBody = message;
            localNotification.applicationIconBadgeNumber = 1;
            localNotification.hasAction = true;
            if (isRepeatDay)
            {
                //是否每天定期循环
                localNotification.repeatCalendar = CalendarIdentifier.ChineseCalendar;
                localNotification.repeatInterval = CalendarUnit.Day;
            }
            localNotification.soundName = LocalNotification.defaultSoundName;
            NotificationServices.ScheduleLocalNotification(localNotification);
            MyDebug.LogWarning("DO通知:" + message + "," + newDate);
#endif
        }
Exemplo n.º 14
0
        public virtual DataAdapter GetSingleBy(string key, string value)
        {
            if (!dictHead.ContainsKey(key))
            {
                MyDebug.LogError("配置【" + fileName + "】不包含键等于【" + key + "】的列");
                return(null);
            }
            int keyIndex = dictHead[key];

            for (int i = 0; i < _count; i++)
            {
                if (arrCfg[i][keyIndex] == value)
                {
                    DataAdapter da = new DataAdapter();
                    da.fileName   = fileName;
                    da.arrStrData = arrCfg[i];
                    da.dictHead   = dictHead;
                    return(da);
                }
            }
            MyDebug.LogWarning("找不到配置:" + fileName + ",key=" + key + ",value=" + value);
            return(null);
        }
 /// <summary>
 /// Set Color preferences
 /// </summary>
 public void SetColor(string key, Color value, bool?useSecurePrefs = null)
 {
     MyDebug.LogWarning("Color preferences are only supported with the PlayerPrefs integration. See Main Menu | Window | Game Framework | Integrations Window for more details.");
 }
 /// <summary>
 /// Get Vector3 preferences
 /// </summary>
 public Vector3?GetVector3(string key, Vector3?defaultValue = null, bool?useSecurePrefs = null)
 {
     MyDebug.LogWarning("Vector3 preferences are only supported with the PlayerPrefs integration. See Main Menu | Window | Game Framework | Integrations Window for more details.");
     return(defaultValue);
 }
 /// <summary>
 /// Get boolean preferences
 /// </summary>
 public bool GetBool(string key, bool defaultValue = false, bool?useSecurePrefs = null)
 {
     MyDebug.LogWarning("Boolean preferences are only supported with the PlayerPrefs integration. See Main Menu | Window | Game Framework | Integrations Window for more details.");
     return(defaultValue);
 }
Exemplo n.º 18
0
        /// <summary>
        /// Main setup routine
        /// </summary>
        protected override void GameSetup()
        {
            base.GameSetup();

            var sb = new System.Text.StringBuilder();

            MyDebug.DebugLevel = DebugLevel;

            sb.Append("GameManager: GameSetup()");
            sb.Append("\nApplication.systemLanguage: ").Append(Application.systemLanguage);

            // 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;
            }

            // Gameplay related properties
            IsUnlocked = PreferencesFactory.GetInt("IsUnlocked", 0) != 0;
#pragma warning disable 618
            IsUserInteractionEnabled = true;
#pragma warning restore 618
            IsSplashScreenShown = false;
            TimesGamePlayed     = PreferencesFactory.GetInt("TimesGamePlayed", 0);
            TimesGamePlayed++;
            TimesLevelsPlayed          = PreferencesFactory.GetInt("TimesLevelsPlayed", 0);
            TimesPlayedForRatingPrompt = PreferencesFactory.GetInt("TimesPlayedForRatingPrompt", 0);
            TimesPlayedForRatingPrompt++;
            sb.Append("\nTimesGamePlayed: ").Append(TimesGamePlayed);
            sb.Append("\nTimesLevelsPlayed: ").Append(TimesLevelsPlayed);
            sb.Append("\nTimesPlayedForRatingPrompt: ").Append(TimesPlayedForRatingPrompt);
            sb.Append("\nApplication.PersistantDataPath: ").Append(Application.persistentDataPath);

            MyDebug.Log(sb.ToString());

            // audio related properties
            BackGroundAudioVolume = 1;              // default if nothing else is set.
            EffectAudioVolume     = 1;              // default if nothing else is set.
            var audioSources = GetComponents <AudioSource>();
            if (audioSources.Length == 0)
            {
                MyDebug.LogWarning(
                    "To make use of the Game Manager audio functions you should add 2 AudioSource components to the same gameobject as the GameManager. The first for background audio and the second for effects.");
            }
            else
            {
                if (audioSources.Length > 0)
                {
                    BackGroundAudioSource = audioSources[0];
                    BackGroundAudioVolume = BackGroundAudioSource.volume;
                }
                if (audioSources.Length > 1)
                {
                    EffectAudioSources = new AudioSource[audioSources.Length - 1];
                    Array.Copy(audioSources, 1, EffectAudioSources, 0, audioSources.Length - 1);
                    EffectAudioVolume = EffectAudioSources[0].volume;
                }
            }

            BackGroundAudioVolume = PreferencesFactory.GetFloat("BackGroundAudioVolume", BackGroundAudioVolume, false);
            EffectAudioVolume     = PreferencesFactory.GetFloat("EffectAudioVolume", EffectAudioVolume, false);

            Assert.IsNotNull(Camera.main, "You need a main camera in your scene!");
            // display related properties
            SetDisplayProperties();

            // Localisation setup. If nothing stored then use system Language if it exists. Otherwise we will default to English.
            LocaliseText.AllowedLanguages = SupportedLanguages;

            // setup players.
            Assert.IsTrue(PlayerCount >= 1, "You need to specify at least 1 player in GameManager");
            Players = new PlayerGameItemManager();
            Players.Load(0, PlayerCount - 1);

            //TODO: Make Obsolete
            if (WorldUnlockMode == GameItem.UnlockModeType.Coins || LevelUnlockMode == GameItem.UnlockModeType.Coins || CharacterUnlockMode == GameItem.UnlockModeType.Coins)
            {
                Debug.LogWarning("GameManager Unlock Modes are deprecated in favour of the more powerful UnlockXxx options in GameItem configuration files and will soon be removed. Change the GameManager settings to Custom to remove this warning and add / configure GameItem configuration files.");
            }

            // handle auto setup of worlds and levels
            if (AutoCreateWorlds)
            {
                var coinsToUnlockWorlds = WorldUnlockMode == GameItem.UnlockModeType.Coins ? CoinsToUnlockWorlds : -1;
                Worlds = new WorldGameItemManager();
                Worlds.Load(1, NumberOfAutoCreatedWorlds, coinsToUnlockWorlds, LoadWorldDatafromResources);

                // if we have worlds then autocreate levels for each world.
                if (AutoCreateLevels)
                {
                    for (var i = 0; i < NumberOfAutoCreatedWorlds; i++)
                    {
                        var coinsToUnlock = LevelUnlockMode == GameItem.UnlockModeType.Coins ? CoinsToUnlockLevels : -1;
                        Worlds.Items[i].Levels = new LevelGameItemManager();
                        Worlds.Items[i].Levels.Load(WorldLevelNumbers[i].Min, WorldLevelNumbers[i].Max, coinsToUnlock, LoadLevelDatafromResources);
                    }

                    // and assign the selected set of levels
                    Levels = Worlds.Selected.Levels;
                }
            }
            else
            {
                // otherwise not automatically setting up worlds so if auto setup of levels then create at root level.
                if (AutoCreateLevels)
                {
                    var coinsToUnlock = LevelUnlockMode == GameItem.UnlockModeType.Coins ? CoinsToUnlockLevels : -1;
                    Levels = new LevelGameItemManager();
                    Levels.Load(1, NumberOfAutoCreatedLevels, coinsToUnlock, LoadLevelDatafromResources);
                }
            }

            // handle auto setup of characters
            if (AutoCreateCharacters)
            {
                Characters = new CharacterGameItemManager();
                if (CharacterUnlockMode == GameItem.UnlockModeType.Coins)
                {
                    Characters.Load(1, NumberOfAutoCreatedCharacters, CoinsToUnlockCharacters, LoadCharacterDatafromResources);
                }
                else
                {
                    Characters.Load(1, NumberOfAutoCreatedCharacters, loadFromResources: LoadCharacterDatafromResources);
                }
            }

            // coroutine to check for display changes (don't need to do this every frame)
            if (!Mathf.Approximately(DisplayChangeCheckDelay, 0))
            {
                StartCoroutine(CheckForDisplayChanges());
            }

            // flag as initialised
            IsInitialised = true;
        }
Exemplo n.º 19
0
    private async void Awake()
    {
        Time.timeScale = 1;

        if ((data = SaveManager.Load()) == null)
        {
            data = new GameData();
        }

        EventManager.eventManager = new EventManager();

        EventManager.eventManager.OnClick += OnClick;

        CheckForNull(data);

        data.timerIncreasingValue = data.modifierValue;

        CheckDate(data);

        StartCoroutine(Save());

        foreach (var acl in data.products)
        {
            if (acl.Value is IAutocliker autocliker)
            {
                autocliker.AutoClick();

                await System.Threading.Tasks.Task.Delay(UnityEngine.Random.Range(400, 600));
            }
        }

        giftNotification = new Notification();

        giftNotification.CreateNotificationChannel("Gift", "OpenGift", "Open gift", Unity.Notifications.Android.Importance.Default);

        void CheckForNull(GameData data)
        {
            if (data.products == null)
            {
                data.products = new Dictionary <string, Product>();
            }
            if (data.products == null)
            {
                data.products = new Dictionary <string, Product>();
            }
            if (data.timeToWinLeft == null)
            {
                data.timeToWinLeft = 90f;
            }
            if (data.enemySpawnStep == null)
            {
                data.enemySpawnStep = 0.2f;
            }
            if (data.timerSkipKoef == null)
            {
                data.timerSkipKoef = 2.5f;
            }
            if (data.permanentSoldierModifier == 0)
            {
                data.permanentSoldierModifier = 1;
            }
            if (data.dayStep == null)
            {
                data.dayStep = 60f;
            }
            if (data.giftTimer == default)
            {
                data.giftTimer = new GiftTimer(60, 0);
            }
        }

        void CheckDate(GameData data)
        {
            if (DateTime.TryParse(data.exitTime, out DateTime exitTime))
            {
                DateTime currentTime = DateTime.Now;
                if (currentTime < exitTime)
                {
                    MyDebug.LogWarning("Перемотка времени detected");
                    data.soldiersCount /= 2;
                    data.aliensHearts  /= 2;
                }
            }
        }
    }
Exemplo n.º 20
0
        /// <summary>
        /// Load LocalisationData files
        /// </summary>
        public static void Reload(LocalisationConfiguration localisationConfiguration = null)
        {
            Clear();

            if (localisationConfiguration == null)
            {
                localisationConfiguration = GameManager.LoadResource <LocalisationConfiguration>("LocalisationConfiguration");
            }
            //localisationConfiguration = GameObject.FindObjectOfType<LocalisationConfiguration>();
            var setupMode = localisationConfiguration == null ? LocalisationConfiguration.SetupModeType.Auto : localisationConfiguration.SetupMode;

            string[] loadedSupportedLanguages = new string[0];

            // set localisation data
            if (setupMode == LocalisationConfiguration.SetupModeType.Auto)
            {
                // Try to load the default Localisation file directly - don't use GameMangager method as we load in 'reverse' as user items
                // should overwrite system ones.
                var asset = Resources.Load <LocalisationData>("Default/Localisation");
                if (asset != null)
                {
                    LocalisationData         = ScriptableObject.Instantiate(asset); // create a copy so we don't overwrite values.
                    loadedSupportedLanguages = asset.GetLanguageNames();
                }

                // try and load identifier localisation if specified and present, or if not user localisation
                var identifierLocalisationLoaded = false;
                if (GameManager.IsActive && GameManager.GetIdentifierBase() != null)
                {
                    asset = Resources.Load <LocalisationData>(GameManager.GetIdentifierBase() + "/Localisation");
                    if (asset != null)
                    {
                        identifierLocalisationLoaded = true;
                        if (LocalisationData == null)
                        {
                            LocalisationData = asset;
                        }
                        else
                        {
                            LocalisationData.Merge(asset);
                        }
                        loadedSupportedLanguages = asset.GetLanguageNames(); // override any previous
                    }
                }
                if (!identifierLocalisationLoaded)
                {
                    asset = Resources.Load <LocalisationData>("Localisation");
                    if (asset != null)
                    {
                        if (LocalisationData == null)
                        {
                            LocalisationData = asset;
                        }
                        else
                        {
                            LocalisationData.Merge(asset);
                        }
                        loadedSupportedLanguages = asset.GetLanguageNames(); // override any previous
                    }
                }
                if (LocalisationData == null)
                {
                    MyDebug.LogWarning("GlobalLocalisation: No localisation data was found so creating an empty one. Please check that a localisation files exist at /Resources/Localisation or /Resources/Default/Localisation!");
                }
            }
            else if (setupMode == LocalisationConfiguration.SetupModeType.Specified)
            {
                foreach (var localisationData in localisationConfiguration.SpecifiedLocalisationData)
                {
                    // first item gets loaded / copied, subsequent get merged into this.
                    if (LocalisationData == null)
                    {
                        LocalisationData = ScriptableObject.Instantiate(localisationData);  // create a copy so we don't overwrite values.
                    }
                    else
                    {
                        LocalisationData.Merge(localisationData);
                    }
                    loadedSupportedLanguages = localisationData.GetLanguageNames(); // if exists override
                }
                if (LocalisationData == null)
                {
                    MyDebug.LogWarning("GlobalLocalisation: No localisation data was found so creating an empty one. Please check that localisation files exist and are in the correct location!");
                }
            }

            // if nothing loaded then create an empty localisation to avoid errors.
            if (LocalisationData == null)
            {
                LocalisationData = ScriptableObject.CreateInstance <LocalisationData>();
                LocalisationData.AddLanguage("English", "en");
                loadedSupportedLanguages = LocalisationData.GetLanguageNames();
            }

            // set Supported Languages - either from config if present or based upon loaded files.
            if (localisationConfiguration != null && localisationConfiguration.SupportedLanguages.Length > 0)
            {
                List <string> validSupportedLanguages = new List <string>();
                foreach (var language in localisationConfiguration.SupportedLanguages)
                {
                    if (LocalisationData.ContainsLanguage(language))
                    {
                        validSupportedLanguages.Add(language);
                    }
                    else
                    {
                        Debug.Log("GlobalLocalisation: Localisation files do not contain definitions for the specified supported language '" + language + "'");
                    }
                }
                SupportedLanguages = validSupportedLanguages.ToArray();
            }
            else
            {
                SupportedLanguages = loadedSupportedLanguages;
            }


            // if no usable language is already set then set to the default language.
            if (!CanUseLanguage(Language))
            {
                SetLanguageToDefault();
            }
        }
Exemplo n.º 21
0
        protected override void GameSetup()
        {
            base.GameSetup();

            var sb = new System.Text.StringBuilder();

            MyDebug.DebugLevel = DebugLevel;

            sb.Append("GameManager: GameSetup()");
            sb.Append("\nApplication.systemLanguage: ").Append(Application.systemLanguage);


            // Gameplay related properties
            IsUnlocked = PlayerPrefs.GetInt("IsUnlocked", 0) != 0;
#pragma warning disable 618
            IsUserInteractionEnabled = true;
#pragma warning restore 618
            IsSplashScreenShown = false;
            TimesGamePlayed     = PlayerPrefs.GetInt("TimesGamePlayed", 0);
            TimesGamePlayed++;
            TimesLevelsPlayed          = PlayerPrefs.GetInt("TimesLevelsPlayed", 0);
            TimesPlayedForRatingPrompt = PlayerPrefs.GetInt("TimesPlayedForRatingPrompt", 0);
            TimesPlayedForRatingPrompt++;
            sb.Append("\nTimesGamePlayed: ").Append(TimesGamePlayed);
            sb.Append("\nTimesLevelsPlayed: ").Append(TimesLevelsPlayed);
            sb.Append("\nTimesPlayedForRatingPrompt: ").Append(TimesPlayedForRatingPrompt);
            sb.Append("\nApplication.PersistantDataPath: ").Append(Application.persistentDataPath);

            MyDebug.Log(sb.ToString());

            // audio related properties
            BackGroundAudioVolume = 1;              // default if nothing else is set.
            EffectAudioVolume     = 1;              // default if nothing else is set.
            var audioSources = GetComponents <AudioSource>();
            if (audioSources.Length == 0)
            {
                MyDebug.LogWarning(
                    "To make use of the Game Manager audio functions you should add 2 AudioSource components to the same gameobject as the GameManager. The first for background audio and the second for effects.");
            }
            else
            {
                if (audioSources.Length > 0)
                {
                    BackGroundAudioSource = audioSources[0];
                    BackGroundAudioVolume = BackGroundAudioSource.volume;
                }
                if (audioSources.Length > 1)
                {
                    EffectAudioSources = new AudioSource[audioSources.Length - 1];
                    Array.Copy(audioSources, 1, EffectAudioSources, 0, audioSources.Length - 1);
                    EffectAudioVolume = EffectAudioSources[0].volume;
                }
            }

            BackGroundAudioVolume = PlayerPrefs.GetFloat("BackGroundAudioVolume", BackGroundAudioVolume);
            EffectAudioVolume     = PlayerPrefs.GetFloat("EffectAudioVolume", EffectAudioVolume);


            // display related properties
            SetDisplayProperties();

            // Localisation setup. If nothing stored then use system Language if it exists. Otherwise we will default to English.
            LocaliseText.AllowedLanguages = SupportedLanguages;

            // setup players.
            Players = new Player[Instance.PlayerCount];
            for (var i = 0; i < Instance.PlayerCount; i++)
            {
                Players[i] = CreatePlayer(i);
            }
            SetPlayerByNumber(0);

            // setup worlds if auto setup
            if (AutoCreateWorlds)
            {
                Worlds = new GameItemsManager <World, GameItem>();
                if (WorldUnlockMode == GameItem.UnlockModeType.Coins)
                {
                    Worlds.LoadDefaultItems(1, NumberOfAutoCreatedWorlds, CoinsToUnlockLevels, LoadWorldDatafromResources);
                }
                else
                {
                    Worlds.LoadDefaultItems(1, NumberOfAutoCreatedWorlds, loadFromResources: LoadWorldDatafromResources);
                }
            }

            // setup levels if auto setup
            if (AutoCreateLevels)
            {
                int startLevel = AutoCreateWorlds ? WorldLevelNumbers[Worlds.Selected.Number - 1].Min : 1;
                int endLevel   = AutoCreateWorlds ? WorldLevelNumbers[Worlds.Selected.Number - 1].Max : NumberOfAutoCreatedLevels;
                Levels = new GameItemsManager <Level, GameItem>();
                if (LevelUnlockMode == GameItem.UnlockModeType.Coins)
                {
                    Levels.LoadDefaultItems(startLevel, endLevel, CoinsToUnlockLevels, LoadLevelDatafromResources);
                }
                else
                {
                    Levels.LoadDefaultItems(startLevel, endLevel, loadFromResources: LoadLevelDatafromResources);
                }
            }

            // setup levels if auto setup
            if (AutoCreateCharacters)
            {
                Characters = new GameItemsManager <Character, GameItem>();
                if (CharacterUnlockMode == GameItem.UnlockModeType.Coins)
                {
                    Characters.LoadDefaultItems(1, NumberOfAutoCreatedCharacters, CoinsToUnlockCharacters, LoadCharacterDatafromResources);
                }
                else
                {
                    Characters.LoadDefaultItems(1, NumberOfAutoCreatedCharacters, loadFromResources: LoadCharacterDatafromResources);
                }
            }

            // coroutine to check for display changes (don't need to do this every frame)
            if (!Mathf.Approximately(DisplayChangeCheckDelay, 0))
            {
                StartCoroutine(CheckForDisplayChanges());
            }

            // flag as initialised
            IsInitialised = true;
        }