Spaces:
Running
Running
Update game.js
Browse files
game.js
CHANGED
@@ -730,6 +730,8 @@ class EnemyFighter {
|
|
730 |
this.speed = 600; // 600ktλ‘ μμ (500-750kt λ²μ)
|
731 |
this.velocity = new THREE.Vector3(0, 0, 0);
|
732 |
this.health = GAME_CONSTANTS.MAX_HEALTH;
|
|
|
|
|
733 |
|
734 |
// AI μν
|
735 |
this.aiState = 'patrol'; // patrol, combat, evade
|
@@ -848,8 +850,11 @@ class EnemyFighter {
|
|
848 |
// λͺ©νλ₯Ό ν₯ν΄ λΆλλ½κ² νμ
|
849 |
this.smoothTurnToTarget(this.targetPosition, deltaTime);
|
850 |
|
851 |
-
// μλ μ μ§ (500-750kt)
|
852 |
-
this.speed
|
|
|
|
|
|
|
853 |
}
|
854 |
|
855 |
executeCombat(playerPosition, deltaTime) {
|
@@ -889,7 +894,7 @@ class EnemyFighter {
|
|
889 |
smoothTurnToTarget(targetPos, deltaTime) {
|
890 |
// νκ² λ°©ν₯ κ³μ°
|
891 |
const direction = targetPos.clone().sub(this.position);
|
892 |
-
direction.y *= 0.
|
893 |
direction.normalize();
|
894 |
|
895 |
// μΆ©λ ννΌ λ²‘ν° μ μ©
|
@@ -916,15 +921,16 @@ class EnemyFighter {
|
|
916 |
}
|
917 |
|
918 |
// Pitch νμ (μ νμ )
|
919 |
-
const maxPitchRate = maxTurnRate * 0.
|
920 |
if (Math.abs(pitchDiff) > maxPitchRate) {
|
921 |
this.rotation.x += Math.sign(pitchDiff) * maxPitchRate;
|
922 |
} else {
|
923 |
this.rotation.x = targetPitch;
|
924 |
}
|
925 |
|
926 |
-
// Pitch μ ν
|
927 |
-
|
|
|
928 |
}
|
929 |
|
930 |
calculateAvoidance() {
|
@@ -960,20 +966,25 @@ class EnemyFighter {
|
|
960 |
const forward = new THREE.Vector3(0, 0, 1);
|
961 |
forward.applyEuler(this.rotation);
|
962 |
|
963 |
-
// μλ μ μ§ (500-750kt, m/sλ‘ λ³ν)
|
964 |
-
this.speed
|
|
|
|
|
|
|
|
|
|
|
965 |
this.velocity = forward.multiplyScalar(this.speed);
|
966 |
|
967 |
-
// μμΉ μ
λ°μ΄νΈ
|
968 |
this.position.add(this.velocity.clone().multiplyScalar(deltaTime));
|
969 |
|
970 |
// κ³ λ μ ν
|
971 |
if (this.position.y < 500) {
|
972 |
this.position.y = 500;
|
973 |
-
this.rotation.x = -0.
|
974 |
} else if (this.position.y > 8000) {
|
975 |
this.position.y = 8000;
|
976 |
-
this.rotation.x = 0.
|
977 |
}
|
978 |
|
979 |
// λ§΅ κ²½κ³ μ²λ¦¬
|
@@ -1017,8 +1028,8 @@ class EnemyFighter {
|
|
1017 |
}
|
1018 |
|
1019 |
shoot() {
|
1020 |
-
// νν μμ±
|
1021 |
-
const bulletGeometry = new THREE.CylinderGeometry(0
|
1022 |
const bulletMaterial = new THREE.MeshBasicMaterial({
|
1023 |
color: 0xff0000,
|
1024 |
emissive: 0xff0000,
|
@@ -1026,19 +1037,22 @@ class EnemyFighter {
|
|
1026 |
});
|
1027 |
const bullet = new THREE.Mesh(bulletGeometry, bulletMaterial);
|
1028 |
|
1029 |
-
// κΈ°μ λμμ λ°μ¬
|
1030 |
-
const muzzleOffset = new THREE.Vector3(0, 0,
|
1031 |
muzzleOffset.applyEuler(this.rotation);
|
1032 |
bullet.position.copy(this.position).add(muzzleOffset);
|
1033 |
|
1034 |
-
//
|
1035 |
bullet.rotation.copy(this.rotation);
|
1036 |
bullet.rotateX(Math.PI / 2);
|
1037 |
|
1038 |
-
// νν
|
|
|
|
|
|
|
1039 |
const direction = new THREE.Vector3(0, 0, 1);
|
1040 |
direction.applyEuler(this.rotation);
|
1041 |
-
bullet.velocity = direction.multiplyScalar(
|
1042 |
|
1043 |
this.scene.add(bullet);
|
1044 |
this.bullets.push(bullet);
|
@@ -1072,8 +1086,9 @@ class EnemyFighter {
|
|
1072 |
continue;
|
1073 |
}
|
1074 |
|
1075 |
-
// 거리 μ ν
|
1076 |
-
if (bullet.position.distanceTo(
|
|
|
1077 |
this.scene.remove(bullet);
|
1078 |
this.bullets.splice(i, 1);
|
1079 |
}
|
@@ -1089,9 +1104,14 @@ class EnemyFighter {
|
|
1089 |
|
1090 |
selectNewPatrolTarget() {
|
1091 |
const mapLimit = GAME_CONSTANTS.MAP_SIZE / 2 * 0.7;
|
|
|
|
|
|
|
|
|
|
|
1092 |
this.targetPosition = new THREE.Vector3(
|
1093 |
(Math.random() - 0.5) * 2 * mapLimit,
|
1094 |
-
|
1095 |
(Math.random() - 0.5) * 2 * mapLimit
|
1096 |
);
|
1097 |
}
|
|
|
730 |
this.speed = 600; // 600ktλ‘ μμ (500-750kt λ²μ)
|
731 |
this.velocity = new THREE.Vector3(0, 0, 0);
|
732 |
this.health = GAME_CONSTANTS.MAX_HEALTH;
|
733 |
+
this.minSpeed = 257; // 500kt in m/s
|
734 |
+
this.maxSpeed = 386; // 750kt in m/s
|
735 |
|
736 |
// AI μν
|
737 |
this.aiState = 'patrol'; // patrol, combat, evade
|
|
|
850 |
// λͺ©νλ₯Ό ν₯ν΄ λΆλλ½κ² νμ
|
851 |
this.smoothTurnToTarget(this.targetPosition, deltaTime);
|
852 |
|
853 |
+
// μλ μ μ§ (500-750kt) - νμ μ΅μ μλ μ΄μ μ μ§
|
854 |
+
if (this.speed < this.minSpeed) {
|
855 |
+
this.speed = this.minSpeed;
|
856 |
+
}
|
857 |
+
this.speed = THREE.MathUtils.clamp(this.speed, this.minSpeed, this.maxSpeed);
|
858 |
}
|
859 |
|
860 |
executeCombat(playerPosition, deltaTime) {
|
|
|
894 |
smoothTurnToTarget(targetPos, deltaTime) {
|
895 |
// νκ² λ°©ν₯ κ³μ°
|
896 |
const direction = targetPos.clone().sub(this.position);
|
897 |
+
direction.y *= 0.5; // μμ§ μ΄λμ λ μ νμ μΌλ‘
|
898 |
direction.normalize();
|
899 |
|
900 |
// μΆ©λ ννΌ λ²‘ν° μ μ©
|
|
|
921 |
}
|
922 |
|
923 |
// Pitch νμ (μ νμ )
|
924 |
+
const maxPitchRate = maxTurnRate * 0.7; // νΌμΉλ μ‘°κΈ λ λΉ λ₯΄κ²
|
925 |
if (Math.abs(pitchDiff) > maxPitchRate) {
|
926 |
this.rotation.x += Math.sign(pitchDiff) * maxPitchRate;
|
927 |
} else {
|
928 |
this.rotation.x = targetPitch;
|
929 |
}
|
930 |
|
931 |
+
// Pitch μ ν (Β±40λ)
|
932 |
+
const maxPitchAngle = Math.PI * 40 / 180; // 40λλ₯Ό λΌλμμΌλ‘
|
933 |
+
this.rotation.x = THREE.MathUtils.clamp(this.rotation.x, -maxPitchAngle, maxPitchAngle);
|
934 |
}
|
935 |
|
936 |
calculateAvoidance() {
|
|
|
966 |
const forward = new THREE.Vector3(0, 0, 1);
|
967 |
forward.applyEuler(this.rotation);
|
968 |
|
969 |
+
// μλ μ μ§ (500-750kt, m/sλ‘ λ³ν) - κ°μ λ‘ μ΅μ μλ μ μ§
|
970 |
+
if (this.speed < this.minSpeed) {
|
971 |
+
this.speed = this.minSpeed;
|
972 |
+
}
|
973 |
+
this.speed = THREE.MathUtils.clamp(this.speed, this.minSpeed, this.maxSpeed);
|
974 |
+
|
975 |
+
// μλ λ²‘ν° μμ± - νμ μ μ§
|
976 |
this.velocity = forward.multiplyScalar(this.speed);
|
977 |
|
978 |
+
// μμΉ μ
λ°μ΄νΈ - νμ μ΄λ
|
979 |
this.position.add(this.velocity.clone().multiplyScalar(deltaTime));
|
980 |
|
981 |
// κ³ λ μ ν
|
982 |
if (this.position.y < 500) {
|
983 |
this.position.y = 500;
|
984 |
+
this.rotation.x = -0.2; // μμΉ
|
985 |
} else if (this.position.y > 8000) {
|
986 |
this.position.y = 8000;
|
987 |
+
this.rotation.x = 0.2; // νκ°
|
988 |
}
|
989 |
|
990 |
// λ§΅ κ²½κ³ μ²λ¦¬
|
|
|
1028 |
}
|
1029 |
|
1030 |
shoot() {
|
1031 |
+
// νν μμ± (νλ μ΄μ΄μ λμΌν ν¬κΈ°)
|
1032 |
+
const bulletGeometry = new THREE.CylinderGeometry(1.0, 1.0, 16, 8);
|
1033 |
const bulletMaterial = new THREE.MeshBasicMaterial({
|
1034 |
color: 0xff0000,
|
1035 |
emissive: 0xff0000,
|
|
|
1037 |
});
|
1038 |
const bullet = new THREE.Mesh(bulletGeometry, bulletMaterial);
|
1039 |
|
1040 |
+
// κΈ°μ λμμ λ°μ¬ (νλ μ΄μ΄μ λμΌνκ² λ μμͺ½μμ)
|
1041 |
+
const muzzleOffset = new THREE.Vector3(0, 0, 10);
|
1042 |
muzzleOffset.applyEuler(this.rotation);
|
1043 |
bullet.position.copy(this.position).add(muzzleOffset);
|
1044 |
|
1045 |
+
// ννμ λ°μ¬ λ°©ν₯μΌλ‘ νμ
|
1046 |
bullet.rotation.copy(this.rotation);
|
1047 |
bullet.rotateX(Math.PI / 2);
|
1048 |
|
1049 |
+
// νν μ΄κΈ° μμΉ μ μ₯
|
1050 |
+
bullet.startPosition = bullet.position.clone();
|
1051 |
+
|
1052 |
+
// νν μλ (νλ μ΄μ΄μ λμΌνκ² 1500)
|
1053 |
const direction = new THREE.Vector3(0, 0, 1);
|
1054 |
direction.applyEuler(this.rotation);
|
1055 |
+
bullet.velocity = direction.multiplyScalar(1500);
|
1056 |
|
1057 |
this.scene.add(bullet);
|
1058 |
this.bullets.push(bullet);
|
|
|
1086 |
continue;
|
1087 |
}
|
1088 |
|
1089 |
+
// 거리 μ ν (νλ μ΄μ΄μ λμΌνκ² 6000m)
|
1090 |
+
if (bullet.position.distanceTo(bullet.startPosition) > 6000 ||
|
1091 |
+
bullet.position.y > GAME_CONSTANTS.MAX_ALTITUDE + 500) {
|
1092 |
this.scene.remove(bullet);
|
1093 |
this.bullets.splice(i, 1);
|
1094 |
}
|
|
|
1104 |
|
1105 |
selectNewPatrolTarget() {
|
1106 |
const mapLimit = GAME_CONSTANTS.MAP_SIZE / 2 * 0.7;
|
1107 |
+
|
1108 |
+
// λ λ€μν κ³ λ μ ν
|
1109 |
+
const minAltitude = 1000;
|
1110 |
+
const maxAltitude = 6000;
|
1111 |
+
|
1112 |
this.targetPosition = new THREE.Vector3(
|
1113 |
(Math.random() - 0.5) * 2 * mapLimit,
|
1114 |
+
minAltitude + Math.random() * (maxAltitude - minAltitude),
|
1115 |
(Math.random() - 0.5) * 2 * mapLimit
|
1116 |
);
|
1117 |
}
|