public override void Update() { angle += angleV; //change angle every frame //circle boss with a distance of 50 x = (float)Math.Cos(angle) * 50 + boss.x; y = (float)Math.Sin(angle) * 50 + boss.y; angleToPlayer = MyMath.PointToPointAngle(x, y, game.player.x, game.player.y); if (gunID == 0) {//shoots at player every 50 frames within an error of 15 degrees count++; if (count % 50 == 0) { game.enemyBullets.Add(new EnemyBullet(x, y, MyRandom.PlusMinus(15 * MyMath.Deg2Rad) + angleToPlayer, 8f)); } } else if (gunID == 1) {//every 100 frames, shoots a shotgun blast of 10 bullets with varying speeds at the player, whithin an error of 45 degrees count++; if (count % 100 == 0) { for (int i = 0; i < 10; i++) { game.enemyBullets.Add(new EnemyBullet(x, y, MyRandom.PlusMinus(45 * MyMath.Deg2Rad) + angleToPlayer, MyRandom.Range(1, 8))); } } } else if (gunID == 2) {//every 10 frames shoots in a random direction count++; if (count % 10 == 0) { game.enemyBullets.Add(new EnemyBullet(x, y, MyRandom.PlusMinus(180 * MyMath.Deg2Rad), 8f)); } } else if (gunID == 3) {//for 10 frames shoo in a circular pattern, resets after 40 frames count++; if (count < 10) { game.enemyBullets.Add(new EnemyBullet(x, y, count * 36 * MyMath.Deg2Rad, count)); } if (count > 50) { count = 0; } } }
public override void Update() { if (state == State.Appear) { x -= 5; if (x <= 750) { state = State.Normal; } } else if (state == State.Normal) { if (playerY > y) { y += 1; } if (playerY < y) { y -= 1; } x += (float)Math.Cos((bulletCount * 3) * MyMath.Deg2Rad); y += (float)Math.Sin((bulletCount * 3) * MyMath.Deg2Rad); bulletCount++; if (bulletCount == 100) { for (int i = 0; i < 50; i++) { game.enemyBullets.Add(new EnemyBullet(x, y, MyRandom.Range(150, 210) * MyMath.Deg2Rad, MyRandom.Range(1f, 8f))); } bulletCount = 0; } if (playerX > x) { for (int i = 0; i < 20; i++) { game.enemyBullets.Add(new EnemyBullet(x, y, MyRandom.PlusMinus(45) * MyMath.Deg2Rad, MyRandom.Range(1f, 8f))); } } } else if (state == State.Swoon) { swoonTime--; if (swoonTime <= 0) { state = State.Angry; } } else if (state == State.Angry) { specialAbilityCount++; if (specialAbilityCount < 100) { if (specialAbilityCount % 2 == 0) { x = x + specialAbilityCount; } if (specialAbilityCount % 2 == 1) { x = x - specialAbilityCount; } } if (specialAbilityCount == 100) { x = Screen.Width + 100; } if (specialAbilityCount == 150) { x = MyRandom.Range(0, Screen.Width); y = MyRandom.Range(0, Screen.Height); for (int i = 0; i < 360; i += 20) { game.enemyBullets.Add(new EnemyBullet(x, y, i * MyMath.Deg2Rad, 8f)); } for (int i = 10; i < 360; i += 20) { game.enemyBullets.Add(new EnemyBullet(x, y, i * MyMath.Deg2Rad, 4f)); } } if (specialAbilityCount == 200) { specialAbilityCount = 0; } } else if (state == State.Dying) { dyingTime--; y += .2f; angle += .2f * MyMath.Deg2Rad; x = MyRandom.Range(x - 2f, x + 2f); if (dyingTime % 4 == 0) { game.explosions.Add(new Explosion( MyRandom.Range(x - Size / 2, x + Size / 2), MyRandom.Range(y - Size / 2, y + Size / 2))); } if (dyingTime <= 0) { isDead = true; for (int i = 0; i < 25; i++) { game.explosions.Add(new Explosion( MyRandom.Range(x - Size / 2, x + Size / 2), MyRandom.Range(y - Size / 2, y + Size / 2))); } } } }