Esempio n. 1
0
		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;
		}
Esempio n. 2
0
        public void InitAnimations(ObjectCollection animations)
        {
            // the remaining sections contain animations to be attached to certain tiles
            for (int j = _animsSectionsStartIdx; j < _theaterIni.Sections.Count; j++)
            {
                var extraSection = _theaterIni.Sections[j];
                var tileSet      = _tileSets.Find(ts => ts.SetName == extraSection.Name);
                if (tileSet == null)
                {
                    continue;
                }

                for (int a = 1; a <= tileSet.TilesInSet; a++)
                {
                    string n        = string.Format("Tile{0:d2}", a);
                    string anim     = extraSection.ReadString(n + "Anim");
                    var    drawable = animations.GetDrawable(anim);

                    if (string.IsNullOrEmpty(anim) || drawable == null)
                    {
                        Logger.Trace("Missing anim {0} ({1}) for tileset {2}", anim, n, tileSet.SetName);
                        continue;
                    }

                    // clone, so that the tile-specific offset doesn't require setting on the original
                    // drawable, meaning it can be reused
                    var drawableClone = drawable.Clone();

                    // in pixels
                    int attachTo = extraSection.ReadInt(n + "AttachesTo");
                    var offset   = new Point(extraSection.ReadInt(n + "XOffset"), extraSection.ReadInt(n + "YOffset"));
                    drawableClone.Props.Offset.Offset(offset.X, offset.Y);
                    drawableClone.Props.ZAdjust = extraSection.ReadInt(n + "ZAdjust");
                    tileSet.Entries[a - 1].AddAnimation(attachTo, drawableClone);
                }
            }
        }
Esempio n. 3
0
		public void InitAnimations(ObjectCollection animations) {
			// the remaining sections contain animations to be attached to certain tiles
			for (int j = _animsSectionsStartIdx; j < _theaterIni.Sections.Count; j++) {
				var extraSection = _theaterIni.Sections[j];
				var tileSet = _tileSets.Find(ts => ts.SetName == extraSection.Name);
				if (tileSet == null) continue;

				for (int a = 1; a <= tileSet.TilesInSet; a++) {
					string n = string.Format("Tile{0:d2}", a);
					string anim = extraSection.ReadString(n + "Anim");
					var drawable = animations.GetDrawable(anim);

					if (string.IsNullOrEmpty(anim) || drawable == null) {
						Logger.Trace("Missing anim {0} ({1}) for tileset {2}", anim, n, tileSet.SetName);
						continue;
					}

					// clone, so that the tile-specific offset doesn't require setting on the original 
					// drawable, meaning it can be reused
					drawable = drawable.Clone();

					// in pixels
					int attachTo = extraSection.ReadInt(n + "AttachesTo");
					var offset = new Point(extraSection.ReadInt(n + "XOffset"), extraSection.ReadInt(n + "YOffset"));
					drawable.Props.Offset.Offset(offset.X, offset.Y);
					tileSet.Entries[a - 1].AddAnimation(attachTo, drawable);
				}
			}
		}