Beispiel #1
0
 private static void GetShots(List <Bullet> bullets, List <UnitModel> units)
 {
     foreach (var bullet in bullets)
     {
         foreach (var unit in units)
         {
             if (MathModule.Length(bullet.Position - unit.Position) < 10)
             {
                 bullet.Exist = false;
                 unit.GetShot(bullet.Damage);
             }
         }
     }
 }
Beispiel #2
0
        public void Move(float deltaTime)
        {
            var delta     = Destination - Position;
            var wayLength = MathModule.Length(delta);

            if (wayLength < 0.01)
            {
                return;
            }
            if (wayLength < _speed)
            {
                Position = Destination;
            }
            else
            {
                var move = delta * (float)(_speed / wayLength) * deltaTime;
                Position += move;
            }
        }
Beispiel #3
0
        public bool AbleToFire(Vector2f target)
        {
            var distance = MathModule.Length(target - Position);

            return((distance > _minRange) && (distance < _maxRange));
        }