Пример #1
0
        /// <summary>
        /// Loads assets relevant for a particular game state.
        /// </summary>
        /// <param name="gameState"> Gamestate that is currently in-play for the client-side player.</param>
        public static void loadStaticAssets(GameState gameState)
        {
            if (gameState == activeState)
            {
                return;
            }
            dumpPreviousResources();
            activeState = gameState;

            if (isInitialLoad)
            {
                batchLoadAssets(COMMON_ASSET_PATH);
            }

            string statePrefix = activeState.ToString();

            switch (gameState)
            {
            case GameState.MAIN_MENU:
                break;

            case GameState.CHARACTER_CREATION:
                batchLoadAssets(CLASS_ICON_PATH, statePrefix);

                break;

            case GameState.BATTLE_STATE:
                batchLoadAssets(STATUS_ICON_PATH, statePrefix);
                break;

            default:
                Debug.LogError($"UnexpecteD Gamestate argument {gameState} provided during asset loading.  {new System.Diagnostics.StackFrame()}");
                break;
            }
        }
Пример #2
0
        /// <summary>
        /// Removes unused assets from the sprite map as the game state changes
        /// </summary>
        private static void dumpPreviousResources()
        {
            List <string> assetsRemoving = new List <string>();

            foreach (var asset in spriteMap)
            {
                if (asset.Key.StartsWith(activeState.ToString()))
                {
                    assetsRemoving.Add(asset.Key);
                }
            }

            foreach (var asset in assetsRemoving)
            {
                spriteMap.Remove(asset);
            }
        }