public void Destroy() { isDead = true; for (int i = 0; i < 2; i++) { int a = Utility.Atan2(Y - Game.Player.Y, Game.Player.X - X) + Game.Random.Next(-60, 60 + 1); Bullet bullet = new SnakeBullet(Game, X, Y, Game.Random.Next(8, 12 + 1), a); Game.AddEnemyBullet(bullet); } int startAngle = Game.Random.Next(90); for (int i = 0; i < 8; i++) { int angle = startAngle + i * 45 + Game.Random.Next(-45, 46); double x = X + 16 * Utility.Cos(angle); double y = Y - 16 * Utility.Sin(angle); double speed = 0.5 + 1.5 * Game.Random.NextDouble(); Effect debris = new Debris(Game, x, y, 128, 128, 128, speed, angle); Game.AddEffect(debris); } Effect effect = new BigExplosionEffect(Game, X, Y, Game.Random.Next(360), 255, 255, 255); Game.AddEffect(effect); Game.PlaySound(Sound.Explosion); }
public override bool Hit() { if (hitPoints > 0) { hitPoints--; if (hitPoints > 0) { Game.PlaySound(Sound.EnemyDamage); } } if (hitPoints == 0) { for (int i = 0; i < message.Length; i++) { for (int j = 0; j < message[i].Length; j++) { double targetX = X - message[i].Length * 8 + j * 16 + 8; double targetY = Y - message.Length * 8 + i * 16 + 8; Effect effect = new SmallExplosionEffect(Game, targetX, targetY, Game.Random.Next(0, 360)); Effect debris1 = new Debris(Game, targetX, targetY, 255, 255, 255, Game.Random.Next(1, 5), Game.Random.Next(0, 360)); Effect debris2 = new Debris(Game, targetX, targetY, 255, 255, 255, Game.Random.Next(1, 5), Game.Random.Next(0, 360)); Game.AddEffect(effect); Game.AddEffect(debris1); Game.AddEffect(debris2); } } Game.PlaySound(Sound.Explosion); hitPoints--; } return(true); }
public override bool Hit() { if (hitPoints > 0) { hitPoints--; damaged = true; if (hitPoints > 0) { Game.PlaySound(Sound.EnemyDamage); } } if (hitPoints == 0) { int startAngle = Game.Random.Next(90); for (int i = 0; i < 12; i++) { int angle = startAngle + i * 45 + Game.Random.Next(-30, 31); double x = X + 24 * Utility.Cos(angle); double y = Y - 24 * Utility.Sin(angle); double speed = 0.5 + 1.5 * Game.Random.NextDouble(); Effect debris = new Debris(Game, x, y, 255, 255, 255, speed, angle); Game.AddEffect(debris); } Effect effect = new BigExplosionEffect(Game, X, Y, Game.Random.Next(360), 255, 255, 255); Game.AddEffect(effect); Game.PlaySound(Sound.Explosion); hitPoints--; } return(true); }
public override bool Hit() { if (hitPoints > 0) { hitPoints--; if (hitPoints > 0) { Game.PlaySound(Sound.EnemyDamage); } } if (hitPoints == 0) { int startAngle = Game.Random.Next(90); for (int i = 0; i < 8; i++) { int angle = startAngle + i * 45 + Game.Random.Next(-45, 46); double x = X + 16 * Utility.Cos(angle); double y = Y - 16 * Utility.Sin(angle); double speed = 0.5 + 1.5 * Game.Random.NextDouble(); Effect debris = new Debris(Game, x, y, type == 0 ? 255 : 0, type == 1 ? 255 : 0, type == 2 ? 255 : 0, speed, angle); Game.AddEffect(debris); } Effect effect = new BigExplosionEffect(Game, X, Y, Game.Random.Next(360), type == 0 ? 255 : 192, type == 1 ? 255 : 192, type == 2 ? 255 : 192); Game.AddEffect(effect); Game.PlaySound(Sound.Explosion); hitPoints--; } return(true); }
public void Hit() { isDead = true; Effect effect = new BigExplosionEffect(Game, X, Y, Game.Random.Next(360), 255, 255, 255); Game.AddEffect(effect); Game.PlaySound(Sound.Explosion); }
public override bool Hit() { isDead = true; Effect effect = new BigExplosionEffect(Game, X, Y, Game.Random.Next(360), 255, 255, 255); Game.AddEffect(effect); Game.PlaySound(Sound.Explosion); return(true); }
public override bool Hit() { if (hitPoints > 0) { hitPoints--; damaged = true; if (hitPoints > 0) { Game.PlaySound(Sound.EnemyDamage); } } if (hitPoints == 0) { isDead = true; foreach (Funnel funnel in funnels) { /* * int startAngle = Game.Random.Next(90); * for (int i = 0; i < 8; i++) * { * int angle = startAngle + i * 45 + Game.Random.Next(-45, 46); * double x = funnel.X + 16 * Utility.Cos(angle); * double y = funnel.Y - 16 * Utility.Sin(angle); * double speed = 0.5 + 1.5 * Game.Random.NextDouble(); * Effect debris = new Debris(Game, x, y, 255, 128, 0, speed, angle); * Game.AddEffect(debris); * } */ Effect effect = new BigExplosionEffect(Game, funnel.X, funnel.Y, Game.Random.Next(360), 255, 224, 192); Game.AddEffect(effect); } { int startAngle = Game.Random.Next(90); for (int i = 0; i < 8; i++) { int angle = startAngle + i * 45 + Game.Random.Next(-45, 46); double x = X + 16 * Utility.Cos(angle); double y = Y - 16 * Utility.Sin(angle); double speed = 0.5 + 1.5 * Game.Random.NextDouble(); Effect debris = new Debris(Game, x, y, 0, 0, 255, speed, angle); Game.AddEffect(debris); } Effect effect = new BigExplosionEffect(Game, X, Y, Game.Random.Next(360), 192, 192, 255); Game.AddEffect(effect); Game.PlaySound(Sound.Explosion); } hitPoints--; } return(true); }
public override bool Hit() { if (hitPoints > 0) { hitPoints--; damaged = true; if (hitPoints > 0) { Game.PlaySound(Sound.EnemyDamage); } } if (hitPoints == 0) { hitPoints--; isDying = true; return(true); } return(!isDying); }
public override bool Hit() { isDead = true; int startAngle = Game.Random.Next(90); for (int i = 0; i < 8; i++) { int angle = startAngle + i * 45 + Game.Random.Next(-45, 46); double x = X + 16 * Utility.Cos(angle); double y = Y - 16 * Utility.Sin(angle); double speed = 0.5 + 1.5 * Game.Random.NextDouble(); Effect debris = new Debris(Game, x, y, 255, 0, 0, speed, angle); Game.AddEffect(debris); } Effect effect = new BigExplosionEffect(Game, X, Y, Game.Random.Next(360), 255, 192, 192); Game.AddEffect(effect); Game.PlaySound(Sound.Explosion); return(true); }
public override bool Hit() { if (hitPoints > 0) { hitPoints--; damaged = true; if (hitPoints > 0) { Game.PlaySound(Sound.EnemyDamage); } } if (hitPoints == 0) { Effect effect = new BigExplosionEffect(Game, X, Y, Game.Random.Next(360), 255, 255, 255); Game.AddEffect(effect); Game.PlaySound(Sound.Explosion); // ˆê‰ž hitPoints--; } return(true); }
public override void Update() { if (waitCount > 0) { double newX = waitX + swingWidth * Utility.Sin(Game.Ticks * 8); double newY = waitY + swingHeight * Utility.Sin(Game.Ticks * 8); vx = newX - X; vy = newY - Y; X = newX; Y = newY; waitCount--; } if (waitCount == 0) { if (!attacking) { if (angle == 90) { angle += Game.Random.Next(2) == 0 ? 1 : -1; } else { int deg = Utility.NormalizeDeg(270 - angle); if (Math.Abs(deg) < 8) { angle = 270; attacking = true; } else { if (deg < 0) { angle -= 8; } else if (deg > 0) { angle += 8; } } } vx += 0.5 * Utility.Cos(angle); vy -= 0.5 * Utility.Sin(angle); Move(); } else { if (X < Game.Player.X + playerXTraceOffset) { vx += 0.25; } else if (X > Game.Player.X + playerXTraceOffset) { vx -= 0.25; } vy += 0.25; Move(); { int deg = Utility.NormalizeDeg(Utility.Atan2(Y - Game.Player.Y, Game.Player.X - X) - angle); if (deg == -180) { angle += Game.Random.Next(2) == 0 ? 1 : -1; } else if (Math.Abs(deg) < 4) { angle = Utility.Atan2(Y - Game.Player.Y, Game.Player.X - X); } else { if (deg < 0) { angle -= 4; } else if (deg > 0) { angle += 4; } } } if (fireCount > 0) { fireCount--; } else if (!Game.Player.IsDead) { if (Y < Game.Player.Y) { Bullet bullet = new EnemyBullet(Game, X + 32 * Utility.Cos(angle), Y - 32 * Utility.Sin(angle), 12, angle); Game.AddEnemyBullet(bullet); Game.PlaySound(Sound.EnemyFire); fireCount = Game.Random.Next(30, 60); playerXTraceOffset = Game.Random.Next(-64, 64 + 1); } else { fireCount = Game.Random.Next(15, 30); playerXTraceOffset = Game.Random.Next(-64, 64 + 1); } } } } }
public override void Update() { if (hitPoints <= 16) { targetRadius = 96; } if (hitPoints <= 8) { targetRadius = 64; } if (shieldRadius < targetRadius) { shieldRadius++; } else if (shieldRadius > targetRadius) { shieldRadius--; } shieldPhase -= 4; if (shieldPhase < 0) { shieldPhase += 360; } if (moveCount > 0) { moveCount--; } else { moveCount = Game.Random.Next(30, 45); targetX = Game.Random.Next(Game.FieldWidth / 2 - 192, Game.FieldWidth / 2 + 192 + 1); targetY = Game.Random.Next(Game.FieldHeight / 4 - 64, Game.FieldHeight / 4 + 64 + 1); } X = targetX * 0.03125 + X * 0.96875; Y = targetY * 0.03125 + Y * 0.96875; for (int i = 0; i < NUM_FUNNEL; i++) { funnels[i].X = X + Utility.Cos(shieldPhase + 360 / NUM_FUNNEL * i) * shieldRadius; funnels[i].Y = Y - Utility.Sin(shieldPhase + 360 / NUM_FUNNEL * i) * shieldRadius / 2; } if (attackCount > 0) { attackCount--; } else { if (!Game.Player.IsDead) { Funnel funnel = funnels[Game.Random.Next(0, NUM_FUNNEL)]; Bullet bullet = new ClipperBullet(Game, funnel.X, funnel.Y + 32, 16, 270); Game.AddEnemyBullet(bullet); Game.PlaySound(Sound.EnemyFire); } if (hitPoints > 16) { attackCount = Game.Random.Next(30, 60); } else if (hitPoints > 8) { attackCount = Game.Random.Next(15, 30); } else { attackCount = Game.Random.Next(10, 20); } } damaged = false; animation = (animation + 1) % 32; }
public override void Update() { damaged = false; if (isDying) { if (dyingCount < 60) { if (dyingCount % 2 == 0) { Effect effect = new SmallExplosionEffect(Game, X + Game.Random.Next(-32, 32 + 1), Y + Game.Random.Next(-32, 32 + - +1), Game.Random.Next(0, 360)); Game.AddEffect(effect); if (dyingCount % 4 == 0) { Game.PlaySound(Sound.Explosion); } } dyingCount++; if (dyingCount == 60) { Effect effect = new BigExplosionEffect(Game, X, Y, Game.Random.Next(0, 360), 255, 255, 255); Game.AddEffect(effect); Game.PlaySound(Sound.Explosion); } } return; } if (moveCount > 0) { moveCount--; } else { targetX = Game.FieldWidth / 2 + Game.Random.Next(-64, 64 + 1); targetY = Game.FieldHeight / 4 - Game.Random.Next(0, 64 + 1); moveCount = Game.Random.Next(30, 60); } spawnEnemyType = (192 - hitPoints) / 32; if (!Game.Player.IsDead && !isDying && Game.Ticks >= 60) { switch (spawnEnemyType) { case 0: if (Game.Ticks % 8 == 0) { Effect effect = new GreenEnemySpawner(Game, X + Game.Random.Next(-64, 65), Y + Game.Random.Next(0, 64)); Game.AddEffect(effect); } break; case 1: if (Game.Ticks % 8 == 0) { Effect effect = new BlueEnemySpawner(Game, X + Game.Random.Next(-64, 65), Y + Game.Random.Next(0, 64)); Game.AddEffect(effect); } break; case 2: if (Game.Ticks % 8 == 0) { Effect effect = new RedEnemySpawner(Game, X + Game.Random.Next(-64, 65), Y + Game.Random.Next(0, 64)); Game.AddEffect(effect); } break; case 3: if (Game.Ticks % 16 == 0) { Effect effect = new OrangeEnemySpawner(Game, X + Game.Random.Next(-64, 65), Y + Game.Random.Next(0, 64)); Game.AddEffect(effect); } break; case 4: if (Game.Ticks % 16 == 0) { Effect effect = new MissileEnemySpawner(Game, X + Game.Random.Next(-64, 65), Y + Game.Random.Next(0, 64)); Game.AddEffect(effect); } break; case 5: if (Game.Ticks % 16 == 0) { Effect effect = new KurageSpawner(Game, X + Game.Random.Next(-64, 65), Y + Game.Random.Next(0, 64)); Game.AddEffect(effect); } break; } } else { hitPoints = 192; } x2 = targetX * 0.125 + x2 * 0.875; y2 = targetY * 0.125 + y2 * 0.875; X = x2 * 0.125 + X * 0.875; Y = y2 * 0.125 + Y * 0.875; animation = (animation + 1) % 8; }
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 override void Update() { if (waitCount > 0) { double newX = waitX + swingWidth * Utility.Sin(Game.Ticks * 8); double newY = waitY + swingHeight * Utility.Sin(Game.Ticks * 8); vx = newX - X; vy = newY - Y; X = newX; Y = newY; waitCount--; } if (waitCount == 0) { if (!attacking) { if (angle == 90) { angle += Game.Random.Next(2) == 0 ? 1 : -1; } else { int deg = Utility.NormalizeDeg(270 - angle); if (Math.Abs(deg) < 8) { angle = 270; attacking = true; } else { if (deg < 0) { angle -= 8; } else if (deg > 0) { angle += 8; } } } vx += 0.5 * Utility.Cos(angle); vy -= 0.5 * Utility.Sin(angle); Move(); } else { if (X < Game.Player.X + playerXTraceOffset) { vx += 0.25; } else if (X > Game.Player.X + playerXTraceOffset) { vx -= 0.25; } vy += 0.25; Move(); { int deg = Utility.NormalizeDeg(Utility.Atan2(Y - Game.Player.Y, Game.Player.X - X) - angle); if (deg == -180) { angle += Game.Random.Next(2) == 0 ? 1 : -1; } else if (Math.Abs(deg) < 2) { angle = Utility.Atan2(Y - Game.Player.Y, Game.Player.X - X); } else { if (deg < 0) { angle -= 2; } else if (deg > 0) { angle += 2; } } angle = (angle % 360 + 360) % 360; if (angle < 225) { angle = 225; } else if (angle > 315) { angle = 315; } } if (fireCount > 0) { fireCount--; } else if (!Game.Player.IsDead) { if (Y < Game.Player.Y) { Bullet bullet1 = new OrangeBullet(Game, X + 32 * Utility.Cos(angle), Y - 32 * Utility.Sin(angle), 12, angle - 15); Bullet bullet2 = new OrangeBullet(Game, X + 32 * Utility.Cos(angle), Y - 32 * Utility.Sin(angle), 12, angle); Bullet bullet3 = new OrangeBullet(Game, X + 32 * Utility.Cos(angle), Y - 32 * Utility.Sin(angle), 12, angle + 15); Game.AddEnemyBullet(bullet1); Game.AddEnemyBullet(bullet2); Game.AddEnemyBullet(bullet3); Game.PlaySound(Sound.OrangeFire); fireCount = Game.Random.Next(60, 90); playerXTraceOffset = Game.Random.Next(-96, 96 + 1); } else { fireCount = Game.Random.Next(15, 30); playerXTraceOffset = Game.Random.Next(-96, 96 + 1); } } } } damaged = false; }
public override void Update() { if (waitCount > 0) { double newX = waitX + swingWidth * Utility.Sin(Game.Ticks * 8); double newY = waitY + swingHeight * Utility.Sin(Game.Ticks * 8); vx = newX - X; vy = newY - Y; X = newX; Y = newY; waitCount--; } if (waitCount == 0) { if (!attacking) { if (angle == 90) { angle += Game.Random.Next(2) == 0 ? 1 : -1; } else { int deg = Utility.NormalizeDeg(270 - angle); if (Math.Abs(deg) < 8) { angle = 270; attacking = true; } else { if (deg < 0) { angle -= 8; } else if (deg > 0) { angle += 8; } } } vx += 0.5 * Utility.Cos(angle); vy -= 0.5 * Utility.Sin(angle); Move(); } else { PlayerBullet playerBullet = null; foreach (PlayerBullet targetBullet in Game.PlayerBulletList) { if (Math.Abs(targetBullet.X - X) < 32) { if (Y < targetBullet.Y && targetBullet.Y - 128 < Y) { if (playerBullet == null || targetBullet.Y < playerBullet.Y) { playerBullet = targetBullet; } } } } if (playerBullet == null) { if (X < Game.Player.X + playerXTraceOffset) { vx += 0.5; } else if (X > Game.Player.X + playerXTraceOffset) { vx -= 0.5; } } else { if (X < playerBullet.X) { vx -= 3; } else if (X > playerBullet.X) { vx += 3; } } vy += 0.25; Move(); { int deg = Utility.NormalizeDeg(Utility.Atan2(Y - Game.Player.Y, Game.Player.X - X) - angle); if (deg == -180) { angle += Game.Random.Next(2) == 0 ? 1 : -1; } else if (Math.Abs(deg) < 2) { angle = Utility.Atan2(Y - Game.Player.Y, Game.Player.X - X); } else { if (deg < 0) { angle -= 2; } else if (deg > 0) { angle += 2; } } angle = (angle % 360 + 360) % 360; if (angle < 225) { angle = 225; } else if (angle > 315) { angle = 315; } } if (fireCount > 0) { fireCount--; } else if (!Game.Player.IsDead) { if (Y < Game.Player.Y) { Bullet bullet = new EnemyBullet(Game, X + 32 * Utility.Cos(angle), Y - 32 * Utility.Sin(angle), 12, angle); Game.AddEnemyBullet(bullet); Game.PlaySound(Sound.EnemyFire); fireCount = Game.Random.Next(60, 90); playerXTraceOffset = Game.Random.Next(-32, 32 + 1); } else { fireCount = Game.Random.Next(15, 30); playerXTraceOffset = Game.Random.Next(-32, 32 + 1); } } } } damaged = false; }
public override void Update() { damaged = false; if (isDying) { if (dyingCount < 30) { if (dyingCount % 2 == 0) { Effect effect = new SmallExplosionEffect(Game, X + Game.Random.Next(-64, 64 + 1), Y + Game.Random.Next(-32, 32 + - +1), Game.Random.Next(0, 360)); Game.AddEffect(effect); if (dyingCount % 4 == 0) { Game.PlaySound(Sound.Explosion); } } dyingCount++; if (dyingCount == 30) { int startAngle = Game.Random.Next(90); for (int i = 0; i < 20; i++) { int angle = startAngle + i * 18 + Game.Random.Next(-18, 19); double x = X + 64 * Utility.Cos(angle); double y = Y - 32 * Utility.Sin(angle); double speed = 0.5 + 1.5 * Game.Random.NextDouble(); Effect debris = new Debris(Game, x, y, 80, 80, 80, speed, angle); Game.AddEffect(debris); } for (int i = -1; i <= 1; i++) { Effect effect = new BigExplosionEffect(Game, X - i * 48, Y, Game.Random.Next(0, 360), 255, 255, 255); Game.AddEffect(effect); } Game.PlaySound(Sound.Explosion); } } return; } if (moveCount > 0) { moveCount--; if (attackMode == 0) { if (!(Math.Abs(X - targetX) < 32 && Math.Abs(Y - targetY) < 32)) { Effect smoke1 = new Smoke(Game, X - 24, Y - 24, Game.Random.Next(0, 360)); Effect smoke2 = new Smoke(Game, X + 24, Y - 24, Game.Random.Next(0, 360)); Game.AddEffect(smoke1); Game.AddEffect(smoke2); } } if (!Game.Player.IsDead) { if (attackMode == 1) { if (moveCount == 4) { Bullet bullet1 = new OrangeBullet(Game, X - 32 + 32 * Utility.Cos(255), Y - 32 * Utility.Sin(255), 12, 255); Bullet bullet2 = new OrangeBullet(Game, X - 32 + 32 * Utility.Cos(270), Y - 32 * Utility.Sin(270), 12, 270); Bullet bullet3 = new OrangeBullet(Game, X - 32 + 32 * Utility.Cos(285), Y - 32 * Utility.Sin(285), 12, 285); Game.AddEnemyBullet(bullet1); Game.AddEnemyBullet(bullet2); Game.AddEnemyBullet(bullet3); Game.PlaySound(Sound.OrangeFire); } else if (moveCount == 8) { Bullet bullet1 = new OrangeBullet(Game, X + 32 + 32 * Utility.Cos(255), Y - 32 * Utility.Sin(255), 12, 255); Bullet bullet2 = new OrangeBullet(Game, X + 32 + 32 * Utility.Cos(270), Y - 32 * Utility.Sin(270), 12, 270); Bullet bullet3 = new OrangeBullet(Game, X + 32 + 32 * Utility.Cos(285), Y - 32 * Utility.Sin(285), 12, 285); Game.AddEnemyBullet(bullet1); Game.AddEnemyBullet(bullet2); Game.AddEnemyBullet(bullet3); Game.PlaySound(Sound.OrangeFire); } } else if (attackMode == 2) { if (moveCount == 4) { Bullet bullet1 = new OrangeBullet(Game, X + 32 + 32 * Utility.Cos(255), Y - 32 * Utility.Sin(255), 12, 255); Bullet bullet2 = new OrangeBullet(Game, X + 32 + 32 * Utility.Cos(270), Y - 32 * Utility.Sin(270), 12, 270); Bullet bullet3 = new OrangeBullet(Game, X + 32 + 32 * Utility.Cos(285), Y - 32 * Utility.Sin(285), 12, 285); Game.AddEnemyBullet(bullet1); Game.AddEnemyBullet(bullet2); Game.AddEnemyBullet(bullet3); Game.PlaySound(Sound.OrangeFire); } else if (moveCount == 8) { Bullet bullet1 = new OrangeBullet(Game, X - 32 + 32 * Utility.Cos(255), Y - 32 * Utility.Sin(255), 12, 255); Bullet bullet2 = new OrangeBullet(Game, X - 32 + 32 * Utility.Cos(270), Y - 32 * Utility.Sin(270), 12, 270); Bullet bullet3 = new OrangeBullet(Game, X - 32 + 32 * Utility.Cos(285), Y - 32 * Utility.Sin(285), 12, 285); Game.AddEnemyBullet(bullet1); Game.AddEnemyBullet(bullet2); Game.AddEnemyBullet(bullet3); Game.PlaySound(Sound.OrangeFire); } } else if (attackMode == 3) { if (moveCount == 12) { Bullet missile = new Missile(Game, X, Y + 16 - 32 * Utility.Sin(255), 270); Game.AddEnemyBullet(missile); Game.PlaySound(Sound.MissileFire); } } } } else { if (attackMode > 0) { attackMode = Game.Random.Next(0, 4); } else { attackMode = Game.Random.Next(1, 4); } targetX = (int)Math.Round(Game.Player.X) + Game.Random.Next(-32, 32 + 1); if (attackMode == 0) { targetY = Game.FieldHeight - 32; } else { targetY = Game.FieldHeight / 4 + Game.Random.Next(-32, 64 + 1); } /* * if (hitPoints > 48) * { * moveCount = Game.Random.Next(30, 60); * } * else if (hitPoints > 24) * { * moveCount = Game.Random.Next(25, 50); * } * else * { * moveCount = Game.Random.Next(20, 40); * } */ moveCount = Game.Random.Next(20, 30); if (targetX < 80) { targetX = 80; } else if (targetX > Game.FieldWidth - 80) { targetX = Game.FieldWidth - 80; } } x2 = targetX * 0.125 + x2 * 0.875; y2 = targetY * 0.125 + y2 * 0.875; X = x2 * 0.125 + X * 0.875; Y = y2 * 0.125 + Y * 0.875; }
public override void Update() { damaged = false; if (isDying) { if (dyingCount < POS_BUF_LEN_SUM) { if (dyingCount % POS_BUF_LEN == 0) { bodies[dyingCount / POS_BUF_LEN].Destroy(); } dyingCount++; } if (dyingCount == POS_BUF_LEN_SUM) { int startAngle = Game.Random.Next(90); for (int i = 0; i < 12; i++) { int angle = startAngle + i * 30 + Game.Random.Next(-30, 31); double x = X + 32 * Utility.Cos(angle); double y = Y - 32 * Utility.Sin(angle); double speed = 0.5 + 1.5 * Game.Random.NextDouble(); Effect debris = new Debris(Game, x, y, 128, 128, 128, speed, angle); Game.AddEffect(debris); } Effect effect1 = new BigExplosionEffect(Game, X + 16, Y, Game.Random.Next(360), 255, 255, 255); Effect effect2 = new BigExplosionEffect(Game, X, Y - 16, Game.Random.Next(360), 255, 255, 255); Effect effect3 = new BigExplosionEffect(Game, X - 16, Y, Game.Random.Next(360), 255, 255, 255); Effect effect4 = new BigExplosionEffect(Game, X, Y + 16, Game.Random.Next(360), 255, 255, 255); Game.AddEffect(effect1); Game.AddEffect(effect2); Game.AddEffect(effect3); Game.AddEffect(effect4); Game.PlaySound(Sound.Explosion); } return; } px = X; py = Y; for (int i = 0; i < POS_BUF_LEN_SUM - 1; i++) { posBufX[i] = posBufX[i + 1]; posBufY[i] = posBufY[i + 1]; angleBuf[i] = angleBuf[i + 1]; } posBufX[POS_BUF_LEN_SUM - 1] = X; posBufY[POS_BUF_LEN_SUM - 1] = Y; angleBuf[POS_BUF_LEN_SUM - 1] = this.angle; if (Game.Ticks % 30 == 0) { if (Game.Random.Next(0, 8) != 0) { targetX = Game.Random.Next(Game.FieldWidth / 2 - 192, Game.FieldWidth / 2 + 192 + 1); targetY = Game.Random.Next(Game.FieldHeight / 4 - 64, Game.FieldHeight / 4 + 192 + 1); } else { targetX = (int)Math.Round(Game.Player.X); targetY = (int)Math.Round(Game.Player.Y); } } if (Math.Abs(targetX - X) < 32 && Math.Abs(targetY - Y) < 32) { targetX = Game.Random.Next(Game.FieldWidth / 2 - 192, Game.FieldWidth / 2 + 192 + 1); targetY = Game.Random.Next(Game.FieldHeight / 4 - 64, Game.FieldHeight / 4 + 192 + 1); } if (X < targetX) { vx += 1; } else if (targetX < X) { vx -= 1; } if (Math.Abs(vx) > MAX_SPEED) { vx = Math.Sign(vx) * MAX_SPEED; } if (Y < targetY) { vy += 1; } else if (targetY < Y) { vy -= 1; } if (Math.Abs(vy) > MAX_SPEED) { vy = Math.Sign(vy) * MAX_SPEED; } X += vx; Y += vy; for (int i = 0; i < NUM_BODIES; i++) { int index = POS_BUF_LEN * i; bodies[i].X = posBufX[index]; bodies[i].Y = posBufY[index]; bodies[i].Angle = angleBuf[index]; } { int deg = Utility.NormalizeDeg(Utility.Atan2(py - Y, X - px) - angle); if (deg == -180) { angle += Game.Random.Next(2) == 0 ? 1 : -1; } else if (Math.Abs(deg) < 16) { angle = Utility.Atan2(py - Y, X - px); } else { if (deg < 0) { angle -= 16; } else if (deg > 0) { angle += 16; } } } if (attackCount > 0) { attackCount--; if (!Game.Player.IsDead) { if (attackCount / 2 < NUM_BODIES) { if (attackCount % 2 == 0) { SnakeBody body = bodies[attackCount / 2]; int a = Utility.Atan2(body.Y - Game.Player.Y, Game.Player.X - body.X) + Game.Random.Next(-45, 45 + 1); Bullet bullet = new SnakeBullet(Game, body.X, body.Y, Game.Random.Next(4, 8 + 1), a); Game.AddEnemyBullet(bullet); } } } } else { attackCount = Game.Random.Next(60, 90); } }