608 lines
20 KiB
C#
608 lines
20 KiB
C#
using LitJson;
|
|
using System;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using Tenkoku.Core;
|
|
using UnityEditor.Animations;
|
|
using UnityEngine;
|
|
using UnityEngine.Networking;
|
|
using UnityEngine.SceneManagement;
|
|
using UnityEngine.UI;
|
|
using static NetMQ.NetMQSelector;
|
|
|
|
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 scenario = true;
|
|
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 Button setting_btn;//对象列表的第二个设置按钮
|
|
//值的范围面板
|
|
public Button off1_btn;//关闭范围值的按钮
|
|
public Button verify1_btn;//值的确认按钮
|
|
public Button cancel_btn;//值的关闭按钮
|
|
public Slider tiem_slider;//时间的滑条
|
|
public Text tiem_text;//和滑条显示对应的时间
|
|
public Slider smash_slider;//击毁的滑动条
|
|
public Text smash_text;//击毁数值显示
|
|
public Slider distance_slider;//距离滑动条
|
|
public Text distance_text;
|
|
public Slider Angle_slider;//角度滑动条
|
|
public Text angle_text;
|
|
//弹窗一
|
|
public Button shezhi_btn11;//
|
|
public Button off_btn23;
|
|
public Button guan_btn;
|
|
public Button qu_btn22;
|
|
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";
|
|
public List<Text> textlist = new List<Text>();
|
|
|
|
[SerializeField]
|
|
public Editinformation scen = new Editinformation();
|
|
[SerializeField]
|
|
public List<Traininginformation> data1 = new List<Traininginformation>();
|
|
[SerializeField]
|
|
List<SubjectsInfoItemm> subjectsInfoItemms = new List<SubjectsInfoItemm>();
|
|
//List<Traininginformation> data1 = new List<Traininginformation>();
|
|
public Slider yangguang;//阳光的滑动条
|
|
public Text yangguang_text; //显示阳光的滑动数值
|
|
public Text subject_text;//想定文件下的科目文本
|
|
public Text subject1_text;//想定文件下的科目文本
|
|
public Button settings1_btnn;//科目训练设置按钮
|
|
public Button settings_btnn;//科目训练设置按钮
|
|
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;//生成的位置
|
|
private List<Text> textlist1 = new List<Text>();//存放生成想定文件的名字
|
|
[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>();
|
|
|
|
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();//对象列表按钮面板
|
|
Fanwei();//值的范围面板
|
|
TZYM();//弹窗
|
|
Dixaing();//想定列表按钮
|
|
Settingbtn();//科目训练按钮三
|
|
}
|
|
|
|
private void Settingbtn()
|
|
{
|
|
off4_btn1.onClick.AddListener(() =>
|
|
{
|
|
basic_information_iamg1.gameObject.SetActive(false);
|
|
});
|
|
verify_bton2.onClick.AddListener(() =>
|
|
{
|
|
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(() =>
|
|
{
|
|
//Singlechoice();
|
|
contingency_list_panl.gameObject.SetActive(false);
|
|
Scenariofile_panl.gameObject.SetActive(true);
|
|
});
|
|
}
|
|
|
|
private void TZYM()
|
|
{
|
|
shezhi_btn11.onClick.AddListener(() =>
|
|
{
|
|
mianban.gameObject.SetActive(true);
|
|
});
|
|
off_btn23.onClick.AddListener(() =>
|
|
{
|
|
mianban.gameObject.SetActive(false);
|
|
});
|
|
guan_btn.onClick.AddListener(() =>
|
|
{
|
|
mianban.gameObject.SetActive(false);
|
|
});
|
|
qu_btn22.onClick.AddListener(() =>
|
|
{
|
|
mianban.gameObject.SetActive(false);
|
|
});
|
|
}
|
|
|
|
void Update()
|
|
{
|
|
tiem_text.text = tiem_slider.value.ToString("0") + "s";
|
|
smash_text.text = smash_slider.value.ToString("0") + "s";
|
|
distance_text.text = distance_slider.value.ToString("f1") + "km";
|
|
angle_text.text = Angle_slider.value.ToString("0") + "°";
|
|
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");
|
|
}
|
|
private void Fanwei()
|
|
{
|
|
setting_btn.onClick.AddListener(() =>
|
|
{
|
|
Radius_panl.gameObject.SetActive(true);
|
|
});
|
|
off1_btn.onClick.AddListener(() =>
|
|
{
|
|
Radius_panl.gameObject.SetActive(false);
|
|
});
|
|
verify1_btn.onClick.AddListener(() =>
|
|
{
|
|
Radius_panl.gameObject.SetActive(false);
|
|
});
|
|
cancel_btn.onClick.AddListener(() =>
|
|
{
|
|
Radius_panl.gameObject.SetActive(false);
|
|
});
|
|
}
|
|
|
|
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);
|
|
duixiang = false;
|
|
}
|
|
else
|
|
{
|
|
object_list_panl.gameObject.SetActive(false);
|
|
duixiang = true;
|
|
}
|
|
});
|
|
}
|
|
|
|
//
|
|
private void Scenariofile()
|
|
{
|
|
//想定文件下的打开按钮
|
|
unpack_btn.onClick.AddListener(() =>
|
|
{
|
|
model_panl.gameObject.SetActive(false);
|
|
ScrollView_unpack.gameObject.SetActive(false);
|
|
object_list_panl.gameObject.SetActive(false);
|
|
contingency_list_panl.gameObject.SetActive(true);
|
|
});
|
|
//想定文件下的保存按钮
|
|
save_btn.onClick.AddListener(() =>
|
|
{
|
|
ScrollView_unpack.gameObject.SetActive(false);
|
|
});
|
|
//想定文件下的退出按钮
|
|
quit.onClick.AddListener(() =>
|
|
{
|
|
ScrollView_unpack.gameObject.SetActive(false);
|
|
});
|
|
//想定页面关闭按钮
|
|
//scenario_btnn.onClick.AddListener(() =>
|
|
//{
|
|
// Scenariofile_panl.gameObject.SetActive(false);
|
|
//});
|
|
//选择设备的关闭按钮
|
|
off_btn.onClick.AddListener(() =>
|
|
{
|
|
select_device_iamg.gameObject.SetActive(false);
|
|
});
|
|
//选择设备确认按钮
|
|
verify.onClick.AddListener(() =>
|
|
{
|
|
select_device_iamg.gameObject.SetActive(false);
|
|
});
|
|
//选择设备取消按钮
|
|
Cancel_btnn.onClick.AddListener(() =>
|
|
{
|
|
select_device_iamg.gameObject.SetActive(false);
|
|
});
|
|
}
|
|
void Scenario(bool bol, string str)
|
|
{
|
|
if (bol)
|
|
{
|
|
Debug.Log(str);
|
|
scen = JsonMapper.ToObject<Editinformation>(str);
|
|
for (int i = 0; i < scen.data.Count; i++)
|
|
{
|
|
Traininginformation temp = new Traininginformation();
|
|
temp = Jsonanalyze.FromJson<Traininginformation>(scen.data[i].VirtualPath);
|
|
data1.Add(temp);
|
|
}
|
|
if (scen.state)
|
|
{
|
|
Debug.Log("几次");
|
|
for (int i = 0; i < data1.Count; i++)
|
|
{
|
|
int index = i;
|
|
Instantiate(scenario_name, weizhi);
|
|
Text text = transform.GetChild(0).transform.GetChild(10).transform.GetChild(4).transform.GetChild(0).transform.GetChild(0).transform.GetChild(i).transform.GetChild(1).GetComponent<Text>();
|
|
text.text = scen.data[i].Name.ToString();
|
|
Toggle toggle = GameObject.Find("Canvas1").transform.GetChild(0).transform.GetChild(10).transform.GetChild(4).transform.GetChild(0).transform.GetChild(0).transform.GetChild(i).transform.GetChild(0).GetComponent<Toggle>();
|
|
toggle.group = togglezujian;
|
|
toggle.onValueChanged.AddListener((isOn) =>
|
|
{
|
|
if (isOn)
|
|
{
|
|
Singlechoice(data1[index]);
|
|
}
|
|
});
|
|
togglelist.Add(toggle);
|
|
}
|
|
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
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;
|
|
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].index.ToString());
|
|
}));
|
|
underneathList.Add(underneathItem);
|
|
}
|
|
}
|
|
|
|
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);
|
|
}
|
|
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)
|
|
{
|
|
environment_configuration1.gameObject.SetActive(false);
|
|
object_list_panl.gameObject.SetActive(false);
|
|
basic_information_iamg.gameObject.SetActive(false);
|
|
model_panl.gameObject.SetActive(true);
|
|
select_device_iamg.gameObject.SetActive(true);
|
|
model = false;
|
|
}
|
|
else
|
|
{
|
|
model_panl.gameObject.SetActive(false);
|
|
select_device_iamg.gameObject.SetActive(false);
|
|
model = true;
|
|
}
|
|
});
|
|
}
|
|
/// <summary>
|
|
/// 环境界面确认取消按钮
|
|
/// </summary>
|
|
private void Huanjin()
|
|
{
|
|
huanjin_btn.onClick.AddListener(() =>
|
|
{
|
|
environment_configuration1.gameObject.SetActive(false);
|
|
});
|
|
huanjin_btn1.onClick.AddListener(() =>
|
|
{
|
|
environment_configuration1.gameObject.SetActive(false);
|
|
});
|
|
}
|
|
/// <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(() =>
|
|
{
|
|
if (scenario == true)
|
|
{
|
|
ScrollView_unpack.gameObject.SetActive(true);
|
|
//scenario = false;
|
|
}
|
|
//else
|
|
//{
|
|
// ScrollView_unpack.gameObject.SetActive(false);
|
|
// Scenariofile_panl.gameObject.SetActive(false);
|
|
// scenario = 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);
|
|
tenkokuModule.weather_WindAmt = windDrop.value * 0.1f;
|
|
}
|
|
|
|
public void SetWindDirection()
|
|
{
|
|
float tempWindDir = 0;
|
|
switch (windDir.value)
|
|
{
|
|
case 1:
|
|
tempWindDir = 0.125f;
|
|
break;
|
|
case 2:
|
|
tempWindDir = 0.25f;
|
|
break;
|
|
case 3:
|
|
tempWindDir = 0.375f;
|
|
break;
|
|
case 4:
|
|
tempWindDir = 0.5f;
|
|
break;
|
|
case 5:
|
|
tempWindDir = 0.625f;
|
|
break;
|
|
case 6:
|
|
tempWindDir = 0.75f;
|
|
break;
|
|
case 7:
|
|
tempWindDir = 0.875f;
|
|
break;
|
|
case 8:
|
|
tempWindDir = 1f;
|
|
break;
|
|
}
|
|
tenkokuModule.weather_WindDir = Mathf.Lerp(0.0f, 1.0f, tempWindDir);
|
|
}
|
|
|
|
public void SetLightValue(float value)
|
|
{
|
|
float valueTemp = 1 - value;
|
|
tenkokuModule.weather_OvercastAmt = Mathf.Lerp(0.0f, 1.0f, valueTemp);
|
|
}
|
|
|
|
|
|
|
|
}
|