Spaces:
Running
Running
Update game.js
Browse files
game.js
CHANGED
@@ -740,10 +740,8 @@ class EnemyFighter {
|
|
740 |
// ์ ํฌ ์์คํ
|
741 |
this.bullets = [];
|
742 |
this.burstCounter = 0; // ํ์ฌ ์ฐ๋ฐ ์นด์ดํฐ
|
743 |
-
this.attackCounter = 0; // ๊ณต๊ฒฉ ํ์ ์นด์ดํฐ
|
744 |
this.lastShootTime = 0;
|
745 |
-
this.
|
746 |
-
this.isEvading = false;
|
747 |
|
748 |
// ๋ถ๋๋ฌ์ด ํ์ ์ ์ํ ๋ณ์
|
749 |
this.targetRotation = this.rotation.clone();
|
@@ -808,11 +806,9 @@ class EnemyFighter {
|
|
808 |
|
809 |
const distanceToPlayer = this.position.distanceTo(playerPosition);
|
810 |
|
811 |
-
// ์ํ ๊ฒฐ์
|
812 |
-
if (distanceToPlayer <= 3000
|
813 |
this.aiState = 'combat';
|
814 |
-
} else if (this.isEvading) {
|
815 |
-
this.aiState = 'evade';
|
816 |
} else {
|
817 |
this.aiState = 'patrol';
|
818 |
}
|
@@ -828,9 +824,6 @@ class EnemyFighter {
|
|
828 |
case 'combat':
|
829 |
this.executeCombat(playerPosition, deltaTime);
|
830 |
break;
|
831 |
-
case 'evade':
|
832 |
-
this.executeEvade(deltaTime);
|
833 |
-
break;
|
834 |
}
|
835 |
|
836 |
// ๋ฌผ๋ฆฌ ์
๋ฐ์ดํธ
|
@@ -863,32 +856,34 @@ class EnemyFighter {
|
|
863 |
// ์กฐ์ค ์ ํ๋ ํ์ธ
|
864 |
const aimAccuracy = this.calculateAimAccuracy(playerPosition);
|
865 |
|
866 |
-
//
|
867 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
868 |
this.fireWeapon();
|
|
|
|
|
|
|
869 |
}
|
870 |
|
871 |
-
//
|
872 |
-
|
873 |
-
|
874 |
-
|
875 |
-
this.attackCounter = 0;
|
876 |
this.selectEvadeTarget();
|
|
|
|
|
|
|
877 |
}
|
878 |
}
|
879 |
|
880 |
-
|
881 |
-
// ํํผ ํ์ด๋จธ ์
๋ฐ์ดํธ
|
882 |
-
this.evadeTimer -= deltaTime;
|
883 |
-
|
884 |
-
if (this.evadeTimer <= 0) {
|
885 |
-
this.isEvading = false;
|
886 |
-
this.selectNewPatrolTarget();
|
887 |
-
} else {
|
888 |
-
// ํํผ ๋ชฉํ๋ฅผ ํฅํด ์ด๋
|
889 |
-
this.smoothTurnToTarget(this.targetPosition, deltaTime);
|
890 |
-
}
|
891 |
-
}
|
892 |
|
893 |
smoothTurnToTarget(targetPos, deltaTime) {
|
894 |
// ํ๊ฒ ๋ฐฉํฅ ๊ณ์ฐ
|
@@ -1013,15 +1008,21 @@ class EnemyFighter {
|
|
1013 |
const now = Date.now();
|
1014 |
|
1015 |
// 0.1์ด์ 1๋ฐ์ฉ, 10๋ฐ ์ฐ๋ฐ
|
1016 |
-
if (now - this.lastShootTime >= 100
|
1017 |
-
|
1018 |
-
this.
|
1019 |
-
this.
|
1020 |
-
|
1021 |
-
|
1022 |
-
|
1023 |
-
this.
|
1024 |
-
this.
|
|
|
|
|
|
|
|
|
|
|
|
|
1025 |
}
|
1026 |
}
|
1027 |
}
|
|
|
740 |
// ์ ํฌ ์์คํ
|
741 |
this.bullets = [];
|
742 |
this.burstCounter = 0; // ํ์ฌ ์ฐ๋ฐ ์นด์ดํฐ
|
|
|
743 |
this.lastShootTime = 0;
|
744 |
+
this.canShoot = false; // ๋ฐ์ฌ ๊ฐ๋ฅ ์ฌ๋ถ
|
|
|
745 |
|
746 |
// ๋ถ๋๋ฌ์ด ํ์ ์ ์ํ ๋ณ์
|
747 |
this.targetRotation = this.rotation.clone();
|
|
|
806 |
|
807 |
const distanceToPlayer = this.position.distanceTo(playerPosition);
|
808 |
|
809 |
+
// ์ํ ๊ฒฐ์ - ๋จ์ํ
|
810 |
+
if (distanceToPlayer <= 3000) {
|
811 |
this.aiState = 'combat';
|
|
|
|
|
812 |
} else {
|
813 |
this.aiState = 'patrol';
|
814 |
}
|
|
|
824 |
case 'combat':
|
825 |
this.executeCombat(playerPosition, deltaTime);
|
826 |
break;
|
|
|
|
|
|
|
827 |
}
|
828 |
|
829 |
// ๋ฌผ๋ฆฌ ์
๋ฐ์ดํธ
|
|
|
856 |
// ์กฐ์ค ์ ํ๋ ํ์ธ
|
857 |
const aimAccuracy = this.calculateAimAccuracy(playerPosition);
|
858 |
|
859 |
+
// ์ง์ง ์ํ ํ์ธ (ํผ์น์ ๋กค์ด ๊ฑฐ์ 0์ ๊ฐ๊น์ด์ง)
|
860 |
+
const isPitchLevel = Math.abs(this.rotation.x) < 0.1; // ์ฝ 5.7๋ ์ด๋ด
|
861 |
+
const isRollLevel = Math.abs(this.rotation.z) < 0.1; // ์ฝ 5.7๋ ์ด๋ด
|
862 |
+
const isStraightFlying = isPitchLevel && isRollLevel;
|
863 |
+
|
864 |
+
// ์ง์ง ๋นํ ์ค์ด๊ณ ์ ํํ ์กฐ์ค ์์๋ง ๋ฐ์ฌ ๊ฐ๋ฅ
|
865 |
+
this.canShoot = isStraightFlying && aimAccuracy < 0.15;
|
866 |
+
|
867 |
+
// ๋ฐ์ฌ ์กฐ๊ฑด ์ถฉ์กฑ ์ ๋ฐ์ฌ
|
868 |
+
if (this.canShoot) {
|
869 |
this.fireWeapon();
|
870 |
+
} else {
|
871 |
+
// ๋ฐ์ฌํ ์ ์์ผ๋ฉด ์ฐ๋ฐ ์นด์ดํฐ ๋ฆฌ์
|
872 |
+
this.burstCounter = 0;
|
873 |
}
|
874 |
|
875 |
+
// ๊ฑฐ๋ฆฌ์ ๋ฐ๋ผ ์์ ๋กญ๊ฒ ๊ธฐ๋ ๊ฒฐ์
|
876 |
+
const distance = this.position.distanceTo(playerPosition);
|
877 |
+
if (distance < 500) {
|
878 |
+
// ๋๋ฌด ๊ฐ๊น์ฐ๋ฉด ํํผ ๊ธฐ๋
|
|
|
879 |
this.selectEvadeTarget();
|
880 |
+
} else if (distance > 2000) {
|
881 |
+
// ๋ฉ๋ฉด ์ ๊ทผ
|
882 |
+
this.targetPosition = playerPosition.clone();
|
883 |
}
|
884 |
}
|
885 |
|
886 |
+
// AI ์ํ (ํํผ ๊ด๋ จ ๋ก์ง ์ ๊ฑฐ, patrol๊ณผ combat๋ง ์ ์ง)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
887 |
|
888 |
smoothTurnToTarget(targetPos, deltaTime) {
|
889 |
// ํ๊ฒ ๋ฐฉํฅ ๊ณ์ฐ
|
|
|
1008 |
const now = Date.now();
|
1009 |
|
1010 |
// 0.1์ด์ 1๋ฐ์ฉ, 10๋ฐ ์ฐ๋ฐ
|
1011 |
+
if (now - this.lastShootTime >= 100) {
|
1012 |
+
// ๋ฐ์ฌ ์ง์ ์ ๋ค์ ํ๋ฒ ์ง์ง ์ํ ํ์ธ
|
1013 |
+
const isPitchLevel = Math.abs(this.rotation.x) < 0.1;
|
1014 |
+
const isRollLevel = Math.abs(this.rotation.z) < 0.1;
|
1015 |
+
|
1016 |
+
if (isPitchLevel && isRollLevel) {
|
1017 |
+
this.shoot();
|
1018 |
+
this.lastShootTime = now;
|
1019 |
+
this.burstCounter++;
|
1020 |
+
|
1021 |
+
// 10๋ฐ ๋ฐ์ฌ ์๋ฃ ์ ์ ์ ํด์
|
1022 |
+
if (this.burstCounter >= 10) {
|
1023 |
+
this.burstCounter = 0;
|
1024 |
+
this.lastShootTime = now + 1000; // 1์ด ๋๊ธฐ
|
1025 |
+
}
|
1026 |
}
|
1027 |
}
|
1028 |
}
|