示例#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)));
 }