Esempio n. 1
0
        void Start()
        {
            var mapSize = HexTileMetrics.GetMapSzie(tilemapBackground);

            hexCellDebugTxtCanvas.BuildHexPosTxt(mapSize.x, mapSize.y);
            marginMeshTilemap.enabled = false;
        }
Esempio n. 2
0
        /// <summary>
        /// 从当前的Tielmap中重新初始化HexGrid
        /// </summary>
        public void ReIntiHexGrid()
        {
            Vector2Int mapSize = HexTileMetrics.GetMapSzie(tilemapBackground);

            HexCell[,] cells = new HexCell[mapSize.x, mapSize.y];
            m_HexGrid        = new HexGrid(
                hexCells: cells,
                gameAssetData: GameDataCentre,
                terrainThroughCostDict: GameDataCentre.TerrainThroughCostDict,
                hexTileMap: HexTileMap);

            for (int x = 0; x < mapSize.x; x++)
            {
                for (int y = 0; y < mapSize.y; y++)
                {
                    string     assetName;
                    Vector2Int callPosition = new Vector2Int(x, y);
                    try { assetName = tilemapBackground.GetTile(callPosition.ToVector3Int()).name; }
                    catch (NullReferenceException) { assetName = "Void00"; }
                    cells[x, y] = new HexCell(m_HexGrid, assetName, callPosition, HexGrid.CalculateNeighbor(callPosition));
                }
            }
            RoleManager.hexGrid = m_HexGrid;
        }