public void SetTileID(int tileID) { m_TileID = tileID; if (m_tileSetRef != null) { SetSourceRectangle(MapHandler.GetInstance().GetSourceRectByID(GetTileID(), m_tileSetRef.Width, m_tileSetRef.Height, (int)GetTileSize().X, (int)GetTileSize().Y)); } }
public List <Vector2> GetAdjacentsToTile(Vector2 tilePosition) { List <Vector2> adjacents = new List <Vector2>(); int x = (int)(tilePosition.X); int y = (int)(tilePosition.Y); for (int i = -1; i < 2; i++) { for (int j = -1; j < 2; j++) { if (j == 0 && i == 0) { continue; } if ((i == 1 || i == -1) && j == 0) { continue; } if (tilePosition.Y % 2 == 1) { if (i < 0) { continue; } } else { if (i > 0) { continue; } } /* * if (((int)tilePosition.Y) % 2 == 0) * { * if ((j == 1 || j == -1) && i == 0) * continue; * } */ Vector2 temp = Vector2.Add(new Vector2(i, j), tilePosition); if (temp.X < 0) { continue; } if (temp.Y < 0) { continue; } if (temp.X >= m_mlActiveLayer.GetMapSize().X) { continue; } if (temp.X >= m_mlActiveLayer.GetMapSize().Y) { continue; } if (MapHandler.GetInstance().IsTileSolid(temp)) { continue; } adjacents.Add(temp); } } return(adjacents); }