예제 #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
        public IEnumerator BuildGrid()
        {
            totalCellCount = 0;
            grid           = PointyHexGrid <TileCell> .Rectangle(width, height);

            map = new PointyHexMap(new Vector2(69, 80) * 3)
                  .To3DXY();

            int cellCount = 0;

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

                cell.transform.localPosition = worldPoint;

                cellCount++;
                totalCellCount++;

                grid[point] = cell;

                if (cellCount >= cellsPerIteration)
                {
                    cellCount = 0;
                    yield return(null);
                }
            }
        }
    private void BuildGrid()
    {
        const int   width    = 6;
        const int   height   = 5;
        const float border   = 0f;
        const float quadSize = 15f;

        grid = PointyHexGrid <MeshTileCell> .HorizontallyWrappedRectangle(width, height);

        map = new PolarPointyBrickMap(Vector2.zero, 50, 350, new VectorPoint(width, height));

        foreach (var point in grid)
        {
            var cell = Instantiate(cellPrefab);
            cell.transform.parent = gridRoot.transform;

            Mesh mesh = cell.GetComponent <MeshFilter>().mesh;

            float innerRadius = map.GetInnerRadius(point) + border / 2;
            float outerRadius = map.GetOuterRadius(point) - border / 2;
            float startAngle  = map.GetStartAngleZ(point);
            float endAngle    = map.GetEndAngleZ(point) - border * Mathf.Rad2Deg / outerRadius;
            int   quadCount   = Mathf.CeilToInt(outerRadius * 2 * Mathf.PI / (quadSize * width));

            MeshUtil.MakeBandedSector(mesh, startAngle, endAngle, innerRadius, outerRadius, quadCount);

            cell.Color          = ExampleUtils.Colors[point.GetColor(3, -1, 2)];
            cell.HighlightOn    = false;
            cell.__CenterOffset = map[point].XYTo3D();

            grid[point] = cell;
        }
    }
예제 #4
0
        public IEnumerator BuildGrid()
        {
            totalCellCount = 0;
            grid = PointyHexGrid<TileCell>.Rectangle(width, height);

            map = new PointyHexMap(new Vector2(69, 80)*3)
                .To3DXY();

            int cellCount = 0;

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

                cell.transform.localPosition = worldPoint;

                cellCount++;
                totalCellCount++;

                grid[point] = cell;

                if (cellCount >= cellsPerIteration)
                {
                    cellCount = 0;
                    yield return null;
                }
            }
        }
예제 #5
0
        public void BuildGrid()
        {
            var grid = PointyHexGrid <UVCell> .ThinRectangle(11, 11);

            var baseMap = new PointyHexMap(cellPrefab.Dimensions * 1.1f);

            Debug.Log(cellPrefab.Dimensions);

            var cellMap = baseMap
                          .WithWindow(ExampleUtils.ScreenRect)
                          .AlignMiddleCenter(grid)
                          .To3DXY();

            var imageMap =
                new ImageMap <PointyHexPoint>(new Rect(0, 0, 1, 1), grid, baseMap);

            foreach (var point in grid)
            {
                var worldPosition = cellMap[point];

                var cell = Instantiate(cellPrefab);
                Debug.Log(cell.Dimensions);

                cell.transform.parent        = gridRoot.transform;
                cell.transform.localScale    = Vector3.one;
                cell.transform.localPosition = worldPosition;

                cell.SetTexture(texture);
                cell.name = point.ToString();

                var imagePoint = imageMap[point];

                cell.SetUVs(imagePoint, imageMap.GetCellDimensions(point));
            }
        }
