Пример #1
0
        protected override Drawable MakeDrawable(string objName)
        {
            Drawable drawable;
            var      rulesSection   = Rules.GetOrCreateSection(objName);
            string   artSectionName = rulesSection.ReadString("Image", objName);
            var      artSection     = Art.GetOrCreateSection(artSectionName);

            switch (Type)
            {
            case CollectionType.Aircraft:
            case CollectionType.Vehicle:
                drawable = new UnitDrawable(rulesSection, artSection);
                break;

            case CollectionType.Building:
                drawable = new BuildingDrawable(rulesSection, artSection);
                break;

            case CollectionType.Infantry:
            case CollectionType.Overlay:
            case CollectionType.Smudge:
            case CollectionType.Terrain:
                drawable = new ShpDrawable(rulesSection, artSection);
                break;

            case CollectionType.Animation:
                drawable = new AnimDrawable(rulesSection, artSection);
                break;

            default:
                throw new InvalidEnumArgumentException();
            }
            return(drawable);
        }
Пример #2
0
		protected override Drawable MakeDrawable(string objName) {
			Drawable drawable;
			var rulesSection = Rules.GetOrCreateSection(objName);
			string artSectionName = rulesSection.ReadString("Image", objName);
			var artSection = Art.GetOrCreateSection(artSectionName);

			switch (Type) {
				case CollectionType.Aircraft:
				case CollectionType.Vehicle:
					drawable = new UnitDrawable(rulesSection, artSection);
					break;
				case CollectionType.Building:
					drawable = new BuildingDrawable(rulesSection, artSection);
					break;
				case CollectionType.Infantry:
				case CollectionType.Overlay:
				case CollectionType.Smudge:
				case CollectionType.Terrain:
					drawable = new ShpDrawable(rulesSection, artSection);
					break;
				case CollectionType.Animation:
					drawable = new AnimDrawable(rulesSection, artSection);
					break;
				default:
					throw new InvalidEnumArgumentException();
			}
			return drawable;
		}
Пример #3
0
        private Drawable InitAnimDrawable(IniFile.IniSection rules, IniFile.IniSection art)
        {
            var anim = new AnimDrawable(rules, art);

            InitDrawableDefaults(anim, art);
            anim.LoadFromRules();
            anim.Shp = VFS.Open <ShpFile>(anim.Image + ".shp");
            return(anim);
        }
Пример #4
0
        private AnimDrawable LoadExtraImage(string extraImage, DrawProperties inheritProps)
        {
            string animSection = Art.ReadString(extraImage);

            if (animSection == "")
            {
                return(null);
            }

            IniFile.IniSection extraRules = OwnerCollection.Rules.GetOrCreateSection(animSection);
            IniFile.IniSection extraArt   = OwnerCollection.Art.GetOrCreateSection(animSection);
            var anim = new AnimDrawable(extraRules, extraArt);

            anim.OwnerCollection = OwnerCollection;
            anim.LoadFromRules();

            anim.NewTheater = this.NewTheater;

            if (extraArt.HasKey("YSortAdjust") || Art.HasKey(extraImage + "YSort") ||
                extraArt.HasKey("ZAdjust") || Art.HasKey(extraImage + "ZAdjust"))
            {
                anim.Props.SortIndex = extraArt.ReadInt("YSortAdjust", Art.ReadInt(extraImage + "YSort"))
                                       - extraArt.ReadInt("ZAdjust", Art.ReadInt(extraImage + "ZAdjust"));
            }
            else
            {
                anim.Props.SortIndex = inheritProps.SortIndex;
            }
            if (Art.HasKey(extraImage + "X") || Art.HasKey(extraImage + "Y"))
            {
                anim.Props.Offset = this.Props.Offset + new Size(Art.ReadInt(extraImage + "X"), Art.ReadInt(extraImage + "Y"));
            }
            else
            {
                anim.Props.Offset = inheritProps.Offset;
            }
            anim.Props.ZAdjust  = Art.ReadInt(extraImage + "ZAdjust");
            anim.IsBuildingPart = true;

            anim.Shp = VFS.Open <ShpFile>(anim.GetFilename());
            return(anim);
        }
