cutechicken commited on
Commit
5ef8126
ยท
verified ยท
1 Parent(s): c78083f

Update index.html

Browse files
Files changed (1) hide show
  1. index.html +120 -0
index.html CHANGED
@@ -1040,9 +1040,129 @@
1040
  threat.style.top = `${y}px`;
1041
 
1042
  rwrThreats.appendChild(threat);
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1043
  }
1044
  });
1045
  }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1046
  }
1047
 
1048
  // startGame ํ•จ์ˆ˜ ์ •์˜
 
1040
  threat.style.top = `${y}px`;
1041
 
1042
  rwrThreats.appendChild(threat);
1043
+
1044
+ // ๋ฝ์˜จ ์ค‘์ธ ์ ์ด๋ฉด RWR์— ๋ฐฉํ–ฅ์„  ํ‘œ์‹œ
1045
+ if (enemy.isLocking && enemy.lockTarget === fighter) {
1046
+ const lockLine = document.createElement('div');
1047
+ lockLine.className = 'rwr-lock-line';
1048
+
1049
+ // ์ค‘์•™์—์„œ ์ ๊นŒ์ง€์˜ ์„ 
1050
+ const lineLength = Math.sqrt(Math.pow(x - 100, 2) + Math.pow(y - 100, 2));
1051
+ const lineAngle = Math.atan2(y - 100, x - 100);
1052
+
1053
+ lockLine.style.width = `${lineLength}px`;
1054
+ lockLine.style.left = '100px';
1055
+ lockLine.style.top = '100px';
1056
+ lockLine.style.transform = `rotate(${lineAngle}rad)`;
1057
+
1058
+ rwrThreats.appendChild(lockLine);
1059
+ }
1060
  }
1061
  });
1062
  }