예제 #6
0
    private static PointyHexGrid<int> tileMap; // Grid's "Hexagonal Array" containing an int corresponding to each type cell. Could be done with a simple 2D array for a square map.

    #endregion Fields

    #region Methods

    // Generate an Hexagonal map with Mathf.Perlin
    public static PointyHexGrid<int> GenerateHex(int width)
    {
        Debug.Log ("Time GenerationStart = " + Time.realtimeSinceStartup);

        tileMap = PointyHexGrid<int>.Hexagon(width); // Define tileMap from the inputted width of the hexagon

        float zoom = Random.Range (0.015f,0.17f);								   // Zoom in for "big smooth" peaks. Zoom out for "small noisy" peaks. Not the best description but gives an idea.
        Vector2 shift = new Vector2(Random.Range (-10,10), Random.Range (-10,10)); // play with this to move on the perlin map. Allow for infinite coherent map divided in chunks.

        // Step on each cell, calculate a noise value with Mathf.Perlin and define a type of cell according to hardcoded cell types
         for(int x = 0; x < (width*2) - 1; x++) // The for loops aren't stepping precisely on the hexagon shape but it works. Could be improved.
        {
            for(int y = 0; y < (width*2) - 1; y++)
            {
                Vector2 pos = zoom * (new Vector2(x,y)) + shift;       						 // Position on the current cell on the perlin map, using value of shift/zoom
                float noise = 1.0f - Mathf.PerlinNoise(pos.x, pos.y);						 // Noise value at evaluated position on perlin map
                PointyHexPoint point = new PointyHexPoint(x - (width - 1), y - (width - 1)); // Calculate the grid's point that correspond to the current cell

                int _curTile = 0; // Default value

                // Define cell type according to noise value
                if (noise>0.90f) 	  _curTile = (int)TileName.Mountain;
                else if (noise>0.80f) _curTile = (int)TileName.Hills;
                else if (noise>0.60f) _curTile = (int)TileName.BorealForest;
                else if (noise>0.50f) _curTile = (int)TileName.GrassLand;
                else if (noise>0.45f) _curTile = (int)TileName.Desert;
                else if (noise>0.30f) _curTile = (int)TileName.shallowWater;
                else 				  _curTile = (int)TileName.deepWater;

                tileMap[point] = _curTile; // Set the current tile int on the tilemap
            }
        }
        Debug.Log ("Time GenerationFinish = " + Time.realtimeSinceStartup);
        return tileMap;
    }
예제 #7
0
	private void BuildGrid()
	{
		const int width = 6;
		const int height = 9;

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

		map = new PointyBrickMap(CellDimensions)
			.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;
		}
	}
예제 #8
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;
            }
        }
예제 #9
0
		public static bool __CompilerHint__PointyHex__TileCell()
		{
			var grid = new PointyHexGrid<TileCell[]>(1, 1);

			foreach(var point in grid) { grid[point] = new TileCell[1]; } 

			var shapeStorageInfo = new ShapeStorageInfo<PointyHexPoint>(new IntRect(), p => true);
			var shapeInfo = new PointyHexShapeInfo<TileCell>(shapeStorageInfo);

			return grid[grid.First()][0] == null || shapeInfo.Translate(PointyHexPoint.Zero) != null;
		}
예제 #10
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);
    }
예제 #11
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);
        }
예제 #12
0
		public static bool __CompilerHint__FlatTri__TileCell()
		{
			var grid1 = new PointyHexGrid<TileCell[]>(1, 1);

			foreach(var point in grid1)	{ grid1[point] = new TileCell[1]; } 

			var grid2 = new FlatTriGrid<TileCell>(1, 1);

			foreach(var point in grid2)	{ grid2[point] = null; } 

			var shapeStorageInfo = new ShapeStorageInfo<FlatTriPoint>(new IntRect(), p => true);
			var shapeInfo = new FlatTriShapeInfo<TileCell>(shapeStorageInfo);

			return grid1[grid1.First()][0] == null || grid2[grid2.First()] == null || shapeInfo.IncIndex(0) != null;
		}
		/** 
			Call this method if you use a PointyHexGrid.
			Replace	the type __CellType to whatever type you have in your grid.

			You can call the method anywhere in your code.
			
				if(!__CompilerHint__PointyHex()) return;

			This methods always returns true.

			@since 1.6
		*/
		public static bool __CompilerHint__PointyHex()
		{
			//Ensures abstract super classes for base grids gets created
			var grid = new PointyHexGrid<__CellType[]>(1, 1);

			foreach(var point in grid)
			{
				grid[point] = new __CellType[1];
			} 

			//Ensures shape infpo classes get created
			var shapeStorageInfo = new ShapeStorageInfo<PointyHexPoint>(new IntRect(), p => true);
			var shapeInfo = new PointyHexShapeInfo<__CellType>(shapeStorageInfo);

			return grid[grid.First()][0] == null || shapeInfo.Translate(PointyHexPoint.Zero) != null;
		}
