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

Update game.js

Browse files
Files changed (1) hide show
  1. game.js +4 -22
game.js CHANGED
@@ -12,7 +12,7 @@ const MAX_HEALTH = 1000;
12
  const ENEMY_MOVE_SPEED = 0.1;
13
  const ENEMY_COUNT_MAX = 3;
14
  const PARTICLE_COUNT = 15;
15
- const BUILDING_COUNT = 25;
16
  const ENEMY_CONFIG = {
17
  ATTACK_RANGE: 100,
18
  ATTACK_INTERVAL: 2000,
@@ -590,7 +590,6 @@ class Enemy {
590
  this.lastPathUpdateTime = 0;
591
  this.pathUpdateInterval = 3000; // 3์ดˆ๋งˆ๋‹ค ๊ฒฝ๋กœ ์—…๋ฐ์ดํŠธ
592
  this.moveSpeed = type === 'tank' ? ENEMY_MOVE_SPEED : ENEMY_MOVE_SPEED * 0.7;
593
- this.hasPlayedWarning = false; // ๊ฒฝ๊ณ ์Œ ์žฌ์ƒ ์—ฌ๋ถ€ ์ถ”์ 
594
 
595
  // AI ์ƒํƒœ ๊ด€๋ฆฌ
596
  this.aiState = {
@@ -740,15 +739,6 @@ class Enemy {
740
  update(playerPosition) {
741
  if (!this.mesh || !this.isLoaded) return;
742
 
743
- // ํ”Œ๋ ˆ์ด์–ด์™€์˜ ๊ฑฐ๋ฆฌ ์ฒดํฌ ๋ฐ ๊ฒฝ๊ณ ์Œ ์žฌ์ƒ
744
- const distanceToPlayer = this.mesh.position.distanceTo(playerPosition);
745
- if (!this.hasPlayedWarning && distanceToPlayer <= ENEMY_CONFIG.ATTACK_RANGE) {
746
- const warningSound = new Audio('sounds/warning.ogg');
747
- warningSound.volume = 0.5;
748
- warningSound.play();
749
- this.hasPlayedWarning = true;
750
- }
751
-
752
  // AI ์ƒํƒœ ์—…๋ฐ์ดํŠธ
753
  this.updateAIState(playerPosition);
754
 
@@ -1773,7 +1763,7 @@ class Game {
1773
  this.obstacles = [];
1774
  }
1775
 
1776
- const BUILDING_COUNT = 25;
1777
  const buildingModels = [
1778
  'models/house1.glb',
1779
  'models/house2.glb',
@@ -2549,9 +2539,6 @@ updateCrosshair() {
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,20 +2546,15 @@ updateCrosshair() {
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() {
 
12
  const ENEMY_MOVE_SPEED = 0.1;
13
  const ENEMY_COUNT_MAX = 3;
14
  const PARTICLE_COUNT = 15;
15
+ const BUILDING_COUNT = 50;
16
  const ENEMY_CONFIG = {
17
  ATTACK_RANGE: 100,
18
  ATTACK_INTERVAL: 2000,
 
590
  this.lastPathUpdateTime = 0;
591
  this.pathUpdateInterval = 3000; // 3์ดˆ๋งˆ๋‹ค ๊ฒฝ๋กœ ์—…๋ฐ์ดํŠธ
592
  this.moveSpeed = type === 'tank' ? ENEMY_MOVE_SPEED : ENEMY_MOVE_SPEED * 0.7;
 
593
 
594
  // AI ์ƒํƒœ ๊ด€๋ฆฌ
595
  this.aiState = {
 
739
  update(playerPosition) {
740
  if (!this.mesh || !this.isLoaded) return;
741
 
 
 
 
 
 
 
 
 
 
742
  // AI ์ƒํƒœ ์—…๋ฐ์ดํŠธ
743
  this.updateAIState(playerPosition);
744
 
 
1763
  this.obstacles = [];
1764
  }
1765
 
1766
+ const BUILDING_COUNT = 50;
1767
  const buildingModels = [
1768
  'models/house1.glb',
1769
  'models/house2.glb',
 
2539
  const raycasterDirection = new THREE.Vector2();
2540
  this.raycaster.setFromCamera(raycasterDirection, this.camera);
2541
 
 
 
 
2542
  // ์  ์ „์ฐจ์˜ ๋ฐ”์šด๋”ฉ ๋ฐ•์Šค๋„ ํฌํ•จํ•˜์—ฌ ๊ฒ€์‚ฌ
2543
  const detectEnemy = this.enemies.some(enemy => {
2544
  if (!enemy.mesh || !enemy.isLoaded) return false;
 
2546
  // ์  ์ „์ฐจ์˜ ๋ฐ”์šด๋”ฉ ๋ฐ•์Šค ์ƒ์„ฑ
2547
  const boundingBox = new THREE.Box3().setFromObject(enemy.mesh);
2548
  const intersects = this.raycaster.ray.intersectsBox(boundingBox);
 
 
 
2549
 
2550
+ // ๋ฐ”์šด๋”ฉ ๋ฐ•์Šค์™€์˜ ๊ต์ฐจ ์—ฌ๋ถ€๋กœ ํŒ๋‹จ
2551
+ return intersects;
2552
  });
2553
 
2554
  if (detectEnemy) {
2555
  this.crosshair.classList.add('target-detected');
 
2556
  } else {
2557
  this.crosshair.classList.remove('target-detected');
 
2558
  }
2559
  }
2560
  updateEnemyLabels() {