Spaces:
Running
Running
Update game.js
Browse files
game.js
CHANGED
|
@@ -766,35 +766,40 @@ class Enemy {
|
|
| 766 |
|
| 767 |
|
| 768 |
shoot(playerPosition) {
|
| 769 |
-
|
| 770 |
-
|
| 771 |
-
|
| 772 |
-
|
| 773 |
|
| 774 |
-
|
| 775 |
|
| 776 |
-
|
| 777 |
-
|
| 778 |
-
|
| 779 |
-
|
| 780 |
-
const bullet = new THREE.Mesh(bulletGeometry, bulletMaterial);
|
| 781 |
|
| 782 |
-
|
| 783 |
-
|
| 784 |
-
|
| 785 |
-
|
| 786 |
-
|
| 787 |
-
|
| 788 |
-
|
| 789 |
-
|
| 790 |
-
|
| 791 |
-
|
| 792 |
-
|
| 793 |
-
|
| 794 |
-
|
| 795 |
-
|
| 796 |
-
|
| 797 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 798 |
|
| 799 |
takeDamage(damage) {
|
| 800 |
this.health -= damage;
|
|
|
|
| 766 |
|
| 767 |
|
| 768 |
shoot(playerPosition) {
|
| 769 |
+
const currentTime = Date.now();
|
| 770 |
+
const attackInterval = this.type === 'tank' ?
|
| 771 |
+
ENEMY_CONFIG.ATTACK_INTERVAL :
|
| 772 |
+
ENEMY_CONFIG.ATTACK_INTERVAL * 1.5;
|
| 773 |
|
| 774 |
+
if (currentTime - this.lastAttackTime < attackInterval) return;
|
| 775 |
|
| 776 |
+
// 발사 사운드 재생
|
| 777 |
+
const enemyFireSound = new Audio('sounds/fireenemy3.ogg');
|
| 778 |
+
enemyFireSound.volume = 0.3; // 볼륨 설정
|
| 779 |
+
enemyFireSound.play();
|
|
|
|
| 780 |
|
| 781 |
+
const bulletGeometry = new THREE.SphereGeometry(this.type === 'tank' ? 0.2 : 0.3);
|
| 782 |
+
const bulletMaterial = new THREE.MeshBasicMaterial({
|
| 783 |
+
color: this.type === 'tank' ? 0xff0000 : 0xff6600
|
| 784 |
+
});
|
| 785 |
+
const bullet = new THREE.Mesh(bulletGeometry, bulletMaterial);
|
| 786 |
+
|
| 787 |
+
bullet.position.copy(this.mesh.position);
|
| 788 |
+
|
| 789 |
+
const direction = new THREE.Vector3()
|
| 790 |
+
.subVectors(playerPosition, this.mesh.position)
|
| 791 |
+
.normalize();
|
| 792 |
+
|
| 793 |
+
const bulletSpeed = this.type === 'tank' ?
|
| 794 |
+
ENEMY_CONFIG.BULLET_SPEED :
|
| 795 |
+
ENEMY_CONFIG.BULLET_SPEED * 0.8;
|
| 796 |
+
|
| 797 |
+
bullet.velocity = direction.multiplyScalar(bulletSpeed);
|
| 798 |
+
|
| 799 |
+
this.scene.add(bullet);
|
| 800 |
+
this.bullets.push(bullet);
|
| 801 |
+
this.lastAttackTime = currentTime;
|
| 802 |
+
}
|
| 803 |
|
| 804 |
takeDamage(damage) {
|
| 805 |
this.health -= damage;
|