Spaces:
Running
Running
Update game.js
Browse files
game.js
CHANGED
@@ -792,7 +792,7 @@ class Fighter {
|
|
792 |
}
|
793 |
}
|
794 |
|
795 |
-
// μ μ ν¬κΈ° ν΄λμ€ -
|
796 |
class EnemyFighter {
|
797 |
constructor(scene, position) {
|
798 |
this.mesh = null;
|
@@ -838,6 +838,9 @@ class EnemyFighter {
|
|
838 |
this.nearbyEnemies = [];
|
839 |
this.avoidanceVector = new THREE.Vector3();
|
840 |
|
|
|
|
|
|
|
841 |
// μ΄κΈ° λͺ©ν μ€μ
|
842 |
this.selectNewPatrolTarget();
|
843 |
}
|
@@ -889,7 +892,7 @@ class EnemyFighter {
|
|
889 |
}
|
890 |
|
891 |
update(playerPosition, deltaTime) {
|
892 |
-
if (!this.mesh || !this.isLoaded) return;
|
893 |
|
894 |
// ννΌ νμ΄λ¨Έ μ
λ°μ΄νΈ
|
895 |
if (this.temporaryEvadeMode && this.evadeTimer > 0) {
|
@@ -905,7 +908,6 @@ class EnemyFighter {
|
|
905 |
if (distanceToPlayer < 100) {
|
906 |
this.isRetreating = true;
|
907 |
this.aiState = 'retreat';
|
908 |
-
// νν΄ μμ μ λ‘κ·Έ
|
909 |
console.log(`Enemy retreating! Distance: ${distanceToPlayer.toFixed(1)}m`);
|
910 |
}
|
911 |
|
@@ -918,7 +920,6 @@ class EnemyFighter {
|
|
918 |
// μν κ²°μ - νν΄κ° μ΅μ°μ
|
919 |
if (this.isRetreating) {
|
920 |
this.aiState = 'retreat';
|
921 |
-
// νν΄ μ€μλ λ€λ₯Έ μνλ‘ λ³κ²½ λΆκ°
|
922 |
} else if (this.temporaryEvadeMode) {
|
923 |
this.aiState = 'evade';
|
924 |
} else if (distanceToPlayer <= 3000) {
|
@@ -956,7 +957,6 @@ class EnemyFighter {
|
|
956 |
this.updateBullets(deltaTime);
|
957 |
}
|
958 |
|
959 |
-
// μλ‘μ΄ λ©μλ: νν΄ μ€ν
|
960 |
executeRetreat(playerPosition, deltaTime) {
|
961 |
// νλ μ΄μ΄λ‘λΆν° λ©μ΄μ§λ λ°©ν₯ κ³μ°
|
962 |
const retreatDirection = this.position.clone().sub(playerPosition).normalize();
|
@@ -1294,7 +1294,7 @@ class EnemyFighter {
|
|
1294 |
}
|
1295 |
|
1296 |
updatePhysics(deltaTime) {
|
1297 |
-
if (!this.mesh) return;
|
1298 |
|
1299 |
// μλ λ²‘ν° κ³μ° (νμ μ μ§)
|
1300 |
const forward = new THREE.Vector3(0, 0, 1);
|
@@ -1482,14 +1482,36 @@ class EnemyFighter {
|
|
1482 |
|
1483 |
takeDamage(damage) {
|
1484 |
this.health -= damage;
|
1485 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
1486 |
}
|
1487 |
|
1488 |
destroy() {
|
1489 |
-
if (this.mesh) {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1490 |
this.scene.remove(this.mesh);
|
|
|
|
|
|
|
1491 |
this.bullets.forEach(bullet => this.scene.remove(bullet));
|
1492 |
this.bullets = [];
|
|
|
1493 |
this.isLoaded = false;
|
1494 |
}
|
1495 |
}
|
|
|
792 |
}
|
793 |
}
|
794 |
|
795 |
+
// μ μ ν¬κΈ° ν΄λμ€ - νλ° μ²λ¦¬ μμ
|
796 |
class EnemyFighter {
|
797 |
constructor(scene, position) {
|
798 |
this.mesh = null;
|
|
|
838 |
this.nearbyEnemies = [];
|
839 |
this.avoidanceVector = new THREE.Vector3();
|
840 |
|
841 |
+
// νκ΄΄ μν μΆκ°
|
842 |
+
this.isDestroyed = false;
|
843 |
+
|
844 |
// μ΄κΈ° λͺ©ν μ€μ
|
845 |
this.selectNewPatrolTarget();
|
846 |
}
|
|
|
892 |
}
|
893 |
|
894 |
update(playerPosition, deltaTime) {
|
895 |
+
if (!this.mesh || !this.isLoaded || this.isDestroyed) return;
|
896 |
|
897 |
// ννΌ νμ΄λ¨Έ μ
λ°μ΄νΈ
|
898 |
if (this.temporaryEvadeMode && this.evadeTimer > 0) {
|
|
|
908 |
if (distanceToPlayer < 100) {
|
909 |
this.isRetreating = true;
|
910 |
this.aiState = 'retreat';
|
|
|
911 |
console.log(`Enemy retreating! Distance: ${distanceToPlayer.toFixed(1)}m`);
|
912 |
}
|
913 |
|
|
|
920 |
// μν κ²°μ - νν΄κ° μ΅μ°μ
|
921 |
if (this.isRetreating) {
|
922 |
this.aiState = 'retreat';
|
|
|
923 |
} else if (this.temporaryEvadeMode) {
|
924 |
this.aiState = 'evade';
|
925 |
} else if (distanceToPlayer <= 3000) {
|
|
|
957 |
this.updateBullets(deltaTime);
|
958 |
}
|
959 |
|
|
|
960 |
executeRetreat(playerPosition, deltaTime) {
|
961 |
// νλ μ΄μ΄λ‘λΆν° λ©μ΄μ§λ λ°©ν₯ κ³μ°
|
962 |
const retreatDirection = this.position.clone().sub(playerPosition).normalize();
|
|
|
1294 |
}
|
1295 |
|
1296 |
updatePhysics(deltaTime) {
|
1297 |
+
if (!this.mesh || this.isDestroyed) return;
|
1298 |
|
1299 |
// μλ λ²‘ν° κ³μ° (νμ μ μ§)
|
1300 |
const forward = new THREE.Vector3(0, 0, 1);
|
|
|
1482 |
|
1483 |
takeDamage(damage) {
|
1484 |
this.health -= damage;
|
1485 |
+
|
1486 |
+
// 체λ ₯μ΄ 0 μ΄νκ° λλ©΄ true λ°ν (νκ΄΄λ¨)
|
1487 |
+
if (this.health <= 0) {
|
1488 |
+
this.isDestroyed = true;
|
1489 |
+
return true;
|
1490 |
+
}
|
1491 |
+
return false;
|
1492 |
}
|
1493 |
|
1494 |
destroy() {
|
1495 |
+
if (this.mesh && !this.isDestroyed) {
|
1496 |
+
// νκ΄΄ μν μ€μ
|
1497 |
+
this.isDestroyed = true;
|
1498 |
+
|
1499 |
+
// νλ° ν¨κ³Ό μμ± - window.gameInstance νμΈ
|
1500 |
+
if (window.gameInstance && window.gameInstance.createExplosionEffect) {
|
1501 |
+
console.log('Enemy destroyed at position:', this.position);
|
1502 |
+
window.gameInstance.createExplosionEffect(this.position.clone());
|
1503 |
+
} else {
|
1504 |
+
console.error('Game instance or createExplosionEffect not available');
|
1505 |
+
}
|
1506 |
+
|
1507 |
+
// λ©μ μ κ±°
|
1508 |
this.scene.remove(this.mesh);
|
1509 |
+
this.mesh = null;
|
1510 |
+
|
1511 |
+
// λ¨μ ννλ€ μ κ±°
|
1512 |
this.bullets.forEach(bullet => this.scene.remove(bullet));
|
1513 |
this.bullets = [];
|
1514 |
+
|
1515 |
this.isLoaded = false;
|
1516 |
}
|
1517 |
}
|