public static void AddPixelMask(string name, PixelMask pixelMask) { if (PIXEL_MASKS.ContainsKey(name)) { throw new Exception("PixelMask with name '" + name + "' already exists!"); } PIXEL_MASKS[name] = pixelMask; }
public PixelMaskSet(Tileset tileset) { masks = new PixelMask[tileset.TileCount]; for (var i = 0; i < tileset.TileCount; i++) { var region = tileset.GetTileRegion(i); masks[i] = new PixelMask(region); } }
private HitInfo(bool hit, Entity other, Tile tile, PixelMask pixelMask) { Hit = hit; Other = other; Tile = tile; PixelMask = pixelMask; DeltaX = 0; DeltaY = 0; Stopped = false; }
public void SetPixelMaskAt(int x, int y, PixelMask pixelMask, Dictionary <string, string> properties = null) { grid[y * Width + x] = new Tile(x, y, pixelMask, properties); }
public Tile(int x, int y, PixelMask pixelMask, Dictionary <string, string> properties = null) : this(x, y, TileSolidType.PixelMask, properties) { PixelMask = pixelMask; }
private bool CollidePixelMaskToPixelMask(float x, float y, float otherX, float otherY, PixelMask otherMask) { var otherOffsetX = (int)(otherX - x); var startX = otherOffsetX; if (startX < 0) { startX = 0; } var otherOffsetY = (int)(otherY - y); var startY = otherOffsetY; if (startY < 0) { startY = 0; } var endX = (int)(otherX + otherMask.WidthPx - x); if (endX > WidthPx) { endX = WidthPx; } var endY = (int)(otherY + otherMask.HeightPx - y); if (endY > HeightPx) { endY = HeightPx; } //Log.Debug("startX=" + startX + " startY=" + startY + " endX=" + endX + " endY=" + endY); for (var ix = startX; ix < endX; ix++) { for (var iy = startY; iy < endY; iy++) { if (mask[ix, iy] && otherMask.mask[ix - otherOffsetX, iy - otherOffsetY]) { return(true); } } } return(false); }
public static HitInfo CreateHit(Tile tile, PixelMask pixelMask = null) { return(new HitInfo(true, null, tile, pixelMask)); }
public static HitInfo CreateHit(Entity other = null, Tile tile = null, PixelMask pixelMask = null) { return(new HitInfo(true, other, tile, pixelMask)); }