cutechicken commited on
Commit
522c84b
โ€ข
1 Parent(s): c7fc102

Update game.js

Browse files
Files changed (1) hide show
  1. game.js +0 -57
game.js CHANGED
@@ -836,21 +836,6 @@ class Enemy {
836
  this.adjustTankTilt();
837
  }
838
 
839
- checkLineOfSight(targetPosition) {
840
- if (!this.mesh) return false;
841
-
842
- const startPos = this.mesh.position.clone();
843
- startPos.y += 2; // ํฌํƒ‘ ๋†’์ด
844
- const direction = new THREE.Vector3()
845
- .subVectors(targetPosition, startPos)
846
- .normalize();
847
- const distance = startPos.distanceTo(targetPosition);
848
-
849
- const raycaster = new THREE.Raycaster(startPos, direction, 0, distance);
850
- const intersects = raycaster.intersectObjects(window.gameInstance.obstacles, true);
851
-
852
- return intersects.length === 0;
853
- }
854
 
855
  findAlternativePath(playerPosition) {
856
  const currentPos = this.mesh.position.clone();
@@ -887,13 +872,6 @@ findAlternativePath(playerPosition) {
887
  return null;
888
  }
889
 
890
- checkPathClear(start, end) {
891
- const direction = new THREE.Vector3().subVectors(end, start).normalize();
892
- const distance = start.distanceTo(end);
893
- const raycaster = new THREE.Raycaster(start, direction, 0, distance);
894
- const intersects = raycaster.intersectObjects(window.gameInstance.obstacles, true);
895
- return intersects.length === 0;
896
- }
897
 
898
  async initialize(loader) {
899
  try {
@@ -936,41 +914,6 @@ checkPathClear(start, end) {
936
  // ์žฅ์• ๋ฌผ์ด ์žˆ์„ ๊ฒฝ์šฐ false ๋ฐ˜ํ™˜
937
  return intersects.length === 0;
938
  }
939
- // ๋Œ€์ฒด ๊ฒฝ๋กœ ์ฐพ๊ธฐ ๋ฉ”์„œ๋“œ
940
- findAlternativePath(playerPosition) {
941
- const currentPos = this.mesh.position.clone();
942
- const directionToPlayer = new THREE.Vector3()
943
- .subVectors(playerPosition, currentPos)
944
- .normalize();
945
-
946
- // ์ขŒ์šฐ 90๋„ ๋ฐฉํ–ฅ ๊ณ„์‚ฐ
947
- const leftDirection = new THREE.Vector3()
948
- .copy(directionToPlayer)
949
- .applyAxisAngle(new THREE.Vector3(0, 1, 0), Math.PI / 2);
950
- const rightDirection = new THREE.Vector3()
951
- .copy(directionToPlayer)
952
- .applyAxisAngle(new THREE.Vector3(0, 1, 0), -Math.PI / 2);
953
-
954
- // ์ขŒ์šฐ 30๋ฏธํ„ฐ ์ง€์  ํ™•์ธ
955
- const checkDistance = 30;
956
- const leftPoint = currentPos.clone().add(leftDirection.multiplyScalar(checkDistance));
957
- const rightPoint = currentPos.clone().add(rightDirection.multiplyScalar(checkDistance));
958
-
959
- // ๊ฐ ๋ฐฉํ–ฅ์˜ ์žฅ์• ๋ฌผ ์ฒดํฌ
960
- const leftClear = this.checkPathClear(currentPos, leftPoint);
961
- const rightClear = this.checkPathClear(currentPos, rightPoint);
962
-
963
- if (leftClear && rightClear) {
964
- // ๋‘˜ ๋‹ค ๊ฐ€๋Šฅํ•˜๋ฉด ๋žœ๋ค ์„ ํƒ
965
- return Math.random() < 0.5 ? leftPoint : rightPoint;
966
- } else if (leftClear) {
967
- return leftPoint;
968
- } else if (rightClear) {
969
- return rightPoint;
970
- }
971
-
972
- return null;
973
- }
974
  // ๊ฒฝ๋กœ ์œ ํšจ์„ฑ ํ™•์ธ
975
  checkPathClear(start, end) {
976
  const direction = new THREE.Vector3().subVectors(end, start).normalize();
 
836
  this.adjustTankTilt();
837
  }
838
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
839
 
840
  findAlternativePath(playerPosition) {
841
  const currentPos = this.mesh.position.clone();
 
872
  return null;
873
  }
874
 
 
 
 
 
 
 
 
875
 
876
  async initialize(loader) {
877
  try {
 
914
  // ์žฅ์• ๋ฌผ์ด ์žˆ์„ ๊ฒฝ์šฐ false ๋ฐ˜ํ™˜
915
  return intersects.length === 0;
916
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
917
  // ๊ฒฝ๋กœ ์œ ํšจ์„ฑ ํ™•์ธ
918
  checkPathClear(start, end) {
919
  const direction = new THREE.Vector3().subVectors(end, start).normalize();