public List <Tuple <GFStatKey, double> > Update(IContext context)
        {
            var guessFactorArray = new List <Tuple <GFStatKey, double> >();

            bool removeVirtualBullet = true;

            while (removeVirtualBullet)
            {
                double?   guessFactor = null;
                GFStatKey key         = null;

                removeVirtualBullet = _vbs.Any() && _vbs.Peek().IsFinished(context, out key, out guessFactor);

                if (removeVirtualBullet && key != null && guessFactor.HasValue)
                {
                    guessFactorArray.Add(new Tuple <GFStatKey, double>(key, guessFactor.Value));
                }
                if (removeVirtualBullet)
                {
                    _vbs.Dequeue();
                }
            }

            return(guessFactorArray);
        }
Ejemplo n.º 2
0
 public VirtualBullet(IContext context)
 {
     _myLocationOriginal = new Vector(context.MyLocation);
     _target             = context.Target;
     _directOriginal     = new Vector(context.Target.LastBlipDirect);
     _key            = new GFStatKey(context.Target);
     _initialTime    = context.Time;
     _bulletSpeed    = context.AimResult.Speed;
     _maxEscapeAngle = GetMaximumEscapeAngle(context.AimResult.Speed);
 }
        public void UpdateHit(IEnumerable <Tuple <GFStatKey, double> > gfs)
        {
            foreach (var kvp in gfs)
            {
                GFStatKey key         = kvp.Item1;
                double    guessFactor = kvp.Item2;

                UpdateHit(key, guessFactor);
            }
        }
        public GuessFactorData GetGuessFactorData(IEnemy enemy)
        {
            var key = new GFStatKey(enemy);

            if (_stats.ContainsKey(key))
            {
                return(_stats[key].GetGuessFactorData());
            }
            else
            {
                var value = new GFStatValue();
                _stats.Add(key, value);
                return(value.GetGuessFactorData());
            }
        }
 public void UpdateHit(GFStatKey key, double gf)
 {
     if (-1d <= gf && gf <= 1d)
     {
         if (_stats.ContainsKey(key))
         {
             _stats[key].Update(gf);
         }
         else
         {
             var value = new GFStatValue();
             value.Update(gf);
             _stats.Add(key, value);
         }
     }
 }
Ejemplo n.º 6
0
        public bool IsFinished(IContext context, out GFStatKey key, out double?guessFactor)
        {
            guessFactor = null;
            key         = null;

            long currentTime = context.Time;

            _currentRadius = _bulletSpeed * (currentTime - _initialTime);
            _directCurrent = _target.LastBlipDirect;

            // not context.Direct!, because the target may have changed
            bool isPassedEnemy = _directCurrent.Magnitude < _currentRadius;

            if (isPassedEnemy)
            {
                // the bullet has passed over the enemy
                double angle = (_directCurrent.Heading - _directOriginal.Heading).Degrees180;
                guessFactor = angle / _maxEscapeAngle;
                key         = _key;
            }
            return(isPassedEnemy);
        }