1063
+
1064
+ // ๋ฝ์˜จ ๊ฒฝ๊ณ  ํ™”์‚ดํ‘œ ์—…๋ฐ์ดํŠธ
1065
+ updateLockWarningArrows(fighter);
1066
+
1067
+ // ๋ฏธ์‚ฌ์ผ ๊ฑฐ๋ฆฌ ๊ฒฝ๊ณ  ์—…๋ฐ์ดํŠธ
1068
+ updateMissileWarnings(fighter);
1069
+ }
1070
+
1071
+ // ๋ฝ์˜จ ๊ฒฝ๊ณ  ํ™”์‚ดํ‘œ ํ‘œ์‹œ
1072
+ function updateLockWarningArrows(fighter) {
1073
+ // ๊ธฐ์กด ํ™”์‚ดํ‘œ ์ œ๊ฑฐ
1074
+ const existingArrows = document.querySelectorAll('.lock-warning-arrow');
1075
+ existingArrows.forEach(arrow => arrow.remove());
1076
+
1077
+ if (!fighter.beingLockedBy || fighter.beingLockedBy.length === 0) return;
1078
+
1079
+ fighter.beingLockedBy.forEach(enemy => {
1080
+ if (!enemy.position) return;
1081
+
1082
+ // ํ™”๋ฉด ๋ฐ–์— ์žˆ๋Š” ์ ๋งŒ ํ™”์‚ดํ‘œ ํ‘œ์‹œ
1083
+ const screenPos = getScreenPosition(enemy.position);
1084
+ if (screenPos) return; // ํ™”๋ฉด ์•ˆ์— ์žˆ์œผ๋ฉด ํ™”์‚ดํ‘œ ๋ถˆํ•„์š”
1085
+
1086
+ // ์ƒ๋Œ€ ์œ„์น˜ ๊ณ„์‚ฐ
1087
+ const relativePos = enemy.position.clone().sub(fighter.position);
1088
+ const angle = Math.atan2(relativePos.x, relativePos.z) - fighter.rotation.y;
1089
+
1090
+ const arrow = document.createElement('div');
1091
+ arrow.className = 'lock-warning-arrow';
1092
+
1093
+ // ํ™”๋ฉด ๊ฐ€์žฅ์ž๋ฆฌ์— ํ™”์‚ดํ‘œ ๋ฐฐ์น˜
1094
+ const screenCenterX = window.innerWidth / 2;
1095
+ const screenCenterY = window.innerHeight / 2;
1096
+ const edgeDistance = Math.min(screenCenterX - 100, screenCenterY - 100);
1097
+
1098
+ const arrowX = screenCenterX + Math.sin(angle) * edgeDistance;
1099
+ const arrowY = screenCenterY - Math.cos(angle) * edgeDistance;
1100
+
1101
+ arrow.style.left = `${arrowX}px`;
1102
+ arrow.style.top = `${arrowY}px`;
1103
+
1104
+ // ํ™”์‚ดํ‘œ ํšŒ์ „
1105
+ const rotationAngle = angle * (180 / Math.PI);
1106
+ arrow.style.transform = `translate(-50%, -50%) rotate(${rotationAngle}deg)`;
1107
+
1108
+ document.body.appendChild(arrow);
1109
+ });
1110
+ }
1111
+
1112
+ // ๋ฏธ์‚ฌ์ผ ๊ฑฐ๋ฆฌ ๊ฒฝ๊ณ  ํ‘œ์‹œ
1113
+ function updateMissileWarnings(fighter) {
1114
+ // ๊ธฐ์กด ๊ฒฝ๊ณ  ํŒจ๋„ ์ œ๊ฑฐ
1115
+ const existingPanel = document.querySelector('.missile-warning-panel');
1116
+ if (existingPanel) existingPanel.remove();
1117
+
1118
+ if (!fighter.incomingMissiles || fighter.incomingMissiles.length === 0) return;
1119
+
1120
+ const panel = document.createElement('div');
1121
+ panel.className = 'missile-warning-panel';
1122
+
1123
+ fighter.incomingMissiles.forEach((missile, index) => {
1124
+ if (!missile.position) return;
1125
+
1126
+ const distance = Math.round(fighter.position.distanceTo(missile.position));
1127
+
1128
+ const warningItem = document.createElement('div');
1129
+ warningItem.className = 'missile-warning-item';
1130
+ warningItem.textContent = `MISSILE ${index + 1}: ${distance}m`;
1131
+
1132
+ // ๊ฑฐ๋ฆฌ์— ๋”ฐ๋ฅธ ์ƒ‰์ƒ ๊ฐ•์กฐ
1133
+ if (distance < 500) {
1134
+ warningItem.style.fontSize = '20px';
1135
+ warningItem.style.color = '#ff0000';
1136
+ warningItem.style.textShadow = '0 0 10px #ff0000, 0 0 20px #ff0000';
1137
+ } else if (distance < 1000) {
1138
+ warningItem.style.fontSize = '18px';
1139
+ }
1140
+
1141
+ panel.appendChild(warningItem);
1142
+ });
1143
+
1144
+ document.body.appendChild(panel);
1145
+ }
1146
+
1147
+ // 3D ์œ„์น˜๋ฅผ ํ™”๋ฉด ์ขŒํ‘œ๋กœ ๋ณ€ํ™˜ํ•˜๋Š” ํ—ฌํผ ํ•จ์ˆ˜
1148
+ function getScreenPosition(worldPosition) {
1149
+ if (!window.gameInstance || !window.gameInstance.camera) return null;
1150
+
1151
+ const vector = worldPosition.clone();
1152
+ vector.project(window.gameInstance.camera);
1153
+
1154
+ // ์นด๋ฉ”๋ผ ๋’ค์— ์žˆ๋Š” ๊ฐ์ฒด๋Š” null ๋ฐ˜ํ™˜
1155
+ if (vector.z > 1) return null;
1156
+
1157
+ const x = (vector.x * 0.5 + 0.5) * window.innerWidth;
1158
+ const y = (-vector.y * 0.5 + 0.5) * window.innerHeight;
1159
+
1160
+ // ํ™”๋ฉด ๋ฐ–์— ์žˆ์œผ๋ฉด null ๋ฐ˜ํ™˜
1161
+ if (x < 0 || x > window.innerWidth || y < 0 || y > window.innerHeight) {
1162
+ return null;
1163
+ }
1164
+
1165
+ return { x, y };
1166
  }
1167
 
1168
  // startGame ํ•จ์ˆ˜ ์ •์˜