Example #1
0
 public override void Update(Room room, Player player)
 {
     timer++;
     if (life == 2)
     {
         angle -= 4f / pathRadius;
     }
     else if (life == 1)
     {
         float distance = Vector2.Distance(position, player.position);
         float speed = 4f + 4f * (radius + player.radius) / distance;
         angle += speed / pathRadius;
     }
     position = center + pathRadius * Helper.AngleToVector2(angle);
     if (!IsHurt && timer >= 90)
     {
         timer = 0;
         float rotation = Helper.Vector2ToAngle(player.position - position);
         RingBullet ring;
         if (life == 3)
         {
             ring = new RingBullet(position, 0f, rotation, 6, 10f, bulletTexture, 180);
         }
         else
         {
             ring = new HomingRingBullet(position, 0f, rotation, 6, 10f, bulletTexture, 180,
                 life == 2 ? 1f : 2f);
         }
         ring.radiusSpeed = 4f;
         room.bullets.Add(ring);
     }
 }
Example #2
0
        public override void Update(Room room, Player player)
        {
            Vector2 offset = player.position - position;
            float distance = offset.Length();
            float range = Tile.tileSize * 6f;
            float speed = 2f;
            if (Math.Abs(distance - range) < speed)
            {
                speed = Math.Abs(distance - range);
            }
            if (distance != 0f)
            {
                offset *= speed / distance;
            }
            if (distance < range)
            {
                offset *= -1f;
            }
            bool collided;
            TopLeft = Collision.MovePos(TopLeft, size, size, offset, room, out collided);

            offset = player.position - position;
            shootTimer++;
            if (shootTimer >= maxShootTimer)
            {
                float rotation = (float)(Main.rand.NextDouble() * 2 * Math.PI);
                RingBullet bullet = new RingBullet(player.position, ringRadius, rotation, 5, 10f, fireTexture, 600);
                bullet.radiusSpeed = ringRadiusSpeed;
                bullet.rotationSpeed = ringAngleSpeed;
                room.bullets.Add(bullet);
                shootTimer = 0;
            }
        }
Example #3
0
 private void CircleAttack(Room room, Player player)
 {
     const float ringRadius = 800f;
     const float radiusSpeed = -2f;
     int waitTime = 30 + 30 * life;
     if (timer % waitTime == 0 && timer <= 600)
     {
         float rotation = (float)(Main.rand.NextDouble() * 2 * Math.PI);
         RingBullet bullet = new RingBullet(player.position, ringRadius, rotation, 6, 10f, fireTexture, 600);
         bullet.radiusSpeed = radiusSpeed;
         bullet.rotationSpeed = 0.03f - 0.005f * life;
         if (Main.rand.Next(2) == 0)
         {
             bullet.rotationSpeed *= -1f;
         }
         room.bullets.Add(bullet);
     }
     timer++;
     if (timer >= 600 - ringRadius / radiusSpeed)
     {
         phase++;
         timer = 0;
     }
 }