CNCMaps.Engine.Game.Theater.Initialize C# (CSharp) Метод

Initialize() публичный Метод

public Initialize ( ) : bool
Результат bool
        public bool Initialize()
        {
            Logger.Info("Initializing theater of type {0}", _theaterType);

            if (!ModConfig.SetActiveTheater(_theaterType))
                return false;
            Active = this;

            // load palettes and additional mix files for this theater
            _palettes = new PaletteCollection();
            _palettes.IsoPalette = new Palette(VFS.Open<PalFile>(ModConfig.ActiveTheater.IsoPaletteName));
            _palettes.OvlPalette = new Palette(VFS.Open<PalFile>(ModConfig.ActiveTheater.OverlayPaletteName));
            _palettes.UnitPalette = new Palette(VFS.Open<PalFile>(ModConfig.ActiveTheater.UnitPaletteName), ModConfig.ActiveTheater.UnitPaletteName, true);

            foreach (string mix in ModConfig.ActiveTheater.Mixes)
                VFS.Add(mix, CacheMethod.Cache); // we wish for these to be cached as they're gonna be hit often

            _palettes.AnimPalette = new Palette(VFS.Open<PalFile>("anim.pal"));

            _animations = new ObjectCollection(CollectionType.Animation, _theaterType, _engine, _rules, _art,
                _rules.GetSection("Animations"), _palettes);

            _tileTypes = new TileCollection(CollectionType.Tiles, _theaterType, _engine, _rules, _art, ModConfig.ActiveTheater);

            _buildingTypes = new ObjectCollection(CollectionType.Building, _theaterType, _engine, _rules, _art,
                _rules.GetSection("BuildingTypes"), _palettes);

            _aircraftTypes = new ObjectCollection(CollectionType.Aircraft, _theaterType, _engine, _rules, _art,
                _rules.GetSection("AircraftTypes"), _palettes);

            _infantryTypes = new ObjectCollection(CollectionType.Infantry, _theaterType, _engine, _rules, _art,
                _rules.GetSection("InfantryTypes"), _palettes);

            _overlayTypes = new ObjectCollection(CollectionType.Overlay, _theaterType, _engine, _rules, _art,
                _rules.GetSection("OverlayTypes"), _palettes);

            _terrainTypes = new ObjectCollection(CollectionType.Terrain, _theaterType, _engine, _rules, _art,
                _rules.GetSection("TerrainTypes"), _palettes);

            _smudgeTypes = new ObjectCollection(CollectionType.Smudge, _theaterType, _engine, _rules, _art,
                _rules.GetSection("SmudgeTypes"), _palettes);

            _vehicleTypes = new ObjectCollection(CollectionType.Vehicle, _theaterType, _engine, _rules, _art,
                _rules.GetSection("VehicleTypes"), _palettes);

            _tileTypes.InitTilesets();
            _tileTypes.InitAnimations(_animations);

            return true;
        }

Usage Example

Пример #1
0
        // between LoadMap and LoadTheater, the VFS should be initialized
        public bool LoadTheater()
        {
            Drawable.TileWidth  = (ushort)TileWidth;
            Drawable.TileHeight = (ushort)TileHeight;

            _theater = new Theater(TheaterType, Engine, _rules, _art);
            if (!_theater.Initialize())
            {
                return(false);
            }

            // needs to be done before drawables are set
            Operations.RecalculateOreSpread(_overlayObjects, Engine);

            RemoveUnknownObjects();
            SetDrawables();

            LoadColors();
            if (Engine >= EngineType.RedAlert2)
            {
                LoadCountries();
            }
            LoadHouses();

            Operations.FixTiles(_tiles, _theater.GetTileCollection());
            if (Engine <= EngineType.Firestorm)
            {
                Operations.RecalculateVeinsSpread(_overlayObjects, _tiles);
            }

            CreateLevelPalettes();
            LoadPalettes();
            ApplyRemappables();
            if (!IgnoreLighting)
            {
                LoadLightSources();
                ApplyLightSources();
            }

            SetBaseTiles();             // requires .AnimationDrawable set on objects

            // first preparing all palettes as above, and only now recalculating them
            // could save a large amount of work in total
            RecalculatePalettes();

            return(true);
        }
All Usage Examples Of CNCMaps.Engine.Game.Theater::Initialize