Пример #5
0
        // Adds fire animations to a building. Supports custom-paletted animations.
        private void LoadFireAnimations()
        {
            // http://modenc.renegadeprojects.com/DamageFireTypes
            int f = 0;

            while (true)               // enumerate as many fires as are existing
            {
                string dfo = Art.ReadString("DamageFireOffset" + f++);
                if (dfo == "")
                {
                    break;
                }

                string[]           coords   = dfo.Split(new[] { ',', '.' }, StringSplitOptions.RemoveEmptyEntries);
                string             fireAnim = OwnerCollection.FireNames[R.Next(OwnerCollection.FireNames.Length)];
                IniFile.IniSection fireArt  = OwnerCollection.Art.GetOrCreateSection(fireAnim);

                var fire = new AnimDrawable(Rules, Art, VFS.Open <ShpFile>(fireAnim + ".shp"));
                fire.Props.PaletteOverride = GetFireAnimPalette(fireArt);
                fire.Props.Offset          = new Point(Int32.Parse(coords[0]), Int32.Parse(coords[1]));
                fire.Props.FrameDecider    = FrameDeciders.RandomFrameDecider;
                _fires.Add(fire);
            }
        }
Пример #6
0
 private void LoadAnimDrawable(AnimDrawable anim)
 {
     InitDrawableDefaults(anim);
     anim.LoadFromRules();
     anim.Shp = VFS.Open <ShpFile>(anim.Image + ".shp");
 }
Пример #7
0
 private void LoadAnimDrawable(AnimDrawable anim)
 {
     InitDrawableDefaults(anim);
     anim.LoadFromRules();
     anim.Shp = _vfs.Open <ShpFile>(anim.GetFilename());
 }
Пример #8
0
		private void LoadAnimDrawable(AnimDrawable anim) {
			InitDrawableDefaults(anim);
			anim.LoadFromRules();
			anim.Shp = VFS.Open<ShpFile>(anim.Image + ".shp");
		}
Пример #9
0
		// Adds fire animations to a building. Supports custom-paletted animations.
		private void LoadFireAnimations() {
			// http://modenc.renegadeprojects.com/DamageFireTypes
			int f = 0;
			while (true) { // enumerate as many fires as are existing
				string dfo = Art.ReadString("DamageFireOffset" + f++);
				if (dfo == "")
					break;

				string[] coords = dfo.Split(new[] { ',', '.' }, StringSplitOptions.RemoveEmptyEntries);
				string fireAnim = OwnerCollection.FireNames[Rand.Next(OwnerCollection.FireNames.Length)];
				IniFile.IniSection fireArt = OwnerCollection.Art.GetOrCreateSection(fireAnim);

				var fire = new AnimDrawable(Rules, Art, VFS.Open<ShpFile>(fireAnim + ".shp"));
				fire.Props.PaletteOverride = GetFireAnimPalette(fireArt);
				fire.Props.Offset = new Point(Int32.Parse(coords[0]), Int32.Parse(coords[1]));
				fire.Props.FrameDecider = FrameDeciders.RandomFrameDecider;
				_fires.Add(fire);
			}
		}
Пример #10
0
		private AnimDrawable LoadExtraImage(string extraImage, DrawProperties inheritProps) {
			string animSection = Art.ReadString(extraImage);
			if (animSection == "") return null;

			IniFile.IniSection extraRules = OwnerCollection.Rules.GetOrCreateSection(animSection);
			IniFile.IniSection extraArt = OwnerCollection.Art.GetOrCreateSection(animSection);
			var anim = new AnimDrawable(extraRules, extraArt);
			anim.OwnerCollection = OwnerCollection;
			anim.LoadFromRules();

			anim.NewTheater = this.NewTheater;

			if (extraArt.HasKey("YSortAdjust") || Art.HasKey(extraImage + "YSort") ||
				extraArt.HasKey("ZAdjust") || Art.HasKey(extraImage + "ZAdjust"))
				anim.Props.SortIndex = extraArt.ReadInt("YSortAdjust", Art.ReadInt(extraImage + "YSort"))
					- extraArt.ReadInt("ZAdjust", Art.ReadInt(extraImage + "ZAdjust"));
			else
				anim.Props.SortIndex = inheritProps.SortIndex;
			if (Art.HasKey(extraImage + "X") || Art.HasKey(extraImage + "Y"))
				anim.Props.Offset = this.Props.Offset + new Size(Art.ReadInt(extraImage + "X"), Art.ReadInt(extraImage + "Y"));
			else
				anim.Props.Offset = inheritProps.Offset;
			anim.Props.ZAdjust = Art.ReadInt(extraImage + "ZAdjust");
			anim.IsBuildingPart = true;

			anim.Shp = VFS.Open<ShpFile>(anim.GetFilename());
			return anim;
		}