Exemplo n.º 1
0
        private void BuildGrid()
        {
            const int width  = 6;
            const int height = 9;

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

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

            foreach (PointyHexPoint 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;
            }
        }
Exemplo n.º 2
0
        private void BuildGrid()
        {
            const int width  = 5;
            const int height = 5;

            grid = PointyRhombGrid <SpriteCell>
                   .BeginShape()
                   .Rectangle(width, height)
                   .EndShape();

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


            foreach (PointyRhombPoint point in grid)
            {
                SpriteCell cell       = Instantiate(cellPrefab);
                Vector3    worldPoint = map[point];
                cell.transform.parent        = root.transform;
                cell.transform.localScale    = Vector3.one;
                cell.transform.localPosition = worldPoint;
                cell.Color = ExampleUtils.Colors[point.GetColor12()];
                cell.name  = point.ToString();
                cell.SetAngle(-360f / PointyRhombPoint.SpliceCount * point.I);

                grid[point] = cell;
            }
        }
Exemplo n.º 3
0
        private void BuildGrid()
        {
            const int side = 3;

            grid = PointyTriGrid <SpriteCell>
                   .Star(side);

            map = new PointyTriMap(TriDimensions)
                  .WithWindow(ExampleUtils.ScreenRect)
                  .AlignMiddleCenter(grid)
                  .AnchorCellMiddleCenter()
                  .To3DXY();

            foreach (PointyTriPoint 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.GetColor(5, 1, 1)];
                cell.name  = point.ToString();
                cell.SetAngle(360f / PointyTriPoint.SpliceCount * point.I);

                grid[point] = cell;
            }
        }
Exemplo n.º 4
0
        private void BuildGrid()
        {
            const int width  = 2;
            const int height = 2;

            grid = CairoGrid <SpriteCell> .Default(width, height);

            map = new CairoMap(CellDimensions)
                  .AnchorCellMiddleCenter()
                  .WithWindow(ExampleUtils.ScreenRect)
                  .AlignMiddleCenter(grid)
                  .To3DXY();

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

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

                cell.Color = ExampleUtils.Colors[ColorMap(point.GetColor12())];
                cell.name  = PointToString(point);
                cell.SetAngle(360f / CairoPoint.SpliceCount * point.I);

                grid[point] = cell;
            }
        }
Exemplo n.º 5
0
    private void BuildGrid()
    {
        root.transform.DestroyChildren();

        grid = FlatHexGrid <SpriteCell> .Hexagon(4);

        map = new FlatHexMap(HexDimensions)
              .AnchorCellMiddleCenter()
              .WithWindow(ExampleUtils.ScreenRect)
              .AlignMiddleCenter(grid)
              .To3DXY()
        ;

        foreach (FlatHexPoint point in grid)
        {
            SpriteCell cell       = Instantiate(cellPrefab);
            Vector3    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;
        }
    }
Exemplo n.º 6
0
        private void BuildGrid()
        {
            // Creates a grid in a rectangular shape.
            grid = RectGrid <SpriteCell> .Rectangle(51, 111);

            // Creates a map...
            map = new RectMap(cellPrefab.Dimensions)             // The cell dimensions usually correspond to the visual
                  // part of the sprite in pixels. Here we use the actual
                  // sprite size, which causes a border between cells.
                  //

                  .WithWindow(ExampleUtils.ScreenRect) // ...that is centered in the rectangle provided
                  .AlignMiddleCenter(grid)             // by this and the previous line.
                  .To3DXY();                           // This makes the 2D map returned by the last function into a 3D map
            // This map assumes the grid is in the XY plane.
            // To3DXZ assumes the grid is in the XZ plane (you have to make sure
            //your tiles are similarly aligned / rotated).


            foreach (RectPoint point in grid)              //Iterates over all points (coordinates) contained in the grid
            {
                SpriteCell cell = Instantiate(cellPrefab); // Instantiate a cell from the given prefab.
                //This generic version of Instantiate is defined in GLMonoBehaviour
                //If you don't want to use GLMonoBehvaiour, you have to cast the result of
                //Instantiate

                Vector3 worldPoint = map[point];                 //Calculate the world point of the current grid point

                cell.transform.parent        = root.transform;   //Parent the cell to the root
                cell.transform.localScale    = Vector3.one;      //Readjust the scale - the re-parenting above may have changed it.
                cell.transform.localPosition = worldPoint;       //Set the localPosition of the cell.


                cell.Color = (point.Magnitude() % 2 == 0)? Color2 : Color2;
                if ((point.X == 3 || point.X == 47) && (point.Y > 2 && point.Y < 108))
                {
                    cell.Color = new Color(0.8f, 0.8f, 0.8f);
                }
                if ((point.Y == 3 || point.Y == 107 || point.Y == 55) && (point.X > 2 && point.X < 48))
                {
                    cell.Color = new Color(0.8f, 0.8f, 0.8f);
                }

                if ((point.X == 21 || point.X == 29) && (point.Y <= 2 || point.Y >= 108))
                {
                    cell.Color = new Color(0.8f, 0.8f, 0.8f);
                }
                if ((point.Y == 0 || point.Y == 110) && (point.X > 21 && point.X < 29))
                {
                    cell.Color = new Color(0.8f, 0.8f, 0.8f);
                }
                cell.name   = point.ToString();     // Makes it easier to identify cells in the editor.
                grid[point] = cell;                 // Finally, put the cell in the grid.

                //if (point.X >= 3 && point.X <= 47 && point.Y >= 3 && point.Y <= 107)
                //{
                rectPointArr[point.X, point.Y] = point;
                //}
            }
        }
