상속: NumberedObject
예제 #1
0
		public static OverlayTibType GetOverlayTibType(OverlayObject o, EngineType engine) {
			if (engine <= EngineType.Firestorm) {
				if (IsTS_Riparius(o)) return OverlayTibType.Riparius;
				else if (IsTS_Cruentus(o)) return OverlayTibType.Cruentus;
				else if (IsTS_Vinifera(o)) return OverlayTibType.Vinifera;
				else if (IsTS_Aboreus(o)) return OverlayTibType.Aboreus;
			}
			else {
				if (IsRA2_Riparius(o)) return OverlayTibType.Riparius;
				else if (IsRA2_Cruentus(o)) return OverlayTibType.Cruentus;
				else if (IsRA2_Vinifera(o)) return OverlayTibType.Vinifera;
				else if (IsRA2_Aboreus(o)) return OverlayTibType.Aboreus;
			}
			return OverlayTibType.NotSpecial;
		}
예제 #2
0
		internal static string GetTibName(OverlayObject o, EngineType engine) {
			if (engine <= EngineType.Firestorm) {
				if (IsTS_Riparius(o)) return "Riparius";
				else if (IsTS_Cruentus(o)) return "Cruentus";
				else if (IsTS_Vinifera(o)) return "Vinifera";
				else if (IsTS_Aboreus(o)) return "Aboreus";
			}
			else {
				if (IsRA2_Riparius(o)) return "Riparius";
				else if (IsRA2_Cruentus(o)) return "Cruentus";
				else if (IsRA2_Vinifera(o)) return "Vinifera";
				else if (IsRA2_Aboreus(o)) return "Aboreus";
			}
			return "";
		}
예제 #3
0
		private void LoadOverlayDrawable(ShpDrawable drawable) {
			var ovl = new OverlayObject((byte)drawable.Index, 0);
			var tibType = SpecialOverlays.GetOverlayTibType(ovl, Engine);
			DrawProperties props = drawable.Props;

			if (Engine >= EngineType.RedAlert2) {
				if (tibType != OverlayTibType.NotSpecial) {
					props.FrameDecider = FrameDeciders.OverlayValueFrameDecider;
					props.PaletteType = PaletteType.Overlay;
					props.LightingType = LightingType.None;
				}
				else if (SpecialOverlays.IsHighBridge(ovl)) {
					props.OffsetHack = OffsetHacks.RA2BridgeOffsets;
					props.ShadowOffsetHack = OffsetHacks.RA2BridgeShadowOffsets;
					drawable.TileElevation = 4; // for lighting
					drawable.Foundation = new Size(3, 1); // ensures they're drawn later --> fixes overlap
				}
			}
			else if (Engine <= EngineType.Firestorm) {
				if (tibType != OverlayTibType.NotSpecial) {
					props.FrameDecider = FrameDeciders.OverlayValueFrameDecider;
					props.PaletteType = PaletteType.Unit;
					props.LightingType = LightingType.None;
					drawable.IsRemapable = true;
				}
				else if (SpecialOverlays.IsHighBridge(ovl) || SpecialOverlays.IsTSHighRailsBridge(ovl)) {
					props.OffsetHack = OffsetHacks.TSBridgeOffsets;
					props.ShadowOffsetHack = OffsetHacks.TSBridgeShadowOffsets;
					drawable.TileElevation = 4; // for lighting
					//drawable.Foundation = new Size(3, 1); // ensures they're drawn later --> fixes overlap
				}
			}
		}
