Kaynağa Gözat

欺骗性干扰

xyh 1 yıl önce
ebeveyn
işleme
97c62391bd
1 değiştirilmiş dosya ile 83 ekleme ve 9 silme
  1. 83 9
      src/views/simulation/index.vue

+ 83 - 9
src/views/simulation/index.vue

@@ -44,13 +44,13 @@
             <span><i class="el-icon-s-flag"></i></span>
           </el-tooltip>
           <el-table :data="redList">
-            <el-table-column label="序号" prop="order" width="50px"></el-table-column>
             <el-table-column label="名称" align="center" prop="name"></el-table-column>
             <el-table-column label="干扰度" align="center" prop="disturb"></el-table-column>
+            <el-table-column label="诱饵数" align="center" prop="toll_number"></el-table-column>
             <el-table-column label="状态" align="center" prop="status">
               <template slot-scope="scope">
         <el-tag
-          :type="scope.row.status === '存活' ? 'success' : 'danger'"
+          :type="scope.row.status === '被拦截' ? 'danger' : 'success'"
           disable-transitions>{{scope.row.status}}</el-tag>
       </template>
             </el-table-column>
@@ -628,12 +628,14 @@ export default {
             
             this.missileList[name] = {
             disturb: disturb,
-            id: this.id
+            id: this.id,
+            toll_number: this.jsonData.redunit[i].toll_json.length
         }
             this.redList.push({
               order: this.redOrder++,
               name: name,
               disturb: disturb,
+              toll_number: this.jsonData.redunit[i].toll_json.length,
               status: '存活'
             })
           }
@@ -643,10 +645,18 @@ export default {
       else if (type == 'blue') {
         color = 'Blue'
         modelUrl = radarModel
+        let fire_number = 0
+        for(let i = 0;i<this.jsonData.blueunit.length;i++){
+          if(name === this.jsonData.blueunit[i].name){
+            fire_number = this.jsonData.blueunit[i].fire_number
+          }
+        }
         this.thaadList[name] = {
           range: 700000.0,
           health: 100.0,
-          id: this.id
+          id: this.id,
+          fire_number: fire_number
+
         }
       }
       else if (type == 'center') {
@@ -1059,6 +1069,7 @@ export default {
     },
     // 根据时间参数请求模型位置并更新 3D
     async requestDataAndUpdateModel3D(startTime, elapsedTime) {
+     
       const jsDate = new Date(startTime);
       // 增加 elapsedTime 秒
       jsDate.setSeconds(jsDate.getSeconds() + elapsedTime);
@@ -1067,7 +1078,8 @@ export default {
       await axios
         .post("/api/pos", { simulation_time: newTimeString + '.000' }).then(res => {
           let data = res.data[1].data
-
+ //恢复雷达拦截数量
+ this.radarFireRecover()
           //依次更新每个模型位置
           for (let i = 0; i < this.nameIdList.length; i++) {
             if (this.nameIdList[i].name in data) {
@@ -1155,30 +1167,92 @@ export default {
       }
       return health;
     },
+    //恢复雷达拦截数
+    radarFireRecover(){
+      for(let item in this.thaadList){
+        for(let i = 0;i<this.jsonData.blueunit.length;i++){
+          if(this.jsonData.blueunit[i].name === item)
+          {
+            this.thaadList[item].fire_number = this.jsonData.blueunit[i].fire_number
+            break
+          }
+        }
+      }
+    },
     //判断导弹是否被拦截
     judgeMissile(viewer, time) {
       for (let key in this.missileList) {
         let missile = viewer.entities.getById(this.missileList[key].id)
         let missilePos = viewer.entities.getById(this.missileList[key].id).position._value
+        let status = ''
+        for(let i =0;i<this.redList.length;i++){
+              if(this.redList[i].name === key){
+                status = this.redList[i].status
+                break
+              }
+            }
         for (let item in this.thaadList) {
+          console.log('this.thaadList[item].fire_number :>> ', this.thaadList[item].fire_number);
           let radarPos = viewer.entities.getById(this.thaadList[item].id).position._value
-          if (this.Cesium.Cartesian3.distance(radarPos, missilePos) <= this.thaadList[item].range * this.thaadList[item].health * 0.01) {
+          if (this.Cesium.Cartesian3.distance(radarPos, missilePos) <= this.thaadList[item].range * this.thaadList[item].health * 0.01&&status!=='逃脱拦截') {
             // 导弹进入了被干扰后的雷达探测范围,判断被拦截 移除实体,删除信息
-            this.messageList.push({
+            if(this.thaadList[item].fire_number>=this.missileList[key].toll_number+1){
+                          this.messageList.push({
+              order: this.order++,
+              time: time,
+              context: '导弹' + key + '被雷达' + item + '拦截!!!'
+            })
+            this.thaadList[item].fire_number = this.thaadList[item].fire_number - this.missileList[key].toll_number -1
+            viewer.entities.remove(missile)
+            this.nameIdList = this.nameIdList.filter(item => item.id !== this.missileList[key].id);
+            delete this.missileList[key]
+            for(let i =0;i<this.redList.length;i++){
+              if(this.redList[i].name === key){
+                this.redList[i].status = '被拦截'
+                break
+              }
+            }
+            break
+            }
+            else{
+              let probability = parseFloat(this.thaadList[item].fire_number)/parseFloat(this.missileList[key].toll_number+1)
+              console.log('probability :>> ', probability);
+              // 生成随机数,范围在 0 到 1 之间
+              let randomNum = Math.random();
+              if(randomNum<=probability){
+                this.messageList.push({
               order: this.order++,
               time: time,
               context: '导弹' + key + '被雷达' + item + '拦截!!!'
             })
+            this.thaadList[item].fire_number = 0
             viewer.entities.remove(missile)
             this.nameIdList = this.nameIdList.filter(item => item.id !== this.missileList[key].id);
             delete this.missileList[key]
-            for(let i =0;i<this.redList;i++){
+            for(let i =0;i<this.redList.length;i++){
               if(this.redList[i].name === key){
                 this.redList[i].status = '被拦截'
                 break
               }
             }
             break
+              }
+              else{
+                this.messageList.push({
+              order: this.order++,
+              time: time,
+              context: '导弹' + key + '成功逃避雷达' + item + '的拦截!!!'
+            })
+            this.thaadList[item].fire_number = 0
+            for(let i =0;i<this.redList.length;i++){
+              if(this.redList[i].name === key){
+                this.redList[i].status = '逃脱拦截'
+                break
+              }
+            }
+            break
+              }
+            }
           }
         }
       }
@@ -1219,7 +1293,7 @@ export default {
       else {
         for (let key in this.missileList) {
           let missilePos = viewer.entities.getById(this.missileList[key].id).position._value
-          if (this.Cesium.Cartesian3.distance(this.centerPosition, missilePos) <= 100) {
+          if (this.Cesium.Cartesian3.distance(this.centerPosition, missilePos) <= 10) {
             this.messageList.push({
               order: this.order,
               time: time,