ยิงอุกาบาต Violent Crime done
This commit is contained in:
File diff suppressed because one or more lines are too long
@@ -108,6 +108,48 @@
|
||||
+ (SPACE_SHOOTER_ASTEROID_RADIUS_AT_FULL - SPACE_SHOOTER_ASTEROID_RADIUS_AT_MIN_HP) * frac;
|
||||
}
|
||||
|
||||
function spaceShooterShipFootprintCellsPlay(md) {
|
||||
const m = md || mapData;
|
||||
if (!m) return { cw: 1, ch: 1 };
|
||||
const { cw, ch } = getCharacterFootprintWH(m);
|
||||
return {
|
||||
cw: Math.max(1, Math.min(4, cw)),
|
||||
ch: Math.max(1, Math.min(4, ch)),
|
||||
};
|
||||
}
|
||||
|
||||
/** ขนาดวาดยานบนจอ — สเกลตาม footprint แผนที่ (editor: กว้าง/สูงตัวละคร) เทียบ tileSize */
|
||||
function spaceShooterShipBodyScreenPxPlay(zDrawVal) {
|
||||
const zD = Number(zDrawVal) > 0 ? zDrawVal : (typeof zoom === 'number' && zoom > 0 ? zoom : 1);
|
||||
const ts = tileSize || 32;
|
||||
const { cw, ch } = spaceShooterShipFootprintCellsPlay(mapData);
|
||||
const kw = 14 / 32;
|
||||
const kh = 22 / 32;
|
||||
return {
|
||||
bodyW: cw * ts * zD * kw,
|
||||
bodyH: ch * ts * zD * kh,
|
||||
};
|
||||
}
|
||||
|
||||
/** รัศมีชนอุกาบาต (พิกัดโลก) — โตตาม footprint เพื่อให้สมกับยานที่วาดใหญ่ขึ้น */
|
||||
function spaceShooterShipHitRadiusWorldPxPlay() {
|
||||
if (!mapData || mapData.gameType !== 'space_shooter') return SPACE_SHOOTER_MISSION_SHIP_HIT_RADIUS;
|
||||
const ts = tileSize || 32;
|
||||
const { cw, ch } = spaceShooterShipFootprintCellsPlay(mapData);
|
||||
const base = SPACE_SHOOTER_MISSION_SHIP_HIT_RADIUS;
|
||||
const geom = Math.sqrt(Math.max(1, cw * ch));
|
||||
const cap = Math.min(54, 0.42 * Math.min(cw * ts, ch * ts));
|
||||
return Math.max(9, Math.min(cap, base * geom));
|
||||
}
|
||||
|
||||
/** ระยะห่างจากขอบโลกซ้าย/ขวาเมื่อบังคับยาน — กันยานใหญ่หลุดกรอบ */
|
||||
function spaceShooterShipEdgePadWorldPxPlay() {
|
||||
if (!mapData || mapData.gameType !== 'space_shooter') return 18;
|
||||
const ts = tileSize || 32;
|
||||
const { cw } = spaceShooterShipFootprintCellsPlay(mapData);
|
||||
return Math.max(18, cw * ts * 0.48);
|
||||
}
|
||||
|
||||
function spaceShooterResetMissionShipStateForAllPlay() {
|
||||
function resetEnt(ent) {
|
||||
if (!ent) return;
|
||||
@@ -125,7 +167,7 @@
|
||||
if (!mapData || mapData.gameType !== 'space_shooter') return;
|
||||
if (!isSpaceShooterMissionUiMapPlay() || spaceShooterMissionPhase !== 'live' || spaceShooterGameEnded) return;
|
||||
const now = performance.now();
|
||||
const shipR = SPACE_SHOOTER_MISSION_SHIP_HIT_RADIUS;
|
||||
const shipR = spaceShooterShipHitRadiusWorldPxPlay();
|
||||
|
||||
function tryHit(ent, cx, cy) {
|
||||
if (!ent || ent.spaceShooterEliminated || cx == null || cy == null) return;
|
||||
@@ -2276,6 +2318,24 @@
|
||||
let stackTowerResultFlashTimer = null;
|
||||
const STACK_TOWER_RESULT_FLASH_MS = 5000;
|
||||
|
||||
/** รูปอุกาบาตขณะตก: 0 = เต็ม HP (Meteo-1); 1 = โดนยิงแล้วแต่ยังมี HP (Meteo-2 เมื่อมี URL ≥3) */
|
||||
function spaceShooterAsteroidLiveSpriteIndexPlay(a) {
|
||||
const urls = playSpaceShooterAsteroidSpriteUrls;
|
||||
if (!urls || !urls.length) return 0;
|
||||
const maxHp = Math.max(1, Math.floor(Number(a && a.maxHp)) || SPACE_SHOOTER_ASTEROID_MAX_HP);
|
||||
const hp = Math.max(0, Math.floor(Number(a && a.hp)) || maxHp);
|
||||
if (hp >= maxHp) return 0;
|
||||
if (urls.length >= 3) return 1;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/** เริ่มแอนิเมชันแตกที่เฟรมถัดจาก «โดนแล้ว» เพื่อไม่ซ้ำ Meteo-2 — แสดง Meteo-3 แล้วจบตาม maxFi */
|
||||
function spaceShooterAsteroidExplosionStartFiPlay() {
|
||||
const urls = playSpaceShooterAsteroidSpriteUrls;
|
||||
if (!urls || urls.length < 2) return 0;
|
||||
return urls.length >= 3 ? 1 : 0;
|
||||
}
|
||||
|
||||
function spaceShooterSpawnAsteroidExplosion(worldX, worldY, r) {
|
||||
const urls = playSpaceShooterAsteroidSpriteUrls;
|
||||
if (!urls || urls.length < 2) return;
|
||||
@@ -2283,7 +2343,7 @@
|
||||
x: worldX,
|
||||
y: worldY,
|
||||
r: Math.max(6, Number(r) || 14),
|
||||
fi: 0,
|
||||
fi: spaceShooterAsteroidExplosionStartFiPlay(),
|
||||
acc: 0,
|
||||
});
|
||||
}
|
||||
@@ -11418,7 +11478,8 @@
|
||||
vy = Math.sin(performance.now() / 700 + bid.charCodeAt(0)) > 0 ? 1 : -1;
|
||||
}
|
||||
const spd = (o.botTier === 'sharp' ? 195 : o.botTier === 'weak' ? 115 : 155);
|
||||
o.spaceShooterCx = Math.max(18, Math.min(mw - 18, o.spaceShooterCx + vx * spd * dt));
|
||||
const padX = spaceShooterShipEdgePadWorldPxPlay();
|
||||
o.spaceShooterCx = Math.max(padX, Math.min(mw - padX, o.spaceShooterCx + vx * spd * dt));
|
||||
o.spaceShooterCy = clampSpaceShooterWorldCy(o.spaceShooterCy + vy * spd * 0.7 * dt, mh);
|
||||
syncSpaceShooterFootFromShipCenter(o);
|
||||
o.tx = o.x;
|
||||
@@ -11494,7 +11555,8 @@
|
||||
const canPilotMe = !(isSpaceShooterMissionUiMapPlay() && me.spaceShooterEliminated);
|
||||
if (canPilotMe) {
|
||||
if (me.spaceShooterCx != null) {
|
||||
me.spaceShooterCx = Math.max(18, Math.min(mw - 18, me.spaceShooterCx + vx * moveSpd * dt));
|
||||
const padX = spaceShooterShipEdgePadWorldPxPlay();
|
||||
me.spaceShooterCx = Math.max(padX, Math.min(mw - padX, me.spaceShooterCx + vx * moveSpd * dt));
|
||||
}
|
||||
if (me.spaceShooterCy != null) {
|
||||
me.spaceShooterCy = clampSpaceShooterWorldCy(me.spaceShooterCy + vy * moveSpd * dt, mh);
|
||||
@@ -11582,22 +11644,24 @@
|
||||
const wallNow = typeof timeMs === 'number' ? timeMs : Date.now();
|
||||
|
||||
const astUrls = playSpaceShooterAsteroidSpriteUrls;
|
||||
const fallAstUrl = astUrls && astUrls.length ? astUrls[0] : '';
|
||||
const fallAstRec = fallAstUrl ? ensureGauntletAssetImage(fallAstUrl) : null;
|
||||
const fallAstImg = fallAstRec && fallAstRec.ready && fallAstRec.img && fallAstRec.img.naturalWidth > 0 ? fallAstRec.img : null;
|
||||
|
||||
for (let i = 0; i < spaceShooterAsteroids.length; i++) {
|
||||
const a = spaceShooterAsteroids[i];
|
||||
const [sx, sy] = worldToScreen(a.x, a.y);
|
||||
const sr = Math.max(6, a.r * zDraw);
|
||||
if (fallAstImg) {
|
||||
const iw = fallAstImg.naturalWidth;
|
||||
const ih = fallAstImg.naturalHeight;
|
||||
const si = spaceShooterAsteroidLiveSpriteIndexPlay(a);
|
||||
let liveUrl = (astUrls && astUrls[si]) ? String(astUrls[si]).trim() : '';
|
||||
if (!liveUrl && si > 0 && astUrls && astUrls[0]) liveUrl = String(astUrls[0]).trim();
|
||||
const liveRec = liveUrl ? ensureGauntletAssetImage(liveUrl) : null;
|
||||
const liveAstImg = liveRec && liveRec.ready && liveRec.img && liveRec.img.naturalWidth > 0 ? liveRec.img : null;
|
||||
if (liveAstImg) {
|
||||
const iw = liveAstImg.naturalWidth;
|
||||
const ih = liveAstImg.naturalHeight;
|
||||
const diam = sr * 2.15;
|
||||
const sc = Math.min(diam / iw, diam / ih);
|
||||
const dw = iw * sc;
|
||||
const dh = ih * sc;
|
||||
ctx.drawImage(fallAstImg, sx - dw * 0.5, sy - dh * 0.5, dw, dh);
|
||||
ctx.drawImage(liveAstImg, sx - dw * 0.5, sy - dh * 0.5, dw, dh);
|
||||
} else {
|
||||
const grd = ctx.createRadialGradient(sx - sr * 0.25, sy - sr * 0.25, sr * 0.1, sx, sy, sr);
|
||||
grd.addColorStop(0, 'rgba(90, 85, 95, 0.95)');
|
||||
@@ -11658,13 +11722,14 @@
|
||||
}
|
||||
}
|
||||
|
||||
const shipBody = spaceShooterShipBodyScreenPxPlay(zDraw);
|
||||
const bodyW = shipBody.bodyW;
|
||||
const bodyH = shipBody.bodyH;
|
||||
refs.forEach((entry, idx) => {
|
||||
const ent = entry.ref;
|
||||
if (ent.spaceShooterCx == null || ent.spaceShooterCy == null) return;
|
||||
const [sx, sy] = worldToScreen(ent.spaceShooterCx, ent.spaceShooterCy);
|
||||
const col = SPACE_SHOOTER_SHIP_COLORS[idx % SPACE_SHOOTER_SHIP_COLORS.length];
|
||||
const bodyW = 14 * zDraw;
|
||||
const bodyH = 22 * zDraw;
|
||||
const elimShip = !!(isSpaceShooterMissionUiMapPlay() && ent.spaceShooterEliminated);
|
||||
const slot = Math.max(1, Math.min(6, Number(ent.spaceShooterSlot) || ((idx % 6) + 1)));
|
||||
const shipUrl = (playSpaceShooterShipImageUrls[slot - 1] || '').trim();
|
||||
|
||||
@@ -3203,7 +3203,7 @@
|
||||
</div>
|
||||
<script src="/Game/socket.io/socket.io.js"></script>
|
||||
<script src="js/version.js?v=0.0306"></script>
|
||||
<script src="js/play.js?v=0.0411"></script>
|
||||
<script src="js/play.js?v=0.0413"></script>
|
||||
<div class="version-tag">v —</div>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
Reference in New Issue
Block a user