3175 lines
109 KiB
C#
3175 lines
109 KiB
C#
using DataModel.Model;
|
||
using LitJson;
|
||
using System;
|
||
using System.Collections;
|
||
using System.Collections.Generic;
|
||
using System.Diagnostics.SymbolStore;
|
||
using System.Reflection;
|
||
using Tenkoku.Core;
|
||
|
||
using UnityEngine;
|
||
using UnityEngine.Experimental.GlobalIllumination;
|
||
using UnityEngine.Networking;
|
||
using UnityEngine.SceneManagement;
|
||
using UnityEngine.UI;
|
||
using UnityTemplateProjects;
|
||
|
||
using static InterfaceManager;
|
||
|
||
|
||
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 Image contingency_list_panl;//想定列表面板
|
||
public Button off_btnn5;//关闭按钮
|
||
public Button queren_btnn3;//确认按钮
|
||
public bool ispbaocun = false;//保存按钮开关
|
||
//private string url = Url_Action;//想定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;//环境编辑提示文本
|
||
public Slider Foggy_slider;//雾天滑动调
|
||
public Text foggy_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 List<Toggle> togglesdisturbs = new List<Toggle>();
|
||
|
||
//public Dropdown Dropdown_frequency;//无线电干扰的频率选项框
|
||
public string frequ;//接收选项框文本id
|
||
public Text frequency_text;//无线电选项框显示文本
|
||
public string drive ="0";
|
||
public Toggle Toggle_Drive;//驱离选项
|
||
//public Text drive_text;//驱离文本
|
||
public Toggle Toggle_Crash;//迫降选项
|
||
//public Text crash_text;//迫降文本
|
||
public List<Toggle> toggledrive = new List<Toggle>();//
|
||
public Dropdown Dropdown_power;//发射功率选项框
|
||
public string power;
|
||
public Text power_text;//功率选项框
|
||
public Slider Slider_angle;//干扰的角度滑动条
|
||
public string angle;
|
||
public Text angle_text;//干扰角度显示文本
|
||
public Slider Slider_distance;//干扰的距离滑动条
|
||
public string distance;
|
||
public Text distance_text;
|
||
public List<Text> wirelesslist = new List<Text>();//地面无线电干扰
|
||
public List<string> wirelesslist2 = new List<string>();
|
||
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 Toggle Toggle1;
|
||
public Toggle Toggle2;
|
||
public Toggle Toggle3;
|
||
public Toggle Toggle4;
|
||
public Toggle Toggle5;
|
||
public Toggle Toggle6;
|
||
public Toggle Toggle7;
|
||
public List<Toggle> Toggleones = new List<Toggle>();
|
||
//电子侦察能力选项
|
||
public Toggle toggle1;
|
||
public Toggle toggle2;
|
||
public Toggle toggle3;
|
||
public Toggle toggle4;
|
||
public Toggle toggle5;
|
||
public Toggle toggle6;
|
||
public Toggle toggle7;
|
||
public List<Toggle> toggles = new List<Toggle>();//无人机选项
|
||
//是否有光学侦察能力
|
||
public Toggle toggle8;
|
||
public Toggle toggle9;
|
||
public List<Toggle> toggleslist = new List<Toggle>();//无人机页面选项
|
||
public List<Text> uavnamelist = new List<Text>();//无人机参数
|
||
public List<string> uavnamelist2 = new List<string>();//无人机数值
|
||
public List<Text> Droneunitlist = new List<Text>();//无人机单位
|
||
public List<string> Droneunitlist2 = new List<string>();//单个单位无人机
|
||
public string quantity1;
|
||
public string quantity2;
|
||
public string quantity3;
|
||
public string quantity4;
|
||
public string quantity5;
|
||
public string quantity6;
|
||
public string quantity7;
|
||
public string 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>();
|
||
public List<string> pinpulist = new List<string>();//保存频谱设备参数id
|
||
public List<string> weiboliist = new List<string>();//保存微波设备参数id
|
||
public Modelequipment modelequipment;
|
||
//频谱探测武器
|
||
public Button shezhi_btn55;//激活频谱探测按钮
|
||
public Button off_button;//频谱探测叉掉按钮
|
||
public Button queren_btno;//频谱探测确认按钮
|
||
public Button quxiao_btno;//频谱探测取消按钮
|
||
public GameObject spectrum_detection_panl;//频谱探测面板
|
||
public Slider Slider_probe1;//探测距离滑动条
|
||
public string pingpu1;
|
||
public Text Text111;//显示距离文本
|
||
public Slider Slider_batch;//批量的处理个数
|
||
public string pingpu2;
|
||
public Text Text222;//显示批量处理个数文本
|
||
public Text text333;//探测帧率
|
||
public List<Toggle> toggleprobes = new List<Toggle>();
|
||
public string pingpu3;
|
||
public Slider Slider_Successful1;//探测成功率
|
||
public string pingpu4;
|
||
public Text Text333;//显示探测成功率的文本
|
||
public Slider Slider_respond;//探测的响应时间
|
||
public string pingpu5;
|
||
public Text Text444;//显示探测响应时间文本
|
||
public Slider Slider_precision;//探测精度
|
||
public string pingpu6;
|
||
public Text Text555;//显示探测精度
|
||
public Slider Slider_minimum1;//最小探测速度
|
||
public string pingpu7;
|
||
public Text Text666;//显示最小探测速度
|
||
public List<Text> tiledlinkedlist = new List<Text>();//储存频谱设备名称
|
||
public List<string> frequencysliderlist = new List<string>();//储存频谱设备参数
|
||
public List<string> frequecystringlist = new List<string>();//存储设备单位
|
||
public List<Text> frequecytestlist = new List<Text>();//实时显示参数和单位
|
||
//微波武器
|
||
public Button shezhi_btn66;//激活微波武器页面
|
||
public Button off1_btn12;//微波武器叉掉页面
|
||
public Button quedin_btn123;//微波武器的确认按钮
|
||
public Button quxiao_btnn33;//微波武器取消按钮
|
||
public GameObject microwave_weapon;//微波武器界面
|
||
public Slider Slidertime1;//微波武器储能时间
|
||
public Text stored_text1;//显示微波武器储能时间
|
||
public Slider Slideraccumulate1;//微波武器处理目标的个数
|
||
public Text accumulate_text1;//显示微波武器处理个数
|
||
public Slider Sliderdistance1;//微波武器射程距离
|
||
public Text dis_text1;//显示微波武器干扰距离
|
||
public Slider SliderAngle2;//微波武器的角度
|
||
public Text angle1_text1;//显示微波武器干扰的角度
|
||
public List<Text> microwavetextlist = new List<Text>();//微波武器的名字
|
||
public List<Slider> microwavesliderlist = new List<Slider>();//微波武器的参数
|
||
public List<string> microwavesstringlist = new List<string>();//微波武器的单位
|
||
public List<Text> microwavestextlists = new List<Text>();//微波武器单位和参数
|
||
|
||
|
||
public Toggle weather1;
|
||
public Toggle weather2;
|
||
public Toggle weather3;
|
||
public Toggle weather4;
|
||
public Toggle weather5;
|
||
public Toggle weather6;
|
||
public Toggle weather7;
|
||
public Toggle weather8;
|
||
public Toggle weather9;
|
||
public Toggle weather10;
|
||
|
||
/// <summary>
|
||
/// 选择的地形
|
||
/// </summary>
|
||
private GameObject xuexiao;//学校地图
|
||
private GameObject caodi;//学校周围的草地
|
||
public GameObject shandi;//山地地图
|
||
public Camera hipotcamera;//学校相机的位置
|
||
void Start()
|
||
{
|
||
xuexiao = GameObject.Find("主席台场景");
|
||
caodi = GameObject.Find("Background");
|
||
|
||
//调用接口
|
||
Debug.Log("Url_Action..:" + Url_Action);
|
||
StartCoroutine(Post1(Url_Action, (bol, str) =>
|
||
{
|
||
Debug.Log(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();//电子侦察能里选项和是否有光子侦察
|
||
Spectrumdetection();//频谱探测的页面按钮
|
||
Microwaveweapon();//微波武器的页面按钮
|
||
Wirelessdian();//初始化无线电对应的频率
|
||
Toggprobe();//初始化频谱探测的干扰
|
||
SetWindValue();//风速传值
|
||
}
|
||
|
||
private void Toggprobe()
|
||
{
|
||
if (toggleprobes.Count > 0)
|
||
{
|
||
for (int i = 0; i < toggleprobes.Count; i++)
|
||
{
|
||
int index = i;
|
||
toggleprobes[index].onValueChanged.AddListener((ison =>
|
||
{
|
||
if (ison)
|
||
{
|
||
pingpu3 += index + ",";
|
||
//Debug.Log(pingpu3);
|
||
}
|
||
else
|
||
{
|
||
pingpu3 = pingpu3.Replace(index + ",", "");
|
||
//Debug.Log(pingpu3);
|
||
}
|
||
}));
|
||
}
|
||
}
|
||
}
|
||
|
||
private void Wirelessdian()
|
||
{
|
||
if (togglesdisturbs.Count > 0)
|
||
{
|
||
for (int i = 0; i < togglesdisturbs.Count; i++)
|
||
{
|
||
int index = i;
|
||
togglesdisturbs[index].onValueChanged.AddListener((ison =>
|
||
{
|
||
if (ison)
|
||
{
|
||
frequ += index + ",";
|
||
//Debug.Log(frequ);
|
||
}
|
||
else
|
||
{
|
||
frequ = frequ.Replace(index + ",", "");
|
||
//Debug.Log(frequ);
|
||
}
|
||
}));
|
||
}
|
||
}
|
||
}
|
||
|
||
private void Microwaveweapon()
|
||
{
|
||
shezhi_btn66.onClick.AddListener(() =>
|
||
{
|
||
if (strlist.Count > 0)
|
||
{
|
||
Bobomethod();
|
||
}
|
||
else
|
||
{
|
||
for (int i = 0; i < microwavesliderlist.Count; i++)
|
||
{
|
||
microwavesliderlist[i].value = 0;
|
||
}
|
||
}
|
||
radar_panl.gameObject.SetActive(false);
|
||
radio_wave_panl.gameObject.SetActive(false);
|
||
argument_panl.gameObject.SetActive(false);
|
||
valuerangepanl.gameObject.SetActive(false);
|
||
spectrum_detection_panl.gameObject.SetActive(false);
|
||
microwave_weapon.gameObject.SetActive(true);
|
||
});
|
||
off1_btn12.onClick.AddListener(() =>
|
||
{
|
||
microwave_weapon.gameObject.SetActive(false);
|
||
});
|
||
quedin_btn123.onClick.AddListener(() =>
|
||
{
|
||
if (strlist.Count > 0)
|
||
{
|
||
Microwavemodification();//微波武器的修改
|
||
}
|
||
microwave_weapon.gameObject.SetActive(false);
|
||
});
|
||
quxiao_btnn33.onClick.AddListener(() =>
|
||
{
|
||
microwave_weapon.gameObject.SetActive(false);
|
||
});
|
||
}
|
||
|
||
private void Microwavemodification()
|
||
{
|
||
List<Aircraft> aircraftlist = new List<Aircraft>();
|
||
for (int i = 0; i < microwavetextlist.Count; i++)
|
||
{
|
||
Aircraft aircraft = new Aircraft();
|
||
aircraft.id = weiboliist[i];
|
||
aircraft.think_device_id = strlist[5];
|
||
aircraft.para_name = microwavetextlist[i].text;
|
||
aircraft.para_value = microwavesliderlist[i].value.ToString();
|
||
aircraft.para_unit = microwavesstringlist[i];
|
||
aircraft.r1 = microwavestextlists[i].text;
|
||
aircraftlist.Add(aircraft);
|
||
}
|
||
string str = Newtonsoft.Json.JsonConvert.SerializeObject(aircraftlist);
|
||
Dictionary<string, string> dict = new Dictionary<string, string>();
|
||
dict.Add("data", str);
|
||
StartCoroutine(PostData2(Url_Updatedevicepara, dict, WB));
|
||
}
|
||
|
||
private void WB(bool arg1, string arg2)
|
||
{
|
||
//Debug.LogError(arg1);
|
||
//Debug.LogError(arg2);
|
||
}
|
||
|
||
private void Bobomethod()
|
||
{
|
||
string url = Url_Querydevicepara;
|
||
url += "think_device_id=";
|
||
url += strlist[5];
|
||
StartCoroutine(Post1(url, WBWQ));
|
||
}
|
||
private void WBWQ(bool bol, string str)
|
||
{
|
||
if (bol)
|
||
{
|
||
Debug.LogError(str);
|
||
weaponitemone1 = Newtonsoft.Json.JsonConvert.DeserializeObject<Weaponitemone>(str);
|
||
}
|
||
if (weaponitemone1.state)
|
||
{
|
||
for (int i = 0; i < weaponitemone1.data.Count; i++)
|
||
{
|
||
microwavetextlist[i].text = weaponitemone1.data[i].para_name;
|
||
microwavesliderlist[i].value = float.Parse(weaponitemone1.data[i].para_value);
|
||
microwavestextlists[i].text = weaponitemone1.data[i].r1;
|
||
}
|
||
}
|
||
}
|
||
private void Spectrumdetection()
|
||
{
|
||
shezhi_btn55.onClick.AddListener(() =>
|
||
{
|
||
if (strlist.Count > 0)
|
||
{
|
||
Spectrumweapon1();
|
||
}
|
||
else
|
||
{
|
||
Slider_probe1.value = 0;
|
||
Slider_batch.value = 0;
|
||
for (int i = 0; i < toggleprobes.Count; i++)
|
||
{
|
||
toggleprobes[i].isOn = false;
|
||
}
|
||
Slider_Successful1.value = 0;
|
||
Slider_respond.value = 0;
|
||
Slider_precision.value = 0;
|
||
Slider_minimum1.value = 0;
|
||
}
|
||
radar_panl.gameObject.SetActive(false);
|
||
radio_wave_panl.gameObject.SetActive(false);
|
||
argument_panl.gameObject.SetActive(false);
|
||
valuerangepanl.gameObject.SetActive(false);
|
||
spectrum_detection_panl.gameObject.SetActive(true);
|
||
microwave_weapon.gameObject.SetActive(false);
|
||
});
|
||
off_button.onClick.AddListener(() =>
|
||
{
|
||
spectrum_detection_panl.gameObject.SetActive(false);
|
||
});
|
||
queren_btno.onClick.AddListener(() =>
|
||
{
|
||
if (strlist.Count > 0)
|
||
{
|
||
Spectrummodification();//频谱探测修改
|
||
}
|
||
spectrum_detection_panl.gameObject.SetActive(false);
|
||
});
|
||
quxiao_btno.onClick.AddListener(() =>
|
||
{
|
||
spectrum_detection_panl.gameObject.SetActive(false);
|
||
});
|
||
}
|
||
|
||
private void Spectrummodification()
|
||
{
|
||
List<Aircraft> aircrafts = new List<Aircraft>();
|
||
if (frequencysliderlist.Count > 0)
|
||
{
|
||
frequencysliderlist.Clear();
|
||
}
|
||
frequencysliderlist.Add(pingpu1);
|
||
frequencysliderlist.Add(pingpu2);
|
||
frequencysliderlist.Add(pingpu3);
|
||
frequencysliderlist.Add(pingpu4);
|
||
frequencysliderlist.Add(pingpu5);
|
||
frequencysliderlist.Add(pingpu6);
|
||
frequencysliderlist.Add(pingpu7);
|
||
for (int i = 0; i < tiledlinkedlist.Count; i++)
|
||
{
|
||
Aircraft aircraft = new Aircraft();
|
||
aircraft.id = pinpulist[i];
|
||
aircraft.think_device_id = strlist[4];
|
||
aircraft.para_name = tiledlinkedlist[i].text;
|
||
aircraft.para_value = frequencysliderlist[i].ToString();
|
||
aircraft.para_unit = frequecystringlist[i];
|
||
aircraft.r1 = frequecytestlist[i].text;
|
||
aircrafts.Add(aircraft);
|
||
}
|
||
string str = Newtonsoft.Json.JsonConvert.SerializeObject(aircrafts);
|
||
Dictionary<string, string> dic = new Dictionary<string, string>();
|
||
dic.Add("data", str);
|
||
StartCoroutine(PostData2(Url_Updatedevicepara, dic, PPTCWQ));
|
||
|
||
}
|
||
|
||
private void PPTCWQ(bool arg1, string arg2)
|
||
{
|
||
//Debug.LogError(arg1);
|
||
//Debug.LogError(arg2);
|
||
}
|
||
|
||
private void Spectrumweapon1()
|
||
{
|
||
string url = Url_Querydevicepara;
|
||
url += "think_device_id=";
|
||
url += strlist[4];
|
||
StartCoroutine(Post1(url, PUTC));
|
||
}
|
||
private void PUTC(bool bol, string str)
|
||
{
|
||
if (bol)
|
||
{
|
||
//Debug.LogError(str);
|
||
weaponitemone1 = Newtonsoft.Json.JsonConvert.DeserializeObject<Weaponitemone>(str);
|
||
}
|
||
for (int i = 0; i < toggleprobes.Count; i++)
|
||
{
|
||
toggleprobes[i].isOn = false;
|
||
}
|
||
if (weaponitemone1.state)
|
||
{
|
||
for (int i = 0; i < weaponitemone1.data.Count; i++)
|
||
{
|
||
tiledlinkedlist[i].text = weaponitemone1.data[i].para_name;
|
||
frequencysliderlist[i] = weaponitemone1.data[i].para_value;
|
||
frequecytestlist[i].text = weaponitemone1.data[i].r1;
|
||
}
|
||
Slider_probe1.value = float.Parse(frequencysliderlist[0]);
|
||
Slider_batch.value = float.Parse(frequencysliderlist[1]);
|
||
string[] str1 = frequencysliderlist[2].Split(',');
|
||
if (str1.Length > 0)
|
||
{
|
||
for (int i = 0; i < str1.Length; i++)
|
||
{
|
||
switch (str1[i])
|
||
{
|
||
case "0":
|
||
toggleprobes[0].isOn = true;
|
||
break;
|
||
case "1":
|
||
toggleprobes[1].isOn = true;
|
||
break;
|
||
case "2":
|
||
toggleprobes[2].isOn = true;
|
||
break;
|
||
case "3":
|
||
toggleprobes[3].isOn = true;
|
||
break;
|
||
case "4":
|
||
toggleprobes[4].isOn = true;
|
||
break;
|
||
case "5":
|
||
toggleprobes[5].isOn = true;
|
||
break;
|
||
case "6":
|
||
toggleprobes[6].isOn = true;
|
||
break;
|
||
default:
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
Slider_Successful1.value = float.Parse(frequencysliderlist[3]);
|
||
Slider_respond.value = float.Parse(frequencysliderlist[4]);
|
||
Slider_precision.value = float.Parse(frequencysliderlist[5]);
|
||
Slider_minimum1.value = float.Parse(frequencysliderlist[6]);
|
||
}
|
||
}
|
||
|
||
private void Electronicreconnaissance()
|
||
{
|
||
if (Toggleones.Count > 0)
|
||
{
|
||
for (int i = 0; i < Toggleones.Count; i++)
|
||
{
|
||
if (Toggleones[i] != null)
|
||
{
|
||
Destroy(Toggleones[i].gameObject);
|
||
}
|
||
}
|
||
toggles.Clear();
|
||
}
|
||
Toggleones.Add(Toggle1);
|
||
Toggleones.Add(Toggle2);
|
||
Toggleones.Add(Toggle3);
|
||
Toggleones.Add(Toggle4);
|
||
Toggleones.Add(Toggle5);
|
||
Toggleones.Add(Toggle6);
|
||
Toggleones.Add(Toggle7);
|
||
for (int i = 0; i < Toggleones.Count; i++)
|
||
{
|
||
int index = i;
|
||
Toggleones[index].onValueChanged.AddListener((is0n) =>
|
||
{
|
||
if (is0n == true)
|
||
{
|
||
quantity6 += index + ",";
|
||
}
|
||
else
|
||
{
|
||
string str = index + ",";
|
||
quantity6 = quantity6.Replace(str, "");
|
||
}
|
||
});
|
||
}
|
||
if (toggles.Count > 0)
|
||
{
|
||
for (int i = 0; i < toggles.Count; i++)
|
||
{
|
||
if (toggles[i] != null)
|
||
{
|
||
Destroy(toggles[i].gameObject);
|
||
}
|
||
}
|
||
toggles.Clear();
|
||
}
|
||
|
||
toggles.Add(toggle1);
|
||
toggles.Add(toggle2);
|
||
toggles.Add(toggle3);
|
||
toggles.Add(toggle4);
|
||
toggles.Add(toggle5);
|
||
toggles.Add(toggle6);
|
||
toggles.Add(toggle7);
|
||
for (int j = 0; j < toggles.Count; j++)
|
||
{
|
||
int index = j;
|
||
toggles[index].onValueChanged.AddListener((ison) =>
|
||
{
|
||
if (ison)
|
||
{
|
||
quantity7 += index + ",";
|
||
//Debug.Log(quantity7);
|
||
}
|
||
else
|
||
{
|
||
string str = index + ",";
|
||
quantity7 = quantity7.Replace(str, "");
|
||
}
|
||
});
|
||
}
|
||
if (toggleslist.Count > 0)
|
||
{
|
||
for (int i = 0; i < toggleslist.Count; i++)
|
||
{
|
||
Destroy(toggleslist[i].gameObject);
|
||
}
|
||
toggleslist.Clear();
|
||
}
|
||
toggleslist.Add(toggle8);
|
||
toggleslist.Add(toggle9);
|
||
for (int i = 0; i < toggleslist.Count; i++)
|
||
{
|
||
int index = i;
|
||
toggleslist[i].onValueChanged.AddListener((ison) =>
|
||
{
|
||
if (ison == true)
|
||
{
|
||
quantity8 = index.ToString();
|
||
}
|
||
});
|
||
}
|
||
}
|
||
|
||
private void Drone()
|
||
{
|
||
shezhi_btn44.onClick.AddListener(() =>
|
||
{
|
||
if (strlist.Count > 0)
|
||
{
|
||
Droneretrieval();
|
||
}
|
||
else
|
||
{
|
||
|
||
toggle1.isOn = false;
|
||
toggle2.isOn = false;
|
||
toggle3.isOn = false;
|
||
toggle4.isOn = false;
|
||
toggle5.isOn = false;
|
||
toggle6.isOn = false;
|
||
toggle7.isOn = false;
|
||
toggle8.isOn = false;
|
||
toggle9.isOn = false;
|
||
Slider_endurance.value = 0;
|
||
Dropdown_wind.value = 0;
|
||
Slider_speed.value = 0;
|
||
Slider_rcs.value = 0;
|
||
Dropdown_orientation.value = 0;
|
||
Toggle1.isOn = false;
|
||
Toggle2.isOn = false;
|
||
Toggle3.isOn = false;
|
||
Toggle4.isOn = false;
|
||
Toggle5.isOn = false;
|
||
Toggle6.isOn = false;
|
||
Toggle7.isOn = false;
|
||
toggle1.isOn = true;
|
||
toggle8.isOn = true;
|
||
|
||
}
|
||
radar_panl.gameObject.SetActive(false);
|
||
radio_wave_panl.gameObject.SetActive(false);
|
||
argument_panl.gameObject.SetActive(true);
|
||
valuerangepanl.gameObject.SetActive(false);
|
||
spectrum_detection_panl.gameObject.SetActive(false);
|
||
microwave_weapon.gameObject.SetActive(false);
|
||
});
|
||
off_btnn4.onClick.AddListener(() =>
|
||
{
|
||
argument_panl.gameObject.SetActive(false);
|
||
});
|
||
//无人机确认按钮
|
||
que_btn.onClick.AddListener(() =>
|
||
{
|
||
if (strlist.Count > 0)
|
||
{
|
||
//Electronicreconnaissance();
|
||
Uavparametermodification();//无人机修改参数
|
||
}
|
||
argument_panl.gameObject.SetActive(false);
|
||
});
|
||
qu_btn.onClick.AddListener(() =>
|
||
{
|
||
argument_panl.gameObject.SetActive(false);
|
||
});
|
||
}
|
||
|
||
private void Uavparametermodification()
|
||
{
|
||
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 = strlist[2];
|
||
aircraft.para_name = uavnamelist[i].text;
|
||
//aircraft.para_type = "";
|
||
aircraft.para_value = uavnamelist2[i];
|
||
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_Updatedevicepara, dic, Two20));
|
||
}
|
||
public void Two20(bool bol, string str)
|
||
{
|
||
//Debug.Log(bol);
|
||
//Debug.Log(str);
|
||
}
|
||
private void Droneretrieval()
|
||
{
|
||
string url = Url_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.Log(str);
|
||
weaponitemone1 = Newtonsoft.Json.JsonConvert.DeserializeObject<Weaponitemone>(str);
|
||
}
|
||
if (weaponitemone1.state)
|
||
{
|
||
if (uavnamelist2.Count > 0)
|
||
{
|
||
uavnamelist2.Clear();
|
||
}
|
||
//Debug.Log(weaponitemone1.data.Count);
|
||
Toggle1.isOn = false;
|
||
Toggle2.isOn = false;
|
||
Toggle3.isOn = false;
|
||
Toggle4.isOn = false;
|
||
Toggle5.isOn = false;
|
||
Toggle6.isOn = false;
|
||
Toggle7.isOn = false;
|
||
toggle1.isOn = false;
|
||
toggle2.isOn = false;
|
||
toggle3.isOn = false;
|
||
toggle4.isOn = false;
|
||
toggle5.isOn = false;
|
||
toggle6.isOn = false;
|
||
toggle7.isOn = false;
|
||
toggle8.isOn = false;
|
||
toggle9.isOn = false;
|
||
for (int i = 0; i < weaponitemone1.data.Count; i++)
|
||
{
|
||
uavnamelist[i].text = weaponitemone1.data[i].para_name;
|
||
uavnamelist2.Add(weaponitemone1.data[i].para_value);
|
||
Droneunitlist[i].text = weaponitemone1.data[i].r1;
|
||
}
|
||
Slider_endurance.value = float.Parse(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 = float.Parse(uavnamelist2[2]);
|
||
Slider_rcs.value = float.Parse(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;
|
||
}
|
||
String[] str1 = uavnamelist2[5].Split(',');
|
||
if (str1.Length > 0)
|
||
{
|
||
for (int i = 0; i < str1.Length; i++)
|
||
{
|
||
switch (str1[i])
|
||
{
|
||
case "0":
|
||
Toggle1.isOn = true;
|
||
break;
|
||
case "1":
|
||
Toggle2.isOn = true;
|
||
break;
|
||
case "2":
|
||
Toggle3.isOn = true;
|
||
break;
|
||
case "3":
|
||
Toggle4.isOn = true;
|
||
break;
|
||
case "4":
|
||
Toggle5.isOn = true;
|
||
break;
|
||
case "5":
|
||
Toggle6.isOn = true;
|
||
break;
|
||
case "6":
|
||
Toggle7.isOn = true;
|
||
break;
|
||
default:
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
String[] str2 = uavnamelist2[6].Split(',');
|
||
if (str2.Length > 0)
|
||
{
|
||
for (int i = 0; i < str2.Length; i++)
|
||
{
|
||
switch (str2[i])
|
||
{
|
||
case "0":
|
||
toggle1.isOn = true;
|
||
break;
|
||
case "1":
|
||
toggle2.isOn = true;
|
||
break;
|
||
case "2":
|
||
toggle3.isOn = true;
|
||
break;
|
||
case "3":
|
||
toggle4.isOn = true;
|
||
break;
|
||
case "4":
|
||
toggle5.isOn = true;
|
||
break;
|
||
case "5":
|
||
toggle6.isOn = true;
|
||
break;
|
||
case "6":
|
||
toggle7.isOn = true;
|
||
break;
|
||
default:
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
switch (uavnamelist2[7])
|
||
{
|
||
case "0":
|
||
toggle8.isOn = true;
|
||
break;
|
||
case "1":
|
||
toggle9.isOn = true;
|
||
break;
|
||
default:
|
||
break;
|
||
}
|
||
}
|
||
}
|
||
private void Radiointerference()
|
||
{
|
||
shezhi_btn22.onClick.AddListener(() =>
|
||
{
|
||
if (strlist.Count > 0)
|
||
{
|
||
Wirelesssearch();//地面无线电查询
|
||
}
|
||
else
|
||
{
|
||
for (int i = 0; i < togglesdisturbs.Count; i++)
|
||
{
|
||
togglesdisturbs[i].isOn = false;
|
||
}
|
||
Toggle_Drive.isOn = true;
|
||
Dropdown_power.value = 0;
|
||
Slider_angle.value = 0;
|
||
Slider_distance.value = 0;
|
||
}
|
||
radar_panl.gameObject.SetActive(false);
|
||
radio_wave_panl.gameObject.SetActive(true);
|
||
argument_panl.gameObject.SetActive(false);
|
||
valuerangepanl.gameObject.SetActive(false);
|
||
spectrum_detection_panl.gameObject.SetActive(false);
|
||
microwave_weapon.gameObject.SetActive(false);
|
||
});
|
||
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);
|
||
});
|
||
if (toggledrive.Count > 0)
|
||
{
|
||
for (int i = 0; i < toggledrive.Count; i++)
|
||
{
|
||
Destroy(toggledrive[i].gameObject);
|
||
}
|
||
toggledrive.Clear();
|
||
}
|
||
toggledrive.Add(Toggle_Drive);
|
||
toggledrive.Add(Toggle_Crash);
|
||
for (int i = 0; i < toggledrive.Count; i++)
|
||
{
|
||
int index = i;
|
||
toggledrive[index].onValueChanged.AddListener((ison) =>
|
||
{
|
||
if (ison == true)
|
||
{
|
||
drive = index.ToString();
|
||
}
|
||
});
|
||
}
|
||
|
||
}
|
||
|
||
private void Wirelessmodification()
|
||
{
|
||
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];
|
||
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_Updatedevicepara, dic, One4));
|
||
}
|
||
public void One4(bool bol, string str)
|
||
{
|
||
//Debug.Log(bol);
|
||
//Debug.Log(str);
|
||
}
|
||
|
||
private void Wirelesssearch()
|
||
{
|
||
string url = Url_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.Log(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(weaponitemone1.data[i].para_value);
|
||
Wirelessunitlist[i].text = weaponitemone1.data[i].r1;
|
||
}
|
||
string[] str1 = wirelesslist2[0].Split(',');
|
||
for (int i = 0; i < str1.Length; i++)
|
||
{
|
||
switch (str1[i])
|
||
{
|
||
case "0":
|
||
togglesdisturbs[0].isOn = true;
|
||
break;
|
||
case "1":
|
||
togglesdisturbs[1].isOn = true;
|
||
break;
|
||
case "2":
|
||
togglesdisturbs[2].isOn = true;
|
||
break;
|
||
case "3":
|
||
togglesdisturbs[3].isOn = true;
|
||
break;
|
||
case "4":
|
||
togglesdisturbs[4].isOn = true;
|
||
break;
|
||
case "5":
|
||
togglesdisturbs[5].isOn = true;
|
||
break;
|
||
case "6":
|
||
togglesdisturbs[6].isOn = true;
|
||
break;
|
||
default:
|
||
break;
|
||
}
|
||
}
|
||
switch (wirelesslist2[1])
|
||
{
|
||
case "0":
|
||
Toggle_Drive.isOn = true;
|
||
break;
|
||
case "1":
|
||
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 = float.Parse(wirelesslist2[3]);
|
||
Slider_distance.value = float.Parse(wirelesslist2[4]);
|
||
}
|
||
}
|
||
private void Radardetection()
|
||
{
|
||
shezhi_btn111.onClick.AddListener(() =>
|
||
{
|
||
if (strlist.Count > 0)
|
||
{
|
||
Aircraftparameters();
|
||
}
|
||
else
|
||
{
|
||
for (int i = 0; i < Radarparameterlist.Count; i++)
|
||
{
|
||
Radarparameterlist[i].value = 0;
|
||
}
|
||
}
|
||
radar_panl.gameObject.SetActive(true);
|
||
radio_wave_panl.gameObject.SetActive(false);
|
||
argument_panl.gameObject.SetActive(false);
|
||
valuerangepanl.gameObject.SetActive(false);
|
||
spectrum_detection_panl.gameObject.SetActive(false);
|
||
microwave_weapon.gameObject.SetActive(false);
|
||
});
|
||
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()
|
||
{
|
||
|
||
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_Updatedevicepara, dic, getInfo5));
|
||
}
|
||
public void getInfo5(bool bol, string str)
|
||
{
|
||
//Debug.Log(bol);
|
||
//Debug.Log(str);
|
||
}
|
||
private void Aircraftparameters()
|
||
{
|
||
string url = Url_Querydevicepara;
|
||
url += "think_device_id=";
|
||
url += strlist[0];
|
||
StartCoroutine(Post1(url, (bol, str) =>
|
||
{
|
||
Weapon3(bol, str);
|
||
}));
|
||
}
|
||
public void Weapon3(bool bol, string str)
|
||
{
|
||
Weaponitemone weaponitemone1 = new Weaponitemone();
|
||
if (bol)
|
||
{
|
||
//Debug.Log(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();//查询接口里面的参数
|
||
}
|
||
else
|
||
{
|
||
for (int i = 0; i < laserquantitylist.Count; i++)
|
||
{
|
||
laserquantitylist[i].value = 0;
|
||
}
|
||
}
|
||
radar_panl.gameObject.SetActive(false);
|
||
radio_wave_panl.gameObject.SetActive(false);
|
||
argument_panl.gameObject.SetActive(false);
|
||
valuerangepanl.gameObject.SetActive(true);
|
||
spectrum_detection_panl.gameObject.SetActive(false);
|
||
microwave_weapon.gameObject.SetActive(false);
|
||
});
|
||
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()
|
||
{
|
||
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("f1");
|
||
aircraft.para_unit = laserunitlists[i];
|
||
aircraft.r1 = Laserunitlist[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_Updatedevicepara, dic, Two1));
|
||
}
|
||
public void Two1(bool bol, string str)
|
||
{
|
||
//Debug.Log(bol);
|
||
//Debug.Log(str);
|
||
}
|
||
private void Laserviewing()
|
||
{
|
||
string url = Url_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.Log(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(() =>
|
||
{
|
||
ispbaocun = true;
|
||
contingency_list_panl.gameObject.SetActive(false);
|
||
Scenariofile_panl.gameObject.SetActive(true);
|
||
model_panl.gameObject.SetActive(false);
|
||
//点击确认按钮清除模型链表的路径和位置
|
||
if (DragManager.Instance.deviceimages1.Count > 0)
|
||
{
|
||
DragManager.Instance.deviceimages1.Clear();
|
||
}
|
||
//清除场景中的模型链表
|
||
if (DragManager.Instance.devices.Count > 0)
|
||
{
|
||
for (int i = 0; i < DragManager.Instance.devices.Count; i++)
|
||
{
|
||
if (DragManager.Instance.devices[i])
|
||
{
|
||
Destroy(DragManager.Instance.devices[i].gameObject);
|
||
}
|
||
}
|
||
DragManager.Instance.devices.Clear();
|
||
}
|
||
StartCoroutine(Post1(Url_Action, (bol, str) =>
|
||
{
|
||
Acquire(bol, str);
|
||
}));
|
||
});
|
||
}
|
||
|
||
private void Acquire(bool bol, string str)
|
||
{
|
||
if (bol)
|
||
{
|
||
Debug.LogError(str);
|
||
scen = JsonMapper.ToObject<Editinformation>(str);//解析最外层的想定名称json文件
|
||
for (int i = 0; i < scen.data.Count; i++)
|
||
{
|
||
if (Id == (scen.data[i].Id))
|
||
{
|
||
if (scen.data[i].EnvRain == "" || scen.data[i].EnvRain == "")
|
||
{
|
||
weather1.isOn = true;
|
||
weather6.isOn = true;
|
||
windDrop.value = 0;
|
||
windDir.value = 0;
|
||
Slider.value = 10;
|
||
Foggy_slider.value = 100;
|
||
break;
|
||
}
|
||
weather1.isOn = false;
|
||
weather2.isOn = false;
|
||
weather3.isOn = false;
|
||
weather4.isOn = false;
|
||
weather5.isOn = false;
|
||
weather6.isOn = false;
|
||
weather7.isOn = false;
|
||
weather8.isOn = false;
|
||
weather9.isOn = false;
|
||
weather10.isOn = false;
|
||
xitong.isOn = true;
|
||
switch (scen.data[i].EnvRain)
|
||
{
|
||
case "0":
|
||
weather1.isOn = true;
|
||
break;
|
||
case "0.25":
|
||
weather2.isOn = true;
|
||
break;
|
||
case "0.5":
|
||
weather3.isOn = true;
|
||
break;
|
||
case "0.75":
|
||
weather4.isOn = true;
|
||
break;
|
||
case "1":
|
||
weather5.isOn = true;
|
||
break;
|
||
default:
|
||
break;
|
||
}
|
||
switch (scen.data[i].EnvSnow)
|
||
{
|
||
case "0":
|
||
weather6.isOn = true;
|
||
break;
|
||
case "0.25":
|
||
weather7.isOn = true;
|
||
break;
|
||
case "0.5":
|
||
weather8.isOn = true;
|
||
break;
|
||
case "0.75":
|
||
weather9.isOn = true;
|
||
break;
|
||
case "1":
|
||
weather10.isOn = true;
|
||
break;
|
||
default:
|
||
break;
|
||
}
|
||
switch (scen.data[i].EnvWindSpeed)
|
||
{
|
||
case "0.1":
|
||
windDrop.value = 0;
|
||
break;
|
||
case "0.2":
|
||
windDrop.value = 1;
|
||
break;
|
||
case "0.3":
|
||
windDrop.value = 2;
|
||
break;
|
||
case "0.4":
|
||
windDrop.value = 3;
|
||
break;
|
||
case "0.5":
|
||
windDrop.value = 4;
|
||
break;
|
||
case "0.6":
|
||
windDrop.value = 5;
|
||
break;
|
||
case "0.7":
|
||
windDrop.value = 6;
|
||
break;
|
||
case "0.8":
|
||
windDrop.value = 7;
|
||
break;
|
||
case "0.9":
|
||
windDrop.value = 8;
|
||
break;
|
||
case "1":
|
||
windDrop.value = 9;
|
||
break;
|
||
default:
|
||
break;
|
||
}
|
||
switch (scen.data[i].EnvWindDir)
|
||
{
|
||
case "45":
|
||
windDir.value = 0;
|
||
break;
|
||
case "90":
|
||
windDir.value = 1;
|
||
break;
|
||
case "135":
|
||
windDir.value = 2;
|
||
break;
|
||
case "180":
|
||
windDir.value = 3;
|
||
break;
|
||
case "225":
|
||
windDir.value = 4;
|
||
break;
|
||
case "270":
|
||
windDir.value = 5;
|
||
break;
|
||
case "315":
|
||
windDir.value = 6;
|
||
break;
|
||
case "360":
|
||
windDir.value = 7;
|
||
break;
|
||
default:
|
||
break;
|
||
}
|
||
|
||
|
||
Slider.value = float.Parse(scen.data[i].EnvLight);
|
||
|
||
|
||
|
||
Foggy_slider.value = float.Parse(scen.data[i].EnvWu);
|
||
SetWindValue();//风速传值
|
||
if (kaiguan == false)
|
||
{
|
||
tmie = auto_text.text;
|
||
}
|
||
if (kaiguan == true)
|
||
{
|
||
tmie = year_text.text + month_text.text + day_text.text + when_text.text;
|
||
kaiguan = false;
|
||
}
|
||
Rain(tenkokuModule.weather_RainAmt);
|
||
Snow(tenkokuModule.weather_SnowAmt.ToString());
|
||
WindAmt(tenkokuModule.weather_WindAmt.ToString());
|
||
WindDir(tenkokuModule.weather_WindDir);
|
||
var ss = Newtonsoft.Json.JsonConvert.DeserializeObject<List<Modelequipment>>(scen.data[i].DeviceContent);
|
||
ss.ForEach((item) =>
|
||
{
|
||
var obj = Resources.Load<GameObject>(item.str);
|
||
GameObject game = Instantiate(obj);
|
||
game.transform.localPosition = new Vector3(item.x, item.y, item.z);
|
||
DragManager.Instance.AddObj(game);
|
||
});
|
||
//for (int j = 0; j < ss.Count; j++)
|
||
//{
|
||
// var s = Resources.Load<GameObject>(ss[j].str);
|
||
// GameObject sss = Instantiate(s);
|
||
// sss.transform.localPosition = new Vector3(ss[j].x, ss[j].y, ss[j].z);
|
||
// DragManager.Instance.AddObj(sss);
|
||
//}
|
||
}
|
||
|
||
}
|
||
}
|
||
}
|
||
|
||
void LateUpdate()
|
||
{
|
||
tenkokuModule.weather_OvercastAmt = Mathf.Lerp(0.0f, 1.0f, 1 - Slider.value / 10);
|
||
tenkokuModule.weather_humidity = Mathf.Lerp(0.0f, 1.0f, 1 - Foggy_slider.value / 100);
|
||
SetWindDirection();
|
||
//SetWindValue();
|
||
|
||
shi_text.text = shijian.value.ToString("0") + "分钟";
|
||
xusshi_text.text = xuslider.value.ToString("f1") + "m/s";
|
||
|
||
yangguang_text.text = yangguang.value.ToString("0");
|
||
angle = Slider_angle.value.ToString("0");
|
||
distance = Slider_distance.value.ToString("0");
|
||
//frequ = Dropdown_frequency.value.ToString("0");
|
||
power = Dropdown_power.value.ToString("0");
|
||
foggy_text.text = Foggy_slider.value.ToString("0") + "%";
|
||
Radar();//雷达页面滑动条显示
|
||
//Frequency(Dropdown_frequency.value);//干扰频率的下拉
|
||
Disturb();//干扰页面的角度和距离
|
||
Swarmdrone();//蜂群无人机页面滑动条
|
||
Laer();//激光火炮控制频台面板
|
||
Spectrumweapon();//频谱探测面板上的参数
|
||
Microwave();//微波武器面板上的参数
|
||
}
|
||
|
||
private void Microwave()
|
||
{
|
||
stored_text1.text = Slidertime1.value.ToString() + "s";
|
||
accumulate_text1.text = Slideraccumulate1.value.ToString() + "s";
|
||
dis_text1.text = Sliderdistance1.value.ToString("f1") + "km";
|
||
angle1_text1.text = SliderAngle2.value.ToString() + "度";
|
||
}
|
||
|
||
private void Spectrumweapon()
|
||
{
|
||
pingpu1 = Slider_probe1.value.ToString("0");
|
||
pingpu2 = Slider_batch.value.ToString("0");
|
||
pingpu4 = Slider_Successful1.value.ToString("0");
|
||
pingpu5 = Slider_respond.value.ToString("0");
|
||
pingpu6 = Slider_precision.value.ToString("0");
|
||
pingpu7 = Slider_minimum1.value.ToString("0");
|
||
Text111.text = Slider_probe1.value.ToString() + "km";
|
||
Text222.text = Slider_batch.value.ToString() + "个";
|
||
Text333.text = Slider_Successful1.value.ToString() + "%";
|
||
Text444.text = Slider_respond.value.ToString() + "s";
|
||
Text555.text = Slider_precision.value.ToString() + "度";
|
||
Text666.text = Slider_minimum1.value.ToString() + "m/s";
|
||
|
||
}
|
||
|
||
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.ToString();
|
||
quantity2 = Dropdown_wind.value.ToString();
|
||
quantity3 = Slider_speed.value.ToString();
|
||
quantity4 = (Mathf.Round(Slider_rcs.value * 100) / 100).ToString();
|
||
quantity5 = Dropdown_orientation.value.ToString();
|
||
endurance_text.text = Slider_endurance.value.ToString("0") + "分钟";
|
||
speed_text.text = Slider_speed.value.ToString("f1") + "km";
|
||
rcs_text.text = Slider_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 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
|
||
Frequencyspectrum();//保存频谱设备参数id
|
||
Microwave1();//微波武器设备参数
|
||
}
|
||
//DragManager.Instance.Modelinformation();
|
||
}
|
||
});
|
||
}
|
||
|
||
private void Microwave1()
|
||
{
|
||
string url = Url_Querydevicepara;
|
||
url += "think_device_id=";
|
||
url += strlist[5];
|
||
StartCoroutine(Post1(url, Weibowuqi));
|
||
}
|
||
|
||
private void Weibowuqi(bool arg1, string arg2)
|
||
{
|
||
if (arg1)
|
||
{
|
||
Debug.LogError(arg2);
|
||
weaponitemone1 = Newtonsoft.Json.JsonConvert.DeserializeObject<Weaponitemone>(arg2);
|
||
}
|
||
if (weaponitemone1.state)
|
||
{
|
||
if (weiboliist.Count > 0)
|
||
{
|
||
weiboliist.Clear();
|
||
}
|
||
for (int i = 0; i < weaponitemone1.data.Count; i++)
|
||
{
|
||
weiboliist.Add(weaponitemone1.data[i].id);
|
||
}
|
||
}
|
||
}
|
||
|
||
private void Frequencyspectrum()
|
||
{
|
||
string url = Url_Querydevicepara;
|
||
url += "think_device_id=";
|
||
url += strlist[4];
|
||
StartCoroutine(Post1(url, Pinbuwuqi));
|
||
}
|
||
|
||
private void Pinbuwuqi(bool arg1, string arg2)
|
||
{
|
||
if (arg1)
|
||
{
|
||
Debug.LogError(arg2);
|
||
weaponitemone1 = Newtonsoft.Json.JsonConvert.DeserializeObject<Weaponitemone>(arg2);
|
||
}
|
||
if (weaponitemone1.state)
|
||
{
|
||
if (pinpulist.Count > 0)
|
||
{
|
||
pinpulist.Clear();
|
||
}
|
||
for (int i = 0; i < weaponitemone1.data.Count; i++)
|
||
{
|
||
pinpulist.Add(weaponitemone1.data[i].id);
|
||
}
|
||
}
|
||
}
|
||
|
||
private void Laserid()
|
||
{
|
||
string url = Url_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.Log(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 = Url_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.Log(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 = Url_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.Log(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 = Url_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.Log(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);
|
||
}
|
||
}
|
||
}
|
||
|
||
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.devices.Count; i++)//判断单例生成预设体
|
||
{
|
||
int index = i;
|
||
if (DragManager.Instance.devices[i] != null)
|
||
{
|
||
Propertypanl pro = Instantiate(propertypanl, Panel_making);//生成预设体对象
|
||
pro.Property(DragManager.Instance.devices[i].name.Replace("(Clone)", ""), () =>
|
||
{
|
||
Destroy(DragManager.Instance.devices[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 (ispbaocun == true)
|
||
{
|
||
ispbaocun = false;
|
||
if (DragManager.Instance.deviceimages1.Count > 0)
|
||
{
|
||
DragManager.Instance.deviceimages1.Clear();
|
||
}
|
||
if (DragManager.Instance.devices.Count > 0)//判断场景的模型是否为空
|
||
{
|
||
for (int i = 0; i < DragManager.Instance.devices.Count; i++)
|
||
{
|
||
|
||
if (DragManager.Instance.devices[i] != null)//如果链表有模型就进入
|
||
{
|
||
DragManager.Instance.devices[i].GetComponent<Modeldata>().SetPos();//初始化获取模型对应位置的值
|
||
DragManager.Instance.Addobj1(DragManager.Instance.devices[i]);//就把对应的模型加到链表类里面
|
||
}
|
||
}
|
||
}
|
||
if (Id.Length > 0)
|
||
{
|
||
Passbyvalue();//把场景中天气插件的值传给接口
|
||
}
|
||
if (DragManager.Instance.devices.Count > 0)//判断模型列表个数是否大于零
|
||
{
|
||
for (int i = 0; i < DragManager.Instance.devices.Count; i++)
|
||
{
|
||
if (DragManager.Instance.devices[i] != null)//如果链表里有一个物体就进去
|
||
{
|
||
Destroy(DragManager.Instance.devices[i].gameObject);//删除链表有的物体
|
||
|
||
}
|
||
}
|
||
DragManager.Instance.devices.Clear();//清空链表
|
||
}
|
||
|
||
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 = Url_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()
|
||
{
|
||
|
||
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.Log(datalist);
|
||
string datas = Newtonsoft.Json.JsonConvert.SerializeObject(datalist);
|
||
//Debug.Log(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_Adddevice, dic, getInfo2));
|
||
}
|
||
public void getInfo2(bool bol, string str)
|
||
{
|
||
//Debug.Log(bol);
|
||
//Debug.Log(str);
|
||
Chaxun();//查询接口
|
||
|
||
}
|
||
private void Chaxun()
|
||
{
|
||
string url = Url_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);
|
||
}
|
||
|
||
}
|
||
}
|
||
Saveaeroplane();//保存飞机参数值
|
||
Wirelessoutput();//无线电波参数值
|
||
Dronereal();//无人机参数值
|
||
Laserfirecontrol();//保存激光火炮的参数
|
||
Spectrumequipmentweapon();//频谱探测设备的参数
|
||
Microwaveequipmentparameter();//微波武器设备参数
|
||
}
|
||
|
||
private void Microwaveequipmentparameter()
|
||
{
|
||
List<Aircraft> aircrafts = new List<Aircraft>();
|
||
for (int i = 0; i < microwavetextlist.Count; i++)
|
||
{
|
||
Aircraft aircraft = new Aircraft();
|
||
aircraft.para_name = microwavetextlist[i].text;
|
||
aircraft.para_value = microwavesliderlist[i].value.ToString();
|
||
aircraft.para_unit = microwavesstringlist[i];
|
||
aircraft.r1 = microwavestextlists[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[5]);
|
||
dic.Add("data", str);
|
||
StartCoroutine(PostData2(Url_Adddevicepara, dic, Weibo));
|
||
}
|
||
private void Weibo(bool bol, string str)
|
||
{
|
||
Debug.LogError(bol);
|
||
Debug.LogError(str);
|
||
}
|
||
private void Spectrumequipmentweapon()
|
||
{
|
||
List<Aircraft> aircrafts = new List<Aircraft>();
|
||
if (frequencysliderlist.Count > 0)
|
||
{
|
||
frequencysliderlist.Clear();
|
||
}
|
||
frequencysliderlist.Add(pingpu1);
|
||
frequencysliderlist.Add(pingpu2);
|
||
frequencysliderlist.Add(pingpu3);
|
||
frequencysliderlist.Add(pingpu4);
|
||
frequencysliderlist.Add(pingpu5);
|
||
frequencysliderlist.Add(pingpu6);
|
||
frequencysliderlist.Add(pingpu7);
|
||
for (int i = 0; i < tiledlinkedlist.Count; i++)
|
||
{
|
||
Aircraft aircraft = new Aircraft();
|
||
aircraft.para_name = tiledlinkedlist[i].text;
|
||
aircraft.para_value = frequencysliderlist[i].ToString();
|
||
aircraft.para_unit = frequecystringlist[i];
|
||
aircraft.r1 = frequecytestlist[i].text;
|
||
aircrafts.Add(aircraft);
|
||
}
|
||
string str = Newtonsoft.Json.JsonConvert.SerializeObject(aircrafts);
|
||
Dictionary<string, string> dict = new Dictionary<string, string>();
|
||
dict.Add("think_device_id", stringlist[4]);
|
||
dict.Add("data", str);
|
||
StartCoroutine(PostData2(Url_Adddevicepara, dict, Pinpu));
|
||
}
|
||
private void Pinpu(bool bol, string str)
|
||
{
|
||
Debug.LogError(bol);
|
||
Debug.LogError(str);
|
||
}
|
||
private void Dronereal()
|
||
{
|
||
|
||
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();
|
||
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_Adddevicepara, dic, One10));
|
||
}
|
||
public void One10(bool bol, string str)
|
||
{
|
||
Debug.Log(bol);
|
||
Debug.Log(str);
|
||
}
|
||
|
||
|
||
private void Wirelessoutput()
|
||
{
|
||
|
||
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];
|
||
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_Adddevicepara, dic, One1));
|
||
}
|
||
public void One1(bool bol, string str)
|
||
{
|
||
Debug.Log(bol);
|
||
Debug.Log(str);
|
||
|
||
}
|
||
|
||
private void Laserfirecontrol()
|
||
{
|
||
|
||
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("f1");
|
||
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_Adddevicepara, dic, One));
|
||
}
|
||
public void One(bool bol, string str)
|
||
{
|
||
Debug.Log(bol);
|
||
Debug.Log(str);
|
||
|
||
}
|
||
|
||
private void Saveaeroplane()
|
||
{
|
||
|
||
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_Adddevicepara, dic, getInfo4));
|
||
}
|
||
|
||
private void getInfo4(bool arg1, string arg2)
|
||
{
|
||
Debug.Log(arg1);
|
||
Debug.Log(arg2);
|
||
Invoke("Clearlist", 2);
|
||
}
|
||
|
||
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()
|
||
{
|
||
|
||
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.Log(dataitem);
|
||
Dictionary<string, string> map = new Dictionary<string, string>();
|
||
map.Add("data", dataitem);
|
||
StartCoroutine(PostData(Url_updatedevice, map, getInfo1));//协程调用网络通信
|
||
}
|
||
public void getInfo1(bool bol, string str)
|
||
{
|
||
Debug.Log(bol);
|
||
Debug.Log(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)
|
||
{
|
||
|
||
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;
|
||
Topographicdetermination(scen.data[index].Field_Char1);
|
||
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 Topographicdetermination(string str)
|
||
{
|
||
if (str=="学校")
|
||
{
|
||
xuexiao.gameObject.SetActive(true);
|
||
caodi.gameObject.SetActive(true);
|
||
shandi.gameObject.SetActive(false);
|
||
SimpleCameraController game = hipotcamera.GetComponent<SimpleCameraController>();
|
||
game.gameObject.SetActive(false);
|
||
hipotcamera.transform.position = new Vector3(-404,200,5);
|
||
game.gameObject.SetActive(true);
|
||
}
|
||
else if (str == "山地")
|
||
{
|
||
xuexiao.gameObject.SetActive(false);
|
||
caodi.gameObject.SetActive(false);
|
||
shandi.gameObject.SetActive(true);
|
||
SimpleCameraController game = hipotcamera.GetComponent<SimpleCameraController>();
|
||
game.gameObject.SetActive(false);
|
||
hipotcamera.transform.position = new Vector3(-140, 200, -2060);
|
||
game.gameObject.SetActive(true);
|
||
}
|
||
}
|
||
|
||
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)
|
||
{
|
||
|
||
|
||
Inquire();//查询设备想定接口
|
||
|
||
environment_configuration1.gameObject.SetActive(false);
|
||
object_list_panl.gameObject.SetActive(false);
|
||
basic_information_iamg1.gameObject.SetActive(false);
|
||
Scenariofile_panl.gameObject.SetActive(false);
|
||
model_panl.gameObject.SetActive(true);
|
||
select_device_iamg.gameObject.SetActive(true);
|
||
|
||
}
|
||
|
||
|
||
});
|
||
}
|
||
private void Inquire()
|
||
{
|
||
string url = Url_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;
|
||
}
|
||
}
|
||
if (weaponitem.data.Count == 0)
|
||
{
|
||
for (int j = 0; j < numberlist.Count; j++)
|
||
{
|
||
numberlist[j].text = "0";
|
||
checklist[j].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)
|
||
{
|
||
|
||
if (kaiguan == false)
|
||
{
|
||
tmie = auto_text.text;
|
||
}
|
||
if (kaiguan == true)
|
||
{
|
||
tmie = year_text.text + month_text.text + day_text.text + when_text.text;
|
||
kaiguan = false;
|
||
}
|
||
Rain(tenkokuModule.weather_RainAmt);
|
||
Snow(tenkokuModule.weather_SnowAmt.ToString());
|
||
WindAmt(tenkokuModule.weather_WindAmt.ToString());
|
||
WindDir(tenkokuModule.weather_WindDir);
|
||
//Debug.LogError(tenkokuModule.weather_WindAmt);
|
||
//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()
|
||
{
|
||
|
||
Environment Environment = new Environment();//需要传值对应类
|
||
//把需要传的值对象参数对应
|
||
Environment.Time = "" + tmie + "";
|
||
Environment.Rain = "" + rainamt + "";
|
||
Environment.Snow = "" + snowamt + "";
|
||
Environment.WindSpeed = "" + windamt + "";
|
||
Environment.WindDir = "" + winddir + "";
|
||
Environment.Light = Slider.value.ToString("f0");
|
||
Environment.EnvWu = Foggy_slider.value.ToString("0");
|
||
|
||
string res = JsonMapper.ToJson(Environment);//利用插件LitJson将类对象转为json
|
||
Debug.Log(res);
|
||
Dictionary<string, string> formDic = new Dictionary<string, string>();//用字典保存到对应的想定id里面
|
||
formDic.Add("Id", "" + Id + "");
|
||
formDic.Add("data", res);
|
||
StartCoroutine(PostData(Url_update_env, formDic, GetInfo));//协程调用网络通信
|
||
|
||
}
|
||
|
||
void GetInfo(bool b, string s)
|
||
{
|
||
Debug.Log(b);
|
||
Debug.Log(s);
|
||
Modelitem();//把模型路径和对应的位置值传给接口
|
||
}
|
||
|
||
private void Modelitem()
|
||
{
|
||
|
||
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_updatecontent, model, Model));
|
||
|
||
}
|
||
public void Model(bool s, string str)
|
||
{
|
||
Debug.Log(s);
|
||
Debug.Log(str);
|
||
}
|
||
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)
|
||
{
|
||
Debug.Log("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.1":
|
||
windamt = "0.1";
|
||
break;
|
||
case "0.2":
|
||
windamt = "0.2";
|
||
break;
|
||
case "0.3":
|
||
windamt = "0.3";
|
||
break;
|
||
case "0.4":
|
||
windamt = "0.4";
|
||
break;
|
||
case "0.5":
|
||
windamt = "0.5";
|
||
break;
|
||
case "0.6":
|
||
windamt = "0.6";
|
||
break;
|
||
case "0.7":
|
||
windamt = "0.7";
|
||
break;
|
||
case "0.8":
|
||
windamt = "0.8";
|
||
break;
|
||
case "0.9":
|
||
windamt = "0.9";
|
||
break;
|
||
case "1":
|
||
windamt = "1";
|
||
break;
|
||
}
|
||
//Debug.LogError(windamt);
|
||
}
|
||
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(tempEintAmt);
|
||
//Debug.LogError(windDrop.value);
|
||
tenkokuModule.weather_WindAmt = Mathf.Lerp(0.0f, 1.0f, tempEintAmt);
|
||
//Debug.LogError(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);
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
}
|