예제 #14
0
        /**
         *      This method is provided for generic testing purposes.
         *      It should generally not be used in production code: it may
         *      be slow and not type-safe.
         */
        public static TGrid MakeGrid <TPoint, TGrid, TCell>(int width, int height, TPoint offset)
            where TPoint : IGridPoint <TPoint>
            where TGrid : IGrid <TCell, TPoint>
        {
            if (typeof(TPoint) == typeof(PointyHexPoint))
            {
                Debug.Assert(typeof(TGrid) == typeof(PointyHexGrid <TCell>));

                return((TGrid)(object)new PointyHexGrid <TCell>(
                           width,
                           height,
                           x => PointyHexGrid <TCell> .DefaultContains(x, width, height),
                           (PointyHexPoint)(object)offset));
            }
            if (typeof(TPoint) == typeof(FlatHexPoint))
            {
                Debug.Assert(typeof(TGrid) == typeof(FlatHexGrid <TCell>));

                return((TGrid)(object)new FlatHexGrid <TCell>(
                           width,
                           height,
                           x => FlatHexGrid <TCell> .DefaultContains(x, width, height),
                           (FlatHexPoint)(object)offset));
            }
            if (typeof(TPoint) == typeof(RectPoint))
            {
                Debug.Assert(typeof(TGrid) == typeof(RectGrid <TCell>));

                return((TGrid)(object)new RectGrid <TCell>(
                           width,
                           height,
                           x => RectGrid <TCell> .DefaultContains(x, width, height),
                           (RectPoint)(object)offset));
            }
            if (typeof(TPoint) == typeof(DiamondPoint))
            {
                Debug.Assert(typeof(TGrid) == typeof(DiamondGrid <TCell>));

                return((TGrid)(object)new DiamondGrid <TCell>(
                           width,
                           height,
                           x => DiamondGrid <TCell> .DefaultContains(x, width, height),
                           (DiamondPoint)(object)offset));
            }

            throw new NotSupportedException();
        }
예제 #15
0
    private void BuildGrid()
    {
        //if(TileGridBuilder.Shape != Hexagon)

        startNode = new PointyHexPoint(1 - size, size - 1);
        endNode   = new PointyHexPoint(size - 1, 1 - size);

        smallGrid = PointyHexGrid <int>
                    .Hexagon(size - 1)
                    .ToList();

        logicalGrid = (PointyHexGrid <bool>)Grid.CloneStructure <bool>();

        foreach (var point in logicalGrid)
        {
            logicalGrid[point] = false;
        }
    }
예제 #16
0
        /*
         * public static IEnumerable<PointyHexPoint> GenerateMazeWalls(PointyHexGrid<Cell> grid)
         * {
         * var walls = grid.CloneStructure<bool>(); //true indicates passable
         *
         * foreach(var point in walls)
         * {
         *      walls[point] = point.GetColor2_4() == 0;
         * }
         *
         * var wallList = new List<PointyHexPoint>();
         *
         * var newMaizePoint = grid.Where(p => p.GetColor2_4() == 0).RandomItem();
         * var inMaze = new List<PointyHexPoint> {newMaizePoint};
         *
         * var edges = newMaizePoint.GetNeighbors();
         * wallList.AddRange(edges);
         *
         * while (wallList.Any())
         * {
         *      var randomWall = wallList.RandomItem();
         *      var faces = GetEdgeFaces(randomWall).Where(grid.Contains);
         *
         *      //At least one of the two faces must be in the maze
         *      if (faces.Any(point => !inMaze.Contains(point)))
         *      {
         *
         *              newMaizePoint = faces.First(point => !inMaze.Contains(point));
         *              inMaze.Add(newMaizePoint);
         *              walls[randomWall] = true;
         *
         *              yield return randomWall;
         *
         *              // Add all edges that are not passages
         *              edges = newMaizePoint.GetNeighbors().Where(edge => !(walls[edge]));
         *              wallList.AddRange(edges);
         *      }
         *      else
         *      {
         *              wallList.Remove(randomWall);
         *      }
         * }
         * }
         */

        public static IEnumerable <PointyHexPoint> GenerateMazeWalls <TCell>(PointyHexGrid <TCell> grid)
        {
            var walls = grid.CloneStructure <bool>();            //true indicates passable

            foreach (var point in walls)
            {
                walls[point] = point.GetColor2_4() == 0;
            }

            var wallList = new PointList <PointyHexPoint>();

            var newMaizePoint = grid.Where(p => p.GetColor2_4() == 0).RandomItem();
            var inMaze        = new PointList <PointyHexPoint> {
                newMaizePoint
            };

            var edges = newMaizePoint.GetNeighbors();

            wallList.AddRange(edges);

            while (wallList.Any())
            {
                var randomWall = wallList.RandomItem();
                var faces      = GetEdgeFaces(randomWall).Where(grid.Contains);

                //At least one of the two faces must be in the maze
                if (faces.Any(point => !inMaze.Contains(point)))
                {
                    newMaizePoint = faces.First(point => !inMaze.Contains(point));
                    inMaze.Add(newMaizePoint);
                    walls[randomWall] = true;

                    yield return(randomWall);

                    // Add all edges that are not passages
                    edges = newMaizePoint.GetNeighbors().Where(edge => !(walls[edge]));
                    wallList.AddRange(edges);
                }
                else
                {
                    wallList.Remove(randomWall);
                }
            }
        }
