cutechicken commited on
Commit
475b62f
โ€ข
1 Parent(s): d9a71bb

Update game.js

Browse files
Files changed (1) hide show
  1. game.js +15 -1
game.js CHANGED
@@ -1948,7 +1948,21 @@ updateCrosshair() {
1948
  this.raycaster.setFromCamera(new THREE.Vector2(), this.camera);
1949
  const intersects = this.raycaster.intersectObjects(this.scene.children, true);
1950
 
1951
- if (intersects.length > 0) {
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1952
  this.crosshair.classList.add('target-detected');
1953
  } else {
1954
  this.crosshair.classList.remove('target-detected');
 
1948
  this.raycaster.setFromCamera(new THREE.Vector2(), this.camera);
1949
  const intersects = this.raycaster.intersectObjects(this.scene.children, true);
1950
 
1951
+ // ์ถฉ๋Œํ•œ ๊ฐ์ฒด๋“ค ์ค‘ ์  ์ „์ฐจ๊ฐ€ ์žˆ๋Š”์ง€ ํ™•์ธ
1952
+ const hasEnemyTank = intersects.some(intersect => {
1953
+ // ๊ต์ฐจํ•œ ๊ฐ์ฒด๋‚˜ ๊ทธ ๋ถ€๋ชจ ๊ฐ์ฒด ์ค‘์— ์  ์ „์ฐจ๊ฐ€ ์žˆ๋Š”์ง€ ํ™•์ธ
1954
+ let current = intersect.object;
1955
+ while (current) {
1956
+ // enemies ๋ฐฐ์—ด์— ์žˆ๋Š” ๋ฉ”์‹œ์™€ ๋น„๊ต
1957
+ if (this.enemies.some(enemy => enemy.mesh === current)) {
1958
+ return true;
1959
+ }
1960
+ current = current.parent;
1961
+ }
1962
+ return false;
1963
+ });
1964
+
1965
+ if (hasEnemyTank) {
1966
  this.crosshair.classList.add('target-detected');
1967
  } else {
1968
  this.crosshair.classList.remove('target-detected');