示例#1
0
        /// <summary>
        /// Load game resources (tiles, models) into memory.
        /// </summary>
        private bool LoadGameResources()
        {
            ServiceManager.Game.Renderer.ActiveScene.ClearAll();

            if (loaded)
            {
                // Only attempt to load the game resources once. This way subsequent loading
                // times are much faster.
                return(true);
            }

            Value = 40;
            if (!TileList.Initialized)
            {
                Message = "Loading tile textures...";
                if (!TileList.Read())
                {
                    // The error message is displayed within the parser, so never mind.
                    return(false);
                }
                Value = 45;
            }

            Message = "Loading background textures...";
            ServiceManager.Resources.GetTexture2D(
                "misc\\background\\background2");

            Message = "Loading tank models...";
            Value   = 50;

            // Pre-load the model resources so that it doesn't have to do so in-game.
            List <object> tankList = GameForms.Utils.GetTankModels();

            foreach (string tankName in tankList)
            {
                ServiceManager.Resources.GetModel(
                    String.Format("tanks{0}{1}", Path.DirectorySeparatorChar, tankName));
            }

            Message = "Loading weapon models...";
            Value   = 60;

            List <string> weaponList = GetWeaponModels();

            foreach (string weaponName in weaponList)
            {
                ServiceManager.Resources.GetModel(
                    String.Format("weapons{0}{1}", Path.DirectorySeparatorChar, weaponName));
            }

            Message = "Loading projectile models...";
            Value   = 70;

            List <string> projectileList = GetProjectileModels();

            foreach (string projectileName in projectileList)
            {
                ServiceManager.Resources.GetModel(
                    String.Format("projectiles{0}{1}", Path.DirectorySeparatorChar, projectileName));
            }


            Message = "Loading utility models...";
            Value   = 75;

            List <string> utilityList = GameForms.Utils.GetUtilityModels();

            foreach (string utilityName in utilityList)
            {
                ServiceManager.Resources.GetModel(
                    String.Format("powerups{0}{1}", Path.DirectorySeparatorChar, utilityName));
            }
            Message = "Loading effects...";
            Value   = 80;

            Message = "Loading event models...";
            Value   = 85;
            List <string> eventList = Toolkit.GetEventList();

            foreach (string eventModel in eventList)
            {
                ServiceManager.Resources.GetModel(@"events\" + eventModel);
            }

            Message = "Loading renderer assets...";
            Value   = 90;
            if (!RendererAssetLoader.HasInitialized)
            {
                RendererAssetLoader.Initialize();
            }

            ParticleEmitterSettings pset = Renderer.RendererAssetPool.ParticleEmitterSettings["Utility"];

            new ParticleEmitter(pset);

            Message = "Loading tank skins...";
            Value   = 95;
            List <string> skinList = Toolkit.GetFullSkinList();

            foreach (string skin in skinList)
            {
                string path = String.Format("{0}{1}", Constants.DEFAULT_SKIN_DIR, skin);
                ServiceManager.Resources.Load <Texture2D>(path);
            }

            loaded = true;
            return(true);
        }