예제 #17
0
    override public void InitGrid()
    {
        //We cast the grid and grid values here for convenience.
        //Casting like this clones the grid. Thus neighbor relations are
        //not preserved (this is a design flaw as of Grids 1.8, to be fixed
        //in a future version). For now it means the actual pathfinding call
        //must use the original grid.
        walkableGrid = (PointyHexGrid <WalkableCell>)Grid.CastValues <WalkableCell, PointyHexPoint>();

        foreach (var point in walkableGrid)
        {
            walkableGrid[point].IsWalkable = true;
        }

        start = walkableGrid.First();
        goal  = walkableGrid.Last();

        UpdatePath();
    }
예제 #18
0
    // Instantiate all cell of the grid
    private IEnumerator BuildGrid()
    {
        //cellsPerIteration = (width*width)/(width/2);
        //const int height = 5;

        grid    = PointyHexGrid<Cell>.Hexagon(width);
        tileMap = PointyHexGrid<int>.Hexagon(width);

        // Generate an hexagonal map defining each cell type
        tileMap = WorldGenerator.GenerateHex (width);

        // Map setup
        map = new PointyHexMap(HexDimensions)
            .AnchorCellMiddleCenter()
            .WithWindow(ExampleUtils.ScreenRect)
            .AlignMiddleCenter(grid)
            .To3DXY();

        // Instantiate each cell over many frames
        foreach(PointyHexPoint point in grid)
        {
            CreateCell(point);
            cellCount++;

            if(cellCount >= cellsPerIteration)
            {

                cellCount = 0;
                //Debug.Log ("Time BuildGridFrame = " + Time.realtimeSinceStartup);

                yield return null;
            }
        }

        // After grid generation
        Debug.Log ("Time BuildGridFinished = " + Time.realtimeSinceStartup);
        CreateCities(); // Put cities on the map
        TimeSystem.SetSpeed(2);
        isGridBuilt = true;
    }
