Exemple #1
0
//        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);
        }
Exemple #2
0
        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();
        }
Exemple #3
0
        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);
        }
Exemple #4
0
        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);
        }
Exemple #5
0
 public bool ContainsPoint(HexPoint hexPoint)
 {
     return(_tiles.ContainsKey(hexPoint));
 }
Exemple #6
0
 public HexTile GetTile(HexPoint point)
 {
     return(_tiles.Get(point));
 }
Exemple #7
0
 public bool ContainsKey(HexPoint point)
 {
     return(_tilesDict.ContainsKey(point));
 }
Exemple #8
0
        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);
        }