예제 #4
0
파일: Map.cs 프로젝트: dkeetonx/ccmaps-net
		/// <summary>Reads all objects. </summary>
		private void LoadAllObjects(MapFile mf) {

			// import tiles
			foreach (var iso in mf.Tiles)
				_tiles[iso.Dx, iso.Dy / 2] = new MapTile(iso.Dx, iso.Dy, iso.Rx, iso.Ry, iso.Z, iso.TileNum, iso.SubTile, _tiles);

			// import terrain
			foreach (var terr in mf.Terrains) {
				var t = new TerrainObject(terr.Name);
				_terrainObjects.Add(t);
				_tiles.GetTile(terr.Tile).AddObject(t);
			}

			// import smudges
			foreach (var sm in mf.Smudges) {
				var s = new SmudgeObject(sm.Name);
				_tiles.GetTile(sm.Tile).AddObject(s);
				_smudgeObjects.Add(s);
			}

			// import overlays
			foreach (var o in mf.Overlays) {
				var ovl = new OverlayObject(o.OverlayID, o.OverlayValue);
				_tiles.GetTile(o.Tile).AddObject(ovl);
				_overlayObjects.Add(ovl);
			}

			// import infantry
			foreach (var i in mf.Infantries) {
				var inf = new InfantryObject(i.Owner, i.Name, i.Health, i.Direction, i.OnBridge);
				_tiles.GetTile(i.Tile).AddObject(inf);
				_infantryObjects.Add(inf);
			}

			foreach (var u in mf.Units) {
				var un = new UnitObject(u.Owner, u.Name, u.Health, u.Direction, u.OnBridge);
				_tiles.GetTile(u.Tile).AddObject(un);
				_unitObjects.Add(un);
			}

			foreach (var a in mf.Aircrafts) {
				var ac = new AircraftObject(a.Owner, a.Name, a.Health, a.Direction, a.OnBridge);
				_tiles.GetTile(a.Tile).AddObject(ac);
				_aircraftObjects.Add(ac);
			}

			foreach (var s in mf.Structures) {
				var str = new StructureObject(s.Owner, s.Name, s.Health, s.Direction);
				str.Upgrade1 = s.Upgrade1;
				str.Upgrade2 = s.Upgrade2;
				str.Upgrade3 = s.Upgrade3;
				_tiles.GetTile(s.Tile).AddObject(str);
				_structureObjects.Add(str);
			}
		}
예제 #5
0
 public static bool IsVeins(OverlayObject o)
 {
     return(o != null && o.Drawable.IsVeins);
 }
예제 #6
0
		private static bool IsRA2_Cruentus(OverlayObject o) {
			return o.OverlayID >= Ra2MinIdCruentus && o.OverlayID <= Ra2MaxIdCruentus;
		}
예제 #7
0
		private static bool IsTS_Aboreus(OverlayObject o) {
			return o.OverlayID >= TsMinIdAboreus && o.OverlayID <= TsMaxIdAboreus;
		}
예제 #8
0
		public static void RecalculateVeinsSpread(IEnumerable<OverlayObject> ovls, TileLayer tiles) {
			OverlayObject anyVeins = null;

			foreach (var o in ovls) {
				if (IsVeins(o) && !o.Drawable.IsVeinHoleMonster && o.OverlayValue / 3 == 15)
					o.IsGeneratedVeins = true;
			}

			foreach (var t in tiles) {
				var o = t.AllObjects.OfType<OverlayObject>().FirstOrDefault();

				int veins = 0, rnd = 0, mul = 1;
				bool amIVeins = IsVeins(o);

				if (amIVeins && !o.Drawable.IsVeinHoleMonster) {
					// see if veins are positioned on ramp
					anyVeins = o;
					var tmpImg = (o.Tile.Drawable as TileDrawable).GetTileImage(o.Tile);
					if (tmpImg != null && tmpImg.RampType != 0) {
						if (tmpImg.RampType == 7) veins = 51;
						else if (tmpImg.RampType == 2) veins = 55;
						else if (tmpImg.RampType == 3) veins = 57;
						else if (tmpImg.RampType == 4) veins = 59;
						else {
							continue;
						}
						rnd = 2;
						mul = 1;
					}
					else {
						var ne = t.Layer.GetNeighbourTile(t, TileLayer.TileDirection.TopRight);
						var se = t.Layer.GetNeighbourTile(t, TileLayer.TileDirection.BottomRight);
						var sw = t.Layer.GetNeighbourTile(t, TileLayer.TileDirection.BottomLeft);
						var nw = t.Layer.GetNeighbourTile(t, TileLayer.TileDirection.TopLeft);

						bool neV = ne != null && ne.AllObjects.OfType<OverlayObject>().Any(IsVeins);
						bool seV = se != null && se.AllObjects.OfType<OverlayObject>().Any(IsVeins);
						bool swV = sw != null && sw.AllObjects.OfType<OverlayObject>().Any(IsVeins);
						bool nwV = nw != null && nw.AllObjects.OfType<OverlayObject>().Any(IsVeins);

						int numNeighbours = CountNeighbouringVeins(ne, se, sw, nw, IsVeins);
						int threshold = numNeighbours != 4 ? 4 : 0;
						var compare = numNeighbours == 4 ? (Func<OverlayObject, bool>)IsFullVeins : IsVeins;
						Func<OverlayObject, bool> thresholdCompare = ov => threshold <= CountNeighbouringVeins(ov.Tile, compare);

						if (neV && ne.AllObjects.OfType<OverlayObject>().Any(thresholdCompare))
							veins += 1;

						if (seV && se.AllObjects.OfType<OverlayObject>().Any(thresholdCompare))
							veins += 2;

						if (swV && sw.AllObjects.OfType<OverlayObject>().Any(thresholdCompare))
							veins += 4;

						if (nwV && nw.AllObjects.OfType<OverlayObject>().Any(thresholdCompare))
							veins += 8;

						if (veins == 15 && !o.IsGeneratedVeins)
							veins++;

						mul = 3;
						rnd = 3;
					}
				}

				if (veins != 0 || amIVeins) {
					if (o == null) {
						// on the fly veins creation..
						o = new OverlayObject(anyVeins.OverlayID, (byte)Rand.Next(3));
						o.IsGeneratedVeins = true;
						o.Drawable = anyVeins.Drawable;
						o.Palette = anyVeins.Palette;
						o.TopTile = o.BottomTile = o.Tile;
						t.AddObject(o);
					}
					else {
						o.OverlayValue = (byte)(veins * mul + Rand.Next(rnd));
						Debug.WriteLine("Replacing veins with value {0} ({1})", o.OverlayValue, veins);
					}
				}


			}
		}
