Esempio n. 1
0
    /// <summary>
    ///     Search and link sorrounding tiles as neighbours.
    /// </summary>
    private void CreateGrid()
    {
        for (int y = 0; y < gridHeigh; y++)
        {
            for (int x = 0; x < gridWidth; x++)
            {
                Tile    hex          = _tileFactory.CreateRandomTile();
                Vector2 gridPosition = new Vector2(x, y);
                hex.transform.position = CalculateWorldPosition(gridPosition);
                hex.transform.parent   = this.transform;
                hex.X    = x;
                hex.Y    = y;
                hex.name = hex.name + "Hexagon" + x + "|" + y;

                tiles[x, y] = hex;
                SetNeighbours(hex);
            }
        }
    }