예제 #19
0
	private void BuildGrid()
	{
		// Creates a grid in a rectangular shape.
		grid = PointyHexGrid<SpriteCell>.FatRectangle(7, 7);

		// Creates a map...
		map = new PointyHexMap(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 (PointyHexPoint 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.GetColor2_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.
		}
	}
예제 #20
0
    public void GenerateMesh()
    {
        var grid = PointyHexGrid <int> .Hexagon(50);

        foreach (var point in grid)
        {
            grid[point] = Random.Range(0, textureCount);
        }

        var dimensions = new Vector2(69, 80);

        var map = new PointyHexMap(dimensions)
                  .WithWindow(new Rect(0, 0, 0, 0))
                  .AlignMiddleCenter(grid)
                  .To3DXZ();

        var mesh = new Mesh();

        GetComponent <MeshFilter>().mesh = mesh;

        GenerateMesh(mesh, grid, map, dimensions);
    }
예제 #21
0
        private void BuildGrid()
        {
            // Creates a grid in a rectangular shape.
            grid = PointyHexGrid <SpriteCell> .FatRectangle(7, 7);

            // Creates a map...
            map = new PointyHexMap(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 (PointyHexPoint 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.GetColor2_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.
            }
        }
예제 #22
0
 public static ArrayPoint ArrayPointFromGridPoint(PointyHexPoint point)
 {
     return(PointyHexGrid <TCell> .ArrayPointFromGridPoint(point));
 }
예제 #23
0
 public PointyRhombShapeInfo <TCell> DownTriangle(int side)
 {
     return(ShapeFromBase(PointyHexGrid <TCell> .BeginShape().DownTriangle(side)));
 }
예제 #24
0
 public PointyRhombShapeInfo <TCell> Diamond(int side)
 {
     return(ShapeFromBase(PointyHexGrid <TCell> .BeginShape().Diamond(side)));
 }
예제 #25
0
 public PointyRhombShapeInfo <TCell> Parallelogram(int width, int height)
 {
     return(ShapeFromBase(PointyHexGrid <TCell> .BeginShape().Parallelogram(width, height)));
 }
예제 #26
0
 public PointyRhombShapeInfo <TCell> ThinRectangle(int width, int height)
 {
     return(ShapeFromBase(PointyHexGrid <TCell> .BeginShape().ThinRectangle(width, height)));
 }
예제 #27
0
		public static bool __CompilerHint__Cairo__UVCell()
		{
			var grid1 = new PointyHexGrid<UVCell[]>(1, 1);

			foreach(var point in grid1)	{ grid1[point] = new UVCell[1]; } 

			var grid2 = new CairoGrid<UVCell>(1, 1);

			foreach(var point in grid2)	{ grid2[point] = null; } 

			var shapeStorageInfo = new ShapeStorageInfo<CairoPoint>(new IntRect(), p => true);
			var shapeInfo = new CairoShapeInfo<UVCell>(shapeStorageInfo);

			return grid1[grid1.First()][0] == null || grid2[grid2.First()] == null || shapeInfo.IncIndex(0) != null;
		}
예제 #28
0
 public PointyRhombShapeInfo <TCell> Hexagon(int side)
 {
     return(ShapeFromBase(PointyHexGrid <TCell> .BeginShape().Hexagon(side)));
 }
예제 #29
0
        public static bool __CompilerHint2__PointyHex()
        {
            //Ensures abstract super classes for base grids gets created
            var grid = new PointyHexGrid<__CellType>(1, 1, p => p == PointyHexPoint.Zero, x => x, x => x, new List<PointyHexPoint>());

            //Ensures shape infpo classes get created
            var shapeStorageInfo = new ShapeStorageInfo<PointyHexPoint>(new IntRect(), p => true);
            var shapeInfo = new PointyHexShapeInfo<__CellType>(shapeStorageInfo);

            return grid[grid.First()] == null || shapeInfo.Translate(PointyHexPoint.Zero) != null;
        }
예제 #30
0
    override public void InitGrid()
    {
        grid = (PointyHexGrid <PipesCell>)Grid.CastValues <PipesCell, PointyHexPoint>();

        Reset();
    }
예제 #31
0
		public static bool __CompilerHint__PointyRhomb__SpriteCell()
		{
			var grid1 = new PointyHexGrid<SpriteCell[]>(1, 1);

			foreach(var point in grid1)	{ grid1[point] = new SpriteCell[1]; } 

			var grid2 = new PointyRhombGrid<SpriteCell>(1, 1);

			foreach(var point in grid2)	{ grid2[point] = null; } 

			var shapeStorageInfo = new ShapeStorageInfo<PointyRhombPoint>(new IntRect(), p => true);
			var shapeInfo = new PointyRhombShapeInfo<SpriteCell>(shapeStorageInfo);

			return grid1[grid1.First()][0] == null || grid2[grid2.First()] == null || shapeInfo.IncIndex(0) != null;
		}
예제 #32
0
 public override void InitGrid()
 {
     grid = (PointyHexGrid <LinesCell>)Grid.CastValues <LinesCell, PointyHexPoint>();
     Reset();
 }
예제 #33
0
 public CairoShapeInfo <TCell> Rectangle(int width, int height)
 {
     return(ShapeFromBase(PointyHexGrid <TCell> .BeginShape().Rectangle(width, height)));
 }
예제 #34
0
 public static PointyHexPoint GridPointFromArrayPoint(ArrayPoint point)
 {
     return(PointyHexGrid <TCell> .GridPointFromArrayPoint(point));
 }
예제 #35
0
    private void BuildGrid()
    {
        // Creates a grid in a rectangular shape.
        grid = PointyHexGrid<SeaTileCell>.Hexagon(10);
        // Creates a map...
        map = new PointyHexMap (AssetManager.Instance.tilePrefab.Dimensions)
          .WithWindow (Utils.ScreenRect)
          .AlignMiddleCenter (grid);

        foreach (PointyHexPoint point in grid) { //Iterates over all points (coordinates) contained in the grid
          SeaTileCell cell = Instantiate (AssetManager.Instance.tilePrefab) as SeaTileCell;

          Vector3 worldPoint = map [point]; //Calculate the world point of the current grid point
          cell.transform.position = worldPoint;

          cell.name = point.ToString (); // Makes it easier to identify cells in the editor.
          cell.onDefault ();
          cell.HighlightOn = false;
          grid [point] = cell; // Finally, put the cell in the grid.
        }
    }