예제 #9
0
		private static bool IsTS_Cruentus(OverlayObject o) {
			return o.OverlayID >= TsMinIdCruentus && o.OverlayID <= TsMaxIdCruentus;
		}
예제 #10
0
		private static bool IsTS_Vinifera(OverlayObject o) {
			return o.OverlayID >= TsMinIdVinifera && o.OverlayID <= TsMaxIdVinifera;
		}
예제 #11
0
		private static bool IsTS_Riparius(OverlayObject o) {
			return o.OverlayID >= TsMinIdRiparius && o.OverlayID <= TsMaxIdRiparius;
		}
예제 #12
0
		private static bool IsRA2_Aboreus(OverlayObject o) {
			return o.OverlayID >= Ra2MinIdAboreus && o.OverlayID <= Ra2MaxIdAboreus;
		}
예제 #13
0
		private static bool IsRA2_Vinifera(OverlayObject o) {
			return o.OverlayID >= Ra2MinIdVinifera && o.OverlayID <= Ra2MaxIdVinifera;
		}
예제 #14
0
		public static bool IsVeins(OverlayObject o) {
			return o != null && o.Drawable.IsVeins;
		}
예제 #15
0
		private static bool IsTib(OverlayObject o) {
			return IsTS_Riparius(o) || IsTS_Cruentus(o) || IsTS_Vinifera(o) || IsTS_Aboreus(o);
		}
예제 #16
0
		public static bool IsFullVeins(OverlayObject o) {
			return o != null && !o.IsGeneratedVeins && o.Drawable.IsVeins && (o.Drawable.IsVeinHoleMonster || o.OverlayValue / 3 == 16);
		}
예제 #17
0
		public static bool IsHighBridge(OverlayObject o) {
			return o.OverlayID == 24 || o.OverlayID == 25 || o.OverlayID == 238 || o.OverlayID == 237;
		}