Exemplo n.º 7
0
        private SpriteCell MakeTile()
        {
            SpriteCell cell = Instantiate(cellPrefab);

            cell.transform.parent     = uiRoot.transform;
            cell.transform.localScale = Vector3.one;

            return(cell);
        }
Exemplo n.º 8
0
    private void BuildGrid()
    {
        // Creates a grid in a rectangular shape.
        grid = RectGrid <SpriteCell> .Rectangle(7, 7);

        // Creates a map...
        map = new RectMap(cellPrefab.Dimensions)                // The cell dimensions usually correspond to the visual
              // part of the sprite in pixels. Here we use the actual
              // sprite size, which causes a border between cells.
              //

              .WithWindow(ExampleUtils.ScreenRect) // ...that is centered in the rectangle provided
              .AlignMiddleCenter(grid)             // by this and the previous line.
              .To3DXY();                           // This makes the 2D map returned by the last function into a 3D map
        // This map assumes the grid is in the XY plane.
        // To3DXZ assumes the grid is in the XZ plane (you have to make sure
        //your tiles are similarly aligned / rotated).


        foreach (RectPoint point in grid)              //Iterates over all points (coordinates) contained in the grid
        {
            SpriteCell cell = Instantiate(cellPrefab); // Instantiate a cell from the given prefab.
            //This generic version of Instantiate is defined in GLMonoBehaviour
            //If you don't want to use GLMonoBehvaiour, you have to cast the result of
            //Instantiate

            Vector3 worldPoint = map[point];                             //Calculate the world point of the current grid point

            cell.transform.parent        = root.transform;               //Parent the cell to the root
            cell.transform.localScale    = Vector3.one;                  //Readjust the scale - the re-parenting above may have changed it.
            cell.transform.localPosition = worldPoint;                   //Set the localPosition of the cell.

            cell.Color = ExampleUtils.Colors[point.GetColor4() % 4 * 4]; //Sets the color of the cell
            //See http://gamelogic.co.za/2013/12/18/what-are-grid-colorings/ for more information on colorings.

            cell.name   = point.ToString(); // Makes it easier to identify cells in the editor.
            grid[point] = cell;             // Finally, put the cell in the grid.
        }
    }
Exemplo n.º 9
0
    private void BuildGrid()
    {
        grid = new NestedRectGrid <SpriteCell>(bigDimensions, smallDimensions);

        var bigCellDimensions = new Vector2(cellDimensions.x * smallDimensions.X, cellDimensions.y * smallDimensions.Y);

        bigMap = new RectMap(bigCellDimensions * 1.05f)
                 .AnchorCellBottomLeft()
                 .WithWindow(ExampleUtils.ScreenRect)
                 .AlignMiddleCenter(grid.BaseGrid)        //pass in the base grid
                 .Scale(1.2f)
                 .To3DXY();

        smallMap = new RectMap(cellDimensions)
                   .Scale(1.05f)
                   .To3DXY();

        foreach (var bigPoint in grid.BaseGrid)
        {
            var smallGrid = grid.GetSmallGrid(bigPoint);

            foreach (var smallPoint in smallGrid)
            {
                SpriteCell cell = Instantiate(cellPrefab);
                cell.transform.parent        = gridRoot.transform;
                cell.transform.localScale    = Vector3.one;
                cell.transform.localPosition = bigMap[bigPoint] + smallMap[smallPoint];

                var colorIndex = bigPoint.GetColor(2, 1, 1) * 4 + smallPoint.GetColor(3, 1, 1);

                cell.Color = ExampleUtils.Colors[colorIndex];
                cell.name  = bigPoint.ToString() + " | " + smallPoint.ToString();
                grid[bigPoint, smallPoint] = cell;
            }
        }
    }
Exemplo n.º 10
0
 private void InitCell(int point, SpriteCell cell)
 {
     cell.Color = colors[GridPoint1.GetColor(point, colorFunction)];
 }
Exemplo n.º 11
0
 private void InitCell(GridPoint2 point, SpriteCell cell)
 {
     cell.Color = colors[point.GetColor(colorFunction)];
 }
Exemplo n.º 12
0
			//All tile points are relative to CurrentPosition
			public void AddTile(RectPoint tilePoint, SpriteCell tileObject)
			{
				tileObjects[tilePoint] = tileObject;
			}
Exemplo n.º 13
0
 //All tile points are relative to CurrentPosition
 public void AddTile(RectPoint tilePoint, SpriteCell tileObject)
 {
     tileObjects[tilePoint] = tileObject;
 }
Exemplo n.º 14
0
 private void InitCell(int point, SpriteCell cell)
 {
     //TODO Make a 1D color function method somewhere
     //Rename ColorFunction to ColorFunction2
     cell.Color = colors[point % colorFunction];
 }