// passes in texture because loading content for each bullet is slow! public static Bullet[] CreateBullet(Texture2D texture,BulletType bulletType,Vector2 direction, Colour colour, bool[] HostileToPlayer, Player p) { Bullet[] bullets = new Bullet[1]; //Texture2D texture; float speed = NORMAL_SPEED; float time = NORMAL_TIME; float scale = NORMAL_SCALE; switch (bulletType) { case (Bullet.BulletType.Normal): bullets[0] = new Bullet(texture, direction, speed, time, colour, HostileToPlayer, bulletType, scale, p); break; case (Bullet.BulletType.Trident): //texture = content.Load<Texture2D>("Bullets/RedTrident"); speed = NORMAL_SPEED; time = NORMAL_TIME; scale = NORMAL_SCALE; bullets = new Bullet[3]; bullets[0] = new Bullet(texture, direction, speed, time, colour, HostileToPlayer, bulletType, scale, p); bullets[1] = new Bullet(texture, RotateVector(direction, (float)Math.PI / 6), speed, time, colour, HostileToPlayer, bulletType, scale, p); bullets[2] = new Bullet(texture, RotateVector(direction, -(float)Math.PI / 6), speed, time, colour, HostileToPlayer, bulletType, scale, p); break; case (Bullet.BulletType.Bubble): //texture = content.Load<Texture2D>("Bullets/BlueBubble"); speed = NORMAL_SPEED; time = NORMAL_TIME; scale = NORMAL_SCALE; bullets[0] = new Bullet(texture, direction, speed, time, colour, HostileToPlayer, bulletType, scale, p); break; case (Bullet.BulletType.Razor): //texture = content.Load<Texture2D>("Bullets/YellowRazor"); speed = NORMAL_SPEED; time = NORMAL_TIME; scale = NORMAL_SCALE; bullets[0] = new Bullet(texture, direction, speed, time, colour, HostileToPlayer, bulletType, scale, p); break; case (Bullet.BulletType.Magnet): //texture = content.Load<Texture2D>("Bullets/GreenMagnet"); speed = NORMAL_SPEED; time = NORMAL_TIME; scale = NORMAL_SCALE; bullets[0] = new Bullet(texture, direction, speed, time, colour, HostileToPlayer, bulletType, scale, p); break; } // create a new entity using the loaded sprite return bullets; }
public void Hit(Bullet b) { hits++; if (hits >= 5) { state = BoatState.dead; deathSplatter.CreateDeathSplatter(position + (60.0f * b.dir) , b.Rotation); } switch (b.type) { case(Bullet.BulletType.Bubble): velocity += b.dir * 100.0f; break; } }