Example #1
0
 public void SetTarget(List<Enemy> enemies)
 {
     Target = null;
     var smallestRange = Radius;
     foreach (var enemy in enemies)
     {
         if (!(Vector2.Distance(Сenter, enemy.Сenter) < smallestRange)) continue;
         smallestRange = Vector2.Distance(Сenter, enemy.Сenter);
         Target = enemy;
     }
 }
Example #2
0
 private void AddEnemy()
 {
     var enemy = new Enemy(_enemyTexture, _level.WayPoints.Peek(), 50, 1, 2f);
     enemy.SetWayPoints(_level.WayPoints);
     _enemies.Add(enemy);
     _spawnTimer = 0;
     _enemiesSpawned++;
 }
Example #3
0
        public override void Update(GameTime gameTime)
        {
            base.Update(gameTime);
            BulletTimer += (float)gameTime.ElapsedGameTime.TotalSeconds;
            if (Target != null)
            {

                if (!IsInRange(Target.Сenter) || Target.IsDead)
                {
                    Target = null;
                    BulletTimer = 0;
                }
                else
                {
                    FaceTarget();
                }
            }
        }