Spaces:
Running
Running
Update game.js
Browse files
game.js
CHANGED
|
@@ -580,6 +580,63 @@ class Enemy {
|
|
| 580 |
this.isLoaded = false;
|
| 581 |
this.moveSpeed = type === 'tank' ? ENEMY_MOVE_SPEED : ENEMY_MOVE_SPEED * 0.7;
|
| 582 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 583 |
|
| 584 |
async initialize(loader) {
|
| 585 |
try {
|
|
@@ -773,9 +830,12 @@ class Enemy {
|
|
| 773 |
|
| 774 |
if (currentTime - this.lastAttackTime < attackInterval) return;
|
| 775 |
|
|
|
|
|
|
|
|
|
|
| 776 |
// 발사 사운드 재생
|
| 777 |
const enemyFireSound = new Audio('sounds/mbtfire5.ogg');
|
| 778 |
-
enemyFireSound.volume = 0.3;
|
| 779 |
enemyFireSound.play();
|
| 780 |
|
| 781 |
const bulletGeometry = new THREE.SphereGeometry(this.type === 'tank' ? 0.2 : 0.3);
|
|
@@ -784,10 +844,17 @@ class Enemy {
|
|
| 784 |
});
|
| 785 |
const bullet = new THREE.Mesh(bulletGeometry, bulletMaterial);
|
| 786 |
|
| 787 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 788 |
|
| 789 |
const direction = new THREE.Vector3()
|
| 790 |
-
.subVectors(playerPosition,
|
| 791 |
.normalize();
|
| 792 |
|
| 793 |
const bulletSpeed = this.type === 'tank' ?
|
|
|
|
| 580 |
this.isLoaded = false;
|
| 581 |
this.moveSpeed = type === 'tank' ? ENEMY_MOVE_SPEED : ENEMY_MOVE_SPEED * 0.7;
|
| 582 |
}
|
| 583 |
+
createMuzzleFlash() {
|
| 584 |
+
if (!this.mesh) return;
|
| 585 |
+
|
| 586 |
+
const flashGroup = new THREE.Group();
|
| 587 |
+
|
| 588 |
+
// 화염 효과
|
| 589 |
+
const flameGeometry = new THREE.SphereGeometry(0.5, 8, 8);
|
| 590 |
+
const flameMaterial = new THREE.MeshBasicMaterial({
|
| 591 |
+
color: 0xff4500,
|
| 592 |
+
transparent: true,
|
| 593 |
+
opacity: 0.8
|
| 594 |
+
});
|
| 595 |
+
const flame = new THREE.Mesh(flameGeometry, flameMaterial);
|
| 596 |
+
flame.scale.set(1.5, 1.5, 2);
|
| 597 |
+
flashGroup.add(flame);
|
| 598 |
+
|
| 599 |
+
// 연기 효과
|
| 600 |
+
const smokeGeometry = new THREE.SphereGeometry(0.4, 8, 8);
|
| 601 |
+
const smokeMaterial = new THREE.MeshBasicMaterial({
|
| 602 |
+
color: 0x444444,
|
| 603 |
+
transparent: true,
|
| 604 |
+
opacity: 0.4
|
| 605 |
+
});
|
| 606 |
+
|
| 607 |
+
for (let i = 0; i < 3; i++) {
|
| 608 |
+
const smoke = new THREE.Mesh(smokeGeometry, smokeMaterial);
|
| 609 |
+
smoke.position.set(
|
| 610 |
+
Math.random() * 0.5 - 0.25,
|
| 611 |
+
Math.random() * 0.5 - 0.25,
|
| 612 |
+
-0.5 - Math.random()
|
| 613 |
+
);
|
| 614 |
+
smoke.scale.set(1, 1, 1);
|
| 615 |
+
flashGroup.add(smoke);
|
| 616 |
+
}
|
| 617 |
+
|
| 618 |
+
// 포구 위치 계산
|
| 619 |
+
const muzzleOffset = new THREE.Vector3(0, 0.5, 3);
|
| 620 |
+
const muzzlePosition = new THREE.Vector3();
|
| 621 |
+
const meshWorldQuaternion = new THREE.Quaternion();
|
| 622 |
+
|
| 623 |
+
this.mesh.getWorldPosition(muzzlePosition);
|
| 624 |
+
this.mesh.getWorldQuaternion(meshWorldQuaternion);
|
| 625 |
+
|
| 626 |
+
muzzleOffset.applyQuaternion(meshWorldQuaternion);
|
| 627 |
+
muzzlePosition.add(muzzleOffset);
|
| 628 |
+
|
| 629 |
+
flashGroup.position.copy(muzzlePosition);
|
| 630 |
+
flashGroup.quaternion.copy(meshWorldQuaternion);
|
| 631 |
+
|
| 632 |
+
this.scene.add(flashGroup);
|
| 633 |
+
|
| 634 |
+
// 이펙트 제거
|
| 635 |
+
setTimeout(() => {
|
| 636 |
+
this.scene.remove(flashGroup);
|
| 637 |
+
}, 100);
|
| 638 |
+
}
|
| 639 |
+
|
| 640 |
|
| 641 |
async initialize(loader) {
|
| 642 |
try {
|
|
|
|
| 830 |
|
| 831 |
if (currentTime - this.lastAttackTime < attackInterval) return;
|
| 832 |
|
| 833 |
+
// 발사 이펙트 생성
|
| 834 |
+
this.createMuzzleFlash();
|
| 835 |
+
|
| 836 |
// 발사 사운드 재생
|
| 837 |
const enemyFireSound = new Audio('sounds/mbtfire5.ogg');
|
| 838 |
+
enemyFireSound.volume = 0.3;
|
| 839 |
enemyFireSound.play();
|
| 840 |
|
| 841 |
const bulletGeometry = new THREE.SphereGeometry(this.type === 'tank' ? 0.2 : 0.3);
|
|
|
|
| 844 |
});
|
| 845 |
const bullet = new THREE.Mesh(bulletGeometry, bulletMaterial);
|
| 846 |
|
| 847 |
+
// 포구 위치에서 발사
|
| 848 |
+
const muzzleOffset = new THREE.Vector3(0, 0.5, 3);
|
| 849 |
+
const muzzlePosition = new THREE.Vector3();
|
| 850 |
+
this.mesh.getWorldPosition(muzzlePosition);
|
| 851 |
+
muzzleOffset.applyQuaternion(this.mesh.quaternion);
|
| 852 |
+
muzzlePosition.add(muzzleOffset);
|
| 853 |
+
|
| 854 |
+
bullet.position.copy(muzzlePosition);
|
| 855 |
|
| 856 |
const direction = new THREE.Vector3()
|
| 857 |
+
.subVectors(playerPosition, muzzlePosition)
|
| 858 |
.normalize();
|
| 859 |
|
| 860 |
const bulletSpeed = this.type === 'tank' ?
|