cutechicken commited on
Commit
a6cfeb9
β€’
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() {