Ejemplo n.º 1
0
 /// <summary>
 /// Only fire the gun if the gun has stopped turning
 /// </summary>
 /// <param name="firepower"></param>
 internal bool CheckFire(double firepower)
 {
     if (Math.Abs(_robot.GunTurnRemainingRadians) < 0.01d && _robot.GunHeat <= 0.0d)
     {
         _robot.SetFire(firepower);
         return(true);
     }
     return(false);
 }
Ejemplo n.º 2
0
        internal void SetScannedRobot(ScannedRobotEvent evnt)
        {
            if (_target == null)
            {
                _target = new Enemy(evnt.Name);
            }
            if (!_target.Name.Equals(evnt.Name, StringComparison.OrdinalIgnoreCase))
            {
                return;
            }
            _target.UpdateState(evnt, _self.X, _self.Y);

            var offset = Rectify(_target.Bearing + _self.Heading - _self.RadarHeading) * 1.5;

            _self.SetTurnRadarRight(offset);

            var power = GetGunPower();


            offset = Rectify(_target.Bearing + _self.Heading - _self.GunHeading);
//            offset = AdjustGunOffset(offset, power);
            _self.SetTurnGunRight(offset);

            _self.SetFire(power);

//            var x = random.Next(_self.SentryBorderSize, (int)_self.BattleFieldWidth - _self.SentryBorderSize);
//            var y = random.Next(_self.SentryBorderSize, (int)_self.BattleFieldHeight - _self.SentryBorderSize);
//            var x = random.NextDouble() * (_self.BattleFieldWidth - _self.SentryBorderSize) + _self.SentryBorderSize / 2;
//            var y = random.NextDouble() * (_self.BattleFieldHeight - _self.SentryBorderSize) + _self.SentryBorderSize / 2;
//            var distance = Math.Sqrt((x - _self.X) * (x - _self.X) + (y - _self.Y) * (y - _self.Y));
//            double angle = Math.Atan((x - _self.X) / (y - _self.Y)) * 180 / Math.PI - _self.Heading;

            var    distance = random.Next(20, 40);
            double angle    = GetMoveAngle(distance);

            //var tolerance = _self.SentryBorderSize;
            //if (_target.Distance < tolerance &&
            //    (_self.X > tolerance && _self.X < _self.BattleFieldWidth - tolerance) &&
            //    (_self.Y > tolerance && _self.Y < _self.BattleFieldHeight - tolerance))
            //    angle = Rectify(angle + 90);
            if (_self.TurnRemaining < 1)
            {
                _self.SetTurnRight(Rectify(angle));
            }
            if (_self.DistanceRemaining < 10)
            {
                _self.SetAhead(distance);
            }
        }