// File management

    static public void Create()
    {
        if (m_Instance == null)
        {
            m_Instance = new PlayerData();

            //if we create the PlayerData, mean it's the very first call, so we use that to init the database
            //this allow to always init the database at the earlier we can, i.e. the start screen if started normally on device
            //or the Loadout screen if testing in editor
            CoroutineHandler.StartStaticCoroutine(CharacterDatabase.LoadDatabase());
            CoroutineHandler.StartStaticCoroutine(ThemeDatabase.LoadDatabase());
        }

        m_Instance.saveFile = Application.persistentDataPath + "/save.bin";

        if (File.Exists(m_Instance.saveFile))
        {
            // If we have a save, we read it.
            m_Instance.Read();
        }
        else
        {
            // If not we create one with default data.
            NewSave();
        }

        m_Instance.CheckMissionsCount();
    }
Example #2
0
    static IEnumerator AsyncLoad()
    {
        // Android store streams assets in a compressed archive, so different file system.
#if !UNITY_EDITOR
#if UNITY_ANDROID
        AssetBundleManager.BaseDownloadingURL = Application.streamingAssetsPath + "/AssetBundles/" + Utility.GetPlatformName() + "/";
#else
        AssetBundleManager.BaseDownloadingURL = "file://" + Application.streamingAssetsPath + "/AssetBundles/" + Utility.GetPlatformName() + "/";
#endif
#else
        AssetBundleManager.BaseDownloadingURL = "file://" + Application.streamingAssetsPath + "/AssetBundles/" + Utility.GetPlatformName() + "/";
#endif

        var request = AssetBundleManager.Initialize();
        if (request != null)
        {
            yield return(CoroutineHandler.StartStaticCoroutine(request));
        }

        // In editor we can directly get all the bundles but in final build, we need to read them from the manifest.
#if UNITY_EDITOR
        string[] bundles;
        if (AssetBundleManager.SimulateAssetBundleInEditor)
        {
            bundles = AssetDatabase.GetAllAssetBundleNames();
        }
        else
        {
            bundles = AssetBundleManager.AssetBundleManifestObject.GetAllAssetBundles();
        }
#else
        string[] bundles = AssetBundleManager.AssetBundleManifestObject.GetAllAssetBundles();
#endif

        List <string> characterPackage = new List <string>();
        List <string> themePackage     = new List <string>();

        for (int i = 0; i < bundles.Length; ++i)
        {
            if (bundles[i].StartsWith("characters/"))
            {
                characterPackage.Add(bundles[i]);
            }
            else if (bundles[i].StartsWith("themes/"))
            {
                themePackage.Add(bundles[i]);
            }
        }

        yield return(CoroutineHandler.StartStaticCoroutine(CharacterDatabase.LoadDatabase(characterPackage)));

        yield return(CoroutineHandler.StartStaticCoroutine(ThemeDatabase.LoadDatabase(themePackage)));
    }
Example #3
0
    void Start()
    {
        PlayerData.Create();

        consumableDatabase.Load();
        CoroutineHandler.StartStaticCoroutine(CharacterDatabase.LoadDatabase());
        CoroutineHandler.StartStaticCoroutine(ThemeDatabase.LoadDatabase());


#if UNITY_ANALYTICS
        AnalyticsEvent.StoreOpened(StoreType.Soft);
#endif

#if !UNITY_EDITOR && !DEVELOPMENT_BUILD
        //Disable cheating on non dev build outside of the editor
        cheatButton.interactable = false;
#else
        cheatButton.interactable = true;
#endif

        m_OpenList = itemList;
        itemList.Open();
    }