Spaces:
Running
Running
cutechicken
commited on
Commit
β’
a6cfeb9
1
Parent(s):
accbc97
Update game.js
Browse files
game.js
CHANGED
@@ -2549,6 +2549,9 @@ updateCrosshair() {
|
|
2549 |
const raycasterDirection = new THREE.Vector2();
|
2550 |
this.raycaster.setFromCamera(raycasterDirection, this.camera);
|
2551 |
|
|
|
|
|
|
|
2552 |
// μ μ μ°¨μ λ°μ΄λ© λ°μ€λ ν¬ν¨νμ¬ κ²μ¬
|
2553 |
const detectEnemy = this.enemies.some(enemy => {
|
2554 |
if (!enemy.mesh || !enemy.isLoaded) return false;
|
@@ -2556,15 +2559,20 @@ updateCrosshair() {
|
|
2556 |
// μ μ μ°¨μ λ°μ΄λ© λ°μ€ μμ±
|
2557 |
const boundingBox = new THREE.Box3().setFromObject(enemy.mesh);
|
2558 |
const intersects = this.raycaster.ray.intersectsBox(boundingBox);
|
|
|
|
|
|
|
2559 |
|
2560 |
-
// λ°μ΄λ© λ°μ€μμ κ΅μ°¨
|
2561 |
-
return intersects;
|
2562 |
});
|
2563 |
|
2564 |
if (detectEnemy) {
|
2565 |
this.crosshair.classList.add('target-detected');
|
|
|
2566 |
} else {
|
2567 |
this.crosshair.classList.remove('target-detected');
|
|
|
2568 |
}
|
2569 |
}
|
2570 |
updateEnemyLabels() {
|
|
|
2549 |
const raycasterDirection = new THREE.Vector2();
|
2550 |
this.raycaster.setFromCamera(raycasterDirection, this.camera);
|
2551 |
|
2552 |
+
// detected μμ κ°μ Έμ€κΈ°
|
2553 |
+
const detectedText = document.getElementById('detected');
|
2554 |
+
|
2555 |
// μ μ μ°¨μ λ°μ΄λ© λ°μ€λ ν¬ν¨νμ¬ κ²μ¬
|
2556 |
const detectEnemy = this.enemies.some(enemy => {
|
2557 |
if (!enemy.mesh || !enemy.isLoaded) return false;
|
|
|
2559 |
// μ μ μ°¨μ λ°μ΄λ© λ°μ€ μμ±
|
2560 |
const boundingBox = new THREE.Box3().setFromObject(enemy.mesh);
|
2561 |
const intersects = this.raycaster.ray.intersectsBox(boundingBox);
|
2562 |
+
|
2563 |
+
// 곡격 λ²μ λ΄μ μλμ§ νμΈ
|
2564 |
+
const inRange = enemy.mesh.position.distanceTo(this.tank.getPosition()) <= ENEMY_CONFIG.ATTACK_RANGE;
|
2565 |
|
2566 |
+
// λ°μ΄λ© λ°μ€μμ κ΅μ°¨ μ¬λΆμ 곡격 λ²μ λ΄ μ¬λΆλ₯Ό λͺ¨λ νμΈ
|
2567 |
+
return intersects && inRange;
|
2568 |
});
|
2569 |
|
2570 |
if (detectEnemy) {
|
2571 |
this.crosshair.classList.add('target-detected');
|
2572 |
+
detectedText.style.display = 'block'; // DETECTED ν
μ€νΈ νμ
|
2573 |
} else {
|
2574 |
this.crosshair.classList.remove('target-detected');
|
2575 |
+
detectedText.style.display = 'none'; // DETECTED ν
μ€νΈ μ¨κΈ°κΈ°
|
2576 |
}
|
2577 |
}
|
2578 |
updateEnemyLabels() {
|