示例#1
0
		public IGrid<TNewCell, FlatTriPoint> MakeVertexGrid<TNewCell>()
		{
			var vertices = this.SelectMany(x => x.GetVertices());
			var storage = FlatTriGrid<TNewCell>.CalculateStorage(vertices);
			var offset = FlatTriGrid<TNewCell>.GridPointFromArrayPoint(storage.offset);

			return new FlatTriGrid<TNewCell>(storage.dimensions.X, storage.dimensions.Y, x => IsInsideVertexGrid(x + offset), offset);
		}
示例#2
0
文件: Op.cs 项目: mhaque3/soa_unity
        public FlatTriShapeInfo <TCell> Default(int width, int height)
        {
            var rawInfow = MakeShapeStorageInfo <FlatTriPoint>(
                width,
                height,
                x => FlatTriGrid <TCell> .DefaultContains(x, width, height));

            return(new FlatTriShapeInfo <TCell>(rawInfow));
        }
示例#3
0
        protected override void InitGrid()
        {
            VectorPoint rectDimensions = Dimensions;

            switch (shape)
            {
            case Shape.Rectangle:
                base.Grid = FlatTriGrid <TileCell> .Rectangle(rectDimensions.X, rectDimensions.Y);

                break;

            case Shape.Parallelogram:
                base.Grid = FlatTriGrid <TileCell> .ParallelogramXY(rectDimensions.X, rectDimensions.Y);

                break;

            case Shape.UpTriangle:
                base.Grid = FlatTriGrid <TileCell> .UpTriangle(size);

                break;

            case Shape.DownTriangle:
                base.Grid = FlatTriGrid <TileCell> .DownTriangle(size);

                break;

            case Shape.Hexagon:
                base.Grid = FlatTriGrid <TileCell> .Hexagon(size);

                break;

            case Shape.Star:
                base.Grid = FlatTriGrid <TileCell> .Star(size);

                break;

            case Shape.Single:
                base.Grid = FlatTriGrid <TileCell> .Single();

                break;

            case Shape.SingleGroup:
                base.Grid = FlatTriGrid <TileCell> .SingleGroup();

                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }
示例#4
0
        /**
         *      @param n Must be positive
         */
        public FlatTriHexagonWrapper(int side)
        {
            if (side <= 0)
            {
                throw new Exception("n Must be a positive integer.");
            }

            int colorCount = 3 * side * side;

            colorFunc = x => x.GetColor(colorCount / side, side, side);

            wrappedPoints = new FlatTriPoint[colorCount * 2];
            var grid = FlatTriGrid <int> .Hexagon(side);

            foreach (var point in grid)
            {
                int color = colorFunc(point);
                wrappedPoints[color] = point;
            }
        }
示例#5
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);
        }
示例#6
0
 protected override ArrayPoint ArrayPointFromGridPoint(PointyHexPoint point)
 {
     return(FlatTriGrid <TCell> .ArrayPointFromGridPoint(point));
 }
示例#7
0
 protected override PointyHexPoint GridPointFromArrayPoint(ArrayPoint point)
 {
     return(FlatTriGrid <TCell> .GridPointFromArrayPoint(point));
 }
示例#8
0
文件: Op.cs 项目: mhaque3/soa_unity
 /**
  *      Starts a compound shape operation.
  *
  *      Any shape that is defined in terms of other shape operations must use this method, and use Endgroup() to end the definition.
  *
  *              public static FlatTriShapeInfo<TCell> MyCustomShape(this FlatTriOp<TCell> op)
  *              {
  *                      return
  *                              BeginGroup()
  *                                      .Shape1()
  *                                      .Union()
  *                                      .Shape2()
  *                              .EndGroup(op);
  *              }
  *
  *      @since 1.1
  */
 public FlatTriOp <TCell> BeginGroup()
 {
     return(FlatTriGrid <TCell> .BeginShape());
 }