public override void Ctrl() { base.Ctrl(); if (!this.OnSpell) { this.Armon = 0.0f; } switch (this.Life) { case 0: this.Velocity = 0.0f; this.DestPoint = (PointF) new Point(this.Ran.Next(100, this.BoundRect.Width - 100), this.Ran.Next(70, 200)); break; case 1: this.Ctrl1(); break; case 2: this.Ctrl2(); break; case 3: this.Ctrl3(); break; case 4: this.Ctrl4(); break; case 5: this.Ctrl5(); break; } this.MoveToPoint(this.DestPoint); if (!this.OnSpell) { if ((double)this.HealthPoint >= (double)this.SpellcardHP && this.Time <= this.SpellTime) { return; } this.HealthPoint = (float)this.SpellcardHP; this.Time = 0; this.OnSpell = true; ShootingStarShard shootingStarShard = new ShootingStarShard(this.StageData, new PointF((float)(this.BoundRect.Width / 2), 0.0f)); } else if ((double)this.HealthPoint <= 0.0 || this.Time > this.SpellTime) { --this.Life; Rectangle boundRect; if ((double)this.HealthPoint <= 0.0 && this.Life >= -1) { this.GiveItems(); StageDataPackage stageData = this.StageData; boundRect = this.BoundRect; PointF OriginalPosition = new PointF((float)(boundRect.Width / 2), 0.0f); ShootingStarShard shootingStarShard = new ShootingStarShard(stageData, OriginalPosition); } if (this.Life <= 0) { if (this.Life == 0) { int x = this.Ran.Next((int)this.OriginalPosition.X - 30, (int)this.OriginalPosition.X + 30); MyRandom ran = this.Ran; PointF originalPosition = this.OriginalPosition; int minValue = (int)originalPosition.Y + 30; originalPosition = this.OriginalPosition; int maxValue = (int)originalPosition.Y + 50; int y = ran.Next(minValue, maxValue); this.DestPoint = (PointF) new Point(x, y); this.Velocity = 0.5f; BulletRemover2 bulletRemover2 = new BulletRemover2(this.StageData, this.OriginalPosition); this.HealthPoint = 0.0f; this.GiveEndEffect(); this.Life = -1; } } else { BulletRemover2 bulletRemover2 = new BulletRemover2(this.StageData, this.OriginalPosition); this.StageData.SoundPlay("se_tan00.wav"); this.HealthPoint = (float)this.MaxHP; this.Time = 0; this.OnSpell = false; boundRect = this.BoundRect; this.DestPoint = (PointF) new Point(boundRect.Width / 2, 120); this.Velocity = 4f; } } }
public void RandomMove1(int T, float velocity) { if (this.Time % T == 0) { double x1 = (double)this.OriginalPosition.X; Rectangle boundRect = this.BoundRect; double num1 = (double)(boundRect.Width / 2 - 50); if (x1 < num1) { MyRandom ran1 = this.Ran; boundRect = this.BoundRect; int minValue1 = boundRect.Width / 2 + 50; boundRect = this.BoundRect; int maxValue1 = boundRect.Width - 110; double num2 = (double)ran1.Next(minValue1, maxValue1); MyRandom ran2 = this.Ran; boundRect = this.BoundRect; int minValue2 = boundRect.Top + 100; boundRect = this.BoundRect; int maxValue2 = boundRect.Top + 150; double num3 = (double)ran2.Next(minValue2, maxValue2); this.DestPoint = new PointF((float)num2, (float)num3); } else { double x2 = (double)this.OriginalPosition.X; boundRect = this.BoundRect; double num2 = (double)(boundRect.Width / 2 + 50); if (x2 > num2) { MyRandom ran1 = this.Ran; boundRect = this.BoundRect; int maxValue1 = boundRect.Width / 2 - 50; double num3 = (double)ran1.Next(110, maxValue1); MyRandom ran2 = this.Ran; boundRect = this.BoundRect; int minValue = boundRect.Top + 100; boundRect = this.BoundRect; int maxValue2 = boundRect.Top + 150; double num4 = (double)ran2.Next(minValue, maxValue2); this.DestPoint = new PointF((float)num3, (float)num4); } else { double x3 = (double)this.MyPlane.OriginalPosition.X; boundRect = this.BoundRect; double num3 = (double)(boundRect.Width / 2); if (x3 < num3) { MyRandom ran1 = this.Ran; boundRect = this.BoundRect; int maxValue1 = boundRect.Width / 2 - 50; double num4 = (double)ran1.Next(110, maxValue1); MyRandom ran2 = this.Ran; boundRect = this.BoundRect; int minValue = boundRect.Top + 100; boundRect = this.BoundRect; int maxValue2 = boundRect.Top + 150; double num5 = (double)ran2.Next(minValue, maxValue2); this.DestPoint = new PointF((float)num4, (float)num5); } else { MyRandom ran1 = this.Ran; boundRect = this.BoundRect; int minValue1 = boundRect.Width / 2 + 50; boundRect = this.BoundRect; int maxValue1 = boundRect.Width - 110; double num4 = (double)ran1.Next(minValue1, maxValue1); MyRandom ran2 = this.Ran; boundRect = this.BoundRect; int minValue2 = boundRect.Top + 100; boundRect = this.BoundRect; int maxValue2 = boundRect.Top + 150; double num5 = (double)ran2.Next(minValue2, maxValue2); this.DestPoint = new PointF((float)num4, (float)num5); } } } this.Velocity = velocity; } this.MoveToPoint(this.DestPoint); }
public Spell_AyaB_Laser(StageDataPackage StageData, PointF OriginalPosition, bool Left) { this.StageData = StageData; this.SpellList.Add((BaseObject)this); this.OriginalPosition = OriginalPosition; this.Damage = 50; this.Region = 25; this.LifeTime = 20; this.Velocity = 50f; this.ScaleLength = 2f; this.ScaleWidth = 1f; this.TxtureObject = this.TextureObjectDictionary["Laser"]; if (this.Boss != null && ((double)this.Boss.OriginalPosition.X > 0.0 && (double)this.Boss.OriginalPosition.X < (double)this.BoundRect.Width && (double)this.Boss.OriginalPosition.Y > 0.0 && (double)this.Boss.OriginalPosition.Y < (double)this.BoundRect.Height)) { this.Target = (BaseObject)this.Boss; } if (this.Target == null) { double dist = 500.0; this.EnemyPlaneList.ForEach((Action <BaseEnemyPlane>)(x => { double distance = this.GetDistance((BaseObject)x); if (distance >= dist) { return; } this.Target = (BaseObject)x; dist = distance; })); } PointF originalPosition; Rectangle boundRect; if (this.Target == null) { this.Target = new BaseObject() { OriginalPosition = new PointF(OriginalPosition.X + (float)this.Ran.Next(-80, 80), OriginalPosition.Y + (float)this.Ran.Next(-80, 80)) }; originalPosition = this.Target.OriginalPosition; if ((double)originalPosition.Y < 0.0) { BaseObject target = this.Target; originalPosition = this.Target.OriginalPosition; PointF pointF = new PointF(originalPosition.X, 0.0f); target.OriginalPosition = pointF; } else { originalPosition = this.Target.OriginalPosition; if ((double)originalPosition.Y > (double)this.BoundRect.Height) { BaseObject target = this.Target; originalPosition = this.Target.OriginalPosition; double x = (double)originalPosition.X; boundRect = this.BoundRect; double height = (double)boundRect.Height; PointF pointF = new PointF((float)x, (float)height); target.OriginalPosition = pointF; } } } int num1; if (!Left) { boundRect = this.BoundRect; num1 = boundRect.Width + 150; } else { num1 = -150; } double num2 = (double)num1; MyRandom ran = this.Ran; originalPosition = this.Target.OriginalPosition; int minValue = (int)originalPosition.Y - 80; originalPosition = this.Target.OriginalPosition; int maxValue = (int)originalPosition.Y + 80; double num3 = (double)ran.Next(minValue, maxValue); this.OriginalPosition = new PointF((float)num2, (float)num3); this.Direction = this.GetDirection(this.Target); this.SpellList[0].OriginalPosition = this.Target.OriginalPosition; }
public override void Update() { if (state == State.Appear) { x += (float)Math.Cos(angle) * 5; y += (float)Math.Sin(angle) * 5; foreach (Turrent turrent in turrents) { turrent.Update(); } if (Math.Abs(MyMath.DistanceBetweenTwoPoints(x, y, CenterPointX, CenterPointY)) < Screen.Width / 2 - Size) {//once the boss reaches a certain portion of the screen move into the main phase state = State.Normal; } } else if (state == State.Normal) { angleToPlayer = MyMath.PointToPointAngle(x, y, game.player.x, game.player.y); foreach (Turrent turrent in turrents) { turrent.Update(); } TurrentCollisionWithPlayerBullet(); //these are needed because these lists are in this class as opposed to the game class PointsForBlowingUpTurrent(); //award 50 points for blowing up a turrent turrents.RemoveAll(t => t.isDead); //remove dead turrents if (turrents.Count < turrentCount + 1) { turrentCount--; mad = true; } if (mad == true) { madCount++; angle += 4 * angleV; //move faster if (madCount == 180) { angleV = -angleV; //reverse direction after "mad" phase madCount = 0; mad = false; } } else { angle += angleV; //default movement speed } x = (float)Math.Cos(angle) * -MyMath.DistanceBetweenTwoPoints(CenterPointX, CenterPointY, x, y) + Screen.Width / 2; y = (float)Math.Sin(angle) * -MyMath.DistanceBetweenTwoPoints(CenterPointX, CenterPointY, x, y) + Screen.Height / 2; if (turrents.Count == 0) { state = State.Swoon; //once turrents are destroyed go into swoon state } } else if (state == State.Swoon) {//state bofore 2nd phase swoonTime--; if (swoonTime <= 0) { state = State.Angry; } } else if (state == State.Angry) {//2nd phase angleToPlayer = MyMath.PointToPointAngle(x, y, game.player.x, game.player.y); if (specialAbilityCount == 0) { 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 > 100) { if (specialAbilityCount % 2 == 0) { x = x + specialAbilityCount - 100; } if (specialAbilityCount % 2 == 1) { x = x - specialAbilityCount + 100; } } if (specialAbilityCount == 200) { specialAbilityCount = 0; state = State.Invincible; } specialAbilityCount++; } else if (state == State.Invincible) {//this is when the boss teleports away - can't be hit in this state specialAbilityCount++; if (specialAbilityCount < 50) { x = game.player.x; y = game.player.y; } if (specialAbilityCount == 100) { specialAbilityCount = 0; state = State.Angry; } } else if (state == State.Dying) {//Death animation dyingTime--; y += .2f; angleToPlayer += .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))); } } } }
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 UpdateData() { if (TimeMain == 50) { BaseEffect baseEffect = new BaseEffect(StageData, "woshixingtu", new PointF(385f, 240f), 4f, 0.0); baseEffect.AngleDegree = 90.0; baseEffect.Active = false; baseEffect.DestPoint = new PointF(320f, 240f); baseEffect.AngleWithDirection = false; baseEffect.Scale = 1f; baseEffect.TransparentValueF = 0.0f; baseEffect.TransparentVelocity = 5f; } else if (TimeMain == 100) { BaseEffect baseEffect = new BaseEffect(StageData, "woshibiaotihebaisi", new PointF(385f, 240f), 4f, 0.0); baseEffect.AngleDegree = 90.0; baseEffect.Active = false; baseEffect.DestPoint = new PointF(320f, 240f); baseEffect.AngleWithDirection = false; baseEffect.Scale = 1f; baseEffect.TransparentValueF = 0.0f; baseEffect.TransparentVelocity = 5f; EmitterTitleStarFall emitterTitleStarFall = new EmitterTitleStarFall(StageData); StageData.MenuGroupList.Add(new MenuGroup_Main(StageData)); } else if (TimeMain == 130) { SelectBox selectBox = new SelectBox(StageData); selectBox.Velocity = 100f; selectBox.OriginalPosition = new PointF(0.0f, 500f); SelectFrame = selectBox; } if (StageData.MenuGroupList.Count > 0) { BaseMenuItem menuItem1 = StageData.MenuGroupList[StageData.MenuGroupList.Count - 1].MenuItemList[StageData.MenuGroupList[StageData.MenuGroupList.Count - 1].MenuSelectIndex]; PointF pointF1; if (StageData.MenuGroupList.Count == 1 || StageData.MenuGroupList[StageData.MenuGroupList.Count - 1] is MenuOption) { StageDataPackage stageData = StageData; MyRandom ran = Ran; pointF1 = menuItem1.OriginalPosition; int minValue = (int)pointF1.X - 10; pointF1 = menuItem1.OriginalPosition; int maxValue = (int)pointF1.X + menuItem1.TxtureObject.PosRect.Width + 10; double num1 = ran.Next(minValue, maxValue); pointF1 = menuItem1.OriginalPosition; double num2 = pointF1.Y + 20.0; PointF Position = new PointF((float)num1, (float)num2); double num3 = StageData.Ran.Next(10, 20) / 10; double Direction = -1.0 * Math.PI / 2.0 - StageData.Ran.Next(1, 5) / 10.0; Particle particle = new Particle(stageData, "Star", Position, (float)num3, Direction); particle.Active = true; particle.Scale = StageData.Ran.Next(15, 40) / 100f; particle.LifeTime = 20; } if (SelectFrame != null) { BaseMenuItem menuItem2 = StageData.MenuGroupList[0].MenuItemList[StageData.MenuGroupList[0].MenuSelectIndex]; pointF1 = SelectFrame.DestPoint; double y1 = pointF1.Y; pointF1 = menuItem2.OriginalPosition; double y2 = pointF1.Y; if (Math.Abs((float)(y1 - y2 - 6.0)) >= 1.0) { BaseEffect selectFrame = SelectFrame; pointF1 = SelectFrame.DestPoint; double y3 = pointF1.Y; pointF1 = menuItem2.OriginalPosition; double y4 = pointF1.Y; double num = Math.Abs((float)(y3 - y4 - 6.0)) / 5.0; selectFrame.Velocity = (float)num; if (SelectFrame.Velocity > 16.0) { SelectFrame.Velocity = 16f; } else if (SelectFrame.Velocity < 2.0) { SelectFrame.Velocity = 2f; } } BaseEffect selectFrame1 = SelectFrame; pointF1 = menuItem2.OriginalPosition; PointF pointF2 = new PointF(0.0f, (float)(pointF1.Y + 6.0)); selectFrame1.DestPoint = pointF2; } } base.UpdateData(); if (0 <= TimeMain && TimeMain < 130) { BackgroundLight += 4; if (BackgroundLight <= byte.MaxValue) { return; } BackgroundLight = byte.MaxValue; } else { BackgroundLight = byte.MaxValue; } }
public void Update() { if (state == State.Normal) { if (enemySpawnCount < maxEnemyCount) { if (game.enemies.Count < waveCount * 2) { enemySpawnCount++; screenSpawnPosition = MyRandom.Range(0, 4); //spawn enemy from one side if (screenSpawnPosition == 0) { game.enemies.Add(new Zako3(game, Screen.Width, MyRandom.Range(0, Screen.Height), HPMultiplier)); if (MyRandom.Range(0, 20) == 0) { game.enemies.Add(new Zako4(game, Screen.Width, MyRandom.Range(0, Screen.Height), HPMultiplier)); } } if (screenSpawnPosition == 1) { game.enemies.Add(new Zako3(game, -64, MyRandom.Range(0, Screen.Height), HPMultiplier)); if (MyRandom.Range(0, 20) == 0) { game.enemies.Add(new Zako4(game, -64, MyRandom.Range(0, Screen.Height), HPMultiplier)); } } if (screenSpawnPosition == 2) { game.enemies.Add(new Zako3(game, MyRandom.Range(0, Screen.Width), Screen.Height, HPMultiplier)); if (MyRandom.Range(0, 20) == 0) { game.enemies.Add(new Zako4(game, MyRandom.Range(0, Screen.Width), Screen.Height, HPMultiplier)); } } else { game.enemies.Add(new Zako3(game, MyRandom.Range(0, Screen.Width), -64, HPMultiplier)); if (MyRandom.Range(0, 20) == 0) { game.enemies.Add(new Zako4(game, MyRandom.Range(0, Screen.Width), -64, HPMultiplier)); } } } } if (enemySpawnCount >= maxEnemyCount && game.enemies.Count == 0) { for (int i = 0; i < waveCount; i++) { screenSpawnPosition = MyRandom.Range(0, 4); if (screenSpawnPosition == 0) { game.enemies.Add(new Boss2(game, Screen.Width, MyRandom.Range(0, Screen.Height), this, HPMultiplier)); } else if (screenSpawnPosition == 1) { game.enemies.Add(new Boss2(game, 0, MyRandom.Range(0, Screen.Height), this, HPMultiplier)); } else if (screenSpawnPosition == 2) { game.enemies.Add(new Boss2(game, MyRandom.Range(0, Screen.Width), Screen.Height, this, HPMultiplier)); } else { game.enemies.Add(new Boss2(game, MyRandom.Range(0, Screen.Width), 0, this, HPMultiplier)); } } state = State.Boss; } } if (state == State.Boss) { if (game.enemies.Count == 0) { if (game.gameType == Game.GameType.Endless) { waveCount++; maxEnemyCount *= waveCount; } if (game.gameType == Game.GameType.EndlessHP) { HPMultiplier++; } enemySpawnCount = 0; state = State.Normal; } } }
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))); } } } }
public void Update() { Input.Update(); //updates inputs if (state == State.Title) { Sound.BGM(Sound.BGMMenu); //play menu music when returning to title screen if (Input.GetButtonDown(DX.PAD_INPUT_8) || Input.GetButtonDown(DX.PAD_INPUT_UP)) {//move up Sound.Play(Sound.menuMovement); menuCount--; if (menuCount < 0) { menuCount = 4; //loop } } else if (Input.GetButtonDown(DX.PAD_INPUT_5) || Input.GetButtonDown(DX.PAD_INPUT_DOWN)) {//move down Sound.Play(Sound.menuMovement); menuCount++; if (menuCount > 4) { menuCount = 0; } } //Pressing Z triggers the bool which in turn activates the 'countdown' //once the 'countdown' counts 60 frames, activate selected option if (Input.GetButtonDown(DX.PAD_INPUT_1)) { Sound.Play(Sound.menuSelect); optionSelected = true; } if (optionSelected) { startCountDown++; } if (menuCount == 0 && startCountDown == 60) { //Normal mode state = State.Restart; optionSelected = false; //reset bool startCountDown = 0; //reset 'countdown' gameType = GameType.Normal; } if (menuCount == 1 && startCountDown == 60) {//Endless mode state = State.Restart; optionSelected = false; startCountDown = 0; gameType = GameType.Endless; } if (menuCount == 2 && startCountDown == 60) {//Endless mode - HP state = State.Restart; optionSelected = false; startCountDown = 0; gameType = GameType.EndlessHP; } if (menuCount == 3 && startCountDown == 60) {//Help optionSelected = false; startCountDown = 0; state = State.Help; } if (menuCount == 4 && startCountDown == 60) {//Options optionSelected = false; startCountDown = 0; state = State.Options; } } if (state == State.Options) { if (Input.GetButtonDown(DX.PAD_INPUT_2) && option == Option.Neutral) {//go back to menu Sound.Play(Sound.cancel); state = State.Title; } //Cicle through the options if (option == Option.Neutral) { if (Input.GetButtonDown(DX.PAD_INPUT_8) || Input.GetButtonDown(DX.PAD_INPUT_UP)) {//Up Sound.Play(Sound.menuMovement); optionCount--; if (optionCount < 0) { optionCount = 2; } } else if (Input.GetButtonDown(DX.PAD_INPUT_5) || Input.GetButtonDown(DX.PAD_INPUT_DOWN)) {//down Sound.Play(Sound.menuMovement); optionCount++; if (optionCount > 2) { optionCount = 0; } } } //If music option was selected if (Input.GetButtonDown(DX.PAD_INPUT_1) && optionCount == 0) { option = Option.Music; } if (option == Option.Music) { //now the player can cicle through the song list if (Input.GetButtonDown(DX.PAD_INPUT_2)) { //back out of music selection Sound.Play(Sound.cancel); option = Option.Neutral; } if (Input.GetButtonDown(DX.PAD_INPUT_8) || Input.GetButtonDown(DX.PAD_INPUT_UP)) {//scroll list up Sound.Play(Sound.menuMovement); musicCount--; if (musicCount < 0) { musicCount = 3; } } else if (Input.GetButtonDown(DX.PAD_INPUT_5) || Input.GetButtonDown(DX.PAD_INPUT_DOWN)) {//scroll list down Sound.Play(Sound.menuMovement); musicCount++; if (musicCount > 3) { musicCount = 0; } } if (Input.GetButtonDown(DX.PAD_INPUT_1)) {//select music that will be played during the game Sound.Play(Sound.menuSelect); if (musicCount == 0) { Sound.musicID = 0; } if (musicCount == 1) { Sound.musicID = 1; } if (musicCount == 2) { Sound.musicID = 2; } if (musicCount == 3) { Sound.musicID = 3; } Sound.SetMusic(); } } //if BGM volume option was selected if (Input.GetButtonDown(DX.PAD_INPUT_1) && optionCount == 1) { option = Option.BGMVolume; Sound.Play(Sound.menuSelect); } if (option == Option.BGMVolume) { if (Input.GetButtonDown(DX.PAD_INPUT_2)) {//back out of BGM Volume setting Sound.Play(Sound.cancel); option = Option.Neutral; } if (Input.GetButtonDown(DX.PAD_INPUT_4) || Input.GetButtonDown(DX.PAD_INPUT_LEFT)) {//press left to lower the volume by 10 Sound.Play(Sound.menuMovement); Sound.BGMVolume -= 10; if (Sound.BGMVolume < 0) { Sound.BGMVolume = 0; } Sound.SetVolume(); //updates the sounds so they actually change volume } if (Input.GetButtonDown(DX.PAD_INPUT_6) || Input.GetButtonDown(DX.PAD_INPUT_RIGHT)) {//press right to increase the volume by 10 Sound.Play(Sound.menuMovement); Sound.BGMVolume += 10; if (Sound.BGMVolume > 200) { Sound.BGMVolume = 200; } Sound.SetVolume(); } } //if SE volume option was selected if (Input.GetButtonDown(DX.PAD_INPUT_1) && optionCount == 2) { option = Option.SEVolume; Sound.Play(Sound.menuSelect); } if (option == Option.SEVolume) { if (Input.GetButtonDown(DX.PAD_INPUT_2)) {//back out of music selection Sound.Play(Sound.cancel); option = Option.Neutral; } if (Input.GetButtonDown(DX.PAD_INPUT_4) || Input.GetButtonDown(DX.PAD_INPUT_LEFT)) {//press left to lower the volume by 10 Sound.Play(Sound.menuMovement); Sound.SEVolume -= 10; if (Sound.SEVolume < 0) { Sound.SEVolume = 0; } Sound.SetVolume(); } if (Input.GetButtonDown(DX.PAD_INPUT_6) || Input.GetButtonDown(DX.PAD_INPUT_RIGHT)) {//press right to increase the volume by 10 Sound.Play(Sound.menuMovement); Sound.SEVolume += 10; if (Sound.SEVolume > 200) { Sound.SEVolume = 200; } Sound.SetVolume(); } } } if (state == State.Help) { if (Input.GetButtonDown(DX.PAD_INPUT_2)) { Sound.Play(Sound.cancel); state = State.Title; } } if (state == State.Restart) { Restart(); } if (state == State.Pause) {//Paused state, press Q again to un-pause if (Input.GetButtonDown(DX.PAD_INPUT_7)) { state = State.Game; } pause = true; } if (state == State.Game || state == State.End || state == State.Clear) { Sound.SetMusic(); //plays set music if (gameType == GameType.Normal) { map.Scroll(scrollSpeed); if (map.enemyCount == 0 && enemies.Count == 0) { state = State.Clear; } } if (gameType == GameType.Endless || gameType == GameType.EndlessHP) { wave.Update(); } if (!player.isDead) { mouse.Update(); player.Update(); } else { state = State.End; } foreach (PlayerBullet b in playerBullets) { b.Update(); } foreach (Enemy e in enemies) { e.Update(); } foreach (EnemyBullet b in enemyBullets) { b.Update(); } foreach (Item i in items) { i.Update(); } foreach (EnemyBullet enemyBullet in enemyBullets) {//player takes damage from enemy bullets if (player.isDead) { break; } if (enemyBullet.isDead) { continue; } if (MyMath.SphereSphereIntersection( player.x, player.y, player.collisionRadius, enemyBullet.x, enemyBullet.y, enemyBullet.collisionRadius)) { player.OnCollisionEnemyBullet(enemyBullet); } } foreach (PlayerBullet playerBullet in playerBullets) { if (playerBullet.isDead) { continue; } //for missiles if (playerBullet is MissileBullet) { MissileBullet missile = (MissileBullet)playerBullet; float shortestDistance = float.MaxValue; foreach (Enemy enemy in enemies) {//missile looks for closest enemy if (MyMath.DistanceBetweenTwoPoints(missile.x, missile.y, enemy.x, enemy.y) < shortestDistance) { shortestDistance = MyMath.DistanceBetweenTwoPoints(missile.x, missile.y, enemy.x, enemy.y); closeEnemyX = enemy.x; closeEnemyY = enemy.y; } missile.AngleToEnemy(closeEnemyX, closeEnemyY); } } //enemies take damage if hit by player bullet foreach (Enemy enemy in enemies) { if (enemy.isDead) { continue; } if (enemy is Boss2) {//if boss2 is in normal state (or when it is teleporting) it can't be hit by bullets - this way only the turrents can be hit Boss2 boss = (Boss2)enemy; if (boss.state == Boss2.State.Normal || boss.state == Boss2.State.Invincible) { continue; } } if (MyMath.SphereSphereIntersection( playerBullet.x, playerBullet.y, playerBullet.collisionRadius, enemy.x, enemy.y, enemy.collisionRadius)) { enemy.OnCollisionPlayerBullet(playerBullet); playerBullet.OnCollisionEnemy(enemy); if (playerBullet.isDead) { break; } } } } foreach (Enemy enemy in enemies) { if (player.isDead) { break; } if (enemy.isDead) { continue; } if (enemy is Boss2) {//can't hurt player when boss is teleporting Boss2 boss = (Boss2)enemy; if (boss.state == Boss2.State.Invincible) { continue; } } if (MyMath.SphereSphereIntersection( player.x, player.y, player.collisionRadius, enemy.x, enemy.y, enemy.collisionRadius)) { player.OnCollisionEnemy(enemy); enemy.OnCollisionPlayer(); } enemy.OutOfBoundsKillFlag(); //enemies are removed if they are outside the boundaries for too long } //this decides item drop chance and score foreach (Enemy enemy in enemies) { if (enemy.isDead) { //items have a 1 in 10 chance to drop something int itemDrop = MyRandom.Range(0, 10); if (itemDrop == 0) { items.Add(new HealthItem(enemy)); } if (itemDrop == 1) { items.Add(new StrightBulletPowerUpItem(enemy)); } if (itemDrop == 2) { items.Add(new SpreadBulletPowerUpItem(enemy)); } if (itemDrop == 3) { items.Add(new MissileBulletPowerUpItem(enemy)); } //most enemies are worth 10 points, 1 type of enemy is worth 20, and the boss is worth 100 //Note - points for mines and boss turrents are calculated in Zako4 and Boss2 respectivly if (enemy is Zako0 || enemy is Zako1 || enemy is Zako2 || enemy is Zako3) { score += 10; } if (enemy is Zako4) { score += 20; } if (enemy is Boss2) { score += 100; } } } //updates items and detects if the player picks them up foreach (Item item in items) { if (player.isDead) { break; } if (item.isDead) { continue; } if (MyMath.SphereSphereIntersection( player.x, player.y, player.collisionRadius, item.x, item.y, item.collisionRadius)) { player.OnCollisionItem(item); item.OnCollisionPlayer(player); } } foreach (Explosion e in explosions) { e.Update(); } //removes all assets that are no longer used playerBullets.RemoveAll(pb => pb.isDead); enemies.RemoveAll(e => e.isDead); enemyBullets.RemoveAll(eb => eb.isDead); explosions.RemoveAll(e => e.isDead); items.RemoveAll(i => i.isDead); if (state == State.End || state == State.Clear) {//only save score if the player finishes or dies on a stage //if current score is higher then max score, change max score to the current score if (gameType == GameType.Normal && score > maxScore0) { maxScore0 = score; } if (gameType == GameType.Endless && score > maxScore1) { maxScore1 = score; } if (gameType == GameType.EndlessHP && score > maxScore2) { maxScore2 = score; } } //player can reset or go back to the title screen at any time if (Input.GetButtonDown(DX.PAD_INPUT_1)) { state = State.Restart; } if (Input.GetButtonDown(DX.PAD_INPUT_2)) { state = State.Title; } //Press Q to pause if (Input.GetButtonDown(DX.PAD_INPUT_7) && pause == false) { state = State.Pause; } if (pause == true) { pause = false; } } }