コード例 #1
0
 public void ReturnTileToPool(HexTile tile)
 {
     hexTilePool.Push(tile.gameObject);
     tile.gameObject.SetActive(false);
 }
コード例 #2
0
        private HexTile NewHexTile(int column, int row)
        {
            Vector3 pos = HexUtils.PositionFromCoordinates(column, row, metrics.tileSize);



            //if ( IsWallAt( column, row ) ) {
            //	hexMesh = MountainHexagon(tileSize, column, row );
            //} else {
            //	hexMesh = Hexagon(tileSize, pos);
            //}

            string     name = string.Format("Tile ({0},{1})", column, row);
            GameObject tile = ObjectFactory.Folder(name, tilesFolder.transform);

            tile.layer = gameObject.layer;
            tile.transform.localPosition = pos;

            HexTile hexTile = tile.AddComponent <HexTile>();

            hexTile.column  = column;
            hexTile.row     = row;
            hexTile.metrics = metrics;
            hexTile.map     = hexMap;

            // Ground Mesh
            {
                Mesh hexMesh;
                hexMesh = meshBuilder.ElevatedTileHexagon(metrics, hexMap, column, row);
                GameObject groundMesh = NewMeshedObject("Ground Mesh", tile.transform, hexMesh, material);
                groundMesh.layer = gameObject.layer;
                hexTile.reusableMeshes.Add(hexMesh);
                groundMesh.transform.localPosition = Vector3.zero;
                //var onlyExists = groundMesh.AddComponent<ExistsOnlyWhenInSight>();
            }

            //// Ground Mesh
            //{
            //	Mesh hexMesh;
            //	hexMesh = meshBuilder.WallsHexagon(metrics, hexMap, column, row);
            //	GameObject groundMesh = NewMeshedObject("Legacy Mesh", tile.transform, hexMesh, material);
            //	groundMesh.layer = gameObject.layer;
            //	hexTile.reusableMeshes.Add(hexMesh);
            //	groundMesh.transform.localPosition = Vector3.zero;
            //	//var onlyExists = groundMesh.AddComponent<ExistsOnlyWhenInSight>();
            //}

            //// Wall Meshes
            //foreach (var corner in HexCornerUtils.AllCorners() ) {
            //	Mesh wallMesh;
            //	wallMesh = meshBuilder.WallMesh(metrics, hexMap, column, row, corner);
            //	GameObject wallMeshObject = NewMeshedObject("Wall Mesh " + corner.ToString(),
            //		tile.transform, wallMesh, wallMaterial);
            //	wallMeshObject.layer = gameObject.layer;
            //	hexTile.reusableMeshes.Add(wallMesh);
            //	wallMeshObject.transform.localPosition = Vector3.zero;
            //}


            //hexTile.staticObstacles.AddRange(obstacles);

            //hexTile.BuildNavMesh();

            return(hexTile);
        }