/// <summary>
        /// Upon the asset being done loading from resources send it to the correct place to store
        /// </summary>
        /// <param name="to"></param>
        public void HandleAssetLoaded(AssetLoadRequestTO to)
        {
            switch (to.assetLoadType)
            {
            case AssetLoadType.Conversation:
                DialogController.GetInstance().LoadDialogFromTO(to);
                DialogController.GetInstance().PreloadPortraits();
                DialogController.GetInstance().PreloadMusic();
                break;

            case AssetLoadType.MapData:
                MapData md = MapData.FromTO(to);
                MapController.GetInstance().LoadMapData(md);
                break;

            case AssetLoadType.MapMaterial:
                MapController.GetInstance().LoadCurrMapMaterialFromTO(to);
                break;

            case AssetLoadType.Metadata:
                MetaDataManager.GetInstance().LoadMetadataFromTO(to);
                break;

            case AssetLoadType.Music:
                MusicController.GetInstance().LoadMusicFromTO(to);
                break;

            case AssetLoadType.SoundEfect:
                SoundEffectController.GetInstance().LoadSoundEffectFromTO(to);
                break;
            }
        }
        /// <summary>
        /// Creates an asset request for a music
        /// </summary>
        public static AssetLoadRequestTO CreateMusicAssetRequest(string fileName)
        {
            AssetLoadRequestTO to = new AssetLoadRequestTO();

            to.assetLoadType = AssetLoadType.Music;
            to.path          = GameConstants.MUSIC_LOC + fileName;
            return(to);
        }
        /// <summary>
        /// Creates an asset request for a metadata json
        /// </summary>
        public static AssetLoadRequestTO CreateMetadataAssetRequest(string fileName)
        {
            AssetLoadRequestTO to = new AssetLoadRequestTO();

            to.assetLoadType = AssetLoadType.Metadata;
            to.path          = GameConstants.METADATA_LOC + fileName;
            return(to);
        }
        public static AssetLoadRequestTO CreateMapMaterialRequest(string fileName)
        {
            AssetLoadRequestTO to = new AssetLoadRequestTO();

            to.assetLoadType = AssetLoadType.MapMaterial;
            to.path          = GameConstants.MATERIAL_LOC + fileName;
            return(to);
        }
        /// <summary>
        /// Creates an asset request for a new conversation json
        /// </summary>
        public static AssetLoadRequestTO CreateConversationRequest(string fileName)
        {
            AssetLoadRequestTO to = new AssetLoadRequestTO();

            to.assetLoadType = AssetLoadType.Conversation;
            to.path          = GameConstants.CONVERSATION_LOC + fileName;
            return(to);
        }
        /// <summary>
        /// Creates an asset request for a sound effect
        /// </summary>
        public static AssetLoadRequestTO CreateSoundEffectAssetRequest(string fileName)
        {
            AssetLoadRequestTO to = new AssetLoadRequestTO();

            to.assetLoadType = AssetLoadType.SoundEfect;
            to.path          = GameConstants.SOUND_LOC + fileName;

            return(to);
        }
        /// <summary>
        /// Creates an asset request to load a texture spritesheet
        /// </summary>
        public static AssetLoadRequestTO CreateSpriteSheetAssetRequest(string fileName)
        {
            AssetLoadRequestTO to = new AssetLoadRequestTO();

            to.assetLoadType = AssetLoadType.SpriteSheet;
            to.path          = GameConstants.TEXTURE_LOC + fileName;

            return(to);
        }
        public void LoadAsset(AssetLoadRequestTO to)
        {
            expected += 1;
            loaded   += 0;

            startDate = DateTime.Now;

            MainLoop main = MainLoop.GetInstance();

            main.StartCoroutine(LoadAsync(to));
        }
        private void LoadAllObjectsInPath(AssetLoadRequestTO to)
        {
            to.loadObjectList = Resources.LoadAll(to.path);
            HandleAssetLoaded(to);

            if (to.callback != null)
            {
                to.callback(to);
            }

            EventController.GetInstance().FireEvent(EventTypeEnum.AssetLoadComplete, null);
            LoadFinished();
        }
Esempio n. 10
0
        private IEnumerator LoadAsync(AssetLoadRequestTO to)
        {
            ResourceRequest req = Resources.LoadAsync(to.path);

            while (!req.isDone)
            {
                Debug.Log("Load Progress: " + req.progress);
                yield return(null);
            }
            to.loadedObject = req.asset;
            HandleAssetLoaded(to);

            if (to.callback != null)
            {
                to.callback(to);
            }

            EventController.GetInstance().FireEvent(EventTypeEnum.AssetLoadComplete, null);
            LoadFinished();
        }
Esempio n. 11
0
        /// <summary>
        /// Loads up a list of assets
        /// </summary>
        public void LoadAssets(List <AssetLoadRequestTO> assetLoadRequestList)
        {
            Debug.Log("Preparing to Load " + assetLoadRequestList.Count + " assets.");

            startDate = DateTime.Now;

            expected += assetLoadRequestList.Count;

            MainLoop main = MainLoop.GetInstance();

            for (int i = 0, count = assetLoadRequestList.Count; i < count; i++)
            {
                AssetLoadRequestTO to = assetLoadRequestList[i];

                if (to.assetLoadType == AssetLoadType.SpriteSheet)
                {
                    LoadAllObjectsInPath(to);
                }
                else
                {
                    main.StartCoroutine(LoadAsync(to));
                }
            }
        }