Пример #1
0
        public virtual void TargetClosestEnemy(List<Enemy> enemies)
        {
            this.target = null;
            float smallest = radius;

            foreach (Enemy enemy in enemies)
            {
                if (Vector2.Distance(base.center, enemy.Center) < smallest)
                {
                    smallest = Vector2.Distance(base.center, enemy.Center);
                    this.target = enemy;
                }
            }
        }
Пример #2
0
        public override void Update(GameTime gametime)
        {
            base.Update(gametime);
            this.bulletTime += (float)gametime.ElapsedGameTime.TotalSeconds;

            if (this.target != null)
            {
                this.FaceTarget();
                if (!this.CanReach(this.target.Center) || target.isDead)
                {
                    this.target = null;
                    this.bulletTime = 0;
                }
            }
        }