private static Squared <Unit> triangleArea(Difference2 u, Difference2 v) { var a = u.NumericValue; var b = v.NumericValue; return(Squared <Unit> .FromValue(Math.Abs(a.X * b.Y - a.Y * b.X) * 0.5f)); }
public Building(GameState game, Position2 topLeft, Difference2 size) : base(game) { this.TopLeft = topLeft; this.Size = size; this.listAs<Building>(); }
public Building(GameState game, Position2 topLeft, Difference2 size) : base(game) { this.TopLeft = topLeft; this.Size = size; this.listAs <Building>(); }
public TileRectangle RectangleIntersecting(Position2 point, Difference2 size) { var tl = point.NumericValue; var br = tl + size.NumericValue; int x0, x1, y0, y1; this.positionToTile(tl.X, tl.Y, out x0, out y0); this.positionToTile(br.X, br.Y, out x1, out y1); return(new TileRectangle(x0, y0, x1, y1)); }
public CommandImplementation(GameState game, IBody body, Direction2 direction) : base(CommandType.ShootDebugParticleFromPlanet, game) { var bodyShape = body.Shape; var d = Difference2.In(direction, 1.U()); this.ps = new CommandParameters( this.game.GetUniqueId <FreeObject>(), bodyShape.Center + d * bodyShape.Radius.NumericValue * 1.5f, d * 1 / TimeSpan.One ); }
public void CalculatesAccelerationCorrectly( float gValue, float massValue, float differenceXValue, float differenceYValue) { var g = new GravitationalConstant(gValue); var mass = new Mass(massValue); var difference = new Difference2(differenceXValue, differenceYValue); var expectedAcceleration = gValue * massValue / new Vector2(differenceXValue, differenceYValue).LengthSquared; var acceleration = g.AccelerationAtDistance(mass, difference); acceleration.NumericValue.Should() .BeApproximatelyOrBothNaNOrInfinity(expectedAcceleration); }
public CommandImplementation(GameState game, IBody body, Player player, Direction2 direction) : base(CommandType.ShootProjectileFromPlanet, game) { var bodyShape = body.Shape; var d = Difference2.In(direction, 0.9f.U()); this.ps = new CommandParameters( this.game.GetUniqueId <FreeObject>(), player, bodyShape.Center + d * bodyShape.Radius.NumericValue * 1.5f, body.Velocity + d / TimeSpan.One ); }
public NavQuad(Position2 SW, Position2 SE, Position2 NW, Position2 NE) { this.SW = SW; this.SE = SE; this.NW = NW; this.NE = NE; this.Center = new Position2((SW.NumericValue + SE.NumericValue + NW.NumericValue + NE.NumericValue) / 4); this.uDiff1 = SE - SW; this.vDiff1 = NW - SW; this.uDiff2 = NW - NE; this.vDiff2 = SE - NE; this.area1 = triangleArea(this.uDiff1, this.vDiff1); this.area2 = triangleArea(this.uDiff2, this.vDiff2); this.Links = this.links.AsReadOnly(); }
public void Update() { var p = this.collider.Position; var r = this.collider.Radius; var d = new Difference2(r, r); var tiles = this.game.Level.RectangleIntersecting(p - d, d * 2); if (tiles == this.currentTiles) return; this.clearTuples(); this.tileCount = tiles.Tiles; this.ensureTuples(); this.fillTiles(tiles); this.currentTiles = tiles; }
public void Update() { var p = this.collider.Position; var r = this.collider.Radius; var d = new Difference2(r, r); var tiles = this.game.Level.RectangleIntersecting(p - d, d * 2); if (tiles == this.currentTiles) { return; } this.clearTuples(); this.tileCount = tiles.Tiles; this.ensureTuples(); this.fillTiles(tiles); this.currentTiles = tiles; }
public Ray(Position2 start, Difference2 direction) { this.Start = start; this.Direction = direction; }
private static bool isInCone(Difference2 difference, Direction2 visionDirection, Angle visionHalfAngle) { return((difference.Direction - visionDirection).Abs() < visionHalfAngle); }
private bool canBePerceivedFrom(Difference2 difference) { return(difference.LengthSquared < this.maxRadiusSquared); }
public IEnumerable<Tile<TileInfo>> TilesIntersecting(Position2 point, Difference2 size) { return this.TilesIn(this.RectangleIntersecting(point, size)); }
public TileRectangle RectangleIntersecting(Position2 point, Difference2 size) { var tl = point.NumericValue; var br = tl + size.NumericValue; int x0, x1, y0, y1; this.positionToTile(tl.X, tl.Y, out x0, out y0); this.positionToTile(br.X, br.Y, out x1, out y1); return new TileRectangle(x0, y0, x1, y1); }
private Footprint(IEnumerable <Step> tileOffsets, Difference2 rootTileOffset) { this.tileOffsets = tileOffsets; this.rootTileOffset = rootTileOffset; }
public IEnumerable <Tile <TileInfo> > TilesIntersecting(Position2 point, Difference2 size) { return(this.TilesIn(this.RectangleIntersecting(point, size))); }