public Enemy(EnemyType type, Level l) { this.Type = type; Health = 1; VelocityModifier = 1.0f; InitializeTimer = 0; Alpha = 1.0f; alphaIncrease = 0.03f; level = l; DashCooldown = 0; Initialized = false; TwirlRotation = 0; SlowRotation = 0; ImprintSpawn = 0; Origin = new Vector2(Type.Texture.Width / 2, Type.Texture.Height / 2); if (Type.Equals(level.DashEnemy)) { Animation = new Animation(Type.Texture, 40, 0.01f); Origin = new Vector2(Animation.FrameWidth / 2, Animation.Texture.Height / 2); } SpawnAnimation = new Animation(l.EnemySpawnTexture, 200.0f, 0.1f); SpawnAlpha = 0.01f; }
// Spawns a group of one enemy type in a corner public void SpawnCornerGroup(int count, EnemyType type) { // Choose a corner int ranCorner = r.Next(4); Vector2 cornerPos; if (ranCorner == 0) { cornerPos = new Vector2(GameRectangle.Left + 50, GameRectangle.Top + 50); } else if (ranCorner == 1) { cornerPos = new Vector2(GameRectangle.Right - 50, GameRectangle.Top + 50); } else if (ranCorner == 2) { cornerPos = new Vector2(GameRectangle.Left + 50, GameRectangle.Bottom - 50); } else { cornerPos = new Vector2(GameRectangle.Right - 50, GameRectangle.Bottom - 50); } // Spawn enemies for (int i = 0; i < count; i++) { if (type.Equals(ClusterEnemy)) { int ran2 = r.Next(3) + 1; for (int j = 0; j < ran2; j++) { Vector2 spawn2 = new Vector2(cornerPos.X + r.Next(-30, 30), cornerPos.Y + r.Next(-30, 30)); SpawnEnemy(ClusterEnemy, spawn2); } } else { Vector2 ranPos = new Vector2(cornerPos.X + r.Next(-50, 50), cornerPos.Y + r.Next(-50, 50)); SpawnEnemy(type, ranPos); } } }
// Spawns an enemy in a random position public void SpawnEnemy(EnemyType type, Vector2 pos) { // Make a new enemy Enemy e = new Enemy(type, this); // Let the enemy use our random number generator (for randomness amongst enemies) e.r = this.r; // Choose closest pod if we behave that way if (type.Behavior.Equals(EnemyType.EnemyBehavior.DashTowardsPlayer) || type.Behavior.Equals(EnemyType.EnemyBehavior.MoveTowardsPlayer)) { Pod pod = GetClosestPod(pos); e.DestinationPod = pod; } // float in random direction e.Position = pos; // Start by fading in e.Alpha = 0; Enemies.Add(e); }
// 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"); }