예제 #18
0
        public static void RecalculateVeinsSpread(IEnumerable <OverlayObject> ovls, TileLayer tiles)
        {
            OverlayObject anyVeins = null;

            foreach (var o in ovls)
            {
                if (IsVeins(o) && !o.Drawable.IsVeinHoleMonster && o.OverlayValue / 3 == 15)
                {
                    o.IsGeneratedVeins = true;
                }
            }

            foreach (var t in tiles)
            {
                var o = t.AllObjects.OfType <OverlayObject>().FirstOrDefault();

                int  veins = 0, rnd = 0, mul = 1;
                bool amIVeins = IsVeins(o);

                if (amIVeins && !o.Drawable.IsVeinHoleMonster)
                {
                    // see if veins are positioned on ramp
                    anyVeins = o;
                    var tmpImg = (o.Tile.Drawable as TileDrawable).GetTileImage(o.Tile);
                    if (tmpImg != null && tmpImg.RampType != 0)
                    {
                        if (tmpImg.RampType == 7)
                        {
                            veins = 51;
                        }
                        else if (tmpImg.RampType == 2)
                        {
                            veins = 55;
                        }
                        else if (tmpImg.RampType == 3)
                        {
                            veins = 57;
                        }
                        else if (tmpImg.RampType == 4)
                        {
                            veins = 59;
                        }
                        else
                        {
                            continue;
                        }
                        rnd = 2;
                        mul = 1;
                    }
                    else
                    {
                        var ne = t.Layer.GetNeighbourTile(t, TileLayer.TileDirection.TopRight);
                        var se = t.Layer.GetNeighbourTile(t, TileLayer.TileDirection.BottomRight);
                        var sw = t.Layer.GetNeighbourTile(t, TileLayer.TileDirection.BottomLeft);
                        var nw = t.Layer.GetNeighbourTile(t, TileLayer.TileDirection.TopLeft);

                        bool neV = ne != null && ne.AllObjects.OfType <OverlayObject>().Any(IsVeins);
                        bool seV = se != null && se.AllObjects.OfType <OverlayObject>().Any(IsVeins);
                        bool swV = sw != null && sw.AllObjects.OfType <OverlayObject>().Any(IsVeins);
                        bool nwV = nw != null && nw.AllObjects.OfType <OverlayObject>().Any(IsVeins);

                        int numNeighbours = CountNeighbouringVeins(ne, se, sw, nw, IsVeins);
                        int threshold     = numNeighbours != 4 ? 4 : 0;
                        var compare       = numNeighbours == 4 ? (Func <OverlayObject, bool>)IsFullVeins : IsVeins;
                        Func <OverlayObject, bool> thresholdCompare = ov => threshold <= CountNeighbouringVeins(ov.Tile, compare);

                        if (neV && ne.AllObjects.OfType <OverlayObject>().Any(thresholdCompare))
                        {
                            veins += 1;
                        }

                        if (seV && se.AllObjects.OfType <OverlayObject>().Any(thresholdCompare))
                        {
                            veins += 2;
                        }

                        if (swV && sw.AllObjects.OfType <OverlayObject>().Any(thresholdCompare))
                        {
                            veins += 4;
                        }

                        if (nwV && nw.AllObjects.OfType <OverlayObject>().Any(thresholdCompare))
                        {
                            veins += 8;
                        }

                        if (veins == 15 && !o.IsGeneratedVeins)
                        {
                            veins++;
                        }

                        mul = 3;
                        rnd = 3;
                    }
                }

                if (veins != 0 || amIVeins)
                {
                    if (o == null)
                    {
                        // on the fly veins creation..
                        o = new OverlayObject(anyVeins.OverlayID, (byte)Rand.Next(3));
                        o.IsGeneratedVeins = true;
                        o.Drawable         = anyVeins.Drawable;
                        o.Palette          = anyVeins.Palette;
                        o.TopTile          = o.BottomTile = o.Tile;
                        t.AddObject(o);
                    }
                    else
                    {
                        o.OverlayValue = (byte)(veins * mul + Rand.Next(rnd));
                        Debug.WriteLine("Replacing veins with value {0} ({1})", o.OverlayValue, veins);
                    }
                }
            }
        }
예제 #19
0
		public static bool IsTSHighRailsBridge(OverlayObject o) {
			return o.OverlayID == 59 || o.OverlayID == 60;
		}
예제 #20
0
 public static bool IsFullVeins(OverlayObject o)
 {
     return(o != null && !o.IsGeneratedVeins && o.Drawable.IsVeins && (o.Drawable.IsVeinHoleMonster || o.OverlayValue / 3 == 16));
 }
예제 #21
0
		private static bool IsRA2_Riparius(OverlayObject o) {
			return o.OverlayID >= Ra2MinIdRiparius && o.OverlayID <= Ra2MaxIdRiparius;
		}