public DebugDrawingSurfaceWindow(DrawingSurface ds, TileLayer tiles, Theater t, Map map) : this() { _drawingSurface = ds; _tiles = tiles; _theater = t; _map = map; ds.Unlock(); pictureBox1.Image = ds.Bitmap; }
public bool Initialize(MapFile mf, EngineType et) { if (et == EngineType.AutoDetect) { Logger.Fatal("Engine type needs to be known by now!"); return(false); } Engine = et; TheaterType = Theater.TheaterTypeFromString(mf.ReadString("Map", "Theater")); FullSize = mf.FullSize; LocalSize = mf.LocalSize; _tiles = new TileLayer(FullSize.Size); LoadAllObjects(mf); if (!IgnoreLighting) { _lighting = mf.Lighting; } else { _lighting = new Lighting { Level = 0.0 } }; _wayPoints.AddRange(mf.Waypoints); if (!LoadInis()) { Logger.Fatal("Ini files couldn't be loaded"); return(false); } Logger.Info("Overriding rules.ini with map INI entries"); _rules.MergeWith(mf); return(true); }
public MapTile(ushort dx, ushort dy, ushort rx, ushort ry, short rz, short tilenum, ushort subtile, TileLayer layer, short setnum = 0) { Dx = dx; Dy = dy; Rx = rx; Ry = ry; Z = rz; TileNum = tilenum; SetNum = setnum; SubTile = subtile; Layer = layer; }
/// <summary>Recalculates tile system. </summary> public static void FixTiles(TileLayer tiles, TileCollection collection) { Logger.Info("Recalculating tile LAT system"); // change all CLAT tiles to their corresponding LAT tiles foreach (MapTile t in tiles) { // If this tile comes from a CLAT (connecting lat) set, // then replace it's set and tilenr by corresponding LAT sets' t.SetNum = collection.GetSetNum(t.TileNum); if (collection.IsCLAT(t.SetNum)) { t.SetNum = collection.GetLAT(t.SetNum); t.TileNum = collection.GetTileNumFromSet(t.SetNum); } } // apply autolat foreach (MapTile t in tiles) { // If this tile is a LAT tile, we might have to connect it if (collection.IsLAT(t.SetNum)) { // Which tile to use from CLAT tileset byte transitionTile = 0; MapTile tileTopRight = tiles.GetNeighbourTile(t, TileLayer.TileDirection.TopRight); MapTile tileBottomRight = tiles.GetNeighbourTile(t, TileLayer.TileDirection.BottomRight); MapTile tileBottomLeft = tiles.GetNeighbourTile(t, TileLayer.TileDirection.BottomLeft); MapTile tileTopLeft = tiles.GetNeighbourTile(t, TileLayer.TileDirection.TopLeft); // Find out setnums of adjacent cells if (tileTopRight != null && collection.ConnectTiles(t.SetNum, tileTopRight.SetNum)) { transitionTile += 1; } if (tileBottomRight != null && collection.ConnectTiles(t.SetNum, tileBottomRight.SetNum)) { transitionTile += 2; } if (tileBottomLeft != null && collection.ConnectTiles(t.SetNum, tileBottomLeft.SetNum)) { transitionTile += 4; } if (tileTopLeft != null && collection.ConnectTiles(t.SetNum, tileTopLeft.SetNum)) { transitionTile += 8; } if (transitionTile > 0) { // Find Tileset that contains the connecting pieces short clatSet = collection.GetCLATSet(t.SetNum); // Do not change this setnum, as then we could recognize it as // a different tileset for later tiles around this one. // (T->SetNum = clatSet;) t.TileNum = collection.GetTileNumFromSet(clatSet, transitionTile); t.Drawable = collection.GetDrawable(t); } } // apply ramp fixup else if (t.SetNum == collection.RampBase) { var ti = t.GetTileImage(); if (ti.RampType < 1 || 4 < ti.TerrainType) { continue; } int fixup = -1; MapTile tileTopRight = tiles.GetNeighbourTile(t, TileLayer.TileDirection.TopRight); MapTile tileBottomRight = tiles.GetNeighbourTile(t, TileLayer.TileDirection.BottomRight); MapTile tileBottomLeft = tiles.GetNeighbourTile(t, TileLayer.TileDirection.BottomLeft); MapTile tileTopLeft = tiles.GetNeighbourTile(t, TileLayer.TileDirection.TopLeft); switch (ti.RampType) { case 1: // northwest facing if (tileTopLeft != null && tileTopLeft.GetTileImage().RampType == 0) { fixup++; } if (tileBottomRight != null && tileBottomRight.GetTileImage().RampType == 0) { fixup += 2; } break; case 2: // northeast facing if (tileTopRight != null && tileTopRight.GetTileImage().RampType == 0) { fixup++; } if (tileBottomLeft != null && tileBottomLeft.GetTileImage().RampType == 0) { fixup += 2; } break; case 3: // southeast facing if (tileBottomRight != null && tileBottomRight.GetTileImage().RampType == 0) { fixup++; } if (tileTopLeft != null && tileTopLeft.GetTileImage().RampType == 0) { fixup += 2; } break; case 4: // southwest facing if (tileBottomLeft != null && tileBottomLeft.GetTileImage().RampType == 0) { fixup++; } if (tileTopRight != null && tileTopRight.GetTileImage().RampType == 0) { fixup += 2; } break; } if (fixup != -1) { t.TileNum = collection.GetTileNumFromSet(collection.RampSmooth, (byte)((ti.RampType - 1) * 3 + fixup)); // update drawable too t.Drawable = collection.GetDrawable(t); } } } }
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); } } } }
public MapTile(ushort dx, ushort dy, ushort rx, ushort ry, short rz, int tilenum, ushort subtile, short icegrowth, TileLayer layer, int setnum = 0) { Dx = dx; Dy = dy; Rx = rx; Ry = ry; Z = rz; TileNum = tilenum; SetNum = setnum; SubTile = subtile; IceGrowth = icegrowth; Layer = layer; }
public ObjectSorter(Theater t, TileLayer map) { _map = map; _t = t; }