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