public void OnScannedRobot(IContext context, ScannedRobotEvent evnt) { Blips.OnScannedRobot(context, evnt); if (Blips.Any()) { VelocityVector = new Vector(Blips.Last().Velocity, Blips.Last().Heading); LateralVelocityScalar = VelocityVector.Magnitude * Math.Sin((VelocityVector.Heading - Direct.Heading).Radians); RadialVelocityScalar = VelocityVector.Magnitude * Math.Cos((VelocityVector.Heading - Direct.Heading).Radians); LateralVelocityVector = new Vector(LateralVelocityScalar, Direct.Heading.Perpendicular); RadialVelocityVector = new Vector(RadialVelocityScalar, Direct.Heading); if (Blips.Count > 1) { Vector previousVelocity = new Vector(Blips.Penultimate().Velocity, Blips.Penultimate().Heading); AccelerationVector = (VelocityVector - previousVelocity) / (Blips.Last().Time - Blips.Penultimate().Time); LateralAccelerationScalar = AccelerationVector.Magnitude * Math.Sin((AccelerationVector.Heading - Direct.Heading).Radians); RadialAccelerationScalar = AccelerationVector.Magnitude * Math.Cos((AccelerationVector.Heading - Direct.Heading).Radians); LateralAccelerationVector = new Vector(LateralAccelerationScalar, Direct.Heading.Perpendicular); RadialAccelerationVector = new Vector(RadialAccelerationScalar, Direct.Heading); } } }
public IEnumerable <Vector> GetPifData(long delta) { var pif = Blips.GetPifRelativeVectors(delta); if (pif != null && pif.Any()) { return(pif); } return(null); }
public Enemy(IContext context, ScannedRobotEvent evnt) { _context = context; var name = evnt.Name; VirtualBullets = new VirtualBullets(); GuessFactorStats = new GuessFactorStatistics(); Waves = new WaveCollection(); Blips = new Blips(); _enemyGuessFactorStats = new EnemyGuessFactorStatistics(); Predictions = new PredictionCollection(); MyBullets = new BulletCollection(name); OnScannedRobot(context, evnt); }
public void Render(IGraphics graphics) { if (Blips != null) { Blips.Render(graphics); } if (VirtualBullets != null) { VirtualBullets.Render(graphics); } if (Waves != null) { Waves.Render(graphics); } if (GuessFactorStats != null) { GuessFactorStats.Render(graphics); } if (_enemyGuessFactorStats != null) { _enemyGuessFactorStats.Render(graphics); } if (Predictions != null) { Predictions.Render(graphics); } //if (Location != null && LateralVelocity != null) //{ // graphics.DrawPolygon(Pens.Yellow, // new PointF[] // { // Location.ToPointF(), // (Location + 20d * LateralVelocity).ToPointF() // }); //} //if (Location != null && RadialVelocity != null) //{ // graphics.DrawPolygon(Pens.Yellow, // new PointF[] // { // Location.ToPointF(), // (Location + 20d * RadialVelocity).ToPointF() // }); //} //if (Location != null && LateralAceleration != null) // //{ // graphics.DrawPolygon(Pens.Orange, // new PointF[] // { // Location.ToPointF(), // (Location + 100d * LateralAceleration).ToPointF() // }); //if (Location != null && RadialAceleration != null) //{ // graphics.DrawPolygon(Pens.Orange, // new PointF[] // { // Location.ToPointF(), // (Location + 100d * RadialAceleration).ToPointF() // }); //} }