/// <summary> /// Adds a MapGrh to the map /// </summary> /// <param name="mg">MapGrh to add to the map</param> public void AddMapGrh(MapGrh mg) { if (mg == null) { const string errmsg = "Parameter mg is null."; if (log.IsErrorEnabled) { log.Error(errmsg); } Debug.Fail(errmsg); return; } // When in debug mode, ensure there are no duplicates Debug.Assert(!Spatial.CollectionContains(mg), string.Format("MapGrh `{0}` is already in the spatial collection.", mg)); // Add to the spatial Spatial.Add(mg); }
private static void LoadMapProcessGroundTiles(int x, int y, Tile tile) { // Compute block position var position = new Vector(x, y) * (Vector)Map.TileSize; position.Y += Map.TileSize.Height - tile.Image.Height; // weird tiled offset thing var bounds = new Rectangle(position, Map.TileSize); var isOneWay = false; // Is this tile a industrial tile? if (tile.TileSet == Assets.GetTileSet("industrial")) { // One way thick if (tile.Id == 65 || tile.Id == 63 || tile.Id == 48 || tile.Id == 49 || tile.Id == 50) { bounds.Height = 30; isOneWay = true; } // One way thin if (tile.Id == 64 || tile.Id == 62 || tile.Id == 34 || tile.Id == 35 || tile.Id == 36) { bounds.Height = 20; isOneWay = true; } } // Generate block var block = AddEntity(new Block(bounds, isOneWay)); Spatial.Add(block, block.Bounds); }
private static void LoadMapProcessPipesTiles(int x, int y, Tile tile) { // Is this a pipes tile? if (tile.TileSet == Assets.GetTileSet("pipes")) { // Offsets for pipe openings var offset1 = new Vector(); var offset2 = new Vector(); var bounds = new Rectangle(Vector.Zero, Map.TileSize); // == Straight Pipes var VP = tile.Id == 88 || tile.Id == 100; var VG = tile.Id == 106; // vertical gold var HP = tile.Id == 89 || tile.Id == 101; var HG = tile.Id == 107; // horizontal gold // Vertical pipe if (VP || VG) { offset1.Set(0, -1); offset2.Set(0, +2); // vertical pipes are 1x2 bounds.Size = (Size)((Vector)bounds.Size * (1, 2)); } // Horizontal pipe if (HP || HG) { offset1.Set(-1, 0); offset2.Set(+2, 0); // vertical pipes are 1x2 bounds.Size = (Size)((Vector)bounds.Size * (2, 1)); } // Is this a gold (input/output) pipe? var isGoldPipe = HG || VG; var isGreyPipe = !isGoldPipe && (tile.Id > 99); // THIS IS BAD BUT FUNCTIONAL // == Corner Pipes var TR = tile.Id == 90 || tile.Id == 102; var TL = tile.Id == 91 || tile.Id == 103; var BL = tile.Id == 92 || tile.Id == 104; var BR = tile.Id == 93 || tile.Id == 105; if (TR) { // Corner elbow is top-right offset1.Set(-1, 0); offset2.Set(+1, 2); } if (TL) { // Corner elbow is top-left offset1.Set(0, 2); offset2.Set(2, 0); } if (BL) { // Corner elbow is bottom-left offset1.Set(0, -1); offset2.Set(2, +1); } if (BR) { // Corner elbow is bottom-right offset1.Set(-1, +1); offset2.Set(+1, -1); } // Corner pipes are 2x2 if (TR || TL || BL || BR) { bounds.Size *= 2; } // Compute Block Position var position = new Vector(x, y) * (Vector)Map.TileSize; position.Y += Map.TileSize.Height - tile.Image.Height; // weird tiled offset thing // Compute connection points in world space var points = new[] { offset1, offset2 }.Select(s => (35, 35) + (s * 70)); // Generate pipe var pipe = AddEntity(new Pipe(tile.Image, bounds, points, isGreyPipe, isGoldPipe)); pipe.Transform.Position = position; pipe.ComputeWorldSpace(); Spatial.Add(pipe, pipe.Bounds); Pipes.Add(pipe); } }