/// <summary> /// Updates the logic and conditional checking for the test boss. /// </summary> /// <param name="gameTime"></param> public override void Update(GameTime gameTime) { float dt = (float)gameTime.ElapsedGameTime.TotalMilliseconds; stageTimer += dt; bulletTimer += dt; float theta = stageTimer / 1000f; //Velocity = new Vector2((float)Math.Cos(theta), (float)Math.Sin(theta)) * 100f; if (bulletTimer > 500f) { bulletTimer = 0f; for (int i = 0; i < 4; i++) { Player p = GetPlayer(i); if (p != null) { float angle = GetAngleBetweenSprite(p); Vector2 vel = new Vector2((float)Math.Cos(angle), (float)Math.Sin(angle)) * 500f; LinearBullet b = new LinearBullet(EntitySide.ENEMY, 7000f, vel) { Texture = BulletTexture, Position = Position, Size = new Point(15, 8), Color = Color.YellowGreen, }; CurrentStage.AddBullet(b); } } } vortexSpawnTimer -= dt; if ((float)(Health) / MAX_HEALTH < 0.5f && vortexSpawnTimer <= 0) { vortexSpawnTimer = 3000f; int Swidth = ScreenManager.GetInstance().Width; int Sheight = ScreenManager.GetInstance().Height; VortexEnemy en = new VortexEnemy(CurrentStage.Players, 4, 4000f, 10000f) { Velocity = new Vector2(0, -200f), Position = new Vector2(200, Sheight), Texture = vortexEnemyTexture, BulletTexture = Blank, Size = new Point(vortexEnemyTexture.Width * SCALE, vortexEnemyTexture.Height * SCALE), }; VortexEnemy en2 = new VortexEnemy(CurrentStage.Players, 4, 4000f, 10000f) { Velocity = new Vector2(0, -200f), Position = new Vector2(Swidth - 200, Sheight), Texture = vortexEnemyTexture, BulletTexture = Blank, Size = new Point(vortexEnemyTexture.Width * SCALE, vortexEnemyTexture.Height * SCALE), }; en.SetBullets(Bullets); en2.SetBullets(Bullets); CurrentStage.AddEnemy(en); CurrentStage.AddEnemy(en2); } //Position += Velocity * (float)gameTime.ElapsedGameTime.TotalSeconds; //Velocity = Vector2.Zero; // no velocity, position is fixed int width = ScreenManager.GetInstance().Width; int height = ScreenManager.GetInstance().Height; Position = new Vector2((float)(Math.Cos(theta) + 1) / 2 * width * 0.75f + 0.125f * width, (float)(Math.Sin(theta) + 1) / 2 * height / 4 + 200); base.Update(gameTime); }
/// <summary> /// Updates the logic and conditional checking for the test boss. /// </summary> /// <param name="gameTime"></param> public override void Update(GameTime gameTime) { float dt = (float)gameTime.ElapsedGameTime.TotalMilliseconds; stageTimer += dt; bulletTimer += dt; sunBeamSafeTimer -= dt; float theta = stageTimer / 1000f; //Velocity = new Vector2((float)Math.Cos(theta), (float)Math.Sin(theta)) * 100f; if (sunBeamSafeTimer < 0 && stageTimer > 5000f) { sunBeamChargeTimer -= dt; if (sunBeamChargeTimer <= 0) { // fire sunBeamTimer -= dt; Vector2 v = (isVertical) ? new Vector2(0, -400f) : new Vector2(400, 0); for (int i = 1; i <= 4; i++) { Vector2 pos = (isVertical) ? new Vector2(i * ScreenManager.GetInstance().Width / 5, ScreenManager.GetInstance().Height) : new Vector2(0, i * ScreenManager.GetInstance().Height / 5); LinearBullet b = new LinearBullet(EntitySide.ENEMY, 7000f, v) { Texture = BulletTexture, Position = pos, Size = new Point(30, 50), Color = Color.LightGoldenrodYellow, }; CurrentStage.AddBullet(b); } if (sunBeamTimer <= 0) { sunBeamSafeTimer = SUN_BEAM_SAFE_TIMER; sunBeamTimer = SUN_BEAM_FIRE_TIMER; sunBeamChargeTimer = SUN_BEAM_CHARGE_TIMER; isVertical = rand.Next(0, 2) == 0; } } } if (stageTimer > 12000f) { sunSpawnTimer += (float)gameTime.ElapsedGameTime.TotalMilliseconds; if (sunSpawnTimer > 5000) { sunSpawnTimer = 0f; int rad = 100; for (int i = 0; i < CurrentStage.GetPlayerCount(); i++) { Vector2 newPos = new Vector2(Position.X + rand.Next(-rad, rad), Position.Y + rand.Next(-rad, rad)); MiniSun s = new MiniSun(Players) { BulletTexture = sunBullet, Position = newPos, Health = 3, Color = Color.White, Texture = Texture, Size = new Point(Texture.Width * SCALE / 3, Texture.Height * SCALE / 3), }; CurrentStage.AddEnemy(s); } } } if (bulletTimer > 400f) { bulletTimer = 0f; for (int i = 0; i < 4; i++) { Player p = GetPlayer(i); if (p != null) { float angle = GetAngleBetweenSprite(p); Vector2 vel = new Vector2((float)Math.Cos(angle), (float)Math.Sin(angle)) * 500f; LinearBullet b = new LinearBullet(EntitySide.ENEMY, 7000f, vel) { Texture = sunBullet, Position = Position, Size = new Point(32, 32), Color = Color.White, }; CurrentStage.AddBullet(b); } } } //Position += Velocity * (float)gameTime.ElapsedGameTime.TotalSeconds; //Velocity = Vector2.Zero; // no velocity, position is fixed int width = ScreenManager.GetInstance().Width; int height = ScreenManager.GetInstance().Height; Position = new Vector2((float)(Math.Cos(theta) + 1) / 2 * width * 0.75f + 0.125f * width, (float)(Math.Sin(theta) + 1) / 2 * height / 4 + 200); base.Update(gameTime); }
public override void Update(GameTime gameTime) { float dt = (float)gameTime.ElapsedGameTime.TotalMilliseconds; timer += dt; spawnTimer += dt; spawnTimer2 += dt; if (Health <= 0) { stage = AsteroidBossStage.DYING; } switch (stage) { case AsteroidBossStage.APPEARING: if (Position.Y < 200) { Velocity = new Vector2(0, 200); } else { timer = 0; stage = AsteroidBossStage.FIRING; } break; case AsteroidBossStage.FIRING: if (spawnTimer > 300f) { spawnTimer = 0; for (int i = 0; i < Players.Length; i++) { if (Players[i] != null) { float scale = (float)(rand.NextDouble() * (SCALE - 3) + 3f); float speed = 1600 / (float)Math.Sqrt(scale); float angle = GetAngleBetweenSprite(Players[i]); Vector2 dir = new Vector2((float)Math.Cos(angle), (float)Math.Sin(angle)); Texture2D aster = asteroidTextures[rand.Next(0, 5)]; Asteroid a = new Asteroid(Bullet.EntitySide.ENEMY, 7000f, dir * speed) { Texture = aster, Position = Position, Size = new Point((int)(aster.Width * scale), (int)(aster.Height * scale)), Health = (int)(Math.Ceiling(scale / 2)), Color = Color.White, InitVelocity = dir * speed, }; CurrentStage.AddBullet(a); } } if (timer > 10000) { timer = 0; stage = AsteroidBossStage.HIDING; } } break; case AsteroidBossStage.HIDING: if (Position.Y > -300) { Velocity = new Vector2(0, -200); } else { if (spawnTimer > 60f) { spawnTimer = 0; Vector2 pos = new Vector2(rand.Next(-100, ScreenManager.GetInstance().Width + 100), -90); float scale = (float)(rand.NextDouble() * (SCALE - 3) + 3f); float speed = 1000 / (float)Math.Sqrt(scale); Texture2D aster = asteroidTextures[rand.Next(0, 5)]; float xSpeed = (float)((rand.NextDouble() - 0.5f) * 100f); float iRot = (float)(rand.NextDouble() * MathHelper.TwoPi); Asteroid a = new Asteroid(Bullet.EntitySide.ENEMY, 7000f, new Vector2(xSpeed, speed)) { Texture = aster, Position = pos, Size = new Point((int)(aster.Width * scale), (int)(aster.Height * scale)), Health = (int)(Math.Ceiling(scale / 2)), Color = Color.White, InitVelocity = new Vector2(xSpeed, speed), Rotation = iRot, }; Bullets.Add(a); } if (timer > 14000) { timer = 0; stage = AsteroidBossStage.APPEARING; } } break; case AsteroidBossStage.DYING: Velocity = new Vector2(0, -100); if (Position.Y < -200) { IsActive = false; } break; } if (Health <= 0) { stage = AsteroidBossStage.DYING; } if (stage != AsteroidBossStage.HIDING && Position.Y > 0) { CheckBulletCollision(); } if (Health / MAX_HEALTH < 0.4f) { if (spawnTimer2 > 800) { spawnTimer2 = 0; Vector2 pos = new Vector2(rand.Next(-100, ScreenManager.GetInstance().Width + 100), -90); float scale = (float)(rand.NextDouble() * (SCALE - 3) + 3f); float speed = 1000 / (float)Math.Sqrt(scale); Texture2D aster = asteroidTextures[rand.Next(0, 5)]; float xSpeed = (float)((rand.NextDouble() - 0.5f) * 100f); Asteroid a = new Asteroid(Bullet.EntitySide.ENEMY, 7000f, new Vector2(xSpeed, speed)) { Texture = aster, Position = pos, Size = new Point((int)(aster.Width * scale), (int)(aster.Height * scale)), Health = (int)Math.Ceiling(scale / 2), Color = Color.White, InitVelocity = new Vector2(xSpeed, speed), }; Bullets.Add(a); } } Rotation += dt / 10000 * MathHelper.TwoPi; Position += Velocity * (float)gameTime.ElapsedGameTime.TotalSeconds; Velocity = Vector2.Zero; }
/// <summary> /// Updates the logic and conditional checking for the test boss. /// </summary> /// <param name="gameTime"></param> public override void Update(GameTime gameTime) { float dt = (float)gameTime.ElapsedGameTime.TotalMilliseconds; stageTimer += dt; bulletTimer += dt; sinSpawner -= dt; sinSpawner2 -= dt; float theta = stageTimer / 1000f; //Velocity = new Vector2((float)Math.Cos(theta), (float)Math.Sin(theta)) * 100f; if (bulletTimer > 300f) { bulletTimer = 0f; for (int i = 0; i < 4; i++) { Player p = GetPlayer(i); if (p == null) { p = CurrentStage.GetRandomPlayer(); } float rot = MathHelper.PiOver2 * i + Rotation; Vector2 offset = new Vector2((float)(Math.Cos(rot)), (float)(Math.Sin(rot))) * 220f; Vector2 pos = Position + offset; float angle = GetAngleBetweenSprite(p, pos); Vector2 vel = new Vector2((float)Math.Cos(angle), (float)Math.Sin(angle)) * 800f; LinearBullet b = new LinearBullet(EntitySide.ENEMY, 7000f, vel) { Texture = BulletTexture, Position = pos, Size = new Point(18, 8), Color = Color.OrangeRed, }; CurrentStage.AddBullet(b); } } vortexSpawnTimer -= dt; if ((float)(Health) / MAX_HEALTH < 0.75f && vortexSpawnTimer <= 0) { vortexSpawnTimer = 2500f; int Swidth = ScreenManager.GetInstance().Width; int Sheight = ScreenManager.GetInstance().Height + 200; VortexEnemy en = new VortexEnemy(CurrentStage.Players, 4, 4000f, 10000f) { Velocity = new Vector2(0, -200f), Position = new Vector2(200, Sheight), Texture = vortexEnemyTexture, BulletTexture = Blank, Size = new Point(vortexEnemyTexture.Width * 3, vortexEnemyTexture.Height * 3), }; VortexEnemy en2 = new VortexEnemy(CurrentStage.Players, 4, 4000f, 10000f) { Velocity = new Vector2(0, -200f), Position = new Vector2(Swidth - 200, Sheight), Texture = vortexEnemyTexture, BulletTexture = Blank, Size = new Point(vortexEnemyTexture.Width * 3, vortexEnemyTexture.Height * 3), }; CurrentStage.AddEnemy(en); CurrentStage.AddEnemy(en2); } if ((float)Health / MAX_HEALTH < 0.5f && sinSpawner <= 0) { sinSpawner = 1750f; CurrentStage.SpawnSinEnemy(new Vector2(ScreenManager.GetInstance().Width + 100, 300), false); } if ((float)Health / MAX_HEALTH <= 0.3f && sinSpawner2 <= 0) { sinSpawner2 = 1750f; CurrentStage.SpawnInvisSinEnemy(new Vector2(-100, 300), true); } if (opacity < 1) { opacity += (float)gameTime.ElapsedGameTime.TotalSeconds / 3; } //Position += Velocity * (float)gameTime.ElapsedGameTime.TotalSeconds; //Velocity = Vector2.Zero; // no velocity, position is fixed int width = ScreenManager.GetInstance().Width; int height = ScreenManager.GetInstance().Height; Position = new Vector2((float)(Math.Cos(theta) + 1) / 2 * width * 0.75f + 0.125f * width, (float)(Math.Sin(theta) + 1) / 2 * height / 4 + 200); Rotation += dt / 3000 * MathHelper.TwoPi; base.Update(gameTime); }