public bool FindTileInMask(Mask m, bool pngTileOnly, ref TileXY txy) { foreach (KeyValuePair <TileXY, TileMeta> pair in tiles) { if (!m.ContainsTile(pair.Key)) { continue; } if (!pngTileOnly || pair.Value.hasAlpha) { txy = pair.Key; while (true) { bool hasParent = false; TileXY[] parents = txy.GetParent().GetSiblings(); for (int i = 0; i < 4; i++) { if (m.ContainsTile(parents[i]) && tiles.ContainsKey(parents[i]) && (!pngTileOnly || tiles[parents[i]].hasAlpha)) { txy = parents[i]; hasParent = true; break; } } if (!hasParent || txy.level == 0) { break; } } return(true); } } return(false); }
public void MoveTo(int offsetx, int offsety, bool isZoomOut, bool isZoomIn) { // get target location TileXY targetXY = centerTilexy; if (isZoomOut) { targetXY = centerTilexy.GetParent(); } else if (isZoomIn) { TileXY[] sons = centerTilexy.GetSon().GetSiblings(); foreach (TileXY txy in sons) { targetXY = txy; if (tiles.ContainsKey(targetXY)) { break; } } } else { targetXY = centerTilexy.GetNeighbor(offsetx, offsety); } // move the center and paint centerTilexy = targetXY; Paint(); }