private static void FixWaterSurfaceTiles(QuickGameTileMap tileMap, BorderTileSet tileSet) { int surfaceTile = tileSet.GetCell(BorderSide.Left | BorderSide.Right | BorderSide.Bottom); List <ArrayGridPoint <int> > tilesToChange = new List <ArrayGridPoint <int> >(); foreach (var tile in tileMap.Tiles.Cells.PointItems) { if (tile.Value == surfaceTile) { var left = tile.GetAdjacent(Direction.Left); if (left.Value != surfaceTile) { tilesToChange.Add(left); } var right = tile.GetAdjacent(Direction.Right); if (right.Value != surfaceTile) { tilesToChange.Add(right); } } } foreach (var tile in tilesToChange) { tile.Set(surfaceTile); } }
public LadderCollisionDetector(QuickGameTileMap map) { map.Layer.CollidableObjects.Add(this); ladders = map.Tiles.Cells.Points.Select(pt => map.GetTileFromGridPoint(pt)) .OfType <QuickGameTile>() .Where(p => p.IsLadder).ToArray(); }
public static void CheckForBrokenTiles(ITileBreaker breaker, QuickGameTileMap map) { if (breaker.CanBreakTiles) { var tilesHit = map.GetTilesHit(breaker.Position).Where(p => p.IsBreakable).ToArray(); var tileToBreak = tilesHit.OrderBy(p => p.Position.Center.GetAbsoluteDistanceTo(breaker.Position.Center)).FirstOrDefault(); if (tileToBreak != null) { breaker.CanBreakTiles = false; BreakTile(tileToBreak); } } }
public Spike(QuickGameScene scene) { TileMap = scene.TileMap; scene.SolidLayer.CollidableObjects.Add(this); }
public static QuickGameTileMap Create(QuickGameScene scene) { var masterMap = scene.MasterTemplate; var template = masterMap.Extract(scene.ID.MapNumber); CalculateObscuredTiles(template.Cells, template.GrassMap); CalculateObscuredTiles(template.Cells, template.WaterMap); ExtendTileMask(template.GrassMap); ExtendTileMask(template.WaterMap); var solidTiles = new QuickGameTileMap(scene.SolidLayer, template.BrownRockMap.TileSet.Texture, template.Cells.Size); solidTiles.EmptyCell = template.BrownRockMap.TileSet.GetCell(BorderSide.EmptySpace); template.BrownRockMap.Apply(solidTiles); template.LadderMap.Apply(solidTiles, applyEmptyCells: false); var grassTiles = new QuickGameTileMap(scene.SolidLayer, template.GrassMap.TileSet.Texture, template.Cells.Size); template.GrassMap.Apply(grassTiles); var waterTiles = new QuickGameTileMap(scene.WaterLayer, template.BrownRockMap.TileSet.Texture, template.Cells.Size); waterTiles.EmptyCell = solidTiles.EmptyCell; template.WaterMap.Apply(waterTiles, true); FixWaterSurfaceTiles(waterTiles, template.WaterMap.TileSet); scene.WaterLayer.FixedDisplayable = new IDisplayable[] { waterTiles }; scene.SolidLayer.FixedDisplayable = new IDisplayable[] { grassTiles, solidTiles }; List <MovingBlockPiece> movingBlockPieces = new List <MovingBlockPiece>(); List <PathPoint> pathPoints = new List <PathPoint>(); foreach (var point in template.Cells.Points) { if (template.Cells.GetFromPoint(point) == ImageCellType.PlayerStart) { scene.PlayerStart = new Vector2(point.X * 16, point.Y * 16); } else if (template.Cells.GetFromPoint(point) == ImageCellType.Spike) { solidTiles.Tiles.Cells.Set(point, solidTiles.Tiles.Texture.PointToIndex(3, 7)); } else if (template.Cells.GetFromPoint(point) == ImageCellType.Spring) { solidTiles.Tiles.Cells.Set(point, solidTiles.Tiles.Texture.PointToIndex(4, 2)); } else if (template.Cells.GetFromPoint(point) == ImageCellType.BreakableBlock) { solidTiles.Tiles.Cells.Set(point, solidTiles.Tiles.Texture.PointToIndex(1, 7)); } else if (template.Cells.GetFromPoint(point) == ImageCellType.Box) { new Box().SetPosition(point.X * 16, point.Y * 16); } else if (template.Cells.GetFromPoint(point) == ImageCellType.MovingBlock) { movingBlockPieces.Add(new MovingBlockPiece(point, solidTiles.Tiles.Texture.CellSize)); } else if (template.Cells.GetFromPoint(point) == ImageCellType.Path) { pathPoints.Add(new PathPoint((int)point.X * 16, (int)point.Y * 16)); } } MovingBlockFactory.CreateBlocks(scene, movingBlockPieces, pathPoints); var agt = GameTiles.AutoGenTiles(); agt.Apply(solidTiles); return(solidTiles); }
public QuickGameNearbyTileChecker(IMovingWorldObject movingObject, QuickGameTileMap map) : base(movingObject, map) { }