public GroundVertex Offset(Vector2 pos, float height) { GroundVertex v = new GroundVertex(tile, localPos + pos); v.height = this.height + height; return(v); }
/// <summary> /// Initialize vertex positions. /// </summary> void InitVertices(HexWorld world) { center = new GroundVertex(this, Random.insideUnitCircle / 5f); ground = new Vertices <GroundVertex>(); river = new Vertices <RiverVertex>(); riverCenter = new RiverVertex(center); waterCenter = new WaterVertex(center); foreach (Direction dir in Direction.directions) { float centerHexOuterRadius = world.RiverWidth / HexWorld.COS_30 * 0.5f; Vector2 edgeLeft = world.LeftVertex(dir); Vector2 edgeMid = world.MiddleVertex(dir); Vector2 edgeRight = world.RightVertex(dir); Vector2 riverEdgeLeft = edgeMid + (edgeLeft - edgeRight).normalized * world.RiverWidth * 0.5f; Vector2 riverEdgeRight = edgeMid + (edgeRight - edgeLeft).normalized * world.RiverWidth * 0.5f; Vector2 a = edgeMid.normalized * centerHexOuterRadius + center.localPos; Vector2 b = edgeLeft.normalized * world.RiverWidth + center.localPos; Vector2 c = b + (edgeRight.normalized * world.RiverWidth + center.localPos - b) * 0.5f; ground[dir] = new GroundVertex[] { new GroundVertex(this, riverEdgeLeft), new GroundVertex(this, edgeMid), new GroundVertex(this, riverEdgeRight), new GroundVertex(this, edgeRight), new GroundVertex(this, b), new GroundVertex(this, c), new GroundVertex(this, a) }; } foreach (Direction dir in Direction.directions) { river[dir] = new RiverVertex[] { new RiverVertex(ground[dir][0]), new RiverVertex(ground[dir][2]), new RiverVertex(ground[dir][4]), new RiverVertex(ground[dir.Clockwise][4]), new RiverVertex(ground[dir][6]) }; } }