| 1 |
/* |
| 2 |
* $Id: enemy.d,v 1.2 2005/07/17 11:02:45 kenta Exp $ |
| 3 |
* |
| 4 |
* Copyright 2005 Kenta Cho. Some rights reserved. |
| 5 |
*/ |
| 6 |
module abagames.gr.enemy; |
| 7 |
|
| 8 |
private import std.math; |
| 9 |
private import opengl; |
| 10 |
private import abagames.util.vector; |
| 11 |
private import abagames.util.actor; |
| 12 |
private import abagames.util.rand; |
| 13 |
private import abagames.util.math; |
| 14 |
private import abagames.util.sdl.shape; |
| 15 |
private import abagames.gr.field; |
| 16 |
private import abagames.gr.bullet; |
| 17 |
private import abagames.gr.ship; |
| 18 |
private import abagames.gr.stagemanager; |
| 19 |
private import abagames.gr.screen; |
| 20 |
private import abagames.gr.particle; |
| 21 |
private import abagames.gr.shot; |
| 22 |
private import abagames.gr.shape; |
| 23 |
private import abagames.gr.soundmanager; |
| 24 |
private import abagames.gr.gamemanager; |
| 25 |
private import abagames.gr.turret; |
| 26 |
private import abagames.gr.letter; |
| 27 |
private import abagames.gr.reel; |
| 28 |
|
| 29 |
/** |
| 30 |
* Enemy ships. |
| 31 |
*/ |
| 32 |
public class Enemy: Actor { |
| 33 |
private: |
| 34 |
EnemySpec spec; |
| 35 |
EnemyState _state; |
| 36 |
|
| 37 |
public override void init(Object[] args) { |
| 38 |
_state = new EnemyState |
| 39 |
(cast(Field) args[0], cast(Screen) args[1], |
| 40 |
cast(BulletPool) args[2], cast(Ship) args[3], |
| 41 |
cast(SparkPool) args[4], cast(SmokePool) args[5], |
| 42 |
cast(FragmentPool) args[6], cast(SparkFragmentPool) args[7], |
| 43 |
cast(NumIndicatorPool) args[8], cast(ScoreReel) args[9]); |
| 44 |
} |
| 45 |
|
| 46 |
public void setEnemyPool(EnemyPool enemies) { |
| 47 |
_state.setEnemyAndPool(this, enemies); |
| 48 |
} |
| 49 |
|
| 50 |
public void setStageManager(StageManager stageManager) { |
| 51 |
_state.setStageManager(stageManager); |
| 52 |
} |
| 53 |
|
| 54 |
public void set(EnemySpec spec) { |
| 55 |
this.spec = spec; |
| 56 |
exists = true; |
| 57 |
} |
| 58 |
|
| 59 |
public override void move() { |
| 60 |
if (!spec.move(state)) |
| 61 |
remove(); |
| 62 |
} |
| 63 |
|
| 64 |
public void checkShotHit(Vector p, Collidable shape, Shot shot) { |
| 65 |
if (_state.destroyedCnt >= 0) |
| 66 |
return; |
| 67 |
if (spec.checkCollision(_state, p.x, p.y, shape, shot)) { |
| 68 |
if (shot) |
| 69 |
shot.removeHitToEnemy(spec.isSmallEnemy); |
| 70 |
} |
| 71 |
} |
| 72 |
|
| 73 |
public bool checkHitShip(float x, float y, bool largeOnly = false) { |
| 74 |
return spec.checkShipCollision(_state, x, y, largeOnly); |
| 75 |
} |
| 76 |
|
| 77 |
public void addDamage(int n) { |
| 78 |
_state.addDamage(n); |
| 79 |
} |
| 80 |
|
| 81 |
public void increaseMultiplier(float m) { |
| 82 |
_state.increaseMultiplier(m); |
| 83 |
} |
| 84 |
|
| 85 |
public void addScore(int s) { |
| 86 |
_state.addScore(s); |
| 87 |
} |
| 88 |
|
| 89 |
public void remove() { |
| 90 |
_state.removeTurrets(); |
| 91 |
exists = false; |
| 92 |
} |
| 93 |
|
| 94 |
public override void draw() { |
| 95 |
spec.draw(_state); |
| 96 |
} |
| 97 |
|
| 98 |
public EnemyState state() { |
| 99 |
return _state; |
| 100 |
} |
| 101 |
|
| 102 |
public Vector pos() { |
| 103 |
return _state.pos; |
| 104 |
} |
| 105 |
|
| 106 |
public float size() { |
| 107 |
return spec.size; |
| 108 |
} |
| 109 |
|
| 110 |
public int index() { |
| 111 |
return _state.idx; |
| 112 |
} |
| 113 |
|
| 114 |
public bool isBoss() { |
| 115 |
return spec.isBoss; |
| 116 |
} |
| 117 |
} |
| 118 |
|
| 119 |
/** |
| 120 |
* Enemy status (position, direction, velocity, turrets, etc). |
| 121 |
*/ |
| 122 |
public class EnemyState { |
| 123 |
public: |
| 124 |
static enum AppearanceType { |
| 125 |
TOP, SIDE, CENTER, |
| 126 |
}; |
| 127 |
static const int TURRET_GROUP_MAX = 10; |
| 128 |
static const int MOVING_TURRET_GROUP_MAX = 4; |
| 129 |
static const float MULTIPLIER_DECREASE_RATIO = 0.005f; |
| 130 |
int appType; |
| 131 |
Vector pos; |
| 132 |
Vector ppos; |
| 133 |
int shield; |
| 134 |
float deg; |
| 135 |
float velDeg; |
| 136 |
float speed; |
| 137 |
float turnWay; |
| 138 |
float trgDeg; |
| 139 |
int turnCnt; |
| 140 |
int state; |
| 141 |
int cnt; |
| 142 |
Vector vel; |
| 143 |
TurretGroup[TURRET_GROUP_MAX] turretGroup; |
| 144 |
MovingTurretGroup[MOVING_TURRET_GROUP_MAX] movingTurretGroup; |
| 145 |
bool damaged; |
| 146 |
int damagedCnt; |
| 147 |
int destroyedCnt; |
| 148 |
int explodeCnt, explodeItv; |
| 149 |
int idx; |
| 150 |
float multiplier; |
| 151 |
EnemySpec spec; |
| 152 |
private: |
| 153 |
static Rand rand; |
| 154 |
static Vector edgePos, explodeVel, damagedPos; |
| 155 |
static int idxCount = 0; |
| 156 |
Field field; |
| 157 |
Screen screen; |
| 158 |
BulletPool bullets; |
| 159 |
Ship ship; |
| 160 |
SparkPool sparks; |
| 161 |
SmokePool smokes; |
| 162 |
FragmentPool fragments; |
| 163 |
SparkFragmentPool sparkFragments; |
| 164 |
NumIndicatorPool numIndicators; |
| 165 |
Enemy enemy; |
| 166 |
EnemyPool enemies; |
| 167 |
StageManager stageManager; |
| 168 |
ScoreReel scoreReel; |
| 169 |
|
| 170 |
invariant { |
| 171 |
assert(pos.x < 15 && pos.x > -15); |
| 172 |
assert(pos.y < 60 && pos.y > -30); |
| 173 |
assert(ppos.x < 15 && ppos.x > -15); |
| 174 |
assert(ppos.y < 60 && ppos.y > -30); |
| 175 |
assert(shield <>= 0); |
| 176 |
assert(deg <>= 0); |
| 177 |
assert(velDeg <>= 0); |
| 178 |
assert(speed < 10 && speed > -10); |
| 179 |
assert(turnWay == 1 || turnWay == -1); |
| 180 |
assert(trgDeg <= 1 && trgDeg >= -1); |
| 181 |
assert(turnCnt >= 0); |
| 182 |
assert(vel.x < 10 && vel.x > -10); |
| 183 |
assert(vel.y < 10 && vel.y > -10); |
| 184 |
assert(explodeItv > 0); |
| 185 |
assert(edgePos.x < 15 && edgePos.x > -15); |
| 186 |
assert(edgePos.y < 60 && edgePos.y > -30); |
| 187 |
assert(explodeVel.x < 10 && explodeVel.x > -10); |
| 188 |
assert(explodeVel.y < 10 && explodeVel.y > -10); |
| 189 |
assert(damagedPos.x < 15 && damagedPos.x > -15); |
| 190 |
assert(damagedPos.y < 60 && damagedPos.y > -30); |
| 191 |
assert(multiplier >= 1); |
| 192 |
} |
| 193 |
|
| 194 |
public static this() { |
| 195 |
rand = new Rand; |
| 196 |
edgePos = new Vector; |
| 197 |
explodeVel = new Vector; |
| 198 |
damagedPos = new Vector; |
| 199 |
} |
| 200 |
|
| 201 |
public static void setRandSeed(long seed) { |
| 202 |
rand.setSeed(seed); |
| 203 |
} |
| 204 |
|
| 205 |
public this(Field field, Screen screen, BulletPool bullets, Ship ship, |
| 206 |
SparkPool sparks, SmokePool smokes, |
| 207 |
FragmentPool fragments, SparkFragmentPool sparkFragments, |
| 208 |
NumIndicatorPool numIndicators, ScoreReel scoreReel) { |
| 209 |
idx = idxCount; |
| 210 |
idxCount++; |
| 211 |
this.field = field; |
| 212 |
this.screen = screen; |
| 213 |
this.bullets = bullets; |
| 214 |
this.ship = ship; |
| 215 |
this.sparks = sparks; |
| 216 |
this.smokes = smokes; |
| 217 |
this.fragments = fragments; |
| 218 |
this.sparkFragments = sparkFragments; |
| 219 |
this.numIndicators = numIndicators; |
| 220 |
this.scoreReel = scoreReel; |
| 221 |
pos = new Vector; |
| 222 |
ppos = new Vector; |
| 223 |
vel = new Vector; |
| 224 |
deg = velDeg = speed = 0; |
| 225 |
turnWay = 1; |
| 226 |
explodeItv = 1; |
| 227 |
multiplier = 1; |
| 228 |
trgDeg = 0; |
| 229 |
turnCnt = 0; |
| 230 |
} |
| 231 |
|
| 232 |
public void setEnemyAndPool(Enemy enemy, EnemyPool enemies) { |
| 233 |
this.enemy = enemy; |
| 234 |
this.enemies = enemies; |
| 235 |
foreach (inout TurretGroup tg; turretGroup) |
| 236 |
tg = new TurretGroup(field, bullets, ship, sparks, smokes, fragments, enemy); |
| 237 |
foreach (inout MovingTurretGroup tg; movingTurretGroup) |
| 238 |
tg = new MovingTurretGroup(field, bullets, ship, sparks, smokes, fragments, enemy); |
| 239 |
} |
| 240 |
|
| 241 |
public void setStageManager(StageManager stageManager) { |
| 242 |
this.stageManager = stageManager; |
| 243 |
} |
| 244 |
|
| 245 |
public void setSpec(EnemySpec spec) { |
| 246 |
this.spec = spec; |
| 247 |
shield = spec.shield; |
| 248 |
for (int i = 0; i < spec.turretGroupNum; i++) |
| 249 |
turretGroup[i].set(spec.turretGroupSpec[i]); |
| 250 |
for (int i = 0; i < spec.movingTurretGroupNum; i++) |
| 251 |
movingTurretGroup[i].set(spec.movingTurretGroupSpec[i]); |
| 252 |
cnt = 0; |
| 253 |
damaged = false; |
| 254 |
damagedCnt = 0; |
| 255 |
destroyedCnt = -1; |
| 256 |
explodeCnt = 0; |
| 257 |
explodeItv = 1; |
| 258 |
multiplier = 1; |
| 259 |
} |
| 260 |
|
| 261 |
public bool setAppearancePos(Field field, Ship ship, Rand rand, |
| 262 |
int appType = AppearanceType.TOP) { |
| 263 |
this.appType = appType; |
| 264 |
for (int i = 0 ; i < 8 ; i++) { |
| 265 |
switch (appType) { |
| 266 |
case AppearanceType.TOP: |
| 267 |
pos.x = rand.nextSignedFloat(field.size.x); |
| 268 |
pos.y = field.outerSize.y * 0.99f + spec.size; |
| 269 |
if (pos.x < 0) |
| 270 |
velDeg = deg = PI - rand.nextFloat(0.5f); |
| 271 |
else |
| 272 |
velDeg = deg = PI + rand.nextFloat(0.5f); |
| 273 |
break; |
| 274 |
case AppearanceType.SIDE: |
| 275 |
if (rand.nextInt(2) == 0) { |
| 276 |
pos.x = -field.outerSize.x * 0.99f; |
| 277 |
velDeg = deg = PI / 2 + rand.nextFloat(0.66f); |
| 278 |
} else { |
| 279 |
pos.x = field.outerSize.x * 0.99f; |
| 280 |
velDeg = deg = -PI / 2 - rand.nextFloat(0.66f); |
| 281 |
} |
| 282 |
pos.y = field.size.y + rand.nextFloat(field.size.y) + spec.size; |
| 283 |
break; |
| 284 |
case AppearanceType.CENTER: |
| 285 |
pos.x = 0; |
| 286 |
pos.y = field.outerSize.y * 0.99f + spec.size; |
| 287 |
velDeg = deg = 0; |
| 288 |
break; |
| 289 |
} |
| 290 |
ppos.x = pos.x; |
| 291 |
ppos.y = pos.y; |
| 292 |
vel.x = vel.y = 0; |
| 293 |
speed = 0; |
| 294 |
if (appType == AppearanceType.CENTER || checkFrontClear(true)) |
| 295 |
return true; |
| 296 |
} |
| 297 |
return false; |
| 298 |
} |
| 299 |
|
| 300 |
public bool checkFrontClear(bool checkCurrentPos = false) { |
| 301 |
int si = 1; |
| 302 |
if (checkCurrentPos) |
| 303 |
si = 0; |
| 304 |
for (int i = si; i < 5; i++) { |
| 305 |
float cx = pos.x + sin(deg) * i * spec.size; |
| 306 |
float cy = pos.y + cos(deg) * i * spec.size; |
| 307 |
if (field.getBlock(cx, cy) >= 0) |
| 308 |
return false; |
| 309 |
if (enemies.checkHitShip(cx, cy, enemy, true)) |
| 310 |
return false; |
| 311 |
} |
| 312 |
return true; |
| 313 |
} |
| 314 |
|
| 315 |
public bool move() { |
| 316 |
ppos.x = pos.x; |
| 317 |
ppos.y = pos.y; |
| 318 |
multiplier -= MULTIPLIER_DECREASE_RATIO; |
| 319 |
if (multiplier < 1) |
| 320 |
multiplier = 1; |
| 321 |
if (destroyedCnt >= 0) { |
| 322 |
destroyedCnt++; |
| 323 |
explodeCnt--; |
| 324 |
if (explodeCnt < 0) { |
| 325 |
explodeItv += 2; |
| 326 |
explodeItv = cast(int) (cast(float) explodeItv * (1.2f + rand.nextFloat(1))); |
| 327 |
explodeCnt = explodeItv; |
| 328 |
destroyedEdge(cast(int) (sqrt(spec.size) * 27.0f / (explodeItv * 0.1f + 1))); |
| 329 |
} |
| 330 |
} |
| 331 |
damaged = false; |
| 332 |
if (damagedCnt > 0) |
| 333 |
damagedCnt--; |
| 334 |
bool alive = false; |
| 335 |
for (int i = 0; i < spec.turretGroupNum; i++) |
| 336 |
alive |= turretGroup[i].move(pos, deg); |
| 337 |
for (int i = 0; i < spec.movingTurretGroupNum; i++) |
| 338 |
movingTurretGroup[i].move(pos, deg); |
| 339 |
if (destroyedCnt < 0 && !alive) |
| 340 |
return destroyed(); |
| 341 |
return true; |
| 342 |
} |
| 343 |
|
| 344 |
public bool checkCollision(float x, float y, Collidable c, Shot shot) { |
| 345 |
float ox = fabs(pos.x - x), oy = fabs(pos.y - y); |
| 346 |
if (ox + oy > spec.size * 2) |
| 347 |
return false; |
| 348 |
for (int i = 0; i < spec.turretGroupNum; i++) |
| 349 |
if (turretGroup[i].checkCollision(x, y, c, shot)) |
| 350 |
return true; |
| 351 |
if (spec.bridgeShape.checkCollision(ox, oy, c)) { |
| 352 |
addDamage(shot.damage, shot); |
| 353 |
return true; |
| 354 |
} |
| 355 |
return false; |
| 356 |
} |
| 357 |
|
| 358 |
public void increaseMultiplier(float m) { |
| 359 |
multiplier += m; |
| 360 |
} |
| 361 |
|
| 362 |
public void addScore(int s) { |
| 363 |
setScoreIndicator(s, 1); |
| 364 |
} |
| 365 |
|
| 366 |
public void addDamage(int n, Shot shot = null) { |
| 367 |
shield -= n; |
| 368 |
if (shield <= 0) { |
| 369 |
destroyed(shot); |
| 370 |
} else { |
| 371 |
damaged = true; |
| 372 |
damagedCnt = 7; |
| 373 |
} |
| 374 |
} |
| 375 |
|
| 376 |
public bool destroyed(Shot shot = null) { |
| 377 |
float vz; |
| 378 |
if (shot) { |
| 379 |
explodeVel.x = Shot.SPEED * sin(shot.deg) / 2; |
| 380 |
explodeVel.y = Shot.SPEED * cos(shot.deg) / 2; |
| 381 |
vz = 0; |
| 382 |
} else { |
| 383 |
explodeVel.x = explodeVel.y = 0; |
| 384 |
vz = 0.05f; |
| 385 |
} |
| 386 |
float ss = spec.size * 1.5f; |
| 387 |
if (ss > 2) |
| 388 |
ss = 2; |
| 389 |
float sn; |
| 390 |
if (spec.size < 1) |
| 391 |
sn = spec.size; |
| 392 |
else |
| 393 |
sn = sqrt(spec.size); |
| 394 |
assert(sn <>= 0); |
| 395 |
if (sn > 3) |
| 396 |
sn = 3; |
| 397 |
for (int i = 0; i < sn * 8; i++) { |
| 398 |
Smoke s = smokes.getInstanceForced(); |
| 399 |
s.set(pos, rand.nextSignedFloat(0.1f) + explodeVel.x, rand.nextSignedFloat(0.1f) + explodeVel.y, |
| 400 |
rand.nextFloat(vz), |
| 401 |
Smoke.SmokeType.EXPLOSION, 32 + rand.nextInt(30), ss); |
| 402 |
} |
| 403 |
for (int i = 0; i < sn * 36; i++) { |
| 404 |
Spark sp = sparks.getInstanceForced(); |
| 405 |
sp.set(pos, rand.nextSignedFloat(0.8f) + explodeVel.x, rand.nextSignedFloat(0.8f) + explodeVel.y, |
| 406 |
0.5f + rand.nextFloat(0.5f), 0.5f + rand.nextFloat(0.5f), 0, 30 + rand.nextInt(30)); |
| 407 |
} |
| 408 |
for (int i = 0; i < sn * 12; i++) { |
| 409 |
Fragment f = fragments.getInstanceForced(); |
| 410 |
f.set(pos, rand.nextSignedFloat(0.33f) + explodeVel.x, rand.nextSignedFloat(0.33f) + explodeVel.y, |
| 411 |
0.05f + rand.nextFloat(0.1f), |
| 412 |
0.2f + rand.nextFloat(0.33f)); |
| 413 |
} |
| 414 |
removeTurrets(); |
| 415 |
int sc = spec.score; |
| 416 |
bool r; |
| 417 |
if (spec.type == EnemySpec.EnemyType.SMALL) { |
| 418 |
SoundManager.playSe("small_destroyed.wav"); |
| 419 |
r = false; |
| 420 |
} else { |
| 421 |
SoundManager.playSe("destroyed.wav"); |
| 422 |
int bn = bullets.removeIndexedBullets(idx); |
| 423 |
destroyedCnt = 0; |
| 424 |
explodeCnt = 1; |
| 425 |
explodeItv = 3; |
| 426 |
sc += bn * 10; |
| 427 |
r = true; |
| 428 |
if (spec.isBoss) |
| 429 |
screen.setScreenShake(45, 0.04f); |
| 430 |
} |
| 431 |
setScoreIndicator(sc, multiplier); |
| 432 |
return r; |
| 433 |
} |
| 434 |
|
| 435 |
private void setScoreIndicator(int sc, float mp) { |
| 436 |
float ty = NumIndicator.getTargetY(); |
| 437 |
if (mp > 1) { |
| 438 |
NumIndicator ni = numIndicators.getInstanceForced(); |
| 439 |
ni.set(sc, NumIndicator.IndicatorType.SCORE, 0.5f, pos); |
| 440 |
ni.addTarget(8, ty, NumIndicator.FlyingToType.RIGHT, 1, 0.5f, sc, 40); |
| 441 |
ni.addTarget(11, ty, NumIndicator.FlyingToType.RIGHT, 0.5f, 0.75f, |
| 442 |
cast(int) (sc * mp), 30); |
| 443 |
ni.addTarget(13, ty, NumIndicator.FlyingToType.RIGHT, 0.25f, 1, |
| 444 |
cast(int) (sc * mp * stageManager.rankMultiplier), 20); |
| 445 |
ni.addTarget(12, -8, NumIndicator.FlyingToType.BOTTOM, 0.5f, 0.1f, |
| 446 |
cast(int) (sc * mp * stageManager.rankMultiplier), 40); |
| 447 |
ni.gotoNextTarget(); |
| 448 |
ni = numIndicators.getInstanceForced(); |
| 449 |
int mn = cast(int) (mp * 1000); |
| 450 |
ni.set(mn, NumIndicator.IndicatorType.MULTIPLIER, 0.7f, pos); |
| 451 |
ni.addTarget(10.5f, ty, NumIndicator.FlyingToType.RIGHT, 0.5f, 0.2f, mn, 70); |
| 452 |
ni.gotoNextTarget(); |
| 453 |
ni = numIndicators.getInstanceForced(); |
| 454 |
int rn = cast(int) (stageManager.rankMultiplier * 1000); |
| 455 |
ni.set(rn, NumIndicator.IndicatorType.MULTIPLIER, 0.4f, 11, 8); |
| 456 |
ni.addTarget(13, ty, NumIndicator.FlyingToType.RIGHT, 0.5f, 0.2f, rn, 40); |
| 457 |
ni.gotoNextTarget(); |
| 458 |
scoreReel.addActualScore(cast(int) (sc * mp * stageManager.rankMultiplier)); |
| 459 |
} else { |
| 460 |
NumIndicator ni = numIndicators.getInstanceForced(); |
| 461 |
ni.set(sc, NumIndicator.IndicatorType.SCORE, 0.3f, pos); |
| 462 |
ni.addTarget(11, ty, NumIndicator.FlyingToType.RIGHT, 1.5f, 0.2f, sc, 40); |
| 463 |
ni.addTarget(13, ty, NumIndicator.FlyingToType.RIGHT, 0.25f, 0.25f, |
| 464 |
cast(int) (sc * stageManager.rankMultiplier), 20); |
| 465 |
ni.addTarget(12, -8, NumIndicator.FlyingToType.BOTTOM, 0.5f, 0.1f, |
| 466 |
cast(int) (sc * stageManager.rankMultiplier), 40); |
| 467 |
ni.gotoNextTarget(); |
| 468 |
ni = numIndicators.getInstanceForced(); |
| 469 |
int rn = cast(int) (stageManager.rankMultiplier * 1000); |
| 470 |
ni.set(rn, NumIndicator.IndicatorType.MULTIPLIER, 0.4f, 11, 8); |
| 471 |
ni.addTarget(13, ty, NumIndicator.FlyingToType.RIGHT, 0.5f, 0.2f, rn, 40); |
| 472 |
ni.gotoNextTarget(); |
| 473 |
scoreReel.addActualScore(cast(int) (sc * stageManager.rankMultiplier)); |
| 474 |
} |
| 475 |
} |
| 476 |
|
| 477 |
public void destroyedEdge(int n) { |
| 478 |
SoundManager.playSe("explode.wav"); |
| 479 |
int sn = n; |
| 480 |
if (sn > 48) |
| 481 |
sn = 48; |
| 482 |
Vector[] spp = (cast(BaseShape) spec.shape.shape).pointPos; |
| 483 |
float[] spd = (cast(BaseShape)spec.shape.shape).pointDeg; |
| 484 |
int si = rand.nextInt(spp.length); |
| 485 |
edgePos.x = spp[si].x * spec.size + pos.x; |
| 486 |
edgePos.y = spp[si].y * spec.size + pos.y; |
| 487 |
float ss = spec.size * 0.5f; |
| 488 |
if (ss > 1) |
| 489 |
ss = 1; |
| 490 |
for (int i = 0; i < sn; i++) { |
| 491 |
Smoke s = smokes.getInstanceForced(); |
| 492 |
float sr = rand.nextFloat(0.5f); |
| 493 |
float sd = spd[si] + rand.nextSignedFloat(0.2f); |
| 494 |
assert(sd <>= 0); |
| 495 |
s.set(edgePos, sin(sd) * sr, cos(sd) * sr, -0.004f, |
| 496 |
Smoke.SmokeType.EXPLOSION, 75 + rand.nextInt(25), ss); |
| 497 |
for (int j = 0; j < 2; j++) { |
| 498 |
Spark sp = sparks.getInstanceForced(); |
| 499 |
sp.set(edgePos, sin(sd) * sr * 2, cos(sd) * sr * 2, |
| 500 |
0.5f + rand.nextFloat(0.5f), 0.5f + rand.nextFloat(0.5f), 0, 30 + rand.nextInt(30)); |
| 501 |
} |
| 502 |
if (i % 2 == 0) { |
| 503 |
SparkFragment sf = sparkFragments.getInstanceForced(); |
| 504 |
sf.set(edgePos, sin(sd) * sr * 0.5f, cos(sd) * sr * 0.5f, 0.06f + rand.nextFloat(0.07f), |
| 505 |
(0.2f + rand.nextFloat(0.1f))); |
| 506 |
} |
| 507 |
} |
| 508 |
} |
| 509 |
|
| 510 |
public void removeTurrets() { |
| 511 |
for (int i = 0; i < spec.turretGroupNum; i++) |
| 512 |
turretGroup[i].remove(); |
| 513 |
for (int i = 0; i < spec.movingTurretGroupNum; i++) |
| 514 |
movingTurretGroup[i].remove(); |
| 515 |
} |
| 516 |
|
| 517 |
public void draw() { |
| 518 |
glPushMatrix(); |
| 519 |
if (destroyedCnt < 0 && damagedCnt > 0) { |
| 520 |
damagedPos.x = pos.x + rand.nextSignedFloat(damagedCnt * 0.01f); |
| 521 |
damagedPos.y = pos.y + rand.nextSignedFloat(damagedCnt * 0.01f); |
| 522 |
Screen.glTranslate(damagedPos); |
| 523 |
} else { |
| 524 |
Screen.glTranslate(pos); |
| 525 |
} |
| 526 |
glRotatef(-deg * 180 / PI, 0, 0, 1); |
| 527 |
if (destroyedCnt >= 0) |
| 528 |
spec.destroyedShape.draw(); |
| 529 |
else if (!damaged) |
| 530 |
spec.shape.draw(); |
| 531 |
else |
| 532 |
spec.damagedShape.draw(); |
| 533 |
if (destroyedCnt < 0) |
| 534 |
spec.bridgeShape.draw(); |
| 535 |
glPopMatrix(); |
| 536 |
if (destroyedCnt >= 0) |
| 537 |
return; |
| 538 |
for (int i = 0; i < spec.turretGroupNum; i++) |
| 539 |
turretGroup[i].draw(); |
| 540 |
if (multiplier > 1) { |
| 541 |
float ox, oy; |
| 542 |
if (multiplier < 10) |
| 543 |
ox = 2.1f; |
| 544 |
else |
| 545 |
ox = 1.4f; |
| 546 |
oy = 1.25f; |
| 547 |
if(spec.isBoss) { |
| 548 |
ox += 4; |
| 549 |
oy -= 1.25f; |
| 550 |
} |
| 551 |
Letter.drawNumSign(cast(int) (multiplier * 1000), |
| 552 |
pos.x + ox, pos.y + oy, 0.33f, 1, 33, 3); |
| 553 |
} |
| 554 |
} |
| 555 |
} |
| 556 |
|
| 557 |
/** |
| 558 |
* Base class for a specification of an enemy. |
| 559 |
*/ |
| 560 |
public class EnemySpec { |
| 561 |
public: |
| 562 |
static enum EnemyType { |
| 563 |
SMALL, LARGE, PLATFORM, |
| 564 |
}; |
| 565 |
protected: |
| 566 |
static Rand rand; |
| 567 |
Field field; |
| 568 |
Ship ship; |
| 569 |
SparkPool sparks; |
| 570 |
SmokePool smokes; |
| 571 |
FragmentPool fragments; |
| 572 |
WakePool wakes; |
| 573 |
int shield; |
| 574 |
float _size; |
| 575 |
float distRatio; |
| 576 |
TurretGroupSpec[EnemyState.TURRET_GROUP_MAX] turretGroupSpec; |
| 577 |
int turretGroupNum; |
| 578 |
MovingTurretGroupSpec[EnemyState.MOVING_TURRET_GROUP_MAX] movingTurretGroupSpec; |
| 579 |
int movingTurretGroupNum; |
| 580 |
EnemyShape shape, damagedShape, destroyedShape, bridgeShape; |
| 581 |
int type; |
| 582 |
|
| 583 |
invariant { |
| 584 |
assert(shield > 0 && shield < 1000); |
| 585 |
assert(_size > 0 && _size < 20); |
| 586 |
assert(distRatio >= 0 && distRatio <= 1); |
| 587 |
assert(turretGroupNum >= 0 && turretGroupNum <= EnemyState.TURRET_GROUP_MAX); |
| 588 |
assert(movingTurretGroupNum >= 0 && movingTurretGroupNum <= EnemyState.MOVING_TURRET_GROUP_MAX); |
| 589 |
assert(type >= 0); |
| 590 |
} |
| 591 |
|
| 592 |
public static this() { |
| 593 |
rand = new Rand; |
| 594 |
} |
| 595 |
|
| 596 |
public static void setRandSeed(long seed) { |
| 597 |
rand.setSeed(seed); |
| 598 |
} |
| 599 |
|
| 600 |
public this(Field field, Ship ship, |
| 601 |
SparkPool sparks, SmokePool smokes, FragmentPool fragments, WakePool wakes) { |
| 602 |
this.field = field; |
| 603 |
this.ship = ship; |
| 604 |
this.sparks = sparks; |
| 605 |
this.smokes = smokes; |
| 606 |
this.fragments = fragments; |
| 607 |
this.wakes = wakes; |
| 608 |
foreach (inout TurretGroupSpec tgs; turretGroupSpec) |
| 609 |
tgs = new TurretGroupSpec; |
| 610 |
foreach (inout MovingTurretGroupSpec tgs; movingTurretGroupSpec) |
| 611 |
tgs = new MovingTurretGroupSpec; |
| 612 |
distRatio = 0; |
| 613 |
shield = 1; |
| 614 |
_size = 1; |
| 615 |
} |
| 616 |
|
| 617 |
public void set(int type) { |
| 618 |
this.type = type; |
| 619 |
_size = 1; |
| 620 |
distRatio = 0; |
| 621 |
turretGroupNum = movingTurretGroupNum = 0; |
| 622 |
} |
| 623 |
|
| 624 |
public TurretGroupSpec getTurretGroupSpec() { |
| 625 |
turretGroupNum++; |
| 626 |
turretGroupSpec[turretGroupNum - 1].init(); |
| 627 |
return turretGroupSpec[turretGroupNum - 1]; |
| 628 |
} |
| 629 |
|
| 630 |
public MovingTurretGroupSpec getMovingTurretGroupSpec() { |
| 631 |
movingTurretGroupNum++; |
| 632 |
movingTurretGroupSpec[movingTurretGroupNum - 1].init(); |
| 633 |
return movingTurretGroupSpec[movingTurretGroupNum - 1]; |
| 634 |
} |
| 635 |
|
| 636 |
protected void addMovingTurret(float rank, bool bossMode = false) { |
| 637 |
int mtn = cast(int) (rank * 0.2f); |
| 638 |
if (mtn > EnemyState.MOVING_TURRET_GROUP_MAX) |
| 639 |
mtn = EnemyState.MOVING_TURRET_GROUP_MAX; |
| 640 |
if (mtn >= 2) |
| 641 |
mtn = 1 + rand.nextInt(mtn - 1); |
| 642 |
else |
| 643 |
mtn = 1; |
| 644 |
float br = rank / mtn; |
| 645 |
int type; |
| 646 |
if (!bossMode) { |
| 647 |
switch (rand.nextInt(4)) { |
| 648 |
case 0: |
| 649 |
case 1: |
| 650 |
type = MovingTurretGroupSpec.MoveType.ROLL; |
| 651 |
break; |
| 652 |
case 2: |
| 653 |
type = MovingTurretGroupSpec.MoveType.SWING_FIX; |
| 654 |
break; |
| 655 |
case 3: |
| 656 |
type = MovingTurretGroupSpec.MoveType.SWING_AIM; |
| 657 |
break; |
| 658 |
} |
| 659 |
} else { |
| 660 |
type = MovingTurretGroupSpec.MoveType.ROLL; |
| 661 |
} |
| 662 |
float rad = 0.9f + rand.nextFloat(0.4f) - mtn * 0.1f; |
| 663 |
float radInc = 0.5f + rand.nextFloat(0.25f); |
| 664 |
float ad = PI * 2; |
| 665 |
float a, av, dv, s, sv; |
| 666 |
switch (type) { |
| 667 |
case MovingTurretGroupSpec.MoveType.ROLL: |
| 668 |
a = 0.01f + rand.nextFloat(0.04f); |
| 669 |
av = 0.01f + rand.nextFloat(0.03f); |
| 670 |
dv = 0.01f + rand.nextFloat(0.04f); |
| 671 |
break; |
| 672 |
case MovingTurretGroupSpec.MoveType.SWING_FIX: |
| 673 |
ad = PI / 10 + rand.nextFloat(PI / 15); |
| 674 |
s = 0.01f + rand.nextFloat(0.02f); |
| 675 |
sv = 0.01f + rand.nextFloat(0.03f); |
| 676 |
break; |
| 677 |
case MovingTurretGroupSpec.MoveType.SWING_AIM: |
| 678 |
ad = PI / 10 + rand.nextFloat(PI / 15); |
| 679 |
if (rand.nextInt(5) == 0) |
| 680 |
s = 0.01f + rand.nextFloat(0.01f); |
| 681 |
else |
| 682 |
s = 0; |
| 683 |
sv = 0.01f + rand.nextFloat(0.02f); |
| 684 |
break; |
| 685 |
} |
| 686 |
for (int i = 0; i < mtn; i++) { |
| 687 |
MovingTurretGroupSpec tgs = getMovingTurretGroupSpec(); |
| 688 |
tgs.moveType = type; |
| 689 |
tgs.radiusBase = rad; |
| 690 |
float sr; |
| 691 |
switch (type) { |
| 692 |
case MovingTurretGroupSpec.MoveType.ROLL: |
| 693 |
tgs.alignDeg = ad; |
| 694 |
tgs.num = 4 + rand.nextInt(6); |
| 695 |
if (rand.nextInt(2) == 0) { |
| 696 |
if (rand.nextInt(2) == 0) |
| 697 |
tgs.setRoll(dv, 0, 0); |
| 698 |
else |
| 699 |
tgs.setRoll(-dv, 0, 0); |
| 700 |
} else { |
| 701 |
if (rand.nextInt(2) == 0) |
| 702 |
tgs.setRoll(0, a, av); |
| 703 |
else |
| 704 |
tgs.setRoll(0, -a, av); |
| 705 |
} |
| 706 |
if (rand.nextInt(3) == 0) |
| 707 |
tgs.setRadiusAmp(1 + rand.nextFloat(1), 0.01f + rand.nextFloat(0.03f)); |
| 708 |
if (rand.nextInt(2) == 0) |
| 709 |
tgs.distRatio = 0.8f + rand.nextSignedFloat(0.3f); |
| 710 |
sr = br / tgs.num; |
| 711 |
break; |
| 712 |
case MovingTurretGroupSpec.MoveType.SWING_FIX: |
| 713 |
tgs.num = 3 + rand.nextInt(5); |
| 714 |
tgs.alignDeg = ad * (tgs.num * 0.1f + 0.3f); |
| 715 |
if (rand.nextInt(2) == 0) |
| 716 |
tgs.setSwing(s, sv); |
| 717 |
else |
| 718 |
tgs.setSwing(-s, sv); |
| 719 |
if (rand.nextInt(6) == 0) |
| 720 |
tgs.setRadiusAmp(1 + rand.nextFloat(1), 0.01f + rand.nextFloat(0.03f)); |
| 721 |
if (rand.nextInt(4) == 0) |
| 722 |
tgs.setAlignAmp(0.25f + rand.nextFloat(0.25f), 0.01f + rand.nextFloat(0.02f)); |
| 723 |
sr = br / tgs.num; |
| 724 |
sr *= 0.6f; |
| 725 |
break; |
| 726 |
case MovingTurretGroupSpec.MoveType.SWING_AIM: |
| 727 |
tgs.num = 3 + rand.nextInt(4); |
| 728 |
tgs.alignDeg = ad * (tgs.num * 0.1f + 0.3f); |
| 729 |
if (rand.nextInt(2) == 0) |
| 730 |
tgs.setSwing(s, sv, true); |
| 731 |
else |
| 732 |
tgs.setSwing(-s, sv, true); |
| 733 |
if (rand.nextInt(4) == 0) |
| 734 |
tgs.setRadiusAmp(1 + rand.nextFloat(1), 0.01f + rand.nextFloat(0.03f)); |
| 735 |
if (rand.nextInt(5) == 0) |
| 736 |
tgs.setAlignAmp(0.25f + rand.nextFloat(0.25f), 0.01f + rand.nextFloat(0.02f)); |
| 737 |
sr = br / tgs.num; |
| 738 |
sr *= 0.4f; |
| 739 |
break; |
| 740 |
} |
| 741 |
if (rand.nextInt(4) == 0) |
| 742 |
tgs.setXReverse(-1); |
| 743 |
tgs.turretSpec.setParam(sr, TurretSpec.TurretType.MOVING, rand); |
| 744 |
if (bossMode) |
| 745 |
tgs.turretSpec.setBossSpec(); |
| 746 |
rad += radInc; |
| 747 |
ad *= 1 + rand.nextSignedFloat(0.2f); |
| 748 |
} |
| 749 |
} |
| 750 |
|
| 751 |
public bool checkCollision(EnemyState es, float x, float y, Collidable c, Shot shot) { |
| 752 |
return es.checkCollision(x, y, c, shot); |
| 753 |
} |
| 754 |
|
| 755 |
public bool checkShipCollision(EnemyState es, float x, float y, bool largeOnly = false) { |
| 756 |
if (es.destroyedCnt >= 0 || (largeOnly && type != EnemyType.LARGE)) |
| 757 |
return false; |
| 758 |
return shape.checkShipCollision(x - es.pos.x, y - es.pos.y, es.deg); |
| 759 |
} |
| 760 |
|
| 761 |
public bool move(EnemyState es) { |
| 762 |
return es.move(); |
| 763 |
} |
| 764 |
|
| 765 |
public void draw(EnemyState es) { |
| 766 |
es.draw(); |
| 767 |
} |
| 768 |
|
| 769 |
public float size() { |
| 770 |
return _size; |
| 771 |
} |
| 772 |
|
| 773 |
public float size(float v) { |
| 774 |
_size = v; |
| 775 |
if (shape) |
| 776 |
shape.size = _size; |
| 777 |
if (damagedShape) |
| 778 |
damagedShape.size = _size; |
| 779 |
if (destroyedShape) |
| 780 |
destroyedShape.size = _size; |
| 781 |
if (bridgeShape) { |
| 782 |
float s = 0.9f; |
| 783 |
bridgeShape.size = s * (1 - distRatio); |
| 784 |
} |
| 785 |
return _size; |
| 786 |
} |
| 787 |
|
| 788 |
public bool isSmallEnemy() { |
| 789 |
if (type == EnemyType.SMALL) |
| 790 |
return true; |
| 791 |
else |
| 792 |
return false; |
| 793 |
} |
| 794 |
|
| 795 |
public abstract int score(); |
| 796 |
public abstract bool isBoss(); |
| 797 |
} |
| 798 |
|
| 799 |
public interface HasAppearType { |
| 800 |
public bool setFirstState(EnemyState es, int appType); |
| 801 |
} |
| 802 |
|
| 803 |
/** |
| 804 |
* Specification for a small class ship. |
| 805 |
*/ |
| 806 |
public class SmallShipEnemySpec: EnemySpec, HasAppearType { |
| 807 |
public: |
| 808 |
static enum MoveType { |
| 809 |
STOPANDGO, CHASE, |
| 810 |
}; |
| 811 |
static enum MoveState { |
| 812 |
STAYING, MOVING, |
| 813 |
}; |
| 814 |
private: |
| 815 |
int type; |
| 816 |
float accel, maxSpeed, staySpeed; |
| 817 |
int moveDuration, stayDuration; |
| 818 |
float speed, turnDeg; |
| 819 |
|
| 820 |
invariant { |
| 821 |
assert(type >= 0); |
| 822 |
assert(accel >= 0 && accel <= 1); |
| 823 |
assert(maxSpeed < 10 && maxSpeed > -10); |
| 824 |
assert(staySpeed < 10 && staySpeed > -10); |
| 825 |
assert(moveDuration > 0 && moveDuration < 500); |
| 826 |
assert(stayDuration > 0 && stayDuration < 500); |
| 827 |
assert(speed < 10 && speed > -10); |
| 828 |
assert(turnDeg < 1 && turnDeg > -1); |
| 829 |
} |
| 830 |
|
| 831 |
public this(Field field, Ship ship, |
| 832 |
SparkPool sparks, SmokePool smokes, FragmentPool fragments, WakePool wakes) { |
| 833 |
super(field, ship, sparks, smokes, fragments, wakes); |
| 834 |
type = 0; |
| 835 |
accel = maxSpeed = staySpeed = 0; |
| 836 |
moveDuration = stayDuration = 1; |
| 837 |
speed = turnDeg = 0; |
| 838 |
} |
| 839 |
|
| 840 |
public void setParam(float rank, Rand rand) { |
| 841 |
set(EnemyType.SMALL); |
| 842 |
shape = new EnemyShape(EnemyShape.EnemyShapeType.SMALL); |
| 843 |
damagedShape = new EnemyShape(EnemyShape.EnemyShapeType.SMALL_DAMAGED); |
| 844 |
bridgeShape = new EnemyShape(EnemyShape.EnemyShapeType.SMALL_BRIDGE); |
| 845 |
type = rand.nextInt(2); |
| 846 |
float sr = rand.nextFloat(rank * 0.8f); |
| 847 |
if (sr > 25) |
| 848 |
sr = 25; |
| 849 |
switch (type) { |
| 850 |
case MoveType.STOPANDGO: |
| 851 |
distRatio = 0.5f; |
| 852 |
size = 0.47f + rand.nextFloat(0.1f); |
| 853 |
accel = 0.5f - 0.5f / (2.0f + rand.nextFloat(rank)); |
| 854 |
maxSpeed = 0.05f * (1.0f + sr); |
| 855 |
staySpeed = 0.03f; |
| 856 |
moveDuration = 32 + rand.nextSignedInt(12); |
| 857 |
stayDuration = 32 + rand.nextSignedInt(12); |
| 858 |
break; |
| 859 |
case MoveType.CHASE: |
| 860 |
distRatio = 0.5f; |
| 861 |
size = 0.5f + rand.nextFloat(0.1f); |
| 862 |
speed = 0.036f * (1.0f + sr); |
| 863 |
turnDeg = 0.02f + rand.nextSignedFloat(0.04f); |
| 864 |
break; |
| 865 |
} |
| 866 |
shield = 1; |
| 867 |
TurretGroupSpec tgs = getTurretGroupSpec(); |
| 868 |
tgs.turretSpec.setParam(rank - sr * 0.5f, TurretSpec.TurretType.SMALL, rand); |
| 869 |
} |
| 870 |
|
| 871 |
public bool setFirstState(EnemyState es, int appType) { |
| 872 |
es.setSpec(this); |
| 873 |
if (!es.setAppearancePos(field, ship, rand, appType)) |
| 874 |
return false; |
| 875 |
switch (type) { |
| 876 |
case MoveType.STOPANDGO: |
| 877 |
es.speed = 0; |
| 878 |
es.state = MoveState.MOVING; |
| 879 |
es.cnt = moveDuration; |
| 880 |
break; |
| 881 |
case MoveType.CHASE: |
| 882 |
es.speed = speed; |
| 883 |
break; |
| 884 |
} |
| 885 |
return true; |
| 886 |
} |
| 887 |
|
| 888 |
public bool move(EnemyState es) { |
| 889 |
if (!super.move(es)) |
| 890 |
return false; |
| 891 |
switch (type) { |
| 892 |
case MoveType.STOPANDGO: |
| 893 |
es.pos.x += sin(es.velDeg) * es.speed; |
| 894 |
es.pos.y += cos(es.velDeg) * es.speed; |
| 895 |
es.pos.y -= field.lastScrollY; |
| 896 |
if (es.pos.y <= -field.outerSize.y) |
| 897 |
return false; |
| 898 |
if (field.getBlock(es.pos) >= 0 || !field.checkInOuterHeightField(es.pos)) { |
| 899 |
es.velDeg += PI; |
| 900 |
es.pos.x += sin(es.velDeg) * es.speed * 2; |
| 901 |
es.pos.y += cos(es.velDeg) * es.speed * 2; |
| 902 |
} |
| 903 |
switch (es.state) { |
| 904 |
case MoveState.MOVING: |
| 905 |
es.speed += (maxSpeed - es.speed) * accel; |
| 906 |
es.cnt--; |
| 907 |
if (es.cnt <= 0) { |
| 908 |
es.velDeg = rand.nextFloat(PI * 2); |
| 909 |
es.cnt = stayDuration; |
| 910 |
es.state = MoveState.STAYING; |
| 911 |
} |
| 912 |
break; |
| 913 |
case MoveState.STAYING: |
| 914 |
es.speed += (staySpeed - es.speed) * accel; |
| 915 |
es.cnt--; |
| 916 |
if (es.cnt <= 0) { |
| 917 |
es.cnt = moveDuration; |
| 918 |
es.state = MoveState.MOVING; |
| 919 |
} |
| 920 |
break; |
| 921 |
} |
| 922 |
break; |
| 923 |
case MoveType.CHASE: |
| 924 |
es.pos.x += sin(es.velDeg) * speed; |
| 925 |
es.pos.y += cos(es.velDeg) * speed; |
| 926 |
es.pos.y -= field.lastScrollY; |
| 927 |
if (es.pos.y <= -field.outerSize.y) |
| 928 |
return false; |
| 929 |
if (field.getBlock(es.pos) >= 0 || !field.checkInOuterHeightField(es.pos)) { |
| 930 |
es.velDeg += PI; |
| 931 |
es.pos.x += sin(es.velDeg) * es.speed * 2; |
| 932 |
es.pos.y += cos(es.velDeg) * es.speed * 2; |
| 933 |
} |
| 934 |
float ad; |
| 935 |
Vector shipPos = ship.nearPos(es.pos); |
| 936 |
if (shipPos.dist(es.pos) < 0.1f) |
| 937 |
ad = 0; |
| 938 |
else |
| 939 |
ad = atan2(shipPos.x - es.pos.x, shipPos.y - es.pos.y); |
| 940 |
assert(ad <>= 0); |
| 941 |
float od = ad - es.velDeg; |
| 942 |
Math.normalizeDeg(od); |
| 943 |
if (od <= turnDeg && od >= -turnDeg) |
| 944 |
es.velDeg = ad; |
| 945 |
else if (od < 0) |
| 946 |
es.velDeg -= turnDeg; |
| 947 |
else |
| 948 |
es.velDeg += turnDeg; |
| 949 |
Math.normalizeDeg(es.velDeg); |
| 950 |
es.cnt++; |
| 951 |
} |
| 952 |
float od = es.velDeg - es.deg; |
| 953 |
Math.normalizeDeg(od); |
| 954 |
es.deg += od * 0.05f; |
| 955 |
Math.normalizeDeg(es.deg); |
| 956 |
if (es.cnt % 6 == 0 && es.speed >= 0.03f) |
| 957 |
shape.addWake(wakes, es.pos, es.deg, es.speed); |
| 958 |
return true; |
| 959 |
} |
| 960 |
|
| 961 |
public int score() { |
| 962 |
return 50; |
| 963 |
} |
| 964 |
|
| 965 |
public bool isBoss() { |
| 966 |
return false; |
| 967 |
} |
| 968 |
} |
| 969 |
|
| 970 |
/** |
| 971 |
* Specification for a large/middle class ship. |
| 972 |
*/ |
| 973 |
public class ShipEnemySpec: EnemySpec, HasAppearType { |
| 974 |
public: |
| 975 |
static enum ShipClass { |
| 976 |
MIDDLE, LARGE, BOSS, |
| 977 |
}; |
| 978 |
private: |
| 979 |
static const int SINK_INTERVAL = 120; |
| 980 |
float speed, degVel; |
| 981 |
int shipClass; |
| 982 |
|
| 983 |
invariant { |
| 984 |
assert(speed < 10 && speed > -10); |
| 985 |
assert(degVel < 1 && degVel > -1); |
| 986 |
} |
| 987 |
|
| 988 |
public this(Field field, Ship ship, |
| 989 |
SparkPool sparks, SmokePool smokes, FragmentPool fragments, WakePool wakes) { |
| 990 |
super(field, ship, sparks, smokes, fragments, wakes); |
| 991 |
speed = degVel = 0; |
| 992 |
} |
| 993 |
|
| 994 |
public void setParam(float rank, int cls, Rand rand) { |
| 995 |
shipClass = cls; |
| 996 |
set(EnemyType.LARGE); |
| 997 |
shape = new EnemyShape(EnemyShape.EnemyShapeType.MIDDLE); |
| 998 |
damagedShape = new EnemyShape(EnemyShape.EnemyShapeType.MIDDLE_DAMAGED); |
| 999 |
destroyedShape = new EnemyShape(EnemyShape.EnemyShapeType.MIDDLE_DESTROYED); |
| 1000 |
bridgeShape = new EnemyShape(EnemyShape.EnemyShapeType.MIDDLE_BRIDGE); |
| 1001 |
distRatio = 0.7f; |
| 1002 |
int mainTurretNum = 0, subTurretNum = 0; |
| 1003 |
float movingTurretRatio = 0; |
| 1004 |
float rk = rank; |
| 1005 |
switch (cls) { |
| 1006 |
case ShipClass.MIDDLE: |
| 1007 |
float sz = 1.5f + rank / 15 + rand.nextFloat(rank / 15); |
| 1008 |
float ms = 2 + rand.nextFloat(0.5f); |
| 1009 |
if (sz > ms) |
| 1010 |
sz = ms; |
| 1011 |
size = sz; |
| 1012 |
speed = 0.015f + rand.nextSignedFloat(0.005f); |
| 1013 |
degVel = 0.005f + rand.nextSignedFloat(0.003f); |
| 1014 |
switch (rand.nextInt(3)) { |
| 1015 |
case 0: |
| 1016 |
mainTurretNum = cast(int) (size * (1 + rand.nextSignedFloat(0.25f)) + 1); |
| 1017 |
break; |
| 1018 |
case 1: |
| 1019 |
subTurretNum = cast(int) (size * 1.6f * (1 + rand.nextSignedFloat(0.5f)) + 2); |
| 1020 |
break; |
| 1021 |
case 2: |
| 1022 |
mainTurretNum = cast(int) (size * (0.5f + rand.nextSignedFloat(0.12f)) + 1); |
| 1023 |
movingTurretRatio = 0.5f + rand.nextFloat(0.25f); |
| 1024 |
rk = rank * (1 - movingTurretRatio); |
| 1025 |
movingTurretRatio *= 2; |
| 1026 |
break; |
| 1027 |
} |
| 1028 |
break; |
| 1029 |
case ShipClass.LARGE: |
| 1030 |
float sz = 2.5f + rank / 24 + rand.nextFloat(rank / 24); |
| 1031 |
float ms = 3 + rand.nextFloat(1); |
| 1032 |
if (sz > ms) |
| 1033 |
sz = ms; |
| 1034 |
size = sz; |
| 1035 |
speed = 0.01f + rand.nextSignedFloat(0.005f); |
| 1036 |
degVel = 0.003f + rand.nextSignedFloat(0.002f); |
| 1037 |
mainTurretNum = cast(int) (size * (0.7f + rand.nextSignedFloat(0.2f)) + 1); |
| 1038 |
subTurretNum = cast(int) (size * 1.6f * (0.7f + rand.nextSignedFloat(0.33f)) + 2); |
| 1039 |
movingTurretRatio = 0.25f + rand.nextFloat(0.5f); |
| 1040 |
rk = rank * (1 - movingTurretRatio); |
| 1041 |
movingTurretRatio *= 3; |
| 1042 |
break; |
| 1043 |
case ShipClass.BOSS: |
| 1044 |
float sz = 5 + rank / 30 + rand.nextFloat(rank / 30); |
| 1045 |
float ms = 9 + rand.nextFloat(3); |
| 1046 |
if (sz > ms) |
| 1047 |
sz = ms; |
| 1048 |
size = sz; |
| 1049 |
speed = ship.scrollSpeedBase + 0.0025f + rand.nextSignedFloat(0.001f); |
| 1050 |
degVel = 0.003f + rand.nextSignedFloat(0.002f); |
| 1051 |
mainTurretNum = cast(int) (size * 0.8f * (1.5f + rand.nextSignedFloat(0.4f)) + 2); |
| 1052 |
subTurretNum = cast(int) (size * 0.8f * (2.4f + rand.nextSignedFloat(0.6f)) + 2); |
| 1053 |
movingTurretRatio = 0.2f + rand.nextFloat(0.3f); |
| 1054 |
rk = rank * (1 - movingTurretRatio); |
| 1055 |
movingTurretRatio *= 2.5f; |
| 1056 |
break; |
| 1057 |
} |
| 1058 |
shield = cast(int) (size * 10); |
| 1059 |
if (cls == ShipClass.BOSS) |
| 1060 |
shield *= 2.4f; |
| 1061 |
if (mainTurretNum + subTurretNum <= 0) { |
| 1062 |
TurretGroupSpec tgs = getTurretGroupSpec(); |
| 1063 |
tgs.turretSpec.setParam(0, TurretSpec.TurretType.DUMMY, rand); |
| 1064 |
} else { |
| 1065 |
float subTurretRank = rk / (mainTurretNum * 3 + subTurretNum); |
| 1066 |
float mainTurretRank = subTurretRank * 2.5f; |
| 1067 |
if (cls != ShipClass.BOSS) { |
| 1068 |
int frontMainTurretNum = cast(int) (mainTurretNum / 2 + 0.99f); |
| 1069 |
int rearMainTurretNum = mainTurretNum - frontMainTurretNum; |
| 1070 |
if (frontMainTurretNum > 0) { |
| 1071 |
TurretGroupSpec tgs = getTurretGroupSpec(); |
| 1072 |
tgs.turretSpec.setParam(mainTurretRank, TurretSpec.TurretType.MAIN, rand); |
| 1073 |
tgs.num = frontMainTurretNum; |
| 1074 |
tgs.alignType = TurretGroupSpec.AlignType.STRAIGHT; |
| 1075 |
tgs.offset.y = -size * (0.9f + rand.nextSignedFloat(0.05f)); |
| 1076 |
} |
| 1077 |
if (rearMainTurretNum > 0) { |
| 1078 |
TurretGroupSpec tgs = getTurretGroupSpec(); |
| 1079 |
tgs.turretSpec.setParam(mainTurretRank, TurretSpec.TurretType.MAIN, rand); |
| 1080 |
tgs.num = rearMainTurretNum; |
| 1081 |
tgs.alignType = TurretGroupSpec.AlignType.STRAIGHT; |
| 1082 |
tgs.offset.y = size * (0.9f + rand.nextSignedFloat(0.05f)); |
| 1083 |
} |
| 1084 |
TurretSpec pts; |
| 1085 |
if (subTurretNum > 0) { |
| 1086 |
int frontSubTurretNum = (subTurretNum + 2) / 4; |
| 1087 |
int rearSubTurretNum = (subTurretNum - frontSubTurretNum * 2) / 2; |
| 1088 |
int tn = frontSubTurretNum; |
| 1089 |
float ad = -PI / 4; |
| 1090 |
for (int i = 0; i < 4; i++) { |
| 1091 |
if (i == 2) |
| 1092 |
tn = rearSubTurretNum; |
| 1093 |
if (tn <= 0) |
| 1094 |
continue; |
| 1095 |
TurretGroupSpec tgs = getTurretGroupSpec(); |
| 1096 |
if (i == 0 || i == 2) { |
| 1097 |
if (rand.nextInt(2) == 0) |
| 1098 |
tgs.turretSpec.setParam(subTurretRank, TurretSpec.TurretType.SUB, rand); |
| 1099 |
else |
| 1100 |
tgs.turretSpec.setParam(subTurretRank, TurretSpec.TurretType.SUB_DESTRUCTIVE, rand); |
| 1101 |
pts = tgs.turretSpec; |
| 1102 |
} else { |
| 1103 |
tgs.turretSpec.setParam(pts); |
| 1104 |
} |
| 1105 |
tgs.num = tn; |
| 1106 |
tgs.alignType = TurretGroupSpec.AlignType.ROUND; |
| 1107 |
tgs.alignDeg = ad; |
| 1108 |
ad += PI / 2; |
| 1109 |
tgs.alignWidth = PI / 6 + rand.nextFloat(PI / 8); |
| 1110 |
tgs.radius = size * 0.75f; |
| 1111 |
tgs.distRatio = distRatio; |
| 1112 |
} |
| 1113 |
} |
| 1114 |
} else { |
| 1115 |
mainTurretRank *= 2.5f; |
| 1116 |
subTurretRank *= 2; |
| 1117 |
TurretSpec pts; |
| 1118 |
if (mainTurretNum > 0) { |
| 1119 |
int frontMainTurretNum = (mainTurretNum + 2) / 4; |
| 1120 |
int rearMainTurretNum = (mainTurretNum - frontMainTurretNum * 2) / 2; |
| 1121 |
int tn = frontMainTurretNum; |
| 1122 |
float ad = -PI / 4; |
| 1123 |
for (int i = 0; i < 4; i++) { |
| 1124 |
if (i == 2) |
| 1125 |
tn = rearMainTurretNum; |
| 1126 |
if (tn <= 0) |
| 1127 |
continue; |
| 1128 |
TurretGroupSpec tgs = getTurretGroupSpec(); |
| 1129 |
if (i == 0 || i == 2) { |
| 1130 |
tgs.turretSpec.setParam(mainTurretRank, TurretSpec.TurretType.MAIN, rand); |
| 1131 |
pts = tgs.turretSpec; |
| 1132 |
pts.setBossSpec(); |
| 1133 |
} else { |
| 1134 |
tgs.turretSpec.setParam(pts); |
| 1135 |
} |
| 1136 |
tgs.num = tn; |
| 1137 |
tgs.alignType = TurretGroupSpec.AlignType.ROUND; |
| 1138 |
tgs.alignDeg = ad; |
| 1139 |
ad += PI / 2; |
| 1140 |
tgs.alignWidth = PI / 6 + rand.nextFloat(PI / 8); |
| 1141 |
tgs.radius = size * 0.45f; |
| 1142 |
tgs.distRatio = distRatio; |
| 1143 |
} |
| 1144 |
} |
| 1145 |
if (subTurretNum > 0) { |
| 1146 |
int[3] tn; |
| 1147 |
tn[0] = (subTurretNum + 2) / 6; |
| 1148 |
tn[1] = (subTurretNum - tn[0] * 2) / 4; |
| 1149 |
tn[2] = (subTurretNum - tn[0] * 2 - tn[1] * 2) / 2; |
| 1150 |
static const float[] ad = [PI / 4, -PI / 4, PI / 2, -PI / 2, PI / 4 * 3, -PI / 4 * 3]; |
| 1151 |
for (int i = 0; i < 6; i++) { |
| 1152 |
int idx = i / 2; |
| 1153 |
if (tn[idx] <= 0) |
| 1154 |
continue; |
| 1155 |
TurretGroupSpec tgs = getTurretGroupSpec(); |
| 1156 |
if (i == 0 || i == 2 || i == 4) { |
| 1157 |
if (rand.nextInt(2) == 0) |
| 1158 |
tgs.turretSpec.setParam(subTurretRank, TurretSpec.TurretType.SUB, rand); |
| 1159 |
else |
| 1160 |
tgs.turretSpec.setParam(subTurretRank, TurretSpec.TurretType.SUB_DESTRUCTIVE, rand); |
| 1161 |
pts = tgs.turretSpec; |
| 1162 |
pts.setBossSpec(); |
| 1163 |
} else { |
| 1164 |
tgs.turretSpec.setParam(pts); |
| 1165 |
} |
| 1166 |
tgs.num = tn[idx]; |
| 1167 |
tgs.alignType = TurretGroupSpec.AlignType.ROUND; |
| 1168 |
tgs.alignDeg = ad[i]; |
| 1169 |
tgs.alignWidth = PI / 7 + rand.nextFloat(PI / 9); |
| 1170 |
tgs.radius = size * 0.75f; |
| 1171 |
tgs.distRatio = distRatio; |
| 1172 |
} |
| 1173 |
} |
| 1174 |
} |
| 1175 |
} |
| 1176 |
if (movingTurretRatio > 0) { |
| 1177 |
if (cls == ShipClass.BOSS) |
| 1178 |
addMovingTurret(rank * movingTurretRatio, true); |
| 1179 |
else |
| 1180 |
addMovingTurret(rank * movingTurretRatio); |
| 1181 |
} |
| 1182 |
} |
| 1183 |
|
| 1184 |
public bool setFirstState(EnemyState es, int appType) { |
| 1185 |
es.setSpec(this); |
| 1186 |
if (!es.setAppearancePos(field, ship, rand, appType)) |
| 1187 |
return false; |
| 1188 |
es.speed = speed; |
| 1189 |
if (es.pos.x < 0) |
| 1190 |
es.turnWay = -1; |
| 1191 |
else |
| 1192 |
es.turnWay = 1; |
| 1193 |
if (isBoss) { |
| 1194 |
es.trgDeg = rand.nextFloat(0.1f) + 0.1f; |
| 1195 |
if (rand.nextInt(2) == 0) |
| 1196 |
es.trgDeg *= -1; |
| 1197 |
es.turnCnt = 250 + rand.nextInt(150); |
| 1198 |
} |
| 1199 |
return true; |
| 1200 |
} |
| 1201 |
|
| 1202 |
public bool move(EnemyState es) { |
| 1203 |
if (es.destroyedCnt >= SINK_INTERVAL) |
| 1204 |
return false; |
| 1205 |
if (!super.move(es)) |
| 1206 |
return false; |
| 1207 |
es.pos.x += sin(es.deg) * es.speed; |
| 1208 |
es.pos.y += cos(es.deg) * es.speed; |
| 1209 |
es.pos.y -= field.lastScrollY; |
| 1210 |
if (es.pos.x <= -field.outerSize.x - size || es.pos.x >= field.outerSize.x + size || |
| 1211 |
es.pos.y <= -field.outerSize.y - size) |
| 1212 |
return false; |
| 1213 |
if (es.pos.y > field.outerSize.y * 2.2f + size) |
| 1214 |
es.pos.y = field.outerSize.y * 2.2f + size; |
| 1215 |
if (isBoss) { |
| 1216 |
es.turnCnt--; |
| 1217 |
if (es.turnCnt <= 0) { |
| 1218 |
es.turnCnt = 250 + rand.nextInt(150); |
| 1219 |
es.trgDeg = rand.nextFloat(0.1f) + 0.2f; |
| 1220 |
if (es.pos.x > 0) |
| 1221 |
es.trgDeg *= -1; |
| 1222 |
} |
| 1223 |
es.deg += (es.trgDeg - es.deg) * 0.0025f; |
| 1224 |
if (ship.higherPos.y > es.pos.y) |
| 1225 |
es.speed += (speed * 2 - es.speed) * 0.005f; |
| 1226 |
else |
| 1227 |
es.speed += (speed - es.speed) * 0.01f; |
| 1228 |
} else { |
| 1229 |
if (!es.checkFrontClear()) { |
| 1230 |
es.deg += degVel * es.turnWay; |
| 1231 |
es.speed *= 0.98f; |
| 1232 |
} else { |
| 1233 |
if (es.destroyedCnt < 0) |
| 1234 |
es.speed += (speed - es.speed) * 0.01f; |
| 1235 |
else |
| 1236 |
es.speed *= 0.98f; |
| 1237 |
} |
| 1238 |
} |
| 1239 |
es.cnt++; |
| 1240 |
if (es.cnt % 6 == 0 && es.speed >= 0.01f && es.destroyedCnt < SINK_INTERVAL / 2) |
| 1241 |
shape.addWake(wakes, es.pos, es.deg, es.speed); |
| 1242 |
return true; |
| 1243 |
} |
| 1244 |
|
| 1245 |
public override void draw(EnemyState es) { |
| 1246 |
if (es.destroyedCnt >= 0) |
| 1247 |
Screen.setColor( |
| 1248 |
EnemyShape.MIDDLE_COLOR_R * (1 - cast(float) es.destroyedCnt / SINK_INTERVAL) * 0.5f, |
| 1249 |
EnemyShape.MIDDLE_COLOR_G * (1 - cast(float) es.destroyedCnt / SINK_INTERVAL) * 0.5f, |
| 1250 |
EnemyShape.MIDDLE_COLOR_B * (1 - cast(float) es.destroyedCnt / SINK_INTERVAL) * 0.5f); |
| 1251 |
super.draw(es); |
| 1252 |
} |
| 1253 |
|
| 1254 |
public int score() { |
| 1255 |
switch (shipClass) { |
| 1256 |
case ShipClass.MIDDLE: |
| 1257 |
return 100; |
| 1258 |
case ShipClass.LARGE: |
| 1259 |
return 300; |
| 1260 |
case ShipClass.BOSS: |
| 1261 |
return 1000; |
| 1262 |
} |
| 1263 |
} |
| 1264 |
|
| 1265 |
public bool isBoss() { |
| 1266 |
if (shipClass == ShipClass.BOSS) |
| 1267 |
return true; |
| 1268 |
return false; |
| 1269 |
} |
| 1270 |
} |
| 1271 |
|
| 1272 |
/** |
| 1273 |
* Specification for a sea-based platform. |
| 1274 |
*/ |
| 1275 |
public class PlatformEnemySpec: EnemySpec { |
| 1276 |
private: |
| 1277 |
|
| 1278 |
public this(Field field, Ship ship, |
| 1279 |
SparkPool sparks, SmokePool smokes, FragmentPool fragments, WakePool wakes) { |
| 1280 |
super(field, ship, sparks, smokes, fragments, wakes); |
| 1281 |
} |
| 1282 |
|
| 1283 |
public void setParam(float rank, Rand rand) { |
| 1284 |
set(EnemyType.PLATFORM); |
| 1285 |
shape = new EnemyShape(EnemyShape.EnemyShapeType.PLATFORM); |
| 1286 |
damagedShape = new EnemyShape(EnemyShape.EnemyShapeType.PLATFORM_DAMAGED); |
| 1287 |
destroyedShape = new EnemyShape(EnemyShape.EnemyShapeType.PLATFORM_DESTROYED); |
| 1288 |
bridgeShape = new EnemyShape(EnemyShape.EnemyShapeType.PLATFORM_BRIDGE); |
| 1289 |
distRatio = 0; |
| 1290 |
size = 1 + rank / 30 + rand.nextFloat(rank / 30); |
| 1291 |
float ms = 1 + rand.nextFloat(0.25f); |
| 1292 |
if (size > ms) |
| 1293 |
size = ms; |
| 1294 |
int mainTurretNum = 0, frontTurretNum = 0, sideTurretNum = 0; |
| 1295 |
float rk = rank; |
| 1296 |
float movingTurretRatio = 0; |
| 1297 |
switch (rand.nextInt(3)) { |
| 1298 |
case 0: |
| 1299 |
frontTurretNum = cast(int) (size * (2 + rand.nextSignedFloat(0.5f)) + 1); |
| 1300 |
movingTurretRatio = 0.33f + rand.nextFloat(0.46f); |
| 1301 |
rk *= (1 - movingTurretRatio); |
| 1302 |
movingTurretRatio *= 2.5f; |
| 1303 |
break; |
| 1304 |
case 1: |
| 1305 |
frontTurretNum = cast(int) (size * (0.5f + rand.nextSignedFloat(0.2f)) + 1); |
| 1306 |
sideTurretNum = cast(int) (size * (0.5f + rand.nextSignedFloat(0.2f)) + 1) * 2; |
| 1307 |
break; |
| 1308 |
case 2: |
| 1309 |
mainTurretNum = cast(int) (size * (1 + rand.nextSignedFloat(0.33f)) + 1); |
| 1310 |
break; |
| 1311 |
} |
| 1312 |
shield = cast(int) (size * 20); |
| 1313 |
int subTurretNum = frontTurretNum + sideTurretNum; |
| 1314 |
float subTurretRank = rk / (mainTurretNum * 3 + subTurretNum); |
| 1315 |
float mainTurretRank = subTurretRank * 2.5f; |
| 1316 |
if (mainTurretNum > 0) { |
| 1317 |
TurretGroupSpec tgs = getTurretGroupSpec(); |
| 1318 |
tgs.turretSpec.setParam(mainTurretRank, TurretSpec.TurretType.MAIN, rand); |
| 1319 |
tgs.num = mainTurretNum; |
| 1320 |
tgs.alignType = TurretGroupSpec.AlignType.ROUND; |
| 1321 |
tgs.alignDeg = 0; |
| 1322 |
tgs.alignWidth = PI * 0.66f + rand.nextFloat(PI / 2); |
| 1323 |
tgs.radius = size * 0.7f; |
| 1324 |
tgs.distRatio = distRatio; |
| 1325 |
} |
| 1326 |
if (frontTurretNum > 0) { |
| 1327 |
TurretGroupSpec tgs = getTurretGroupSpec(); |
| 1328 |
tgs.turretSpec.setParam(subTurretRank, TurretSpec.TurretType.SUB, rand); |
| 1329 |
tgs.num = frontTurretNum; |
| 1330 |
tgs.alignType = TurretGroupSpec.AlignType.ROUND; |
| 1331 |
tgs.alignDeg = 0; |
| 1332 |
tgs.alignWidth = PI / 5 + rand.nextFloat(PI / 6); |
| 1333 |
tgs.radius = size * 0.8f; |
| 1334 |
tgs.distRatio = distRatio; |
| 1335 |
} |
| 1336 |
sideTurretNum /= 2; |
| 1337 |
if (sideTurretNum > 0) { |
| 1338 |
TurretSpec pts; |
| 1339 |
for (int i = 0; i < 2; i++) { |
| 1340 |
TurretGroupSpec tgs = getTurretGroupSpec(); |
| 1341 |
if (i == 0) { |
| 1342 |
tgs.turretSpec.setParam(subTurretRank, TurretSpec.TurretType.SUB, rand); |
| 1343 |
pts = tgs.turretSpec; |
| 1344 |
} else { |
| 1345 |
tgs.turretSpec.setParam(pts); |
| 1346 |
} |
| 1347 |
tgs.num = sideTurretNum; |
| 1348 |
tgs.alignType = TurretGroupSpec.AlignType.ROUND; |
| 1349 |
tgs.alignDeg = PI / 2 - PI * i; |
| 1350 |
tgs.alignWidth = PI / 5 + rand.nextFloat(PI / 6); |
| 1351 |
tgs.radius = size * 0.75f; |
| 1352 |
tgs.distRatio = distRatio; |
| 1353 |
} |
| 1354 |
} |
| 1355 |
if (movingTurretRatio > 0) { |
| 1356 |
addMovingTurret(rank * movingTurretRatio); |
| 1357 |
} |
| 1358 |
} |
| 1359 |
|
| 1360 |
public bool setFirstState(EnemyState es, float x, float y, float d) { |
| 1361 |
es.setSpec(this); |
| 1362 |
es.pos.x = x; |
| 1363 |
es.pos.y = y; |
| 1364 |
es.deg = d; |
| 1365 |
es.speed = 0; |
| 1366 |
if (!es.checkFrontClear(true)) |
| 1367 |
return false; |
| 1368 |
return true; |
| 1369 |
} |
| 1370 |
|
| 1371 |
public bool move(EnemyState es) { |
| 1372 |
if (!super.move(es)) |
| 1373 |
return false; |
| 1374 |
es.pos.y -= field.lastScrollY; |
| 1375 |
if (es.pos.y <= -field.outerSize.y) |
| 1376 |
return false; |
| 1377 |
return true; |
| 1378 |
} |
| 1379 |
|
| 1380 |
public int score() { |
| 1381 |
return 100; |
| 1382 |
} |
| 1383 |
|
| 1384 |
public bool isBoss() { |
| 1385 |
return false; |
| 1386 |
} |
| 1387 |
} |
| 1388 |
|
| 1389 |
public class EnemyPool: ActorPool!(Enemy) { |
| 1390 |
private: |
| 1391 |
|
| 1392 |
public this(int n, Object[] args) { |
| 1393 |
super(n, args); |
| 1394 |
foreach (Enemy e; actor) |
| 1395 |
e.setEnemyPool(this); |
| 1396 |
} |
| 1397 |
|
| 1398 |
public void setStageManager(StageManager stageManager) { |
| 1399 |
foreach (Enemy e; actor) |
| 1400 |
e.setStageManager(stageManager); |
| 1401 |
} |
| 1402 |
|
| 1403 |
public void checkShotHit(Vector pos, Collidable shape, Shot shot = null) { |
| 1404 |
foreach (Enemy e; actor) |
| 1405 |
if (e.exists) |
| 1406 |
e.checkShotHit(pos, shape, shot); |
| 1407 |
} |
| 1408 |
|
| 1409 |
public Enemy checkHitShip(float x, float y, Enemy deselection = null, bool largeOnly = false) { |
| 1410 |
foreach (Enemy e; actor) |
| 1411 |
if (e.exists && e != deselection) |
| 1412 |
if (e.checkHitShip(x, y, largeOnly)) |
| 1413 |
return e; |
| 1414 |
return null; |
| 1415 |
} |
| 1416 |
|
| 1417 |
public bool hasBoss() { |
| 1418 |
foreach (Enemy e; actor) |
| 1419 |
if (e.exists && e.isBoss) |
| 1420 |
return true; |
| 1421 |
return false; |
| 1422 |
} |
| 1423 |
} |