cutechicken commited on
Commit
a6cfeb9
ยท
verified ยท
1 Parent(s): accbc97

Update game.js

Browse files
Files changed (1) hide show
  1. game.js +10 -2
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() {