Example #1
0
        public override void OnScannedRobot(ScannedRobotEvent e)
        {
            // Calculate exact location of the robot
            double absoluteBearing = Heading + e.Bearing;
            double bearingFromGun = Utils.NormalRelativeAngle(absoluteBearing - GunHeading);

            // If it's close enough, fire!
            if (Math.Abs(bearingFromGun) <= 3)
            {
                TurnGunRight(bearingFromGun);
                // We check gun heat here, because calling Fire()
                // uses a turn, which could cause us to lose track
                // of the other robot.
                if (GunHeat == 0 && bullet == null)
                {
                    Bullet lbullet = FireBullet(Math.Min(3 - Math.Abs(bearingFromGun), Energy - .1));

                    bullet = lbullet;
                }
            } // otherwise just set the gun to turn.
                // Note:  This will have no effect until we call Scan()
            else
            {
                TurnGunRight(bearingFromGun);
            }
            // Generates another scan event if we see a robot.
            // We only need to call this if the gun (and therefore radar)
            // are not turning.  Otherwise, scan is called automatically.
            if (bearingFromGun == 0)
            {
                Scan();
            }
        }
Example #2
0
        // P U B L I C   M E T H O D S
        // ---------------------------
        public BulletData(Bullet bulletStats,
						  Point2D bulletOrigin, 
						  Point2D bulletDestination)
        {
            Stats = bulletStats;
            Origin = bulletOrigin;
            Destination = bulletDestination;
        }
Example #3
0
 ///<summary>
 ///  Called by the game to create a new BulletHitEvent.
 ///</summary>
 public BulletHitEvent(string name, double energy, Bullet bullet)
 {
     this.name = name;
     this.energy = energy;
     this.bullet = bullet;
 }
Example #4
0
            public object deserialize(RbSerializerN serializer, ByteBuffer buffer)
            {
                var bullet = new Bullet(0, 0, 0, 0, null, null, false, buffer.getInt());
                string name = serializer.deserializeString(buffer);
                double energy = buffer.getDouble();

                return new BulletHitEvent(name, energy, bullet);
            }
            public object deserialize(RbSerializerN serializer, ByteBuffer buffer)
            {
                var bullet = new Bullet(0, 0, 0, 0, null, null, false, buffer.getInt());

                return new BulletMissedEvent(bullet);
            }
 /// 
 ///<summary>
 ///  Called by the game to create a new BulletMissedEvent.
 ///</summary>
 public BulletMissedEvent(Bullet bullet)
 {
     this.bullet = bullet;
 }
Example #7
0
        public void OnScannedRobot(ScannedRobotEvent evnt)
        {
            count(evnt);

            // Turn gun to point at the Scanned robot
            peer.TurnGun(Utils.NormalAbsoluteAngle(peer.GetBodyHeading() + evnt.BearingRadians - peer.GetGunHeading()));
            //

            // Fire!
            const double power = 1;

            Bullet firedBullet = peer.Fire(power);

            if (firedBullet != null)
            {
                bullet = firedBullet;
            }
        }
        protected Bullet setFireImpl(double power)
        {
            if (Double.IsNaN(power))
            {
                println("SYSTEM: You cannot call Fire(NaN)");
                return null;
            }
            if (getGunHeatImpl() > 0 || getEnergyImpl() == 0)
            {
                return null;
            }

            power = Math.Min(getEnergyImpl(), Math.Min(Math.Max(power, Rules.MIN_BULLET_POWER), Rules.MAX_BULLET_POWER));

            Bullet bullet;
            BulletCommand wrapper;
            Event currentTopEvent = eventManager.getCurrentTopEvent();

            bulletCounter++;

            if (currentTopEvent != null && currentTopEvent.Time == status.Time && !statics.IsAdvancedRobot()
                && status.GunHeadingRadians == status.RadarHeadingRadians
                && typeof (ScannedRobotEvent).IsAssignableFrom(currentTopEvent.GetType()))
            {
                // this is angle assisted bullet
                var e = (ScannedRobotEvent) currentTopEvent;
                double fireAssistAngle = Utils.NormalAbsoluteAngle(status.HeadingRadians + e.BearingRadians);

                bullet = new Bullet(fireAssistAngle, GetX(), GetY(), power, statics.getName(), null, true, bulletCounter);
                wrapper = new BulletCommand(power, true, fireAssistAngle, bulletCounter);
            }
            else
            {
                // this is normal bullet
                bullet = new Bullet(status.GunHeadingRadians, GetX(), GetY(), power, statics.getName(), null, true,
                                    bulletCounter);
                wrapper = new BulletCommand(power, false, 0, bulletCounter);
            }

            firedEnergy += power;
            firedHeat += Rules.GetGunHeat(power);

            commands.getBullets().Add(wrapper);

            bullets.Add(bulletCounter, bullet);

            return bullet;
        }
 // Needed for .NET version
 internal override void UpdateBullets(Dictionary <int, Bullet> bullets)
 {
     // we need to pass same instance
     bullet = bullets[bullet.getBulletId()];
 }
Example #10
0
 /// <summary>
 /// Called by the game to create a new HitByBulletEvent.
 /// </summary>
 public HitByBulletEvent(double bearing, Bullet bullet)
 {
     this.bearing = bearing;
     this.bullet = bullet;
 }
Example #11
0
 public void update(Bullet bullet, double x, double y, string victimName, bool isActive)
 {
     bullet.update(x, y, victimName, isActive);
 }
Example #12
0
 ///<summary>
 ///  Called by the game to create a new BulletHitEvent.
 ///</summary>
 public BulletHitBulletEvent(Bullet bullet, Bullet hitBullet)
 {
     this.bullet = bullet;
     this.hitBullet = hitBullet;
 }
Example #13
0
            public object deserialize(RbSerializerN serializer, ByteBuffer buffer)
            {
                var bullet = new Bullet(0, 0, 0, 0, null, null, false, buffer.getInt());
                var hitBullet = (Bullet) serializer.deserializeAny(buffer);

                return new BulletHitBulletEvent(bullet, hitBullet);
            }
Example #14
0
 public void update(Bullet bullet, double x, double y, string victimName, bool isActive)
 {
     bullet.update(x, y, victimName, isActive);
 }
            public object deserialize(RbSerializerN serializer, ByteBuffer buffer)
            {
                var bullet = new Bullet(0, 0, 0, 0, null, null, false, buffer.getInt());

                return(new BulletMissedEvent(bullet));
            }
Example #16
0
 // Needed for .NET version
 internal override void UpdateBullets(Dictionary<int, Bullet> bullets)
 {
     // we need to pass same instance
     bullet = bullets[bullet.getBulletId()];
 }
Example #17
0
 public static void Update(Bullet bullet, double x, double y, string victimName, bool isActive)
 {
     bulletHelper.update(bullet, x, y, victimName, isActive);
 }
 ///
 ///<summary>
 ///  Called by the game to create a new BulletMissedEvent.
 ///</summary>
 public BulletMissedEvent(Bullet bullet)
 {
     this.bullet = bullet;
 }