Beispiel #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);
            }
        }
 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);
     }
 }
Beispiel #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);
            }
        }
 protected virtual void shoot(GameTime gameTime, EnemyBase target)
 {
     target.TakeDamage(damage * (float)gameTime.ElapsedGameTime.TotalSeconds);
 }