2390 lines
80 KiB
C#
2390 lines
80 KiB
C#
using DataModel.Model;
|
||
using LitJson;
|
||
using Newtonsoft.Json.Linq;
|
||
using System;
|
||
using System.Collections;
|
||
using System.Collections.Generic;
|
||
using System.Diagnostics.SymbolStore;
|
||
using System.Linq;
|
||
using System.Runtime.ConstrainedExecution;
|
||
using System.Security.Principal;
|
||
using Tenkoku.Core;
|
||
using UnityEditor.Animations;
|
||
using UnityEditor.VersionControl;
|
||
using UnityEngine;
|
||
using UnityEngine.Networking;
|
||
using UnityEngine.Playables;
|
||
using UnityEngine.Rendering.PostProcessing;
|
||
using UnityEngine.SceneManagement;
|
||
using UnityEngine.UI;
|
||
|
||
using YL;
|
||
using static NetMQ.NetMQSelector;
|
||
using static UnityEditor.ShaderData;
|
||
|
||
public class Scenariopage : MonoBehaviour
|
||
{
|
||
public Button scenario_file_btn;//想定文件按钮
|
||
public RectTransform ScrollView_unpack;//打开保存退出按钮显示
|
||
public RectTransform Scenariofile_panl;//想定页面
|
||
public Image object_list_panl;//对象列表面板
|
||
public Image Radius_panl;//值范围面板
|
||
public Image mianban;//
|
||
public Button object_list_btn;//对象列表按钮
|
||
public Button basic_info_btn;//基本信息按钮
|
||
public Image basic_information_iamg;//基本信息面板
|
||
public Button off4_btn;//基本信息关闭按钮
|
||
public Button model_list_btn;//模型按钮
|
||
public RectTransform select_device_iamg;//模型页面
|
||
public Button verify;//设备信息确认按钮
|
||
public Button Cancel_btnn;//设备信息取消按钮
|
||
public Image details_panl;//设备详情页面
|
||
public Button Fork_off_btn;//设备详情叉掉面板
|
||
public Button queren_btn;//设备详情确认按钮
|
||
public Button quxiao_btn;//设备详情取消按钮
|
||
public Image model_panl;//模型页面按钮
|
||
public Button off_btn;//选择设备的关闭按钮
|
||
public RectTransform environment_configuration1;//环境页面
|
||
public Button environment_setting_btn;//环境按钮
|
||
public Button fork_off_btn;//关闭按钮
|
||
public Button send_back_btn;//返回按钮
|
||
public Button verify_bton1;//基本信息确定按钮
|
||
public Button cancel_bton1;//基本信息取消按钮
|
||
public Button huanjin_btn;//环境配置确认按钮
|
||
public Button huanjin_btn1;//环境配置取消按钮
|
||
public Button quan_btn;//全部按钮
|
||
public Button can_btn;//探测按钮
|
||
public Button lu_btn;//陆
|
||
public Button kong_btn;//空
|
||
public Button qita_btn;//其他
|
||
public Image moxin_yemian;//显示模型框
|
||
public Image moyin_yemian1;
|
||
public Image moyin_yemian2;
|
||
public Image moyin_yemian3;
|
||
public Image moyin_yemian4;
|
||
|
||
private bool model = true;
|
||
private bool duixiang = true;
|
||
public Button queding;
|
||
|
||
public Dropdown windDrop;
|
||
public Dropdown windDir;
|
||
|
||
public TenkokuModule tenkokuModule;
|
||
public Button unpack_btn;//想定编辑打开按钮
|
||
public Button save_btn;//保存按钮
|
||
public Button quit;//退出按钮
|
||
|
||
|
||
//弹窗一
|
||
|
||
|
||
public Slider shijian;
|
||
public Text shi_text;
|
||
public Slider xuslider;
|
||
public Text xusshi_text;
|
||
public Slider Rcs;
|
||
public Text Rcs_text;
|
||
public Image contingency_list_panl;//想定列表面板
|
||
public Button off_btnn5;//关闭按钮
|
||
public Button queren_btnn3;//确认按钮
|
||
private string url = "http://172.16.1.254:48888/Handler/Thinkingfile.ashx?action=all";//想定Wbe接口
|
||
//public List<Text> textlist = new List<Text>();
|
||
[SerializeField]
|
||
Editinformation scen = new Editinformation();
|
||
[SerializeField]
|
||
List<Traininginformation> data1 = new List<Traininginformation>();//
|
||
|
||
//List<Traininginformation> data1 = new List<Traininginformation>();
|
||
public Slider yangguang;//阳光的滑动条
|
||
public Text yangguang_text; //显示阳光的滑动数值
|
||
|
||
public Image basic_information_iamg1;//训练科目基本信息页面
|
||
public Text xunkian_txt;//显示的想定的名字
|
||
public Text time_txt;//显示基本信息的训练时间
|
||
public Text mode_text;//显示基本信息页面训练模式
|
||
public Text post_txt;//显示基本信息的设备数量
|
||
public Button off4_btn1;//训练科目基本信息叉掉按钮;
|
||
public Button verify_bton2;//训练科目基本信息确认按钮
|
||
public Button cancel_bton2;//训练科目基本信息取消按钮
|
||
public GameObject scenario_name;//想定编辑的预设体
|
||
public Transform weizhi;//生成的位置
|
||
|
||
[SerializeField] List<Toggle> togglelist = new List<Toggle>();//存放想定文件下的打勾按钮
|
||
public ToggleGroup togglezujian;//获取toggle组件
|
||
public Underneath underneath;//想定文件下的科目预设体
|
||
public Transform scenario_file_iamg;//生成的预设体的位置
|
||
[SerializeField] List<Underneath> underneathList = new List<Underneath>();
|
||
public GameObject scenarname;//想定名称
|
||
public Scenarioname scenar_name;//想定名称
|
||
[SerializeField] List<Scenarioname> scenarList = new List<Scenarioname>();
|
||
public Text year_text;//年
|
||
public Text month_text;//月
|
||
public Text day_text;//天
|
||
public Text when_text;//时
|
||
public Environmentconfiguration Environmentconfiguration;
|
||
public Slider Slider;//天气变化的滑动条
|
||
public Text tips_text;//环境编辑提示文本
|
||
//[SerializeField] List<Environment> environments = new List<Environment>();
|
||
[SerializeField] string rainamt;//天气雨的传值
|
||
[SerializeField] string snowamt;//天气雪的传值
|
||
[SerializeField] string windamt;//风的等级的传值
|
||
[SerializeField] string winddir;//雪的等级的传值
|
||
public string Name1;
|
||
public string practicemode;
|
||
public Text scenarioname_text;//基本信息的想定名称
|
||
public Text practricemode_text;//基本信息模式
|
||
public int time;
|
||
public int quantity;
|
||
public Text time1_text;//相对训练的时间
|
||
public Text quantity_text;//基本信息页面设备数量
|
||
public Toggle xitong;//系统时间勾选
|
||
public Toggle shodo;//手动设置时间
|
||
public Button hand_btn;//手动设置按钮
|
||
public Text auto_text;//自动时间文本
|
||
public bool isptime = false;//时间显示判断文本
|
||
public bool kaiguan = false;
|
||
public Propertypanl propertypanl;//需要生成的物体
|
||
public Transform Panel_making;//生成的面板的位置
|
||
public List<Propertypanl> properties = new List<Propertypanl>();
|
||
public Weaponitem weaponitem = new Weaponitem();
|
||
public string Id;//获取想定名称的ID
|
||
public Deviceinformation deviceinformations;//武器预设体面板
|
||
public Transform weapontrans;//武器的位置
|
||
public List<Deviceinformation> devicelist = new List<Deviceinformation>();//面板武器值预设体存放
|
||
public List<Text> namelists = new List<Text>();//设备名称
|
||
public List<InputField> numberlist = new List<InputField>();//设备的个数
|
||
public List<Toggle> checklist = new List<Toggle>();//是否启用
|
||
public bool weaper = true;//武器名字开关
|
||
public bool isp = true;//第一次不进行修改
|
||
public List<string> strlist = new List<string>();//查询时候把接口里面的值传到面板上
|
||
public List<string> stringlist = new List<string>();//保存的查询id的链表
|
||
//激光火炮面板
|
||
public Image valuerangepanl;//激光火炮面板
|
||
public Button shezhi_btn33;//激光火炮生成按钮
|
||
public Button off1_btn1;//叉掉激光火炮面板按钮
|
||
public Button quxiao_btnn3;//取消激光火炮面板按钮
|
||
public Button quedin_btn12;//确认激光火炮面板按钮
|
||
public Slider Slidertime;//储能间隔时间滑动条
|
||
public Text stored_text;//储能间隔滑动条显示文本
|
||
public Slider Slideraccumulate;//毁伤目标累计作用时间滑动条
|
||
public Text accumulate_text;//毁伤目标累计作用时间显示文本
|
||
public Slider Sliderdistance;//干扰距离时间滑动条
|
||
public Text dis_text;//干扰距离显示文本
|
||
public Slider SliderAngle1;//干扰角度文本滑动条
|
||
public Text angle1_text;//干扰距离文本显示
|
||
public List<Text> laserlist = new List<Text>();//存取激光武器的名称
|
||
public List<Slider> laserquantitylist = new List<Slider>();//存取武器的个数
|
||
public List<Text> Laserunitlist = new List<Text>();//保存面板上的激光单位
|
||
public List<string> laserunitlists = new List<string>();//只保存单个单位个数
|
||
//探测雷达面板
|
||
public Image radar_panl;//探测雷达面板
|
||
public Button shezhi_btn111;//雷达探测按钮
|
||
public Button offguan1_btn;//叉掉雷达面板按钮
|
||
public Button verify1_btnn;//确定雷达面板按钮
|
||
public Button Cancel1_btnn;//取消雷达面板按钮
|
||
public List<Text> Rettalist = new List<Text>();//记录雷达参数名称
|
||
public List<Slider> Radarparameterlist = new List<Slider>();//记录雷达参数
|
||
public List<string> unitlist = new List<string>();
|
||
public List<Text> Radarunitlist = new List<Text>();//记录雷达参数单位
|
||
public Slider Slider_turntable;//转台转速滑动条
|
||
public Text turntable_text;//转台转速显示文本
|
||
public Slider Slider_probe;//探测距离滑动条
|
||
public Text probe_text;//探测距离显示文本
|
||
public Slider Slider_nearblind;//近盲区显示滑动条
|
||
public Text nearblind_text;//近盲区显示文本
|
||
public Slider Slider_handle;//批量目标处理滑动条
|
||
public Text handle_text;//批量目标处理显示文本
|
||
public Slider Slider_Successful;//探测成功率滑动条
|
||
public Text successful_text;//探测成功率显示文本
|
||
public Slider Slider_minimum;//探测最小速度滑动条
|
||
public Text minimum_text;//探测最小速度文本
|
||
public Slider Slider_distinguish;//距离分辨率滑动条
|
||
public Text distinguish_text;//距离分辨率显示文本
|
||
public Slider Slider_orientation;//方向分辨率滑动条
|
||
public Text orientation_text;//方向分辨率显示文本
|
||
public Slider Slider_breadth;//方位波束滑动条
|
||
public Text breadth_text;//方位波束显示文本
|
||
public Slider Slider_beam;//俯仰波束宽度滑动条
|
||
public Text beam_text;//俯仰波束宽度显示文本
|
||
|
||
//地面无线电干扰
|
||
public Image radio_wave_panl;//无线电干扰面板
|
||
public Button shezhi_btn22;//无线电显示面板设置按钮
|
||
public Button offbi_btn;//无线电面板叉掉按钮
|
||
public Button queren_btnn;//无线电面板确认按钮
|
||
public Button quxia_btnn;//无线电面板取消按钮
|
||
public Dropdown Dropdown_frequency;//无线电干扰的频率选项框
|
||
public float frequ;//接收选项框文本id
|
||
public Text frequency_text;//无线电选项框显示文本
|
||
public float drive;
|
||
public Toggle Toggle_Drive;//驱离选项
|
||
public Text drive_text;//驱离文本
|
||
public Toggle Toggle_Crash;//迫降选项
|
||
public Text crash_text;//迫降文本
|
||
public Dropdown Dropdown_power;//发射功率选项框
|
||
public float power;
|
||
public Text power_text;//功率选项框
|
||
public Slider Slider_angle;//干扰的角度滑动条
|
||
public float angle;
|
||
public Text angle_text;//干扰角度显示文本
|
||
public Slider Slider_distance;//干扰的距离滑动条
|
||
public float distance;
|
||
public Text distance_text;
|
||
public List<Text> wirelesslist = new List<Text>();//地面无线电干扰
|
||
public List<float> wirelesslist2 = new List<float>();
|
||
public List<Text> Wirelessunitlist = new List<Text>();//无线单位
|
||
public List<string> wirelessunitlist2 = new List<string>();
|
||
//无人机蜂群
|
||
public Image argument_panl;//无人机蜂群页面
|
||
public Button shezhi_btn44;//无人机页面设置按钮
|
||
public Button off_btnn4;//无人机页面叉掉按钮
|
||
public Button que_btn;//无人机页面确认按钮
|
||
public Button qu_btn;//无人机页面取消按钮
|
||
public Slider Slider_endurance;//无人机续航的时间滑动条
|
||
public Text endurance_text;//无人机续航时间文本显示
|
||
public Dropdown Dropdown_wind;//抗风等级选项框
|
||
public Text wind_text;//抗风等级显示文本
|
||
public Slider Slider_speed;//最大飞行速度滑动条
|
||
public Text speed_text;//最大飞行速度文本显示
|
||
public Slider Slider_rcs;//最大的RCS滑动条
|
||
public Text rcs_text;//显示RCS的文本
|
||
public Dropdown Dropdown_orientation;//卫星定位的频率选项框
|
||
public Text orienttation_text;//卫星定位显示文本
|
||
public Dropdown Dropdown_communication;//网络同信选项框
|
||
public Text communication_text;//网络同信的显示文本
|
||
//电子侦察能力选项
|
||
public Toggle toggle1;
|
||
public Toggle toggle2;
|
||
public Toggle toggle3;
|
||
public Toggle toggle4;
|
||
public Toggle toggle5;
|
||
public Toggle toggle6;
|
||
public Toggle toggle7;
|
||
//是否有光学侦察能力
|
||
public Toggle toggle8;
|
||
public Toggle toggle9;
|
||
public List<Text> uavnamelist = new List<Text>();//无人机参数
|
||
public List<float> uavnamelist2 = new List<float>();//无人机数值
|
||
public List<Text> Droneunitlist = new List<Text>();//无人机单位
|
||
public List<string> Droneunitlist2 = new List<string>();//单个单位无人机
|
||
public float quantity1;
|
||
public float quantity2;
|
||
public float quantity3;
|
||
public float quantity4;
|
||
public float quantity5;
|
||
public float quantity6;
|
||
public float quantity7;
|
||
public float quantity8;
|
||
public Weaponitemone weaponitemone1;
|
||
public List<string> radaridlist = new List<string>();
|
||
public List<string> wirelessidlist = new List<string>();
|
||
public List<string> droneidlist = new List<string>();
|
||
public List<string> laseridlist = new List<string>();
|
||
|
||
|
||
|
||
|
||
void Start()
|
||
{
|
||
//调用接口
|
||
StartCoroutine(Post1(url, (bol, str) =>
|
||
{
|
||
Scenario(bol, str);
|
||
}));
|
||
Scenario();//想定文件
|
||
Basic();//基本信息按钮
|
||
Scenariofile();//想定文件下面按钮
|
||
Environment1();//环境按钮
|
||
send_back_btn.onClick.AddListener(() =>
|
||
{
|
||
GameMain.tiao = false;
|
||
SceneManager.LoadScene("SampleScene");
|
||
});
|
||
//SetLightValue(1f);
|
||
queding.onClick.AddListener(() =>
|
||
{
|
||
//SetWindValue();
|
||
//SetWindDirection();
|
||
environment_configuration1.gameObject.SetActive(false);
|
||
});
|
||
Jiben();//基本信息确认取消按钮
|
||
Huanjin();
|
||
Moxing();
|
||
Moxingxuanze();
|
||
|
||
Duixiaang();//对象列表按钮面板
|
||
|
||
|
||
Dixaing();//想定列表按钮
|
||
Settingbtn();//科目训练按钮三
|
||
Timesetting();//系统时间和自动设置时间
|
||
Lasergun();//激光火炮按钮
|
||
Radardetection();//雷达探测页面设置
|
||
Radiointerference();//无线电干扰页面设置
|
||
Drone();//无人机蜂群页面
|
||
Electronicreconnaissance();//电子侦察能里选项和是否有光子侦察
|
||
}
|
||
|
||
private void Electronicreconnaissance()
|
||
{
|
||
toggle1.onValueChanged.AddListener((ison) =>
|
||
{
|
||
if (ison)
|
||
{
|
||
quantity7 = 1;
|
||
}
|
||
});
|
||
toggle2.onValueChanged.AddListener((ison) =>
|
||
{
|
||
if (ison)
|
||
{
|
||
quantity7 = 2;
|
||
}
|
||
});
|
||
toggle3.onValueChanged.AddListener((ison) =>
|
||
{
|
||
if (ison)
|
||
{
|
||
quantity7 = 3;
|
||
}
|
||
});
|
||
toggle4.onValueChanged.AddListener((ison) =>
|
||
{
|
||
if (ison)
|
||
{
|
||
quantity7 = 4;
|
||
}
|
||
});
|
||
toggle5.onValueChanged.AddListener((ison) =>
|
||
{
|
||
if (ison)
|
||
{
|
||
quantity7 = 5;
|
||
}
|
||
});
|
||
toggle6.onValueChanged.AddListener((ison) =>
|
||
{
|
||
if (ison)
|
||
{
|
||
quantity7 = 6;
|
||
}
|
||
});
|
||
toggle7.onValueChanged.AddListener((ison) =>
|
||
{
|
||
if (ison)
|
||
{
|
||
quantity7 = 7;
|
||
}
|
||
});
|
||
toggle8.onValueChanged.AddListener((ison) =>
|
||
{
|
||
if (ison)
|
||
{
|
||
quantity8 = 1;
|
||
}
|
||
});
|
||
toggle9.onValueChanged.AddListener((ison) =>
|
||
{
|
||
if (ison)
|
||
{
|
||
quantity8 = 2;
|
||
}
|
||
});
|
||
}
|
||
|
||
private void Drone()
|
||
{
|
||
shezhi_btn44.onClick.AddListener(() =>
|
||
{
|
||
if (strlist.Count > 0)
|
||
{
|
||
Droneretrieval();
|
||
}
|
||
argument_panl.gameObject.SetActive(true);
|
||
});
|
||
off_btnn4.onClick.AddListener(() =>
|
||
{
|
||
argument_panl.gameObject.SetActive(false);
|
||
});
|
||
//无人机确认按钮
|
||
que_btn.onClick.AddListener(() =>
|
||
{
|
||
if (strlist.Count > 0)
|
||
{
|
||
Uavparametermodification();//无人机修改参数
|
||
}
|
||
argument_panl.gameObject.SetActive(false);
|
||
});
|
||
qu_btn.onClick.AddListener(() =>
|
||
{
|
||
argument_panl.gameObject.SetActive(false);
|
||
});
|
||
}
|
||
|
||
private void Uavparametermodification()
|
||
{
|
||
string url = "http://172.16.1.254:48888/Handler/Thinkingfile.ashx?action=updatedevicepara";
|
||
List<Aircraft> aircrafts = new List<Aircraft>();
|
||
if (uavnamelist2.Count > 0)
|
||
{
|
||
uavnamelist2.Clear();
|
||
}
|
||
uavnamelist2.Add(quantity1);
|
||
uavnamelist2.Add(quantity2);
|
||
uavnamelist2.Add(quantity3);
|
||
uavnamelist2.Add(quantity4);
|
||
uavnamelist2.Add(quantity5);
|
||
uavnamelist2.Add(quantity6);
|
||
uavnamelist2.Add(quantity7);
|
||
uavnamelist2.Add(quantity8);
|
||
for (int i = 0; i < uavnamelist.Count; i++)
|
||
{
|
||
Aircraft aircraft = new Aircraft();
|
||
aircraft.id = droneidlist[i];
|
||
aircraft.think_device_id = PlayerPrefs.GetString("id2");
|
||
aircraft.para_name = uavnamelist[i].text;
|
||
//aircraft.para_type = "";
|
||
aircraft.para_value = uavnamelist2[i].ToString("0");
|
||
aircraft.para_unit = Droneunitlist2[i];
|
||
aircraft.r1 = Droneunitlist[i].text;
|
||
//aircraft.r2 = "";
|
||
//aircraft.r3 = "";
|
||
aircrafts.Add(aircraft);
|
||
|
||
}
|
||
|
||
string str = Newtonsoft.Json.JsonConvert.SerializeObject(aircrafts);
|
||
Debug.Log(str);
|
||
Dictionary<string, string> dic = new Dictionary<string, string>();
|
||
dic.Add("data", str);
|
||
StartCoroutine(PostData2(url, dic, Two20));
|
||
}
|
||
public void Two20(bool bol, string str)
|
||
{
|
||
Debug.Log(bol);
|
||
Debug.Log(str);
|
||
}
|
||
private void Droneretrieval()
|
||
{
|
||
string url = "http://172.16.1.254:48888/Handler/Thinkingfile.ashx?action=querydevicepara&";
|
||
url += "think_device_id=";
|
||
url += strlist[2];
|
||
StartCoroutine(Post1(url, (bol, str) =>
|
||
{
|
||
Two10(bol, str);
|
||
}));
|
||
}
|
||
public void Two10(bool bol, string str)
|
||
{
|
||
if (bol)
|
||
{
|
||
Debug.LogError(str);
|
||
weaponitemone1 = Newtonsoft.Json.JsonConvert.DeserializeObject<Weaponitemone>(str);
|
||
}
|
||
if (weaponitemone1.state)
|
||
{
|
||
if (uavnamelist2.Count > 0)
|
||
{
|
||
uavnamelist2.Clear();
|
||
}
|
||
Debug.Log(weaponitemone1.data.Count);
|
||
for (int i = 0; i < weaponitemone1.data.Count; i++)
|
||
{
|
||
uavnamelist[i].text = weaponitemone1.data[i].para_name;
|
||
uavnamelist2.Add(float.Parse(weaponitemone1.data[i].para_value));
|
||
Droneunitlist[i].text = weaponitemone1.data[i].r1;
|
||
}
|
||
Slider_endurance.value = uavnamelist2[0];
|
||
switch (uavnamelist2[1])
|
||
{
|
||
case 0:
|
||
Dropdown_wind.value = 0;
|
||
break;
|
||
case 1:
|
||
Dropdown_wind.value = 1;
|
||
break;
|
||
case 2:
|
||
Dropdown_wind.value = 2;
|
||
break;
|
||
case 3:
|
||
Dropdown_wind.value = 3;
|
||
break;
|
||
case 4:
|
||
Dropdown_wind.value = 4;
|
||
break;
|
||
case 5:
|
||
Dropdown_wind.value = 5;
|
||
break;
|
||
default:
|
||
break;
|
||
}
|
||
Slider_speed.value = uavnamelist2[2];
|
||
Slider_rcs.value = uavnamelist2[3];
|
||
switch (uavnamelist2[4])
|
||
{
|
||
case 0:
|
||
Dropdown_orientation.value = 0;
|
||
break;
|
||
case 1:
|
||
Dropdown_orientation.value = 1;
|
||
break;
|
||
case 2:
|
||
Dropdown_orientation.value = 2;
|
||
break;
|
||
default:
|
||
break;
|
||
}
|
||
switch (uavnamelist2[5])
|
||
{
|
||
case 0:
|
||
Dropdown_communication.value = 0;
|
||
break;
|
||
case 1:
|
||
Dropdown_communication.value = 1;
|
||
break;
|
||
case 2:
|
||
Dropdown_communication.value = 2;
|
||
break;
|
||
default:
|
||
break;
|
||
}
|
||
switch (uavnamelist2[6])
|
||
{
|
||
case 1:
|
||
toggle1.isOn = true;
|
||
break;
|
||
case 2:
|
||
toggle2.isOn = true;
|
||
break;
|
||
case 3:
|
||
toggle3.isOn = true;
|
||
break;
|
||
case 4:
|
||
toggle4.isOn = true;
|
||
break;
|
||
case 5:
|
||
toggle5.isOn = true;
|
||
break;
|
||
case 6:
|
||
toggle6.isOn = true;
|
||
break;
|
||
case 7:
|
||
toggle7.isOn = true;
|
||
break;
|
||
default:
|
||
break;
|
||
}
|
||
switch (uavnamelist2[7])
|
||
{
|
||
case 1:
|
||
toggle8.isOn = true;
|
||
break;
|
||
case 2:
|
||
toggle9.isOn = true;
|
||
break;
|
||
default:
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
private void Radiointerference()
|
||
{
|
||
shezhi_btn22.onClick.AddListener(() =>
|
||
{
|
||
if (strlist.Count > 0)
|
||
{
|
||
Wirelesssearch();//地面无线电查询
|
||
}
|
||
radio_wave_panl.gameObject.SetActive(true);
|
||
});
|
||
offbi_btn.onClick.AddListener(() =>
|
||
{
|
||
radio_wave_panl.gameObject.SetActive(false);
|
||
});
|
||
//无线电确认按钮
|
||
queren_btnn.onClick.AddListener(() =>
|
||
{
|
||
if (strlist.Count > 0)
|
||
{
|
||
Wirelessmodification();//地面无线电修改
|
||
}
|
||
radio_wave_panl.gameObject.SetActive(false);
|
||
});
|
||
quxia_btnn.onClick.AddListener(() =>
|
||
{
|
||
radio_wave_panl.gameObject.SetActive(false);
|
||
});
|
||
Toggle_Drive.onValueChanged.AddListener((ison) =>
|
||
{
|
||
if (ison)
|
||
{
|
||
drive = 1;
|
||
drive_text.text = "驱离";
|
||
}
|
||
});
|
||
Toggle_Crash.onValueChanged.AddListener((ison) =>
|
||
{
|
||
if (ison)
|
||
{
|
||
drive = 2;
|
||
crash_text.text = "迫降";
|
||
}
|
||
});
|
||
}
|
||
|
||
private void Wirelessmodification()
|
||
{
|
||
string url = "http://172.16.1.254:48888/Handler/Thinkingfile.ashx?action=updatedevicepara";
|
||
List<Aircraft> aircrafts = new List<Aircraft>();
|
||
if (wirelesslist2.Count > 0)
|
||
{
|
||
wirelesslist2.Clear();
|
||
}
|
||
wirelesslist2.Add(frequ);
|
||
wirelesslist2.Add(drive);
|
||
wirelesslist2.Add(power);
|
||
wirelesslist2.Add(angle);
|
||
wirelesslist2.Add(distance);
|
||
for (int i = 0; i < wirelesslist.Count; i++)
|
||
{
|
||
Aircraft aircraft = new Aircraft();
|
||
aircraft.id = wirelessidlist[i];
|
||
aircraft.think_device_id = strlist[1];
|
||
aircraft.para_name = wirelesslist[i].text;
|
||
//aircraft.para_type = "";
|
||
aircraft.para_value = wirelesslist2[i].ToString("0");
|
||
aircraft.para_unit = wirelessunitlist2[i];
|
||
aircraft.r1 = Wirelessunitlist[i].text;
|
||
//aircraft.r2 = "";
|
||
//aircraft.r3 = "";
|
||
aircrafts.Add(aircraft);
|
||
|
||
}
|
||
|
||
string str = Newtonsoft.Json.JsonConvert.SerializeObject(aircrafts);
|
||
Debug.Log(str);
|
||
Dictionary<string, string> dic = new Dictionary<string, string>();
|
||
dic.Add("data", str);
|
||
StartCoroutine(PostData2(url, dic, One4));
|
||
}
|
||
public void One4(bool bol, string str)
|
||
{
|
||
Debug.Log(bol);
|
||
Debug.Log(str);
|
||
}
|
||
|
||
private void Wirelesssearch()
|
||
{
|
||
string url = "http://172.16.1.254:48888/Handler/Thinkingfile.ashx?action=querydevicepara&";
|
||
url += "think_device_id=";
|
||
url += strlist[1];
|
||
StartCoroutine(Post1(url, (bol, str) =>
|
||
{
|
||
|
||
One3(bol, str);
|
||
}));
|
||
}
|
||
public void One3(bool bol, string str)
|
||
{
|
||
if (bol)
|
||
{
|
||
Debug.LogError(str);
|
||
weaponitemone1 = Newtonsoft.Json.JsonConvert.DeserializeObject<Weaponitemone>(str);
|
||
}
|
||
if (weaponitemone1.state)
|
||
{
|
||
if (wirelesslist2.Count > 0)
|
||
{
|
||
wirelesslist2.Clear();
|
||
}
|
||
Debug.Log(weaponitemone1.data.Count);
|
||
for (int i = 0; i < weaponitemone1.data.Count; i++)
|
||
{
|
||
wirelesslist[i].text = weaponitemone1.data[i].para_name;
|
||
wirelesslist2.Add(float.Parse(weaponitemone1.data[i].para_value));
|
||
Wirelessunitlist[i].text = weaponitemone1.data[i].r1;
|
||
}
|
||
switch (wirelesslist2[0])
|
||
{
|
||
case 0:
|
||
Dropdown_frequency.value = 0;
|
||
break;
|
||
case 1:
|
||
Dropdown_frequency.value = 1;
|
||
break;
|
||
case 2:
|
||
Dropdown_frequency.value = 2;
|
||
break;
|
||
case 3:
|
||
Dropdown_frequency.value = 3;
|
||
break;
|
||
case 4:
|
||
Dropdown_frequency.value = 4;
|
||
break;
|
||
case 5:
|
||
Dropdown_frequency.value = 5;
|
||
break;
|
||
default:
|
||
break;
|
||
}
|
||
switch (wirelesslist2[1])
|
||
{
|
||
case 1:
|
||
Toggle_Drive.isOn = true;
|
||
break;
|
||
case 2:
|
||
Toggle_Crash.isOn = true;
|
||
break;
|
||
default:
|
||
break;
|
||
}
|
||
switch (wirelesslist2[2])
|
||
{
|
||
case 0:
|
||
Dropdown_power.value = 0;
|
||
break;
|
||
case 1:
|
||
Dropdown_power.value = 1;
|
||
break;
|
||
case 2:
|
||
Dropdown_power.value = 2;
|
||
break;
|
||
default:
|
||
break;
|
||
}
|
||
Slider_angle.value = wirelesslist2[3];
|
||
Slider_distance.value = wirelesslist2[4];
|
||
}
|
||
}
|
||
private void Radardetection()
|
||
{
|
||
shezhi_btn111.onClick.AddListener(() =>
|
||
{
|
||
if (strlist.Count > 0)
|
||
{
|
||
Aircraftparameters();
|
||
}
|
||
radar_panl.gameObject.SetActive(true);
|
||
});
|
||
offguan1_btn.onClick.AddListener(() =>
|
||
{
|
||
radar_panl.gameObject.SetActive(false);
|
||
});
|
||
verify1_btnn.onClick.AddListener(() =>
|
||
{
|
||
if (strlist.Count > 0)
|
||
{
|
||
Modifyequipment();//修改武器设备的参数
|
||
}
|
||
radar_panl.gameObject.SetActive(false);
|
||
});
|
||
Cancel1_btnn.onClick.AddListener(() =>
|
||
{
|
||
radar_panl.gameObject.SetActive(false);
|
||
});
|
||
}
|
||
|
||
private void Modifyequipment()
|
||
{
|
||
string url = "http://172.16.1.254:48888/Handler/Thinkingfile.ashx?action=updatedevicepara";
|
||
List<Aircraft> aircrafts = new List<Aircraft>();
|
||
for (int i = 0; i < Rettalist.Count; i++)
|
||
{
|
||
Aircraft aircraft = new Aircraft();
|
||
aircraft.id = radaridlist[i];
|
||
aircraft.think_device_id = strlist[0];
|
||
aircraft.para_name = Rettalist[i].text;
|
||
//aircraft.para_type = "";
|
||
aircraft.para_value = Radarparameterlist[i].value.ToString("0");
|
||
aircraft.para_unit = unitlist[i];
|
||
aircraft.r1 = Radarunitlist[i].text;
|
||
//aircraft.r2 = "";
|
||
//aircraft.r3 = "";
|
||
aircrafts.Add(aircraft);
|
||
|
||
}
|
||
|
||
string str = Newtonsoft.Json.JsonConvert.SerializeObject(aircrafts);
|
||
Debug.Log(str);
|
||
Dictionary<string, string> dic = new Dictionary<string, string>();
|
||
dic.Add("data", str);
|
||
StartCoroutine(PostData2(url, dic, getInfo5));
|
||
}
|
||
public void getInfo5(bool bol, string str)
|
||
{
|
||
Debug.Log(bol);
|
||
Debug.Log(str);
|
||
}
|
||
private void Aircraftparameters()
|
||
{
|
||
string url = "http://172.16.1.254:48888/Handler/Thinkingfile.ashx?action=querydevicepara&";
|
||
url += "think_device_id=";
|
||
url += strlist[0];
|
||
StartCoroutine(Post1(url, (bol, str) =>
|
||
{
|
||
Weapon3(bol, str);
|
||
}));
|
||
}
|
||
public void Weapon3(bool bol, string str)
|
||
{
|
||
if (bol)
|
||
{
|
||
Debug.LogError(str);
|
||
weaponitemone1 = Newtonsoft.Json.JsonConvert.DeserializeObject<Weaponitemone>(str);
|
||
}
|
||
if (weaponitemone1.state)
|
||
{
|
||
Debug.Log(weaponitemone1.data.Count);
|
||
for (int i = 0; i < weaponitemone1.data.Count; i++)
|
||
{
|
||
Rettalist[i].text = weaponitemone1.data[i].para_name;
|
||
Radarparameterlist[i].value = float.Parse(weaponitemone1.data[i].para_value);
|
||
Radarunitlist[i].text = weaponitemone1.data[i].r1;
|
||
}
|
||
}
|
||
}
|
||
private void Lasergun()
|
||
{
|
||
shezhi_btn33.onClick.AddListener(() =>
|
||
{
|
||
if (strlist.Count > 0)
|
||
{
|
||
Laserviewing();//查询接口里面的参数
|
||
}
|
||
valuerangepanl.gameObject.SetActive(true);
|
||
});
|
||
off1_btn1.onClick.AddListener(() =>
|
||
{
|
||
valuerangepanl.gameObject.SetActive(false);
|
||
});
|
||
quxiao_btnn3.onClick.AddListener(() =>
|
||
{
|
||
valuerangepanl.gameObject.SetActive(false);
|
||
});
|
||
quedin_btn12.onClick.AddListener(() =>
|
||
{
|
||
if (strlist.Count > 0)
|
||
{
|
||
Lasermodification();//激光修改方法
|
||
}
|
||
valuerangepanl.gameObject.SetActive(false);
|
||
});
|
||
}
|
||
|
||
private void Lasermodification()
|
||
{
|
||
string url = "http://172.16.1.254:48888/Handler/Thinkingfile.ashx?action=updatedevicepara";
|
||
List<Aircraft> aircrafts = new List<Aircraft>();
|
||
for (int i = 0; i < laserlist.Count; i++)
|
||
{
|
||
Aircraft aircraft = new Aircraft();
|
||
aircraft.id = laseridlist[i];
|
||
aircraft.think_device_id = strlist[3];
|
||
aircraft.para_name = laserlist[i].text;
|
||
//aircraft.para_type = "";
|
||
aircraft.para_value = laserquantitylist[i].value.ToString("0");
|
||
aircraft.para_unit = laserunitlists[i];
|
||
aircraft.r1 = Laserunitlist[i].text;
|
||
//aircraft.r2 = "";
|
||
//aircraft.r3 = ""; k,
|
||
aircrafts.Add(aircraft);
|
||
}
|
||
string str = Newtonsoft.Json.JsonConvert.SerializeObject(aircrafts);
|
||
Debug.Log(str);
|
||
Dictionary<string, string> dic = new Dictionary<string, string>();
|
||
dic.Add("data", str);
|
||
StartCoroutine(PostData2(url, dic, Two1));
|
||
}
|
||
public void Two1(bool bol, string str)
|
||
{
|
||
Debug.Log(bol);
|
||
Debug.Log(str);
|
||
}
|
||
private void Laserviewing()
|
||
{
|
||
string url = "http://172.16.1.254:48888/Handler/Thinkingfile.ashx?action=querydevicepara&";
|
||
url += "think_device_id=";
|
||
url += strlist[3];
|
||
StartCoroutine(Post1(url, (bol, str) =>
|
||
{
|
||
Two(bol, str);
|
||
}));
|
||
}
|
||
|
||
private void Two(bool bol, string str)
|
||
{
|
||
if (bol)
|
||
{
|
||
Debug.LogError(str);
|
||
weaponitemone1 = Newtonsoft.Json.JsonConvert.DeserializeObject<Weaponitemone>(str);
|
||
}
|
||
if (weaponitemone1.state)
|
||
{
|
||
Debug.Log(weaponitemone1.data.Count);
|
||
for (int i = 0; i < weaponitemone1.data.Count; i++)
|
||
{
|
||
laserlist[i].text = weaponitemone1.data[i].para_name;
|
||
laserquantitylist[i].value = float.Parse(weaponitemone1.data[i].para_value);
|
||
Laserunitlist[i].text = weaponitemone1.data[i].r1;
|
||
}
|
||
}
|
||
}
|
||
|
||
private void Timesetting()
|
||
{
|
||
xitong.onValueChanged.AddListener((ison) =>
|
||
{
|
||
if (ison)
|
||
{
|
||
year_text.gameObject.SetActive(false);
|
||
month_text.gameObject.SetActive(false);
|
||
day_text.gameObject.SetActive(false);
|
||
when_text.gameObject.SetActive(false);
|
||
hand_btn.gameObject.SetActive(false);
|
||
auto_text.gameObject.SetActive(true);
|
||
kaiguan = false;
|
||
tmie = null;
|
||
}
|
||
});
|
||
shodo.onValueChanged.AddListener((ison) =>
|
||
{
|
||
if (ison)
|
||
{
|
||
auto_text.gameObject.SetActive(false);
|
||
hand_btn.gameObject.SetActive(true);
|
||
year_text.gameObject.SetActive(true);
|
||
month_text.gameObject.SetActive(true);
|
||
day_text.gameObject.SetActive(true);
|
||
|
||
if (isptime == true)
|
||
{
|
||
when_text.gameObject.SetActive(true);
|
||
}
|
||
isptime = true;
|
||
kaiguan = true;
|
||
tmie = null;
|
||
}
|
||
});
|
||
}
|
||
|
||
private void Settingbtn()
|
||
{
|
||
off4_btn1.onClick.AddListener(() =>
|
||
{
|
||
basic_information_iamg1.gameObject.SetActive(false);
|
||
});
|
||
verify_bton2.onClick.AddListener(() =>
|
||
{
|
||
//Scenariofile_panl.gameObject.SetActive(false);
|
||
basic_information_iamg1.gameObject.SetActive(false);
|
||
});
|
||
cancel_bton2.onClick.AddListener(() =>
|
||
{
|
||
basic_information_iamg1.gameObject.SetActive(false);
|
||
});
|
||
}
|
||
|
||
private void Dixaing()
|
||
{
|
||
off_btnn5.onClick.AddListener(() =>
|
||
{
|
||
contingency_list_panl.gameObject.SetActive(false);
|
||
});
|
||
queren_btnn3.onClick.AddListener(() =>
|
||
{
|
||
|
||
contingency_list_panl.gameObject.SetActive(false);
|
||
Scenariofile_panl.gameObject.SetActive(true);
|
||
});
|
||
}
|
||
|
||
|
||
void LateUpdate()
|
||
{
|
||
tenkokuModule.weather_OvercastAmt = Mathf.Lerp(0.0f, 1.0f, 1 - Slider.value / 10);
|
||
SetWindDirection();
|
||
SetWindValue();
|
||
|
||
shi_text.text = shijian.value.ToString("0") + "分钟";
|
||
xusshi_text.text = xuslider.value.ToString("f1") + "m/s";
|
||
Rcs_text.text = Rcs.value.ToString("f2");
|
||
yangguang_text.text = yangguang.value.ToString("0");
|
||
angle = Slider_angle.value;
|
||
distance = Slider_distance.value;
|
||
frequ = Dropdown_frequency.value;
|
||
power = Dropdown_power.value;
|
||
Radar();//雷达页面滑动条显示
|
||
Frequency(Dropdown_frequency.value);//干扰频率的下拉框
|
||
Power();//功率下拉选项框
|
||
Disturb();//干扰页面的角度和距离
|
||
Swarmdrone();//蜂群无人机页面滑动条
|
||
Laer();//激光火炮控制频台面板
|
||
}
|
||
|
||
private void Laer()
|
||
{
|
||
stored_text.text = Slidertime.value.ToString("0") + "s";
|
||
accumulate_text.text = Slideraccumulate.value.ToString("0") + "s";
|
||
dis_text.text = Sliderdistance.value.ToString("f1") + "km";
|
||
angle1_text.text = SliderAngle1.value.ToString("0") + "度";
|
||
}
|
||
|
||
private void Swarmdrone()
|
||
{
|
||
quantity1 = Slider_endurance.value;
|
||
quantity2 = Dropdown_wind.value;
|
||
quantity3 = Slider_speed.value;
|
||
quantity4 = Slider_rcs.value;
|
||
quantity5 = Dropdown_orientation.value;
|
||
quantity6 = Dropdown_communication.value;
|
||
endurance_text.text = Slider_endurance.value.ToString("0") + "分钟";
|
||
speed_text.text = Slider_speed.value.ToString("f1") + "km";
|
||
rcs_text.text = Rcs.value.ToString("f2");
|
||
}
|
||
|
||
private void Disturb()
|
||
{
|
||
angle_text.text = Slider_angle.value.ToString("0") + "度";
|
||
distance_text.text = Slider_distance.value.ToString("0") + "km";
|
||
}
|
||
|
||
private void Power()
|
||
{
|
||
Debug.Log(power_text.text);
|
||
}
|
||
|
||
private void Frequency(int value)
|
||
{
|
||
switch (value)
|
||
{
|
||
case 0:
|
||
frequency_text.text = "430~470MHz";
|
||
break;
|
||
case 1:
|
||
frequency_text.text = "832~940MHz";
|
||
break;
|
||
case 2:
|
||
frequency_text.text = "1.2~1.3GHz";
|
||
break;
|
||
case 3:
|
||
frequency_text.text = "1.56~1.62GHz";
|
||
break;
|
||
case 4:
|
||
frequency_text.text = "2.4~2.5GHz";
|
||
break;
|
||
case 5:
|
||
frequency_text.text = "5.725~5.85GHz";
|
||
break;
|
||
default:
|
||
break;
|
||
}
|
||
}
|
||
|
||
private void Radar()
|
||
{
|
||
turntable_text.text = Slider_turntable.value.ToString("0") + "s/圈";
|
||
probe_text.text = Slider_probe.value.ToString("0") + "km";
|
||
nearblind_text.text = Slider_nearblind.value.ToString("0") + "m";
|
||
handle_text.text = Slider_handle.value.ToString("0") + "个";
|
||
successful_text.text = Slider_Successful.value.ToString("0") + "%";
|
||
minimum_text.text = Slider_minimum.value.ToString("0") + "m/s";
|
||
distinguish_text.text = Slider_distinguish.value.ToString("0") + "km";
|
||
orientation_text.text = Slider_orientation.value.ToString("0") + "km";
|
||
breadth_text.text = Slider_breadth.value.ToString("0") + "度";
|
||
beam_text.text = Slider_beam.value.ToString("0") + "度";
|
||
}
|
||
|
||
private void Duixiaang()
|
||
{
|
||
object_list_btn.onClick.AddListener(() =>
|
||
{
|
||
if (duixiang == true)
|
||
{
|
||
model_panl.gameObject.SetActive(false);
|
||
Scenariofile_panl.gameObject.SetActive(false);
|
||
object_list_panl.gameObject.SetActive(true);
|
||
Screen();
|
||
Propertymodel();
|
||
if (strlist.Count > 0)
|
||
{
|
||
Radarid();//保存雷达id
|
||
Wirelessid();//无线电id保存
|
||
Droneid();//无人机id保存
|
||
Laserid();//保存激光id
|
||
}
|
||
//DragManager.Instance.Modelinformation();
|
||
}
|
||
});
|
||
}
|
||
|
||
private void Laserid()
|
||
{
|
||
string url = "http://172.16.1.254:48888/Handler/Thinkingfile.ashx?action=querydevicepara&";
|
||
url += "think_device_id=";
|
||
url += strlist[3];
|
||
StartCoroutine(Post1(url, (bol, str) =>
|
||
{
|
||
Laserid1(bol, str);
|
||
}));
|
||
}
|
||
public void Laserid1(bool bol, string str)
|
||
{
|
||
if (bol)
|
||
{
|
||
Debug.LogError(str);
|
||
weaponitemone1 = Newtonsoft.Json.JsonConvert.DeserializeObject<Weaponitemone>(str);
|
||
}
|
||
if (weaponitemone1.state)
|
||
{
|
||
if (laseridlist.Count > 0)
|
||
{
|
||
laseridlist.Clear();
|
||
}
|
||
for (int i = 0; i < weaponitemone1.data.Count; i++)
|
||
{
|
||
laseridlist.Add(weaponitemone1.data[i].id);
|
||
}
|
||
}
|
||
}
|
||
private void Droneid()
|
||
{
|
||
string url = "http://172.16.1.254:48888/Handler/Thinkingfile.ashx?action=querydevicepara&";
|
||
url += "think_device_id=";
|
||
url += strlist[2];
|
||
StartCoroutine(Post1(url, (bol, str) =>
|
||
{
|
||
Droneid1(bol, str);
|
||
}));
|
||
}
|
||
public void Droneid1(bool bol, string str)
|
||
{
|
||
if (bol)
|
||
{
|
||
Debug.LogError(str);
|
||
weaponitemone1 = Newtonsoft.Json.JsonConvert.DeserializeObject<Weaponitemone>(str);
|
||
}
|
||
if (weaponitemone1.state)
|
||
{
|
||
if (droneidlist.Count > 0)
|
||
{
|
||
droneidlist.Clear();
|
||
}
|
||
for (int i = 0; i < weaponitemone1.data.Count; i++)
|
||
{
|
||
droneidlist.Add(weaponitemone1.data[i].id);
|
||
}
|
||
}
|
||
}
|
||
private void Wirelessid()
|
||
{
|
||
string url = "http://172.16.1.254:48888/Handler/Thinkingfile.ashx?action=querydevicepara&";
|
||
url += "think_device_id=";
|
||
url += strlist[1];
|
||
StartCoroutine(Post1(url, (bol, str) =>
|
||
{
|
||
Wirelessid1(bol, str);
|
||
}));
|
||
}
|
||
public void Wirelessid1(bool bol, string str)
|
||
{
|
||
if (bol)
|
||
{
|
||
Debug.LogError(str);
|
||
weaponitemone1 = Newtonsoft.Json.JsonConvert.DeserializeObject<Weaponitemone>(str);
|
||
}
|
||
if (weaponitemone1.state)
|
||
{
|
||
if (wirelessidlist.Count > 0)
|
||
{
|
||
wirelessidlist.Clear();
|
||
}
|
||
for (int i = 0; i < weaponitemone1.data.Count; i++)
|
||
{
|
||
wirelessidlist.Add(weaponitemone1.data[i].id);
|
||
}
|
||
}
|
||
}
|
||
private void Radarid()
|
||
{
|
||
string url = "http://172.16.1.254:48888/Handler/Thinkingfile.ashx?action=querydevicepara&";
|
||
url += "think_device_id=";
|
||
url += strlist[0];
|
||
StartCoroutine(Post1(url, (bol, str) =>
|
||
{
|
||
Radarid1(bol, str);
|
||
}));
|
||
}
|
||
public void Radarid1(bool bol, string str)
|
||
{
|
||
if (bol)
|
||
{
|
||
Debug.LogError(str);
|
||
weaponitemone1 = Newtonsoft.Json.JsonConvert.DeserializeObject<Weaponitemone>(str);
|
||
}
|
||
if (weaponitemone1.state)
|
||
{
|
||
if (radaridlist.Count > 0)
|
||
{
|
||
radaridlist.Clear();
|
||
}
|
||
for (int i = 0; i < weaponitemone1.data.Count; i++)
|
||
{
|
||
radaridlist.Add(weaponitemone1.data[i].id);
|
||
}
|
||
}
|
||
}
|
||
public void Screen()
|
||
{
|
||
int a = 1;
|
||
int b = 1;
|
||
int c = 1;
|
||
int d = 1;
|
||
int e = 1;
|
||
int f = 1;
|
||
int g = 1;
|
||
int h = 1;
|
||
int y = 1;
|
||
int z = 1;
|
||
int a1 = 1;
|
||
int a2 = 1;
|
||
int a3 = 1;
|
||
int a4 = 1;
|
||
int a5 = 1;
|
||
int a6 = 1;
|
||
int a7 = 1;
|
||
int a8 = 1;
|
||
int a9 = 1;
|
||
for (int i = 0; i < DragManager.Instance.modellist.Count; i++)
|
||
{
|
||
if (DragManager.Instance.modellist[i] == "车辆1")
|
||
{
|
||
DragManager.Instance.modellist[i] += " (" + a + ")";
|
||
a++;
|
||
}
|
||
if (DragManager.Instance.modellist[i] == "车辆2")
|
||
{
|
||
DragManager.Instance.modellist[i] += " (" + b + ")";
|
||
b++;
|
||
}
|
||
if (DragManager.Instance.modellist[i] == "石块1")
|
||
{
|
||
DragManager.Instance.modellist[i] += " (" + c + ")";
|
||
c++;
|
||
}
|
||
if (DragManager.Instance.modellist[i] == "石块2")
|
||
{
|
||
DragManager.Instance.modellist[i] += " (" + d + ")";
|
||
d++;
|
||
}
|
||
if (DragManager.Instance.modellist[i] == "石块3")
|
||
{
|
||
DragManager.Instance.modellist[i] += " (" + e + ")";
|
||
e++;
|
||
}
|
||
if (DragManager.Instance.modellist[i] == "石块4")
|
||
{
|
||
DragManager.Instance.modellist[i] += " (" + f + ")";
|
||
f++;
|
||
}
|
||
if (DragManager.Instance.modellist[i] == "石块5")
|
||
{
|
||
DragManager.Instance.modellist[i] += " (" + g + ")";
|
||
g++;
|
||
}
|
||
if (DragManager.Instance.modellist[i] == "树木1")
|
||
{
|
||
DragManager.Instance.modellist[i] += " (" + h + ")";
|
||
h++;
|
||
}
|
||
if (DragManager.Instance.modellist[i] == "树木2")
|
||
{
|
||
DragManager.Instance.modellist[i] += " (" + y + ")";
|
||
y++;
|
||
}
|
||
if (DragManager.Instance.modellist[i] == "树木3")
|
||
{
|
||
DragManager.Instance.modellist[i] += " (" + z + ")";
|
||
z++;
|
||
}
|
||
if (DragManager.Instance.modellist[i] == "三间瓦屋1")
|
||
{
|
||
DragManager.Instance.modellist[i] += " (" + a1 + ")";
|
||
a1++;
|
||
}
|
||
if (DragManager.Instance.modellist[i] == "三间瓦屋2")
|
||
{
|
||
DragManager.Instance.modellist[i] += " (" + a2 + ")";
|
||
a2++;
|
||
}
|
||
if (DragManager.Instance.modellist[i] == "三间瓦屋3")
|
||
{
|
||
DragManager.Instance.modellist[i] += " (" + a3 + ")";
|
||
a3++;
|
||
}
|
||
if (DragManager.Instance.modellist[i] == "三间瓦屋4")
|
||
{
|
||
DragManager.Instance.modellist[i] += " (" + a4 + ")";
|
||
a4++;
|
||
}
|
||
if (DragManager.Instance.modellist[i] == "三间瓦屋5")
|
||
{
|
||
DragManager.Instance.modellist[i] += " (" + a5 + ")";
|
||
a5++;
|
||
}
|
||
if (DragManager.Instance.modellist[i] == "三间瓦屋6")
|
||
{
|
||
DragManager.Instance.modellist[i] += " (" + a6 + ")";
|
||
a6++;
|
||
}
|
||
if (DragManager.Instance.modellist[i] == "二层小楼")
|
||
{
|
||
DragManager.Instance.modellist[i] += " (" + a7 + ")";
|
||
a7++;
|
||
}
|
||
if (DragManager.Instance.modellist[i] == "储物间1")
|
||
{
|
||
DragManager.Instance.modellist[i] += " (" + a8 + ")";
|
||
a8++;
|
||
}
|
||
if (DragManager.Instance.modellist[i] == "储物间2")
|
||
{
|
||
DragManager.Instance.modellist[i] += " (" + a9 + ")";
|
||
a9++;
|
||
}
|
||
}
|
||
}
|
||
private void Propertymodel()
|
||
{
|
||
if (properties.Count > 0)//判断生成UI预设体的个数是否大于零
|
||
{
|
||
for (int j = 0; j < properties.Count; j++)
|
||
{
|
||
if (properties[j] != null)//如果链表里面存在物体就进去
|
||
{
|
||
Destroy(properties[j].gameObject);//删除
|
||
}
|
||
}
|
||
properties.Clear();//清空链表
|
||
}
|
||
for (int i = 0; i < DragManager.Instance.deviceimages.Count; i++)//判断单例生成预设体
|
||
{
|
||
int index = i;
|
||
Propertypanl pro = Instantiate(propertypanl, Panel_making);//生成预设体对象
|
||
pro.Property(DragManager.Instance.modellist[index], () =>
|
||
{
|
||
Destroy(DragManager.Instance.deviceimages[index].gameObject);//删除
|
||
Destroy(pro.gameObject);//删除
|
||
});
|
||
properties.Add(pro);
|
||
}
|
||
}
|
||
|
||
//
|
||
private void Scenariofile()
|
||
{
|
||
//想定文件下的打开按钮
|
||
unpack_btn.onClick.AddListener(() =>
|
||
{
|
||
model_panl.gameObject.SetActive(false);
|
||
ScrollView_unpack.gameObject.SetActive(false);
|
||
object_list_panl.gameObject.SetActive(false);
|
||
//scenario = true;
|
||
contingency_list_panl.gameObject.SetActive(true);
|
||
});
|
||
//想定文件下的保存按钮
|
||
save_btn.onClick.AddListener(() =>
|
||
{
|
||
if (DragManager.Instance.deviceimages.Count > 0)//判断场景的模型是否为空
|
||
{
|
||
for (int i = 0; i < DragManager.Instance.deviceimages.Count; i++)
|
||
{
|
||
if (DragManager.Instance.deviceimages[i] != null)//如果模型没有被删除
|
||
{
|
||
DragManager.Instance.deviceimages[i].GetComponent<Modeldata>().SetPos();//初始化获取模型对应位置的值
|
||
DragManager.Instance.Addobj1(DragManager.Instance.deviceimages[i]);//就把对应的模型加到链表类里面
|
||
}
|
||
}
|
||
}
|
||
Passbyvalue();//把场景中天气插件的值传给接口
|
||
//Modelitem();//把模型路径和对应的位置值传给接口
|
||
if (Id.Length > 1)
|
||
{
|
||
View();//添加想定的设备接口
|
||
}
|
||
ScrollView_unpack.gameObject.SetActive(false);
|
||
});
|
||
//想定文件下的退出按钮
|
||
quit.onClick.AddListener(() =>
|
||
{
|
||
ScrollView_unpack.gameObject.SetActive(false);
|
||
});
|
||
|
||
//选择设备的关闭按钮
|
||
off_btn.onClick.AddListener(() =>
|
||
{
|
||
select_device_iamg.gameObject.SetActive(false);
|
||
});
|
||
//选择设备确认按钮
|
||
verify.onClick.AddListener(() =>
|
||
{
|
||
if (strlist.Count > 0)
|
||
{
|
||
Preservation();//修改接口
|
||
}
|
||
select_device_iamg.gameObject.SetActive(false);
|
||
});
|
||
//选择设备取消按钮
|
||
Cancel_btnn.onClick.AddListener(() =>
|
||
{
|
||
select_device_iamg.gameObject.SetActive(false);
|
||
});
|
||
}
|
||
|
||
private void View()
|
||
{
|
||
string url = "http://172.16.1.254:48888/Handler/Thinkingfile.ashx?action=querydevice&";
|
||
url += "think_id=";
|
||
url += "" + Id + "";
|
||
StartCoroutine(Post1(url, (bol, str) =>
|
||
{
|
||
Weapon5(bol, str);
|
||
}));
|
||
|
||
}
|
||
private void Weapon5(bool bol, string str)
|
||
{
|
||
if (bol)
|
||
{
|
||
Debug.Log(str);
|
||
weaponitem = Newtonsoft.Json.JsonConvert.DeserializeObject<Weaponitem>(str);
|
||
if (weaponitem.state)
|
||
{
|
||
if (stringlist.Count > 0)
|
||
{
|
||
stringlist.Clear();
|
||
}
|
||
for (int i = 0; i < weaponitem.data.Count; i++)
|
||
{
|
||
stringlist.Add(weaponitem.data[i].id);
|
||
}
|
||
}
|
||
}
|
||
if (stringlist.Count == 0)
|
||
{
|
||
Addweapons();//添加想定武器参数
|
||
}
|
||
}
|
||
private void Addweapons()
|
||
{
|
||
string url = "http://172.16.1.254:48888/Handler/Thinkingfile.ashx?action=adddevice";
|
||
List<DataItem1> datalist = new List<DataItem1>();
|
||
for (int i = 0; i < namelists.Count; i++)
|
||
{
|
||
DataItem1 data = new DataItem1();
|
||
data.device_name = namelists[i].text;
|
||
data.device_count = numberlist[i].text;
|
||
if (checklist[i].isOn == true)
|
||
{
|
||
data.r1 = "1";
|
||
}
|
||
else
|
||
{
|
||
data.r1 = "0";
|
||
}
|
||
datalist.Add(data);
|
||
}
|
||
Debug.LogError(datalist);
|
||
string datas = Newtonsoft.Json.JsonConvert.SerializeObject(datalist);
|
||
Debug.LogError(datas);
|
||
Dictionary<string, string> dic = new Dictionary<string, string>();
|
||
//dic.Add("action", "adddevice");
|
||
dic.Add("think_id", "" + Id + "");
|
||
dic.Add("data", datas);
|
||
StartCoroutine(PostData(url, dic, getInfo2));
|
||
}
|
||
public void getInfo2(bool bol, string str)
|
||
{
|
||
Debug.LogError(bol);
|
||
Debug.LogError(str);
|
||
Chaxun();//查询接口
|
||
|
||
}
|
||
private void Chaxun()
|
||
{
|
||
string url = "http://172.16.1.254:48888/Handler/Thinkingfile.ashx?action=querydevice&";
|
||
url += "think_id=";
|
||
url += "" + Id + "";
|
||
StartCoroutine(Post1(url, (bol, str) =>
|
||
{
|
||
Weapon6(bol, str);
|
||
}));
|
||
|
||
}
|
||
public void Weapon6(bool bol, string str)
|
||
{
|
||
if (bol)
|
||
{
|
||
weaponitem = Newtonsoft.Json.JsonConvert.DeserializeObject<Weaponitem>(str);
|
||
if (weaponitem.state)
|
||
{
|
||
if (stringlist.Count > 0)
|
||
{
|
||
stringlist.Clear();
|
||
}
|
||
for (int i = 0; i < weaponitem.data.Count; i++)
|
||
{
|
||
stringlist.Add(weaponitem.data[i].id);
|
||
}
|
||
//PlayerPrefs.SetString("id0", stringlist[0]);
|
||
//PlayerPrefs.SetString("id1", stringlist[1]);
|
||
//PlayerPrefs.SetString("id2", stringlist[2]);
|
||
//PlayerPrefs.SetString("id3", stringlist[3]);
|
||
}
|
||
}
|
||
Saveaeroplane();//保存飞机参数值
|
||
Wirelessoutput();//无线电波参数值
|
||
Dronereal();//无人机参数值
|
||
Laserfirecontrol();//保存激光火炮的参数
|
||
}
|
||
|
||
private void Dronereal()
|
||
{
|
||
string url = "http://172.16.1.254:48888/Handler/Thinkingfile.ashx?action=adddevicepara";
|
||
List<Aircraft> aircrafts = new List<Aircraft>();
|
||
if (uavnamelist2.Count>0)
|
||
{
|
||
uavnamelist2.Clear();
|
||
}
|
||
uavnamelist2.Add(quantity1);
|
||
uavnamelist2.Add(quantity2);
|
||
uavnamelist2.Add(quantity3);
|
||
uavnamelist2.Add(quantity4);
|
||
uavnamelist2.Add(quantity5);
|
||
uavnamelist2.Add(quantity6);
|
||
uavnamelist2.Add(quantity7);
|
||
uavnamelist2.Add(quantity8);
|
||
for (int i = 0; i < uavnamelist.Count; i++)
|
||
{
|
||
Aircraft aircraft = new Aircraft();
|
||
aircraft.para_name = uavnamelist[i].text;
|
||
aircraft.para_value = uavnamelist2[i].ToString("0");
|
||
aircraft.para_unit = Droneunitlist2[i];
|
||
aircraft.r1 = Droneunitlist[i].text;
|
||
aircrafts.Add(aircraft);
|
||
}
|
||
string str = Newtonsoft.Json.JsonConvert.SerializeObject(aircrafts);
|
||
Dictionary<string, string> dic = new Dictionary<string, string>();
|
||
dic.Add("think_device_id", stringlist[2]);
|
||
dic.Add("data", str);
|
||
StartCoroutine(PostData2(url, dic, One10));
|
||
}
|
||
public void One10(bool bol, string str)
|
||
{
|
||
Debug.Log(bol);
|
||
Debug.Log(str);
|
||
}
|
||
|
||
|
||
private void Wirelessoutput()
|
||
{
|
||
string url = "http://172.16.1.254:48888/Handler/Thinkingfile.ashx?action=adddevicepara";
|
||
List<Aircraft> aircrafts = new List<Aircraft>();
|
||
if (wirelesslist2.Count>0)
|
||
{
|
||
wirelesslist2.Clear();
|
||
}
|
||
wirelesslist2.Add(frequ);
|
||
wirelesslist2.Add(drive);
|
||
wirelesslist2.Add(power);
|
||
wirelesslist2.Add(angle);
|
||
wirelesslist2.Add(distance);
|
||
for (int i = 0; i < wirelesslist.Count; i++)
|
||
{
|
||
Aircraft aircraft = new Aircraft();
|
||
aircraft.para_name = wirelesslist[i].text;
|
||
aircraft.para_value = wirelesslist2[i].ToString("0");
|
||
aircraft.para_unit = wirelessunitlist2[i];
|
||
aircraft.r1 = Wirelessunitlist[i].text;
|
||
aircrafts.Add(aircraft);
|
||
}
|
||
string str = Newtonsoft.Json.JsonConvert.SerializeObject(aircrafts);
|
||
Dictionary<string, string> dic = new Dictionary<string, string>();
|
||
dic.Add("think_device_id", stringlist[1]);
|
||
dic.Add("data", str);
|
||
StartCoroutine(PostData2(url, dic, One1));
|
||
}
|
||
public void One1(bool bol, string str)
|
||
{
|
||
Debug.Log(bol);
|
||
Debug.Log(str);
|
||
|
||
}
|
||
|
||
private void Laserfirecontrol()
|
||
{
|
||
string url = "http://172.16.1.254:48888/Handler/Thinkingfile.ashx?action=adddevicepara";
|
||
List<Aircraft> aircrafts = new List<Aircraft>();
|
||
for (int i = 0; i < laserlist.Count; i++)
|
||
{
|
||
Aircraft aircraft = new Aircraft();
|
||
aircraft.para_name = laserlist[i].text;
|
||
aircraft.para_value = laserquantitylist[i].value.ToString("0");
|
||
aircraft.para_unit = laserunitlists[i];
|
||
aircraft.r1 = Laserunitlist[i].text;
|
||
aircrafts.Add(aircraft);
|
||
}
|
||
string str = Newtonsoft.Json.JsonConvert.SerializeObject(aircrafts);
|
||
Dictionary<string, string> dic = new Dictionary<string, string>();
|
||
dic.Add("think_device_id", stringlist[3]);
|
||
dic.Add("data", str);
|
||
StartCoroutine(PostData2(url, dic, One));
|
||
}
|
||
public void One(bool bol, string str)
|
||
{
|
||
Debug.Log(bol);
|
||
Debug.Log(str);
|
||
|
||
}
|
||
|
||
private void Saveaeroplane()
|
||
{
|
||
string url = "http://172.16.1.254:48888/Handler/Thinkingfile.ashx?action=adddevicepara";
|
||
List<Aircraft> aircrafts = new List<Aircraft>();
|
||
for (int i = 0; i < Rettalist.Count; i++)
|
||
{
|
||
Aircraft aircraft = new Aircraft();
|
||
aircraft.para_name = Rettalist[i].text;
|
||
aircraft.para_value = Radarparameterlist[i].value.ToString("0");
|
||
aircraft.para_unit = unitlist[i];
|
||
aircraft.r1 = Radarunitlist[i].text;
|
||
aircrafts.Add(aircraft);
|
||
}
|
||
string str = Newtonsoft.Json.JsonConvert.SerializeObject(aircrafts);
|
||
Dictionary<string, string> dic = new Dictionary<string, string>();
|
||
dic.Add("think_device_id", stringlist[0]);
|
||
dic.Add("data", str);
|
||
StartCoroutine(PostData2(url, dic, getInfo4));
|
||
}
|
||
|
||
private void getInfo4(bool arg1, string arg2)
|
||
{
|
||
Debug.Log(arg1);
|
||
Debug.Log(arg2);
|
||
Clearlist();
|
||
}
|
||
|
||
private void Clearlist()
|
||
{
|
||
stringlist.Clear();
|
||
}
|
||
|
||
public static IEnumerator PostData2(string url, Dictionary<string, string> keyValuePairs, System.Action<bool, string> action)
|
||
{
|
||
WWWForm form = new WWWForm();
|
||
|
||
foreach (var item in keyValuePairs)
|
||
{
|
||
form.AddField(item.Key, item.Value);//把字典的键值对存到from
|
||
//Debug.LogError(item.Key + " " + item.Value);
|
||
}
|
||
|
||
UnityWebRequest request = UnityWebRequest.Post(url, form);
|
||
yield return request.SendWebRequest();//发送请求
|
||
if (request.isNetworkError || request.isHttpError)
|
||
{
|
||
print("cannot get data:" + request.responseCode);
|
||
action(false, null);
|
||
}
|
||
else
|
||
{
|
||
if (!string.IsNullOrEmpty(request.downloadHandler.text))
|
||
action(true, request.downloadHandler.text);
|
||
else
|
||
action(false, null);
|
||
}
|
||
}
|
||
|
||
private void Preservation()
|
||
{
|
||
string url = "http://172.16.1.254:48888/Handler/Thinkingfile.ashx?action=updatedevice";
|
||
List<DataItem1> dataItem1s = new List<DataItem1>();
|
||
for (int i = 0; i < weaponitem.data.Count; i++)
|
||
{
|
||
DataItem1 dataItem1 = new DataItem1();
|
||
dataItem1.id = weaponitem.data[i].id;
|
||
dataItem1.think_id = weaponitem.data[i].think_id;
|
||
dataItem1.device_name = namelists[i].text;
|
||
dataItem1.device_count = numberlist[i].text;
|
||
if (checklist[i].isOn == true)
|
||
{
|
||
dataItem1.r1 = "1";
|
||
}
|
||
else
|
||
{
|
||
dataItem1.r1 = "0";
|
||
}
|
||
dataItem1s.Add(dataItem1);
|
||
}
|
||
string dataitem = Newtonsoft.Json.JsonConvert.SerializeObject(dataItem1s);
|
||
Debug.LogError(dataitem);
|
||
Dictionary<string, string> map = new Dictionary<string, string>();
|
||
map.Add("data", dataitem);
|
||
StartCoroutine(PostData(url, map, getInfo1));//协程调用网络通信
|
||
}
|
||
public void getInfo1(bool bol, string str)
|
||
{
|
||
Debug.Log(bol);
|
||
Debug.Log(str);
|
||
}
|
||
private void Modelitem()
|
||
{
|
||
string url = "http://172.16.1.254:48888/Handler/Thinkingfile.ashx?action=updatecontent";
|
||
string jsonmodel = Newtonsoft.Json.JsonConvert.SerializeObject(DragManager.Instance.deviceimages1);//把模型路径和位置参数转成json对象
|
||
//Debug.LogError(jsonmodel);
|
||
Dictionary<string, string> model = new Dictionary<string, string>();
|
||
model.Add("Id", "" + Id + "");//对应的想定ID
|
||
model.Add("DeviceContent", jsonmodel);//把对应的Json传到接口对应的字段里面
|
||
StartCoroutine(PostData1(url, model, Model));
|
||
|
||
}
|
||
public void Model(bool s, string str)
|
||
{
|
||
Debug.LogError(s);
|
||
Debug.LogError(str);
|
||
}
|
||
public static IEnumerator PostData1(string url, Dictionary<string, string> model, System.Action<bool, string> action)
|
||
{
|
||
WWWForm form = new WWWForm();
|
||
|
||
foreach (var item in model)
|
||
{
|
||
form.AddField(item.Key, item.Value);//把字典的键值对存到from
|
||
//Debug.LogError(item.Key + " " + item.Value);
|
||
}
|
||
|
||
UnityWebRequest request = UnityWebRequest.Post(url, form);
|
||
yield return request.SendWebRequest();//发送请求
|
||
if (request.isNetworkError || request.isHttpError)
|
||
{
|
||
print("cannot get data:" + request.responseCode);
|
||
action(false, null);
|
||
}
|
||
else
|
||
{
|
||
if (!string.IsNullOrEmpty(request.downloadHandler.text))
|
||
action(true, request.downloadHandler.text);
|
||
else
|
||
action(false, null);
|
||
}
|
||
}
|
||
void Scenario(bool bol, string str)
|
||
{
|
||
if (bol)
|
||
{
|
||
Debug.Log(str);
|
||
scen = JsonMapper.ToObject<Editinformation>(str);//解析最外层的想定名称json文件
|
||
for (int i = 0; i < scen.data.Count; i++)
|
||
{
|
||
Traininginformation temp = new Traininginformation();//接收json解析的新对象这样接收对象就不会被覆盖,因为每次都是需要一个新的对象
|
||
temp = Jsonanalyze.FromJson<Traininginformation>(scen.data[i].VirtualPath);//解析里面字符串json文件
|
||
data1.Add(temp);//把对象添加到对象链表中
|
||
}
|
||
if (scen.state)//如果state这个bool值为true进来
|
||
{
|
||
if (scenarList.Count > 0)//如果想定链表的数量量大于零个进入
|
||
{
|
||
for (int j = 0; j < scenarList.Count; j++)//循环一下对应的列表
|
||
{
|
||
Destroy(scenarList[j].gameObject);//删除链表每一个物体
|
||
}
|
||
scenarList.Clear();//清空链表
|
||
}
|
||
|
||
for (int i = 0; i < data1.Count; i++)//循环一下对象的个数
|
||
{
|
||
int index = i;//用一个值去接收循环的数值,因为用于按钮这些操作可能会被覆盖,得不到对应的值
|
||
Scenarioname scenarioname = Instantiate(scenar_name, weizhi);//生成想定名称预设体和位置
|
||
//这是预设体对应的类去接收
|
||
scenarioname.Scenario(scen.data[index].Name.ToString(), togglezujian, () =>//传对应的值到文本
|
||
{
|
||
Id = scen.data[index].Id;
|
||
//Name1 = scen.data[index].Name;
|
||
//practicemode = scen.data[index].PracticeMode;
|
||
time = 0;
|
||
quantity = 0;
|
||
Singlechoice(data1[index]);//把相对应的对象传到方法中
|
||
Basicinformation(scen.data[index].Name, scen.data[index].PracticeMode);//把想定里面对应的名字和训练模式传到对应面板文本上
|
||
});
|
||
scenarList.Add(scenarioname);//把对象添加到链表中
|
||
}
|
||
|
||
}
|
||
}
|
||
}
|
||
private void Singlechoice(Traininginformation ti)//用相应类对象传过来
|
||
{
|
||
if (underneathList.Count > 0)//如果链表的个数大于零进入
|
||
{
|
||
for (int i = 0; i < underneathList.Count; i++)//循环链表的个数
|
||
{
|
||
Destroy(underneathList[i].gameObject);//把链表对应的个数一一删除
|
||
}
|
||
underneathList.Clear();//清除链表
|
||
}
|
||
for (int f = 0; f < ti.subjectsInfo.Count; f++)//循环对应链表对应的个数
|
||
{
|
||
int index = f;//用数去接收for循环
|
||
Underneath underneathItem = Instantiate(underneath, scenario_file_iamg);//把克隆对象生成预设体,用相应对象去接收
|
||
underneathItem.SetValue(ti.subjectsInfo[index].subjectName, (() =>//传对应的值给文本
|
||
{
|
||
OnUnderNeathSetBtn(ti.subjectsInfo[index].subjectName, ti.subjectsInfo[index].SubTime.ToString(), ti.subjectsInfo[index].mode, ti.subjectsInfo[index].seatInfos.Count.ToString());
|
||
}));
|
||
time += ti.subjectsInfo[index].SubTime;//把想定科目里面所有时间记录下来
|
||
quantity += ti.subjectsInfo[index].seatInfos.Count;//把想定科目里面所有设备数量记录下来
|
||
underneathList.Add(underneathItem);//把生成对象加入链表中
|
||
}
|
||
//Debug.LogError(time);
|
||
//Debug.LogError(quantity);
|
||
Train();//把想定对应的科目时间总和和设备数量总和传给想定面板
|
||
}
|
||
private void Train()
|
||
{
|
||
time1_text.text = time.ToString();
|
||
quantity_text.text = quantity.ToString();
|
||
}
|
||
private void Basicinformation(string str, string str1)
|
||
{
|
||
scenarioname_text.text = str;
|
||
practricemode_text.text = str1;
|
||
}
|
||
|
||
public void OnUnderNeathSetBtn(string _name, string _time, string _trainModel, string deviceCount)//接收需要传的对应值
|
||
{
|
||
xunkian_txt.text = _name;
|
||
time_txt.text = _time;
|
||
mode_text.text = _trainModel;
|
||
post_txt.text = deviceCount;
|
||
basic_information_iamg1.gameObject.SetActive(true);
|
||
}
|
||
|
||
public IEnumerator Post1(string url, System.Action<bool, string> action)
|
||
{
|
||
WWWForm form = new WWWForm();//网络通信
|
||
UnityWebRequest request = UnityWebRequest.Post(url, form);
|
||
yield return request.SendWebRequest();
|
||
if (request.isNetworkError || request.isHttpError)
|
||
{
|
||
action(false, null);
|
||
Debug.Log("网络请求失败了");
|
||
}
|
||
else
|
||
{
|
||
if (!string.IsNullOrEmpty(request.downloadHandler.text))
|
||
{
|
||
action(true, request.downloadHandler.text);
|
||
}
|
||
else
|
||
{
|
||
action(false, null);
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
/// <summary>
|
||
/// 模型页面的相互跳转
|
||
/// </summary>
|
||
///
|
||
private void Moxingxuanze()
|
||
{
|
||
quan_btn.onClick.AddListener(() =>
|
||
{
|
||
moxin_yemian.gameObject.gameObject.SetActive(true);
|
||
moyin_yemian1.gameObject.gameObject.SetActive(false);
|
||
moyin_yemian2.gameObject.gameObject.SetActive(false);
|
||
moyin_yemian3.gameObject.gameObject.SetActive(false);
|
||
moyin_yemian4.gameObject.gameObject.SetActive(false);
|
||
});
|
||
can_btn.onClick.AddListener(() =>
|
||
{
|
||
moxin_yemian.gameObject.gameObject.SetActive(false);
|
||
moyin_yemian1.gameObject.gameObject.SetActive(true);
|
||
moyin_yemian2.gameObject.gameObject.SetActive(false);
|
||
moyin_yemian3.gameObject.gameObject.SetActive(false);
|
||
moyin_yemian4.gameObject.gameObject.SetActive(false);
|
||
});
|
||
lu_btn.onClick.AddListener(() =>
|
||
{
|
||
moxin_yemian.gameObject.gameObject.SetActive(false);
|
||
moyin_yemian1.gameObject.gameObject.SetActive(false);
|
||
moyin_yemian2.gameObject.gameObject.SetActive(true);
|
||
moyin_yemian3.gameObject.gameObject.SetActive(false);
|
||
moyin_yemian4.gameObject.gameObject.SetActive(false);
|
||
});
|
||
kong_btn.onClick.AddListener(() =>
|
||
{
|
||
moxin_yemian.gameObject.gameObject.SetActive(false);
|
||
moyin_yemian1.gameObject.gameObject.SetActive(false);
|
||
moyin_yemian2.gameObject.gameObject.SetActive(false);
|
||
moyin_yemian3.gameObject.gameObject.SetActive(true);
|
||
moyin_yemian4.gameObject.gameObject.SetActive(false);
|
||
});
|
||
qita_btn.onClick.AddListener(() =>
|
||
{
|
||
moxin_yemian.gameObject.gameObject.SetActive(false);
|
||
moyin_yemian1.gameObject.gameObject.SetActive(false);
|
||
moyin_yemian2.gameObject.gameObject.SetActive(false);
|
||
moyin_yemian3.gameObject.gameObject.SetActive(false);
|
||
moyin_yemian4.gameObject.gameObject.SetActive(true);
|
||
});
|
||
|
||
|
||
}
|
||
/// <summary>
|
||
/// 模型数据库界面
|
||
/// </summary>
|
||
private void Moxing()
|
||
{
|
||
model_list_btn.onClick.AddListener(() =>
|
||
{
|
||
|
||
if (model == true)
|
||
{
|
||
if (DragManager.Instance.deviceimages.Count > 0)//判断模型列表个数是否大于零
|
||
{
|
||
for (int i = 0; i < DragManager.Instance.deviceimages.Count; i++)
|
||
{
|
||
if (DragManager.Instance.deviceimages[i] != null)//如果链表里有一个物体就进去
|
||
{
|
||
Destroy(DragManager.Instance.deviceimages[i].gameObject);//删除链表有的物体
|
||
}
|
||
}
|
||
DragManager.Instance.deviceimages.Clear();//清空链表
|
||
}
|
||
if (DragManager.Instance.modellist.Count > 0)
|
||
{
|
||
DragManager.Instance.modellist.Clear();//清空模型链表的名字
|
||
}
|
||
|
||
Inquire();//查询接口
|
||
|
||
environment_configuration1.gameObject.SetActive(false);
|
||
object_list_panl.gameObject.SetActive(false);
|
||
basic_information_iamg1.gameObject.SetActive(false);
|
||
model_panl.gameObject.SetActive(true);
|
||
select_device_iamg.gameObject.SetActive(true);
|
||
|
||
}
|
||
|
||
|
||
});
|
||
}
|
||
private void Inquire()
|
||
{
|
||
string url = "http://172.16.1.254:48888/Handler/Thinkingfile.ashx?action=querydevice&";
|
||
url += "think_id=";
|
||
url += "" + Id + "";
|
||
StartCoroutine(Post1(url, (bol, str) =>
|
||
{
|
||
Weapon(bol, str);
|
||
}));
|
||
}
|
||
private void Weapon(bool bol, string str)
|
||
{
|
||
if (bol)
|
||
{
|
||
Debug.Log(str);
|
||
weaponitem = Newtonsoft.Json.JsonConvert.DeserializeObject<Weaponitem>(str);
|
||
if (weaponitem.state)
|
||
{
|
||
if (strlist.Count > 0)
|
||
{
|
||
strlist.Clear();
|
||
}
|
||
for (int i = 0; i < weaponitem.data.Count; i++)
|
||
{
|
||
strlist.Add(weaponitem.data[i].id);
|
||
namelists[i].text = weaponitem.data[i].device_name;
|
||
numberlist[i].text = weaponitem.data[i].device_count;
|
||
if (weaponitem.data[i].r1 == "1")
|
||
{
|
||
checklist[i].isOn = true;
|
||
}
|
||
else
|
||
{
|
||
checklist[i].isOn = false;
|
||
}
|
||
}
|
||
}
|
||
}
|
||
|
||
}
|
||
/// <summary>
|
||
/// 环境界面确认取消按钮
|
||
/// </summary>
|
||
public string tmie;//接收环境的界面日期时间
|
||
private void Huanjin()
|
||
{
|
||
huanjin_btn.onClick.AddListener(() =>
|
||
{
|
||
if (year_text.text.Length >= 1 || auto_text.text.Length >= 1)
|
||
{
|
||
Rain(tenkokuModule.weather_RainAmt);
|
||
Snow(tenkokuModule.weather_SnowAmt.ToString());
|
||
WindAmt(tenkokuModule.weather_WindAmt.ToString("f1"));
|
||
WindDir(tenkokuModule.weather_WindDir);
|
||
//Debug.LogError(tenkokuModule.weather_WindAmt);
|
||
//tmie = year_text.text + " " + month_text.text + " " + day_text.text + " " + when_text.text;
|
||
if (kaiguan == false)
|
||
{
|
||
tmie = auto_text.text;
|
||
}
|
||
if (kaiguan == true)
|
||
{
|
||
tmie = year_text.text + month_text.text + day_text.text + when_text.text;
|
||
}
|
||
|
||
environment_configuration1.gameObject.SetActive(false);
|
||
}
|
||
else
|
||
{
|
||
tips_text.text = "请输入日期";
|
||
Invoke("Tips", 1.5f);
|
||
}
|
||
|
||
});
|
||
huanjin_btn1.onClick.AddListener(() =>
|
||
{
|
||
environment_configuration1.gameObject.SetActive(false);
|
||
});
|
||
}
|
||
void Passbyvalue()
|
||
{
|
||
string url = "http://172.16.1.254:48888/Handler/Thinkingfile.ashx?action=update_env";//获取需要传值的接口
|
||
|
||
Environment Environment = new Environment();//需要传值对应类
|
||
//把需要传的值对象参数对应
|
||
Environment.Time = "" + tmie + "";
|
||
Environment.Rain = "" + rainamt + "";
|
||
Environment.Snow = "" + snowamt + "";
|
||
Environment.WindSpeed = "" + windamt + "";
|
||
Environment.WindDir = "" + winddir + "";
|
||
Environment.Light = "" + Slider.value.ToString("0") + "";
|
||
string res = JsonMapper.ToJson(Environment);//利用插件LitJson将类对象转为json
|
||
Debug.LogError(res);
|
||
Dictionary<string, string> formDic = new Dictionary<string, string>();//用字典保存到对应的想定id里面
|
||
formDic.Add("Id", "" + Id + "");
|
||
formDic.Add("data", res);
|
||
StartCoroutine(PostData(url, formDic, GetInfo));//协程调用网络通信
|
||
|
||
}
|
||
|
||
void GetInfo(bool b, string s)
|
||
{
|
||
Debug.LogError(b);
|
||
Debug.LogError(s);
|
||
Modelitem();//把模型路径和对应的位置值传给接口
|
||
}
|
||
|
||
|
||
public static IEnumerator PostData(string url, Dictionary<string, string> keyValuePairs, System.Action<bool, string> action)
|
||
{
|
||
WWWForm form = new WWWForm();
|
||
|
||
foreach (var item in keyValuePairs)
|
||
{
|
||
form.AddField(item.Key, item.Value);//把字典的键值对存到from
|
||
//Debug.LogError(item.Key + " " + item.Value);
|
||
}
|
||
|
||
UnityWebRequest request = UnityWebRequest.Post(url, form);
|
||
yield return request.SendWebRequest();//发送请求
|
||
if (request.isNetworkError || request.isHttpError)
|
||
{
|
||
print("cannot get data:" + request.responseCode);
|
||
action(false, null);
|
||
}
|
||
else
|
||
{
|
||
if (!string.IsNullOrEmpty(request.downloadHandler.text))
|
||
action(true, request.downloadHandler.text);
|
||
else
|
||
action(false, null);
|
||
}
|
||
}
|
||
|
||
private void Rain(float rain)
|
||
{
|
||
switch (rain)
|
||
{
|
||
case 0:
|
||
rainamt = "0";
|
||
break;
|
||
case 0.25f:
|
||
rainamt = "0.25";
|
||
break;
|
||
case 0.5f:
|
||
rainamt = "0.5";
|
||
break;
|
||
case 0.75f:
|
||
rainamt = "0.75";
|
||
break;
|
||
case 1f:
|
||
rainamt = "1";
|
||
break;
|
||
default:
|
||
break;
|
||
}
|
||
}
|
||
private void Snow(string sonw)
|
||
{
|
||
switch (sonw)
|
||
{
|
||
case "0":
|
||
snowamt = "0";
|
||
break;
|
||
case "0.25":
|
||
snowamt = "0.25";
|
||
break;
|
||
case "0.5":
|
||
snowamt = "0.5";
|
||
break;
|
||
case "0.75":
|
||
snowamt = "0.75";
|
||
break;
|
||
case "1":
|
||
snowamt = "1";
|
||
break;
|
||
default:
|
||
break;
|
||
}
|
||
}
|
||
private void WindAmt(string windamt1)
|
||
{
|
||
switch (windamt1)
|
||
{
|
||
case "0.2":
|
||
windamt = "1";
|
||
break;
|
||
case "0.3":
|
||
windamt = "2";
|
||
break;
|
||
case "0.4":
|
||
windamt = "3";
|
||
break;
|
||
case "0.5":
|
||
windamt = "4";
|
||
break;
|
||
case "0.6":
|
||
windamt = "5";
|
||
break;
|
||
case "0.7":
|
||
windamt = "6";
|
||
break;
|
||
case "0.8":
|
||
windamt = "7";
|
||
break;
|
||
case "0.9":
|
||
windamt = "8";
|
||
break;
|
||
case "1.0":
|
||
windamt = "9";
|
||
break;
|
||
case "1.1":
|
||
windamt = "10";
|
||
break;
|
||
}
|
||
|
||
}
|
||
private void WindDir(float wind)
|
||
{
|
||
switch (wind)
|
||
{
|
||
case 45:
|
||
winddir = "45";
|
||
break;
|
||
case 90:
|
||
winddir = "90";
|
||
break;
|
||
case 135:
|
||
winddir = "135";
|
||
break;
|
||
case 180:
|
||
winddir = "180";
|
||
break;
|
||
case 225:
|
||
winddir = "225";
|
||
break;
|
||
case 270:
|
||
winddir = "270";
|
||
break;
|
||
case 315:
|
||
winddir = "315";
|
||
break;
|
||
case 360:
|
||
winddir = "360";
|
||
break;
|
||
default:
|
||
break;
|
||
}
|
||
}
|
||
public void Tips()
|
||
{
|
||
tips_text.text = null;
|
||
}
|
||
|
||
/// <summary>
|
||
/// 基本信息确定取消按钮
|
||
/// </summary>
|
||
private void Jiben()
|
||
{
|
||
verify_bton1.onClick.AddListener(() =>
|
||
{
|
||
basic_information_iamg.gameObject.SetActive(false);
|
||
});
|
||
cancel_bton1.onClick.AddListener(() =>
|
||
{
|
||
basic_information_iamg.gameObject.SetActive(false);
|
||
});
|
||
}
|
||
/// <summary>
|
||
/// 环境按钮激活失活
|
||
/// </summary>
|
||
private void Environment1()
|
||
{
|
||
environment_setting_btn.onClick.AddListener(() =>
|
||
{
|
||
environment_configuration1.gameObject.SetActive(true);
|
||
basic_information_iamg.gameObject.SetActive(false);
|
||
select_device_iamg.gameObject.SetActive(false);
|
||
});
|
||
fork_off_btn.onClick.AddListener(() =>
|
||
{
|
||
environment_configuration1.gameObject.SetActive(false);
|
||
});
|
||
}
|
||
|
||
|
||
/// <summary>
|
||
/// 基本信息页面激活失活
|
||
/// </summary>
|
||
private void Basic()
|
||
{
|
||
basic_info_btn.onClick.AddListener(() =>
|
||
{
|
||
basic_information_iamg.gameObject.SetActive(true);
|
||
environment_configuration1.gameObject.SetActive(false);
|
||
select_device_iamg.gameObject.SetActive(false);
|
||
});
|
||
off4_btn.onClick.AddListener(() =>
|
||
{
|
||
basic_information_iamg.gameObject.SetActive(false);
|
||
});
|
||
}
|
||
/// <summary>
|
||
/// 想定文件地下页面失活激活
|
||
/// </summary>
|
||
private void Scenario()
|
||
{
|
||
scenario_file_btn.onClick.AddListener(() =>
|
||
{
|
||
ScrollView_unpack.gameObject.SetActive(true);
|
||
});
|
||
}
|
||
|
||
public void SetRainValue(float value)
|
||
{
|
||
tenkokuModule.weather_RainAmt = Mathf.Lerp(0.0f, 1.0f, value);
|
||
|
||
}
|
||
public void SetSnowValue(float value)
|
||
{
|
||
tenkokuModule.weather_SnowAmt = Mathf.Lerp(0.0f, 1.0f, value);
|
||
}
|
||
|
||
public void SetWindValue()
|
||
{
|
||
//tenkokuModule.weather_WindAmt = Mathf.Lerp(0.0f, 1.0f, value);
|
||
|
||
float tempEintAmt = 0;
|
||
switch (windDrop.value)
|
||
{
|
||
case 0:
|
||
tempEintAmt = 0.1f;
|
||
break;
|
||
case 1:
|
||
tempEintAmt = 0.2f;
|
||
break;
|
||
case 2:
|
||
tempEintAmt = 0.3f;
|
||
break;
|
||
case 3:
|
||
tempEintAmt = 0.4f;
|
||
break;
|
||
case 4:
|
||
tempEintAmt = 0.5f;
|
||
break;
|
||
case 5:
|
||
tempEintAmt = 0.6f;
|
||
break;
|
||
case 6:
|
||
tempEintAmt = 0.7f;
|
||
break;
|
||
case 7:
|
||
tempEintAmt = 0.8f;
|
||
break;
|
||
case 8:
|
||
tempEintAmt = 0.9f;
|
||
break;
|
||
case 9:
|
||
|
||
tempEintAmt = 1.0f;
|
||
break;
|
||
}
|
||
//Debug.LogError(windDrop.value);
|
||
tenkokuModule.weather_WindAmt = Mathf.Lerp(0.1f, 1.1f, tempEintAmt);
|
||
Debug.Log(tenkokuModule.weather_WindAmt);
|
||
|
||
}
|
||
|
||
public void SetWindDirection()
|
||
{
|
||
float tempWindDir = 0;
|
||
switch (windDir.value)
|
||
{
|
||
case 0:
|
||
tempWindDir = 0.125f;
|
||
break;
|
||
case 1:
|
||
tempWindDir = 0.25f;
|
||
break;
|
||
case 2:
|
||
tempWindDir = 0.375f;
|
||
break;
|
||
case 3:
|
||
tempWindDir = 0.5f;
|
||
break;
|
||
case 4:
|
||
tempWindDir = 0.625f;
|
||
break;
|
||
case 5:
|
||
tempWindDir = 0.75f;
|
||
break;
|
||
case 6:
|
||
tempWindDir = 0.875f;
|
||
break;
|
||
case 7:
|
||
tempWindDir = 1f;
|
||
break;
|
||
}
|
||
//Debug.LogError(windDir.value);
|
||
tenkokuModule.weather_WindDir = Mathf.Lerp(0.0f, 360.0f, tempWindDir);
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
}
|