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