public Bullet(BulletType bType, Vector2 velocity, Level level) { this.Type = bType; this.Velocity = velocity; this.level = level; Reset(); }
public Gun(Texture2D texture, float fireRate, BulletType bullet) { this.texture = texture; this.FireRate = fireRate; this.bullet = bullet; Origin = new Vector2(texture.Width / 2, texture.Height / 2); GunOrigin = new Vector2(15, 15); }
// Spawns a light fade with set scale public void SpawnLightFade(Vector2 Pos, BulletType bt, float fadePerFrame, float newScale) { // Choose the right texture Texture2D texture; if (bt.Equals(RedBullet)) { texture = RedLight; } else if (bt.Equals(BlueBullet)) { texture = BlueLight; } else if (bt.Equals(GreenBullet)) { texture = GreenLight; } else { texture = YellowLight; } Particle p = null; if (ParticlePool.Count > 0) { p = ParticlePool.Pop(); p.Reset(); p.Texture = texture; p.Position = Pos; } else { p = new Particle(texture, Pos); } p.Velocity = Vector2.Zero; p.LightFadeParticle = true; p.FadeDecrease = fadePerFrame; p.Scale = newScale; Particles.Add(p); }
// Spawn explosion public void SpawnExplosion(List<Particle> ParticleList, int count, Vector2 Pos, BulletType bt, int minVel, int range, float fadePerFrame) { for(int i = 0; i < count; i++) { float rotation = ((float)r.Next(628)) / 10.0f; float vel = ((float)r.Next(range * 10)) / 10.0f; vel += (float)minVel; Vector2 velocity = new Vector2(vel * (float)Math.Cos(rotation), vel * (float)Math.Sin(rotation)); // Choose the right texture Texture2D texture; Color c = Color.White; if (bt.Equals(RedBullet)) { texture = RedExplosionParticle; } else if (bt.Equals(BlueBullet)) { texture = BlueExplosionParticle; } else if (bt.Equals(GreenBullet)) { texture = GreenExplosionParticle; } else if(bt.Equals(YellowBullet)) { texture = YellowExplosionParticle; } else { texture = YellowGunExplosionParticle; } Particle p = null; if (ParticlePool.Count > 0) { p = ParticlePool.Pop(); p.Reset(); p.Texture = texture; p.Position = Pos; } else { p = new Particle(texture, Pos); } p.color = c; p.Velocity = velocity; p.Acceleration = -(p.Velocity / 200.0f); p.ExplosionParticle = true; if (fadePerFrame == 0) { p.RocketParticle = true; } p.FadeDecrease = fadePerFrame; ParticleList.Add(p); } }
// Loads all the content for the level public void LoadContent() { // Loads the background boxes backgroundBoxTexture = Content.Load<Texture2D>("Graphics/BackgroundBox"); topRight = topLeft = bottomRight = bottomLeft = Color.LightGreen; LinesHighscoresLevel = Content.Load<Texture2D>("Graphics/Menu/LinesHighscoresLevel"); // Loads each gun into existance // Red Gun RedBullet = new BulletType(Content.Load<Texture2D>("Graphics/Bullets/RedBullet"), 5.0f, 15, BulletType.BulletProperties.Fire, 6.0f, 25, 0.01f); Red = new Gun(Content.Load<Texture2D>("Graphics/Pods/RedShip"), 350.0f, RedBullet); Red.GunTexture = Content.Load<Texture2D>("Graphics/Pods/RedWeapon"); Red.Color = Color.Orange; // Yellow Gun YellowBullet = new BulletType(Content.Load<Texture2D>("Graphics/Bullets/YellowBullet"), 100.0f, 50, BulletType.BulletProperties.Bounce, 5.0f, 36, 0.02f); YellowBulletReplaced = new BulletType(Content.Load<Texture2D>("Graphics/Bullets/YellowBullet"), 100.0f, 50, BulletType.BulletProperties.Bounce, 5.0f, 40, 0); Yellow = new Gun(Content.Load<Texture2D>("Graphics/Pods/YellowShip"), 350.0f, YellowBullet); Yellow.GunTexture = Content.Load<Texture2D>("Graphics/Pods/YellowWeapon"); Yellow.Color = Color.LightYellow; // Green Gun GreenBullet = new BulletType(Content.Load<Texture2D>("Graphics/Bullets/GreenBullet"), 50.0f, 25, BulletType.BulletProperties.None, 10.0f, 38, 0); Green = new Gun(Content.Load<Texture2D>("Graphics/Pods/GreenShip"), 125.0f, GreenBullet); Green.GunTexture = Content.Load<Texture2D>("Graphics/Pods/GreenWeapon"); Green.Color = Color.LightGreen; // Blue Gun BlueBullet = new BulletType(Content.Load<Texture2D>("Graphics/Bullets/BlueBullet"), 20.0f, 12, BulletType.BulletProperties.Ice, 10.0f, 45, 0); Blue = new Gun(Content.Load<Texture2D>("Graphics/Pods/BlueShip"), 190.0f, BlueBullet); Blue.GunTexture = Content.Load<Texture2D>("Graphics/Pods/BlueWeapon"); Blue.Color = Color.LightBlue; // Loads the various enemies FollowEnemy = new EnemyType(Content.Load<Texture2D>("Graphics/Enemies/Follow"), 6.0f, 15, 50, EnemyType.EnemyBehavior.MoveTowardsPlayer); DashEnemy = new EnemyType(Content.Load<Texture2D>("Graphics/Enemies/Dash"), 9.0f, 20, 50, EnemyType.EnemyBehavior.DashTowardsPlayer); FloatEnemy = new EnemyType(Content.Load<Texture2D>("Graphics/Enemies/Random"), 4.0f, 10, 50, EnemyType.EnemyBehavior.Float); ClusterEnemy = new EnemyType(Content.Load<Texture2D>("Graphics/Enemies/Cluster"), 4.0f, 5, 16, EnemyType.EnemyBehavior.MoveTowardsPlayer); SnakeEnemy = new EnemyType(Content.Load<Texture2D>("Graphics/Enemies/Snake"), 3.0f, 15, 30, EnemyType.EnemyBehavior.Snake); EnemySpawnTexture = Content.Load<Texture2D>("Graphics/Enemies/Spawn"); EnemySpawnOrigin = new Vector2(100, EnemySpawnTexture.Height / 2); // ThinkFast BlueIcon = Content.Load<Texture2D>("Graphics/ThinkFast/BlueIcon"); BlueMode = Content.Load<Texture2D>("Graphics/ThinkFast/BlueMode"); DontMoveMode = Content.Load<Texture2D>("Graphics/ThinkFast/DontMoveMode"); DontShootMode = Content.Load<Texture2D>("Graphics/ThinkFast/DontShootMode"); GreenIcon = Content.Load<Texture2D>("Graphics/ThinkFast/GreenIcon"); GreenMode = Content.Load<Texture2D>("Graphics/ThinkFast/GreenMode"); RedIcon = Content.Load<Texture2D>("Graphics/ThinkFast/RedIcon"); RedMode = Content.Load<Texture2D>("Graphics/ThinkFast/RedMode"); StopMIcon = Content.Load<Texture2D>("Graphics/ThinkFast/StopSIcon"); StopSIcon = Content.Load<Texture2D>("Graphics/ThinkFast/StopMIcon"); YellowIcon = Content.Load<Texture2D>("Graphics/ThinkFast/YellowIcon"); YellowMode = Content.Load<Texture2D>("Graphics/ThinkFast/YellowMode"); ThinkFastOrigin = new Vector2(BlueMode.Width / 2, BlueMode.Height / 2); ThinkFastIconPoint = new Vector2(640, 85); ThinkFastIconOrigin = new Vector2(BlueIcon.Width / 2, BlueIcon.Height / 2); // The point dots PointDotTexture = Content.Load<Texture2D>("Graphics/Extras/PointDot"); // The travel points WhitePoint = Content.Load<Texture2D>("Graphics/Waypoints/MPTravel2"); WhitePointOutside = Content.Load<Texture2D>("Graphics/Waypoints/MPTravel1"); RedPoint = Content.Load<Texture2D>("Graphics/Waypoints/RedTravel2"); RedPointOutside = Content.Load<Texture2D>("Graphics/Waypoints/RedTravel1"); BluePoint = Content.Load<Texture2D>("Graphics/Waypoints/BlueTravel2"); BluePointOutside = Content.Load<Texture2D>("Graphics/Waypoints/BlueTravel1"); YellowPoint = Content.Load<Texture2D>("Graphics/Waypoints/YellowTravel2"); YellowPointOutside = Content.Load<Texture2D>("Graphics/Waypoints/YellowTravel1"); GreenPoint = Content.Load<Texture2D>("Graphics/Waypoints/GreenTravel2"); GreenPointOutside = Content.Load<Texture2D>("Graphics/Waypoints/GreenTravel1"); gameFont = Content.Load<SpriteFont>("Fonts/Quartz"); gameFontLarge = Content.Load<SpriteFont>("Fonts/QuartzLarge"); gameFontExtraLarge = Content.Load<SpriteFont>("Fonts/QuartzExtraLarge"); // HUDS RedHudTime = Content.Load<Texture2D>("Graphics/HUD/SPTHudRed"); RedHudNoTime = Content.Load<Texture2D>("Graphics/HUD/SPNTHudRed"); GreenHudTime = Content.Load<Texture2D>("Graphics/HUD/SPTHudGreen"); GreenHudNoTime = Content.Load<Texture2D>("Graphics/HUD/SPNTHudGreen"); BlueHudTime = Content.Load<Texture2D>("Graphics/HUD/SPTHudBlue"); BlueHudNoTime = Content.Load<Texture2D>("Graphics/HUD/SPNTHudBlue"); YellowHudTime = Content.Load<Texture2D>("Graphics/HUD/SPTHudYellow"); YellowHudNoTime = Content.Load<Texture2D>("Graphics/HUD/SPNTHudYellow"); TwoPlayerHudTime = Content.Load<Texture2D>("Graphics/HUD/MPTHud2"); TwoPlayerHudNoTime = Content.Load<Texture2D>("Graphics/HUD/MPNTHud2"); ThreePlayerHudTime = Content.Load<Texture2D>("Graphics/HUD/MPTHud3"); ThreePlayerHudNoTime = Content.Load<Texture2D>("Graphics/HUD/MPNTHud3"); FourPlayerHudTime = Content.Load<Texture2D>("Graphics/HUD/MPTHud4"); FourPlayerHudNoTime = Content.Load<Texture2D>("Graphics/HUD/MPNTHud4"); // Powerups FourWayShoot = Content.Load<Texture2D>("Graphics/Extras/FourWayPU2"); FourWayShootSpin = Content.Load<Texture2D>("Graphics/Extras/FourWayPU1"); FastShoot = Content.Load<Texture2D>("Graphics/Extras/SpeedPU2"); FastShootSpin = Content.Load<Texture2D>("Graphics/Extras/SpeedPU1"); OneUp = Content.Load<Texture2D>("Graphics/Extras/OneUpPU2"); OneUpSpin = Content.Load<Texture2D>("Graphics/Extras/OneUpPU1"); // The zone textures WhiteZoneLit = Content.Load<Texture2D>("Graphics/Zones/MPZoneA1"); WhiteZoneLitOutside = Content.Load<Texture2D>("Graphics/Zones/MPZoneA2"); WhiteZoneUnlit = Content.Load<Texture2D>("Graphics/Zones/MPZoneIA1"); WhiteZoneUnlitOutside = Content.Load<Texture2D>("Graphics/Zones/MPZoneIA2"); BlueZoneLit = Content.Load<Texture2D>("Graphics/Zones/BlueZoneA1"); BlueZoneLitOutside = Content.Load<Texture2D>("Graphics/Zones/BlueZoneA2"); BlueZoneUnlit = Content.Load<Texture2D>("Graphics/Zones/BlueZoneIA1"); BlueZoneUnlitOutside = Content.Load<Texture2D>("Graphics/Zones/BlueZoneIA2"); RedZoneLit = Content.Load<Texture2D>("Graphics/Zones/RedZoneA1"); RedZoneLitOutside = Content.Load<Texture2D>("Graphics/Zones/RedZoneA2"); RedZoneUnlit = Content.Load<Texture2D>("Graphics/Zones/RedZoneIA1"); RedZoneUnlitOutside = Content.Load<Texture2D>("Graphics/Zones/RedZoneIA2"); YellowZoneLit = Content.Load<Texture2D>("Graphics/Zones/YellowZoneA1"); YellowZoneLitOutside = Content.Load<Texture2D>("Graphics/Zones/YellowZoneA2"); YellowZoneUnlit = Content.Load<Texture2D>("Graphics/Zones/YellowZoneIA1"); YellowZoneUnlitOutside = Content.Load<Texture2D>("Graphics/Zones/YellowZoneIA2"); GreenZoneLit = Content.Load<Texture2D>("Graphics/Zones/GreenZoneA1"); GreenZoneLitOutside = Content.Load<Texture2D>("Graphics/Zones/GreenZoneA2"); GreenZoneUnlit = Content.Load<Texture2D>("Graphics/Zones/GreenZoneIA1"); GreenZoneUnlitOutside = Content.Load<Texture2D>("Graphics/Zones/GreenZoneIA2"); // Sound effects GreenLaserSound = Content.Load<SoundEffect>("Sound/GreenLaser"); ExplosionSound = Content.Load<SoundEffect>("Sound/Explosion"); RedSound = Content.Load<SoundEffect>("Sound/Red"); YellowSound = Content.Load<SoundEffect>("Sound/Yellow"); BlueSound = Content.Load<SoundEffect>("Sound/Blue"); PowerUpSound = Content.Load<SoundEffect>("Sound/PowerUpSound"); ThinkFastWarning = Content.Load<SoundEffect>("Sound/ThinkFastFinal"); DeathSound = Content.Load<SoundEffect>("Sound/DeathSoundEffect3"); // Particles RegularParticle = Content.Load<Texture2D>("Graphics/Particles/Particle"); BlueParticle = Content.Load<Texture2D>("Graphics/Particles/BParticle"); YellowParticle = Content.Load<Texture2D>("Graphics/Particles/YParticle"); RedParticle = Content.Load<Texture2D>("Graphics/Particles/RParticle"); GreenParticle = Content.Load<Texture2D>("Graphics/Particles/GParticle"); RedExplosionParticle = Content.Load<Texture2D>("Graphics/Particles/REParticle"); BlueExplosionParticle = Content.Load<Texture2D>("Graphics/Particles/BEParticle"); YellowExplosionParticle = Content.Load<Texture2D>("Graphics/Particles/YEParticle"); YellowGunExplosionParticle = Content.Load<Texture2D>("Graphics/Particles/YCParticle"); GreenExplosionParticle = Content.Load<Texture2D>("Graphics/Particles/GEParticle"); RedLight = Content.Load<Texture2D>("Graphics/Particles/RELight"); BlueLight = Content.Load<Texture2D>("Graphics/Particles/BELight"); YellowLight = Content.Load<Texture2D>("Graphics/Particles/YELight"); GreenLight = Content.Load<Texture2D>("Graphics/Particles/GELight"); PulseTexture = RegularParticle; BlankPixel = Content.Load<Texture2D>("Graphics/Extras/BlankDot"); }