Пример #1
0
    public void Start()
    {
        map = new SimpleLayeredMap <PointyHexPoint>(new PointyHexMap(new Vector2(69, 80) * 5f), 200, 0);

        var shapes = new []
        {
            PointyHexGrid <Block> .BeginShape().Hexagon(6),
            PointyHexGrid <Block> .BeginShape().Hexagon(5),
            PointyHexGrid <Block> .BeginShape().Hexagon(4),
            PointyHexGrid <Block> .BeginShape().Hexagon(3),
            PointyHexGrid <Block> .BeginShape().Hexagon(2),
            PointyHexGrid <Block> .BeginShape().Hexagon(1)
        };

        grid = LayeredGrid <Block, PointyHexPoint> .Make <
            PointyHexShapeInfo <Block>,
            PointyHexGrid <Block>,
            PointyHexPoint, PointyHexPoint, PointyHexOp <Block> >(shapes);

        foreach (LayeredPoint <PointyHexPoint> point in grid)
        {
            var cell = Instantiate(cellPrefab);

            cell.transform.parent        = transform;
            cell.transform.localPosition = map[point];

            var color = ExampleUtils.Colors[(point.Point.GetColor1_3()) + 4];
            cell.GetComponent <Renderer>().material.color = color;

            cell.name = point.ToString();

            grid[point] = cell;
        }
    }
Пример #2
0
    override public IGrid <TCell, TPoint> MakeGrid <TCell, TPoint>()
    {
        var grid = PointyHexGrid <TCell>
                   .BeginShape()
                   .Rectangle(2, 2)
                   .Translate(2, 2)
                   .Union()
                   .Rectangle(2, 2)
                   .EndShape();

        return((IGrid <TCell, TPoint>)grid);
    }
Пример #3
0
        private void BuildGrid()
        {
            //This is the base grid, we will use it to define
            //the shape of the splice grid.
            //The contents is not important.
            var baseGrid = PointyHexGrid <bool>
                           .BeginShape()
                           .Hexagon(5)
                           .EndShape();

            //This is the base map, used for the course
            //mapping
            var baseMap = new PointyHexMap(cellDimensions)
                          .WithWindow(ExampleUtils.ScreenRect)
                          .AlignMiddleCenter(baseGrid);

            //Now we make the actual spliced grid.
            //We feed it the base grid, and the number
            //of splices we want.
            grid = new SplicedGrid <SpriteCell, PointyHexPoint>(baseGrid, spliceOffsets.Length);

            //Now we make a spliced map. This is just a one-way map --
            //it only maps grid points to the world (using the base map plus
            //splice point offsets
            var splicedMap = new SplicedMap <PointyHexPoint>(baseMap, spliceOffsets);

            //Finally, we make the above into a two way map. This map uses a Vonoroi diagram
            //to do the inverse mapping
            map = new VoronoiMap <SplicedPoint <PointyHexPoint> >(grid, splicedMap).To3DXY();

            //Then we instantiate cells as usual, and put them in our grid.
            foreach (var point in grid)
            {
                var     cell       = Instantiate(cellPrefab);
                Vector3 worldPoint = map[point];

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

                //slightly lighter than the DefaultColors we will use to paint the background
                cell.Color = ExampleUtils.Colors[ColorFunction(point)] + Color.white * 0.1f;
                cell.name  = point.ToString();

                grid[point] = cell;
            }

            // To make it easier to see how points are mapped, we
            ExampleUtils.PaintScreenTexture(plane, map.To2D(), ColorFunction);
        }
Пример #4
0
 public PointyRhombShapeInfo <TCell> Diamond(int side)
 {
     return(ShapeFromBase(PointyHexGrid <TCell> .BeginShape().Diamond(side)));
 }
Пример #5
0
 public PointyRhombShapeInfo <TCell> DownTriangle(int side)
 {
     return(ShapeFromBase(PointyHexGrid <TCell> .BeginShape().DownTriangle(side)));
 }
Пример #6
0
 public PointyRhombShapeInfo <TCell> ThinRectangle(int width, int height)
 {
     return(ShapeFromBase(PointyHexGrid <TCell> .BeginShape().ThinRectangle(width, height)));
 }
Пример #7
0
 public PointyRhombShapeInfo <TCell> Parallelogram(int width, int height)
 {
     return(ShapeFromBase(PointyHexGrid <TCell> .BeginShape().Parallelogram(width, height)));
 }
Пример #8
0
 public PointyRhombShapeInfo <TCell> Hexagon(int side)
 {
     return(ShapeFromBase(PointyHexGrid <TCell> .BeginShape().Hexagon(side)));
 }
Пример #9
0
 public CairoShapeInfo <TCell> Rectangle(int width, int height)
 {
     return(ShapeFromBase(PointyHexGrid <TCell> .BeginShape().Rectangle(width, height)));
 }