public override void Update(GameCommand command) { base.Update(command); for (int i = 0; i < NUM_STARS / 4; i++) { starY[i] += 3; if (starY[i] > Game.FieldHeight + 2) { starX[i] = Random.Next(-2, Game.FieldWidth + 2 + 1); starY[i] = -2; } } for (int i = NUM_STARS / 4; i < NUM_STARS / 2; i++) { starY[i] += 2; if (starY[i] > Game.FieldHeight + 2) { starX[i] = Random.Next(-2, Game.FieldWidth + 2 + 1); starY[i] = -2; } } for (int i = NUM_STARS / 2; i < NUM_STARS; i++) { starY[i] += 1; if (starY[i] > Game.FieldHeight + 2) { starX[i] = Random.Next(-2, Game.FieldWidth + 2 + 1); starY[i] = -2; } } }
public override void Update(GameCommand command) { base.Update(command); if (endGame) { if (endGameCount <= 60) { endGameCount++; } else { endingGameOver = true; } } }
public virtual void Update(GameCommand command) { ClearSounds(); foreach (Effect effect in effectList) { effect.Update(); } foreach (Bullet bullet in playerBulletList) { bullet.Update(); } player.Update(command); foreach (Bullet bullet in enemyBulletList) { bullet.Update(); } foreach (Enemy enemy in enemyList) { enemy.Update(); } foreach (Enemy enemy in enemyAddList) { enemyList.Add(enemy); } enemyAddList.Clear(); foreach (Bullet bullet in playerBulletList) { foreach (Enemy enemy in enemyList) { if (bullet.IsRemoved || enemy.IsRemoved) { continue; } if (Math.Abs(enemy.X - bullet.X) < enemy.HalfWidth && Math.Abs(enemy.Y - bullet.Y) < enemy.HalfHeight) { bullet.Hit(); if (enemy.Hit()) { tension += 100; score += tension; } } foreach (Enemy child in enemy.Children) { if (bullet.IsRemoved || child.IsRemoved) { continue; } if (Math.Abs(child.X - bullet.X) < child.HalfWidth && Math.Abs(child.Y - bullet.Y) < child.HalfHeight) { bullet.Hit(); if (child.Hit()) { tension += 100; score += tension; } } } } } if (!player.IsDead && !warping) { foreach (Enemy enemy in enemyList) { if (enemy.IsRemoved || !enemy.IsObstacle) { continue; } if (Math.Abs(player.X - enemy.X) < player.HalfWidth + enemy.HalfWidth && Math.Abs(player.Y - enemy.Y) < player.HalfHeight + enemy.HalfHeight) { enemy.Hit(); player.Hit(); } foreach (Enemy child in enemy.Children) { if (child.IsRemoved || !child.IsObstacle) { continue; } if (Math.Abs(player.X - child.X) < player.HalfWidth + child.HalfWidth && Math.Abs(player.Y - child.Y) < player.HalfHeight + child.HalfHeight) { child.Hit(); player.Hit(); } } } foreach (Bullet bullet in enemyBulletList) { if (bullet.IsRemoved) { continue; } if (Math.Abs(player.X - bullet.X) < player.HalfWidth && Math.Abs(player.Y - bullet.Y) < player.HalfHeight) { bullet.Hit(); player.Hit(); } } } playerBulletList.RemoveAll(Bullet.ShouldBeRemoved); foreach (Enemy enemy in enemyList) { if (Enemy.ShouldBeRemoved(enemy)) { enemy.OnRemove(); } } enemyList.RemoveAll(Enemy.ShouldBeRemoved); enemyBulletList.RemoveAll(Bullet.ShouldBeRemoved); effectList.RemoveAll(Effect.ShouldBeRemoved); foreach (Enemy enemy in enemyAddList) { enemyList.Add(enemy); } enemyAddList.Clear(); if (player.IsDead) { if (playerDeadTicks < 30) { playerDeadTicks++; } else { gameOver = true; } // �ꉞ warping = false; warpTicks = 0; } else if (enemyList.Count == 0 && enemyBulletList.Count == 0) { warping = true; } if (warping) { if (warpTicks < 60) { if (warpTicks == 15) { player.Freeze(); } else if (warpTicks > 15) { if (warpTicks == 30) { PlaySound(Sound.Warp); } player.Warp(warpTicks >= 30); } warpTicks++; } else { score += tension * 50; goingToNextStage = true; } } if (command.Exit) { returnToTitle = true; } if (CoutAliveEnemies() > 0) { tension -= 10; if (tension < 0) { tension = 0; } } ticks++; }
public override void Update(GameCommand command) { base.Update(command); scroll += 2; }
public override void Update(GameCommand command) { base.Update(command); scroll += 3; }
public void Update(GameCommand command) { if (isDead || freeze) { return; } if (command.Left != command.Right) { if (command.Left) { vx -= SPEED_UP; if (vx < -MAX_SPEED) { vx = -MAX_SPEED; } } if (command.Right) { vx += SPEED_UP; if (vx > MAX_SPEED) { vx = MAX_SPEED; } } } else { if (Math.Abs(vx) < SPEED_DOWN) { vx = 0; } else { vx -= Math.Sign(vx) * SPEED_DOWN; } } if (command.Up != command.Down) { if (command.Up) { vy -= SPEED_UP; if (vy < -MAX_SPEED) { vy = -MAX_SPEED; } } if (command.Down) { vy += SPEED_UP; if (vy > MAX_SPEED) { vy = MAX_SPEED; } } } else { if (Math.Abs(vy) < SPEED_DOWN) { vy = 0; } else { vy -= Math.Sign(vy) * SPEED_DOWN; } } X += vx; Y += vy; if (X < 16) { X = 16; } else if (X > Game.FieldWidth - 16) { X = Game.FieldWidth - 16; } if (Y < Game.FieldHeight / 4) { Y = Game.FieldHeight / 4; } else if (Y > Game.FieldHeight - 16) { Y = Game.FieldHeight - 16; } if (fireCount > 0) { fireCount--; } if (command.Button1) { if (fireCount == 0) { if (Game.PlayerBulletList.Count < 8) { Bullet bullet = new PlayerBullet(Game, X, Y - 32, 16, 90); Game.AddPlayerBullet(bullet); Game.PlaySound(Sound.PlayerFire); fireCount = 2; } } } }
public virtual void Update(GameCommand command) { ClearSounds(); foreach (Effect effect in effectList) { effect.Update(); } foreach (Bullet bullet in playerBulletList) { bullet.Update(); } player.Update(command); foreach (Bullet bullet in enemyBulletList) { bullet.Update(); } foreach (Enemy enemy in enemyList) { enemy.Update(); } foreach (Enemy enemy in enemyAddList) { enemyList.Add(enemy); } enemyAddList.Clear(); foreach (Bullet bullet in playerBulletList) { foreach (Enemy enemy in enemyList) { if (bullet.IsRemoved || enemy.IsRemoved) { continue; } if (Math.Abs(enemy.X - bullet.X) < enemy.HalfWidth && Math.Abs(enemy.Y - bullet.Y) < enemy.HalfHeight) { bullet.Hit(); if (enemy.Hit()) { tension += 100; score += tension; } } foreach (Enemy child in enemy.Children) { if (bullet.IsRemoved || child.IsRemoved) { continue; } if (Math.Abs(child.X - bullet.X) < child.HalfWidth && Math.Abs(child.Y - bullet.Y) < child.HalfHeight) { bullet.Hit(); if (child.Hit()) { tension += 100; score += tension; } } } } } if (!player.IsDead && !warping) { foreach (Enemy enemy in enemyList) { if (enemy.IsRemoved || !enemy.IsObstacle) { continue; } if (Math.Abs(player.X - enemy.X) < player.HalfWidth + enemy.HalfWidth && Math.Abs(player.Y - enemy.Y) < player.HalfHeight + enemy.HalfHeight) { enemy.Hit(); player.Hit(); } foreach (Enemy child in enemy.Children) { if (child.IsRemoved || !child.IsObstacle) { continue; } if (Math.Abs(player.X - child.X) < player.HalfWidth + child.HalfWidth && Math.Abs(player.Y - child.Y) < player.HalfHeight + child.HalfHeight) { child.Hit(); player.Hit(); } } } foreach (Bullet bullet in enemyBulletList) { if (bullet.IsRemoved) { continue; } if (Math.Abs(player.X - bullet.X) < player.HalfWidth && Math.Abs(player.Y - bullet.Y) < player.HalfHeight) { bullet.Hit(); player.Hit(); } } } playerBulletList.RemoveAll(Bullet.ShouldBeRemoved); foreach (Enemy enemy in enemyList) { if (Enemy.ShouldBeRemoved(enemy)) { enemy.OnRemove(); } } enemyList.RemoveAll(Enemy.ShouldBeRemoved); enemyBulletList.RemoveAll(Bullet.ShouldBeRemoved); effectList.RemoveAll(Effect.ShouldBeRemoved); foreach (Enemy enemy in enemyAddList) { enemyList.Add(enemy); } enemyAddList.Clear(); if (player.IsDead) { if (playerDeadTicks < 30) { playerDeadTicks++; } else { gameOver = true; } // ˆê‰ž warping = false; warpTicks = 0; } else if (enemyList.Count == 0 && enemyBulletList.Count == 0) { warping = true; } if (warping) { if (warpTicks < 60) { if (warpTicks == 15) { player.Freeze(); } else if (warpTicks > 15) { if (warpTicks == 30) { PlaySound(Sound.Warp); } player.Warp(warpTicks >= 30); } warpTicks++; } else { score += tension * 50; goingToNextStage = true; } } if (command.Exit) { returnToTitle = true; } if (CoutAliveEnemies() > 0) { tension -= 10; if (tension < 0) { tension = 0; } } ticks++; }