예제 #1
0
        private void BuildGrid()
        {
            const int width  = 7;
            const int height = 9;

            grid = FlatHexGrid <SpriteCell> .FatRectangle(width, height);

            map = new FlatBrickMap(cellPrefab.Dimensions)
                  .AnchorCellMiddleCenter()
                  .WithWindow(ExampleUtils.ScreenRect)
                  .AlignMiddleCenter(grid)
                  .To3DXY()
            ;

            foreach (FlatHexPoint point in grid)
            {
                SpriteCell cell       = Instantiate(cellPrefab);
                Vector2    worldPoint = map[point];

                cell.transform.parent        = root.transform;
                cell.transform.localScale    = Vector3.one;
                cell.transform.localPosition = worldPoint;

                cell.Color = ExampleUtils.Colors[point.GetColor3_7()];
                cell.name  = point.ToString();

                grid[point] = cell;
            }
        }
예제 #2
0
    private void BuildGrid()
    {
        grid = (FlatHexGrid <CellScript>) FlatHexGrid <CellScript> .FatRectangle((int)gridSize.x, (int)gridSize.y);

        map = new FlatHexMap(CellDimensions)
              .AnchorCellTopLeft()
              .WithWindow(ExampleUtils.ScreenRect)
              .AlignMiddleCenter(grid)
              .To3DXY();

        gridCount = grid.Count();

        foreach (FlatHexPoint point in grid)
        {
            if (Random.value < 0.5f)
            {
                SpawnCell(healthyCellPrefab, point);
            }
        }

        FlatHexPoint cancerSpawnPoint = grid.ToArray <FlatHexPoint> ()[(int)Random.Range(0, grid.ToArray <FlatHexPoint>().Count())];

        if (grid[cancerSpawnPoint] != null)
        {
            Destroy(grid[cancerSpawnPoint].gameObject);
        }
        SpawnCell(cancerCellPrefab, cancerSpawnPoint);
    }