// private Sprite _sprite; public HexTile(HexPoint point, Vector3 position, Color color, TileHeight height) { _point = point; _position = position; _color = color; Height = height; _unit = null; _resource = null; // BoardManager.Instance.UpdateReachablePoints(this); }
public void LoadJsonTileList(List <HexTileJson> jsonList) { _tiles.Initialize(); for (int i = 0; i < jsonList.Count; i++) { HexPoint point = new HexPoint(jsonList[i].hexPoint.x, jsonList[i].hexPoint.y, jsonList[i].hexPoint.z); Vector3 position = new Vector3(jsonList[i].point.x, jsonList[i].point.y, jsonList[i].point.z); Color color = new Color(jsonList[i].color.r, jsonList[i].color.g, jsonList[i].color.b); HexTile.TileHeight height = jsonList[i].height.height; _tiles.CreateTile(point, position, color, height); } _tiles.Triangulate(); }
public void Add(int y, HexPoint point, HexTile tile) { _tilesDict.Add(point, tile); if (_tilesList.Count <= y) { int tileCount = _tilesList.Count; for (int i = 0; i <= y - tileCount; i++) { _tilesList.Add(new List <HexTile>()); } } _tilesList[y].Add(tile); }
private void CreateTile(int x, int y) { Vector3 position; position.x = (x + (y & 1) / 2f) * (BoardUtils.innerRadius * 2f); position.y = y * BoardUtils.outerRadius * 1.5f; position.z = 0f; HexPoint point = HexPoint.FromOffsetPoint(x, y); HexTile.TileHeight height = (Random.Range(0, 2) & 1) == 0 ? HexTile.TileHeight.DEFAULT : HexTile.TileHeight.LOW; Color color = BoardUtils.colors[Random.Range(0, BoardUtils.colors.Length)]; HexTile tile = new HexTile(point, position, color, height); Add(y, point, tile); }
public bool ContainsPoint(HexPoint hexPoint) { return(_tiles.ContainsKey(hexPoint)); }
public HexTile GetTile(HexPoint point) { return(_tiles.Get(point)); }
public bool ContainsKey(HexPoint point) { return(_tilesDict.ContainsKey(point)); }
public void CreateTile(HexPoint point, Vector3 position, Color color, HexTile.TileHeight height) { HexTile tile = new HexTile(point, position, color, height); Add(point.Z, point, tile); }