Пример #1
0
        public override void Update(GameTime gameTime)
        {
            //Från ditt shooterspel
            direction = target.pos - pos;
            direction.Normalize();
            pos += direction * (speed * 50) * gameTime.ElapsedGameTime.Milliseconds / 1000;

            rectangle = new Rectangle((int)pos.X, (int)pos.Y, size, size);

            angle = (float)(Math.Atan2(pos.Y - target.pos.Y, pos.X - target.pos.X) - Math.PI / 2); // Radianer?!?!?!?!??!?!?!

            if (Vector2.Distance(pos, target.pos) < 10)
            {
                dead = true;

                TowerShooting.NewExplotion(target.pos);

                foreach (EnemyBase enemy in EnemyController.EnemyList)
                {
                    if (Vector2.Distance(pos, enemy.pos) < 100)
                    {
                        enemy.TakeDamage((float)(damage - (0.35 * Vector2.Distance(pos, enemy.pos))));
                    }
                }
                target.TakeDamage(damage);
            }
        }
Пример #2
0
 protected override void shoot(GameTime gameTime, EnemyBase target)
 {
     //Skada fiende
     target.TakeDamage(damage * (float)gameTime.ElapsedGameTime.TotalSeconds);
     //Rita ut "lasern"
     if (currentTarget != target)
     {
         TowerShooting.NewLaser(pos, target, range);
     }
 }
Пример #3
0
        public override void Update(GameTime gameTime)
        {
            //Från ditt shooterspel
            direction = target.pos - pos;
            direction.Normalize();
            pos += direction * (speed * 50) * gameTime.ElapsedGameTime.Milliseconds / 1000;

            rectangle = new Rectangle((int)pos.X, (int)pos.Y, size, size);

            if (rectangle.Intersects(target.rectangle))
            {
                dead = true;
                target.TakeDamage(damage);
            }
        }
Пример #4
0
 protected virtual void shoot(GameTime gameTime, EnemyBase target)
 {
     target.TakeDamage(damage * (float)gameTime.ElapsedGameTime.TotalSeconds);
 }