public ClickMenu(Town town, Location location, Tile tile, Entity entity) { this.town = town; this.location = location; this.tile = tile; this.entity = entity; InitializeComponent(); }
public Tile getTileAt(Location loc) { foreach(Tile tile in tiles) { if(tile.getLocation() == loc) { return tile; } } return null; }
public Entity getEntityAt(Location loc) { foreach (Entity entity in entities) { if (entity.location == loc) { return entity; } } return null; }
public void handleClick(Point point) { Location location = new Location(point.X, point.Y); Location loc = town.getLocationOnGrid(location); while (true) { Tile tile = town.getTileAt(loc); Entity entity = town.getEntityAt(loc); ClickMenu menu = new ClickMenu(town, loc, tile, entity); menu.Location = board.PointToScreen(point); if (Screen.AllScreens[1].Bounds.Right < menu.Location.X + menu.Width) { menu.Location = new Point(menu.Location.X - menu.Width, menu.Location.Y); } if (Screen.AllScreens[1].Bounds.Bottom < menu.Location.Y + menu.Height) { menu.Location = new Point(menu.Location.X, menu.Location.Y - menu.Height); } menu.ShowDialog(); if(menu.DialogResult == DialogResult.Cancel){ break; } } }
public Location getLocationOnGrid(Location location) { return new Location(location.x / gridSize * gridSize, location.y / gridSize * gridSize); }
public Tile(Location location, TileType type) { this.location = location; this.type = type; }