1122 lines
37 KiB
C#
1122 lines
37 KiB
C#
using DataModel.Model;
|
||
using LitJson;
|
||
using Newtonsoft.Json.Linq;
|
||
using System;
|
||
using System.Collections;
|
||
using System.Collections.Generic;
|
||
using System.Linq;
|
||
using System.Security.Principal;
|
||
using Tenkoku.Core;
|
||
using UnityEditor.Animations;
|
||
using UnityEditor.VersionControl;
|
||
using UnityEngine;
|
||
using UnityEngine.Networking;
|
||
using UnityEngine.Rendering.PostProcessing;
|
||
using UnityEngine.SceneManagement;
|
||
using UnityEngine.UI;
|
||
using YL;
|
||
using static NetMQ.NetMQSelector;
|
||
using static UnityEditor.ShaderData;
|
||
|
||
public class Scenariopage : MonoBehaviour
|
||
{
|
||
public Button scenario_file_btn;//想定文件按钮
|
||
public RectTransform ScrollView_unpack;//打开保存退出按钮显示
|
||
public RectTransform Scenariofile_panl;//想定页面
|
||
public Image object_list_panl;//对象列表面板
|
||
public Image Radius_panl;//值范围面板
|
||
public Image mianban;//
|
||
public Button object_list_btn;//对象列表按钮
|
||
public Button basic_info_btn;//基本信息按钮
|
||
public Image basic_information_iamg;//基本信息面板
|
||
public Button off4_btn;//基本信息关闭按钮
|
||
public Button model_list_btn;//模型按钮
|
||
public RectTransform select_device_iamg;//模型页面
|
||
public Button verify;//设备信息确认按钮
|
||
public Button Cancel_btnn;//设备信息取消按钮
|
||
public Image details_panl;//设备详情页面
|
||
public Button Fork_off_btn;//设备详情叉掉面板
|
||
public Button queren_btn;//设备详情确认按钮
|
||
public Button quxiao_btn;//设备详情取消按钮
|
||
public Image model_panl;//模型页面按钮
|
||
public Button off_btn;//选择设备的关闭按钮
|
||
public RectTransform environment_configuration1;//环境页面
|
||
public Button environment_setting_btn;//环境按钮
|
||
public Button fork_off_btn;//关闭按钮
|
||
public Button send_back_btn;//返回按钮
|
||
public Button verify_bton1;//基本信息确定按钮
|
||
public Button cancel_bton1;//基本信息取消按钮
|
||
public Button huanjin_btn;//环境配置确认按钮
|
||
public Button huanjin_btn1;//环境配置取消按钮
|
||
public Button quan_btn;//全部按钮
|
||
public Button can_btn;//探测按钮
|
||
public Button lu_btn;//陆
|
||
public Button kong_btn;//空
|
||
public Button qita_btn;//其他
|
||
public Image moxin_yemian;//显示模型框
|
||
public Image moyin_yemian1;
|
||
public Image moyin_yemian2;
|
||
public Image moyin_yemian3;
|
||
public Image moyin_yemian4;
|
||
private bool 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";//想定Wbe接口
|
||
//public List<Text> textlist = new List<Text>();
|
||
[SerializeField]
|
||
Editinformation scen = new Editinformation();
|
||
[SerializeField]
|
||
List<Traininginformation> data1 = new List<Traininginformation>();
|
||
|
||
//List<Traininginformation> data1 = new List<Traininginformation>();
|
||
public Slider yangguang;//阳光的滑动条
|
||
public Text yangguang_text; //显示阳光的滑动数值
|
||
|
||
public Image basic_information_iamg1;//训练科目基本信息页面
|
||
public Text xunkian_txt;//显示的想定的名字
|
||
public Text time_txt;//显示基本信息的训练时间
|
||
public Text mode_text;//显示基本信息页面训练模式
|
||
public Text post_txt;//显示基本信息的设备数量
|
||
public Button off4_btn1;//训练科目基本信息叉掉按钮;
|
||
public Button verify_bton2;//训练科目基本信息确认按钮
|
||
public Button cancel_bton2;//训练科目基本信息取消按钮
|
||
public GameObject scenario_name;//想定编辑的预设体
|
||
public Transform weizhi;//生成的位置
|
||
|
||
[SerializeField] List<Toggle> togglelist = new List<Toggle>();//存放想定文件下的打勾按钮
|
||
public ToggleGroup togglezujian;//获取toggle组件
|
||
public Underneath underneath;//想定文件下的科目预设体
|
||
public Transform scenario_file_iamg;//生成的预设体的位置
|
||
[SerializeField] List<Underneath> underneathList = new List<Underneath>();
|
||
public GameObject scenarname;//想定名称
|
||
public Scenarioname scenar_name;//想定名称
|
||
[SerializeField] List<Scenarioname> scenarList = new List<Scenarioname>();
|
||
public Text year_text;//年
|
||
public Text month_text;//月
|
||
public Text day_text;//天
|
||
public Text when_text;//时
|
||
public Environmentconfiguration Environmentconfiguration;
|
||
public Slider Slider;//天气变化的滑动条
|
||
public Text tips_text;//环境编辑提示文本
|
||
//[SerializeField] List<Environment> environments = new List<Environment>();
|
||
[SerializeField] string rainamt;//天气雨的传值
|
||
[SerializeField] string snowamt;//天气雪的传值
|
||
[SerializeField] string windamt;//风的等级的传值
|
||
[SerializeField] string winddir;//雪的等级的传值
|
||
public string Name1;
|
||
public string practicemode;
|
||
public Text scenarioname_text;//基本信息的想定名称
|
||
public Text practricemode_text;//基本信息模式
|
||
public int time;
|
||
public int quantity;
|
||
public Text time1_text;//相对训练的时间
|
||
public Text quantity_text;//基本信息页面设备数量
|
||
public Toggle xitong;//系统时间勾选
|
||
public Toggle shodo;//手动设置时间
|
||
public Button hand_btn;//手动设置按钮
|
||
public Text auto_text;//自动时间文本
|
||
public bool isptime = false;//时间显示判断文本
|
||
public bool kaiguan = false;
|
||
public Propertypanl propertypanl;//需要生成的物体
|
||
public Transform Panel_making;//生成的面板的位置
|
||
public List<Propertypanl> properties = new List<Propertypanl>();
|
||
public List<Devuce> devuces = new List<Devuce>();
|
||
|
||
|
||
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();//科目训练按钮三
|
||
Timesetting();
|
||
}
|
||
|
||
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);
|
||
//time_text.gameObject.SetActive(true);
|
||
if (isptime == true)
|
||
{
|
||
when_text.gameObject.SetActive(true);
|
||
}
|
||
isptime = true;
|
||
kaiguan = true;
|
||
tmie = null;
|
||
}
|
||
});
|
||
}
|
||
|
||
private void Settingbtn()
|
||
{
|
||
off4_btn1.onClick.AddListener(() =>
|
||
{
|
||
basic_information_iamg1.gameObject.SetActive(false);
|
||
});
|
||
verify_bton2.onClick.AddListener(() =>
|
||
{
|
||
//Scenariofile_panl.gameObject.SetActive(false);
|
||
basic_information_iamg1.gameObject.SetActive(false);
|
||
});
|
||
cancel_bton2.onClick.AddListener(() =>
|
||
{
|
||
basic_information_iamg1.gameObject.SetActive(false);
|
||
});
|
||
}
|
||
|
||
private void Dixaing()
|
||
{
|
||
off_btnn5.onClick.AddListener(() =>
|
||
{
|
||
contingency_list_panl.gameObject.SetActive(false);
|
||
});
|
||
queren_btnn3.onClick.AddListener(() =>
|
||
{
|
||
|
||
contingency_list_panl.gameObject.SetActive(false);
|
||
Scenariofile_panl.gameObject.SetActive(true);
|
||
});
|
||
}
|
||
|
||
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 LateUpdate()
|
||
{
|
||
tenkokuModule.weather_OvercastAmt = Mathf.Lerp(0.0f, 1.0f, 1 - Slider.value / 10);
|
||
SetWindDirection();
|
||
SetWindValue();
|
||
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);
|
||
Screen();
|
||
Propertymodel();
|
||
}
|
||
});
|
||
}
|
||
|
||
public void Screen()
|
||
{
|
||
int a = 1;
|
||
int b = 1;
|
||
int c = 1;
|
||
int d = 1;
|
||
int e = 1;
|
||
int f = 1;
|
||
int g = 1;
|
||
int h = 1;
|
||
int y = 1;
|
||
int z = 1;
|
||
int a1 = 1;
|
||
int a2 = 1;
|
||
int a3 = 1;
|
||
int a4 = 1;
|
||
int a5 = 1;
|
||
int a6 = 1;
|
||
int a7 = 1;
|
||
int a8 = 1;
|
||
int a9 = 1;
|
||
for (int i = 0; i < DragManager.Instance.modellist.Count; i++)
|
||
{
|
||
if (DragManager.Instance.modellist[i] == "车辆1")
|
||
{
|
||
DragManager.Instance.modellist[i] += " (" + a + ")";
|
||
a++;
|
||
}
|
||
if (DragManager.Instance.modellist[i] == "车辆2")
|
||
{
|
||
DragManager.Instance.modellist[i] += " (" + b + ")";
|
||
b++;
|
||
}
|
||
if (DragManager.Instance.modellist[i] == "石块1")
|
||
{
|
||
DragManager.Instance.modellist[i] += " (" + c + ")";
|
||
c++;
|
||
}
|
||
if (DragManager.Instance.modellist[i] == "石块2")
|
||
{
|
||
DragManager.Instance.modellist[i] += " (" + d + ")";
|
||
d++;
|
||
}
|
||
if (DragManager.Instance.modellist[i] == "石块3")
|
||
{
|
||
DragManager.Instance.modellist[i] += " (" + e + ")";
|
||
e++;
|
||
}
|
||
if (DragManager.Instance.modellist[i] == "石块4")
|
||
{
|
||
DragManager.Instance.modellist[i] += " (" + f + ")";
|
||
f++;
|
||
}
|
||
if (DragManager.Instance.modellist[i] == "石块5")
|
||
{
|
||
DragManager.Instance.modellist[i] += " (" + g + ")";
|
||
g++;
|
||
}
|
||
if (DragManager.Instance.modellist[i] == "树木1")
|
||
{
|
||
DragManager.Instance.modellist[i] += " (" + h + ")";
|
||
h++;
|
||
}
|
||
if (DragManager.Instance.modellist[i] == "树木2")
|
||
{
|
||
DragManager.Instance.modellist[i] += " (" + y + ")";
|
||
y++;
|
||
}
|
||
if (DragManager.Instance.modellist[i] == "树木3")
|
||
{
|
||
DragManager.Instance.modellist[i] += " (" + z + ")";
|
||
z++;
|
||
}
|
||
if (DragManager.Instance.modellist[i] == "三间瓦屋1")
|
||
{
|
||
DragManager.Instance.modellist[i] += " (" + a1 + ")";
|
||
a1++;
|
||
}
|
||
if (DragManager.Instance.modellist[i] == "三间瓦屋2")
|
||
{
|
||
DragManager.Instance.modellist[i] += " (" + a2 + ")";
|
||
a2++;
|
||
}
|
||
if (DragManager.Instance.modellist[i] == "三间瓦屋3")
|
||
{
|
||
DragManager.Instance.modellist[i] += " (" + a3 + ")";
|
||
a3++;
|
||
}
|
||
if (DragManager.Instance.modellist[i] == "三间瓦屋4")
|
||
{
|
||
DragManager.Instance.modellist[i] += " (" + a4 + ")";
|
||
a4++;
|
||
}
|
||
if (DragManager.Instance.modellist[i] == "三间瓦屋5")
|
||
{
|
||
DragManager.Instance.modellist[i] += " (" + a5 + ")";
|
||
a5++;
|
||
}
|
||
if (DragManager.Instance.modellist[i] == "三间瓦屋6")
|
||
{
|
||
DragManager.Instance.modellist[i] += " (" + a6 + ")";
|
||
a6++;
|
||
}
|
||
if (DragManager.Instance.modellist[i] == "二层小楼")
|
||
{
|
||
DragManager.Instance.modellist[i] += " (" + a7 + ")";
|
||
a7++;
|
||
}
|
||
if (DragManager.Instance.modellist[i] == "储物间1")
|
||
{
|
||
DragManager.Instance.modellist[i] += " (" + a8 + ")";
|
||
a8++;
|
||
}
|
||
if (DragManager.Instance.modellist[i] == "储物间2")
|
||
{
|
||
DragManager.Instance.modellist[i] += " (" + a9 + ")";
|
||
a9++;
|
||
}
|
||
}
|
||
}
|
||
private void Propertymodel()
|
||
{
|
||
if (properties.Count > 0)//判断生成UI预设体的个数是否大于零
|
||
{
|
||
for (int j = 0; j < properties.Count; j++)
|
||
{
|
||
if (properties[j] != null)//如果链表里面存在物体就进去
|
||
{
|
||
Destroy(properties[j].gameObject);
|
||
}
|
||
}
|
||
properties.Clear();//清空链表
|
||
}
|
||
for (int i = 0; i < DragManager.Instance.deviceimages.Count; i++)//判断单例生成预设体
|
||
{
|
||
int index = i;
|
||
Propertypanl pro = Instantiate(propertypanl, Panel_making);//生成预设体对象
|
||
pro.Property(DragManager.Instance.modellist[index], () =>
|
||
{
|
||
Destroy(DragManager.Instance.deviceimages[index].gameObject);
|
||
Destroy(pro.gameObject);
|
||
});
|
||
properties.Add(pro);
|
||
}
|
||
}
|
||
|
||
//
|
||
private void Scenariofile()
|
||
{
|
||
//想定文件下的打开按钮
|
||
unpack_btn.onClick.AddListener(() =>
|
||
{
|
||
model_panl.gameObject.SetActive(false);
|
||
ScrollView_unpack.gameObject.SetActive(false);
|
||
object_list_panl.gameObject.SetActive(false);
|
||
scenario = true;
|
||
contingency_list_panl.gameObject.SetActive(true);
|
||
});
|
||
//想定文件下的保存按钮
|
||
save_btn.onClick.AddListener(() =>
|
||
{
|
||
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);
|
||
});
|
||
}
|
||
public string Id;
|
||
void Scenario(bool bol, string str)
|
||
{
|
||
if (bol)
|
||
{
|
||
Debug.Log(str);
|
||
scen = JsonMapper.ToObject<Editinformation>(str);//解析最外层的想定名称json文件
|
||
for (int i = 0; i < scen.data.Count; i++)
|
||
{
|
||
Traininginformation temp = new Traininginformation();//接收json解析的新对象这样接收对象就不会被覆盖,因为每次都是需要一个新的对象
|
||
temp = Jsonanalyze.FromJson<Traininginformation>(scen.data[i].VirtualPath);//解析里面字符串json文件
|
||
data1.Add(temp);//把对象添加到对象链表中
|
||
}
|
||
if (scen.state)//如果state这个bool值为true进来
|
||
{
|
||
if (scenarList.Count > 0)//如果想定链表的数量量大于零个进入
|
||
{
|
||
for (int j = 0; j < scenarList.Count; j++)//循环一下对应的列表
|
||
{
|
||
Destroy(scenarList[j].gameObject);//删除链表每一个物体
|
||
}
|
||
scenarList.Clear();//清空链表
|
||
}
|
||
|
||
for (int i = 0; i < data1.Count; i++)//循环一下对象的个数
|
||
{
|
||
int index = i;//用一个值去接收循环的数值,因为用于按钮这些操作可能会被覆盖,得不到对应的值
|
||
Scenarioname scenarioname = Instantiate(scenar_name, weizhi);//生成想定名称预设体和位置
|
||
//这是预设体对应的类去接收
|
||
scenarioname.Scenario(scen.data[index].Name.ToString(), togglezujian, () =>//传对应的值到文本
|
||
{
|
||
Id = scen.data[index].Id;
|
||
Name1 = scen.data[index].Name;
|
||
practicemode = scen.data[index].PracticeMode;
|
||
time = 0;
|
||
quantity = 0;
|
||
Singlechoice(data1[index]);//把相对应的对象传到方法中
|
||
Basicinformation();
|
||
});
|
||
scenarList.Add(scenarioname);//把对象添加到链表中
|
||
}
|
||
|
||
}
|
||
}
|
||
}
|
||
|
||
|
||
private void Singlechoice(Traininginformation ti)//用相应类对象去接收
|
||
{
|
||
if (underneathList.Count > 0)//如果链表的个数大于零进入
|
||
{
|
||
for (int i = 0; i < underneathList.Count; i++)//循环链表的个数
|
||
{
|
||
Destroy(underneathList[i].gameObject);//把链表对应的个数一一删除
|
||
}
|
||
underneathList.Clear();//清除链表
|
||
}
|
||
for (int f = 0; f < ti.subjectsInfo.Count; f++)//循环对应链表对应的个数
|
||
{
|
||
int index = f;//用数去接收for循环
|
||
Underneath underneathItem = Instantiate(underneath, scenario_file_iamg);//把克隆对象生成预设体,用相应对象去接收
|
||
underneathItem.SetValue(ti.subjectsInfo[index].subjectName, (() =>//传对应的值给文本
|
||
{
|
||
OnUnderNeathSetBtn(ti.subjectsInfo[index].subjectName, ti.subjectsInfo[index].SubTime.ToString(), ti.subjectsInfo[index].mode, ti.subjectsInfo[index].seatInfos.Count.ToString());
|
||
}));
|
||
time += ti.subjectsInfo[index].SubTime;
|
||
quantity += ti.subjectsInfo[index].seatInfos.Count;
|
||
underneathList.Add(underneathItem);//把生成对象加入链表中
|
||
}
|
||
//Debug.LogError(time);
|
||
//Debug.LogError(quantity);
|
||
Train();
|
||
}
|
||
private void Train()
|
||
{
|
||
time1_text.text = time.ToString();
|
||
quantity_text.text = quantity.ToString();
|
||
}
|
||
private void Basicinformation()
|
||
{
|
||
scenarioname_text.text = Name1;
|
||
practricemode_text.text = practicemode;
|
||
}
|
||
|
||
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(() =>
|
||
{
|
||
string url = "http://172.16.1.254:48888/Handler/Thinkingfile.ashx?action=adddevice";
|
||
if (model == true)
|
||
{
|
||
if (DragManager.Instance.deviceimages.Count > 0)
|
||
{
|
||
for (int i = 0; i < DragManager.Instance.deviceimages.Count; i++)
|
||
{
|
||
if (DragManager.Instance.deviceimages[i] != null)
|
||
{
|
||
Destroy(DragManager.Instance.deviceimages[i].gameObject);
|
||
}
|
||
}
|
||
DragManager.Instance.deviceimages.Clear();
|
||
}
|
||
if (DragManager.Instance.modellist.Count > 0)
|
||
{
|
||
DragManager.Instance.modellist.Clear();
|
||
}
|
||
url += "think_id";
|
||
url += "" + Id + "";
|
||
StartCoroutine(Post1(url, (bol, str) =>
|
||
{
|
||
Weapon(bol, str);
|
||
}));
|
||
environment_configuration1.gameObject.SetActive(false);
|
||
object_list_panl.gameObject.SetActive(false);
|
||
basic_information_iamg1.gameObject.SetActive(false);
|
||
model_panl.gameObject.SetActive(true);
|
||
select_device_iamg.gameObject.SetActive(true);
|
||
//model = false;
|
||
}
|
||
//else
|
||
//{
|
||
// model_panl.gameObject.SetActive(false);
|
||
// select_device_iamg.gameObject.SetActive(false);
|
||
// model = true;
|
||
//}
|
||
});
|
||
}
|
||
public void Weapon(bool bol,string str)
|
||
{
|
||
if (bol)
|
||
{
|
||
Debug.LogError(str);
|
||
devuces=JsonMapper.ToObject<List<Devuce>>(str);
|
||
|
||
}
|
||
}
|
||
/// <summary>
|
||
/// 环境界面确认取消按钮
|
||
/// </summary>
|
||
public string tmie;//接收环境的界面日期时间
|
||
private void Huanjin()
|
||
{
|
||
huanjin_btn.onClick.AddListener(() =>
|
||
{
|
||
if (year_text.text.Length >= 1 || auto_text.text.Length >= 1)
|
||
{
|
||
Rain(tenkokuModule.weather_RainAmt.ToString());
|
||
Snow(tenkokuModule.weather_SnowAmt.ToString());
|
||
WindAmt(tenkokuModule.weather_WindAmt.ToString("f1"));
|
||
WindDir(tenkokuModule.weather_WindDir);
|
||
//Debug.LogError(tenkokuModule.weather_WindAmt);
|
||
//tmie = year_text.text + " " + month_text.text + " " + day_text.text + " " + when_text.text;
|
||
if (kaiguan == false)
|
||
{
|
||
tmie = auto_text.text;
|
||
}
|
||
if (kaiguan == true)
|
||
{
|
||
tmie = year_text.text + " " + month_text.text + " " + day_text.text + " " + when_text.text;
|
||
}
|
||
Passbyvalue();//给接口传值
|
||
environment_configuration1.gameObject.SetActive(false);
|
||
}
|
||
else
|
||
{
|
||
tips_text.text = "请输入日期";
|
||
Invoke("Tips", 1.5f);
|
||
}
|
||
|
||
});
|
||
huanjin_btn1.onClick.AddListener(() =>
|
||
{
|
||
environment_configuration1.gameObject.SetActive(false);
|
||
});
|
||
}
|
||
void Passbyvalue()
|
||
{
|
||
string url = "http://172.16.1.254:48888/Handler/Thinkingfile.ashx?action=update_env";//获取需要传值的接口
|
||
|
||
Environment Environment = new Environment();//需要传值对应类
|
||
//把需要传的值对象参数对应
|
||
Environment.Time = "" + tmie + "";
|
||
Environment.Rain = "" + rainamt + "";
|
||
Environment.Snow = "" + snowamt + "";
|
||
Environment.WindSpeed = "" + windamt + "";
|
||
Environment.WindDir = "" + winddir + "";
|
||
Environment.Light = "" + Slider.value.ToString("0") + "";
|
||
string res = JsonMapper.ToJson(Environment);//利用插件LitJson将类对象转为json
|
||
Debug.LogError(res);
|
||
Dictionary<string, string> formDic = new Dictionary<string, string>();
|
||
formDic.Add("Id", "" + Id + "");
|
||
formDic.Add("data", res);
|
||
//formDic.Add("file",tex.ToString());
|
||
StartCoroutine(PostData(url, formDic, getInfo)); //协程调用网络通信
|
||
|
||
}
|
||
|
||
void getInfo(bool b, string s)
|
||
{
|
||
Debug.LogError(b);
|
||
Debug.LogError(s);
|
||
}
|
||
|
||
|
||
public static IEnumerator PostData(string url, Dictionary<string, string> keyValuePairs, System.Action<bool, string> action)
|
||
{
|
||
WWWForm form = new WWWForm();
|
||
|
||
foreach (var item in keyValuePairs)
|
||
{
|
||
form.AddField(item.Key, item.Value);//把字典的键值对存到from
|
||
//Debug.LogError(item.Key + " " + item.Value);
|
||
}
|
||
|
||
UnityWebRequest request = UnityWebRequest.Post(url, form);
|
||
yield return request.SendWebRequest();//发送请求
|
||
if (request.isNetworkError || request.isHttpError)
|
||
{
|
||
print("cannot get data:" + request.responseCode);
|
||
action(false, null);
|
||
}
|
||
else
|
||
{
|
||
if (!string.IsNullOrEmpty(request.downloadHandler.text))
|
||
action(true, request.downloadHandler.text);
|
||
else
|
||
action(false, null);
|
||
}
|
||
}
|
||
|
||
private void Rain(string rain)
|
||
{
|
||
switch (rain)
|
||
{
|
||
case "0":
|
||
rainamt = "无";
|
||
break;
|
||
case "0.25":
|
||
rainamt = "小雨";
|
||
break;
|
||
case "0.5":
|
||
rainamt = "中雨";
|
||
break;
|
||
case "0.75":
|
||
rainamt = "大雨";
|
||
break;
|
||
case "1":
|
||
rainamt = "暴雨";
|
||
break;
|
||
default:
|
||
break;
|
||
}
|
||
}
|
||
private void Snow(string sonw)
|
||
{
|
||
switch (sonw)
|
||
{
|
||
case "0":
|
||
snowamt = "无";
|
||
break;
|
||
case "0.25":
|
||
snowamt = "小雪";
|
||
break;
|
||
case "0.5":
|
||
snowamt = "中雪";
|
||
break;
|
||
case "0.75":
|
||
snowamt = "大雪";
|
||
break;
|
||
case "1":
|
||
snowamt = "暴雪";
|
||
break;
|
||
default:
|
||
break;
|
||
}
|
||
}
|
||
private void WindAmt(string windamt1)
|
||
{
|
||
switch (windamt1)
|
||
{
|
||
case "0.2":
|
||
windamt = "1";
|
||
break;
|
||
case "0.3":
|
||
windamt = "2";
|
||
break;
|
||
case "0.4":
|
||
windamt = "3";
|
||
break;
|
||
case "0.5":
|
||
windamt = "4";
|
||
break;
|
||
case "0.6":
|
||
windamt = "5";
|
||
break;
|
||
case "0.7":
|
||
windamt = "6";
|
||
break;
|
||
case "0.8":
|
||
windamt = "7";
|
||
break;
|
||
case "0.9":
|
||
windamt = "8";
|
||
break;
|
||
case "1.0":
|
||
windamt = "9";
|
||
break;
|
||
case "1.1":
|
||
windamt = "10";
|
||
break;
|
||
}
|
||
Debug.LogError(windamt);
|
||
}
|
||
private void WindDir(float wind)
|
||
{
|
||
switch (wind)
|
||
{
|
||
case 45:
|
||
winddir = "东";
|
||
break;
|
||
case 90:
|
||
winddir = "南";
|
||
break;
|
||
case 135:
|
||
winddir = "西";
|
||
break;
|
||
case 180:
|
||
winddir = "北";
|
||
break;
|
||
case 225f:
|
||
winddir = "东南";
|
||
break;
|
||
case 270f:
|
||
winddir = "东北";
|
||
break;
|
||
case 315f:
|
||
winddir = "西南";
|
||
break;
|
||
case 360f:
|
||
winddir = "西北";
|
||
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(() =>
|
||
{
|
||
if (scenario == true)
|
||
{
|
||
ScrollView_unpack.gameObject.SetActive(true);
|
||
scenario = false;
|
||
}
|
||
else if (scenario == false)
|
||
{
|
||
ScrollView_unpack.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);
|
||
|
||
float tempEintAmt = 0;
|
||
switch (windDrop.value)
|
||
{
|
||
case 0:
|
||
tempEintAmt = 0.1f;
|
||
break;
|
||
case 1:
|
||
tempEintAmt = 0.2f;
|
||
break;
|
||
case 2:
|
||
tempEintAmt = 0.3f;
|
||
break;
|
||
case 3:
|
||
tempEintAmt = 0.4f;
|
||
break;
|
||
case 4:
|
||
tempEintAmt = 0.5f;
|
||
break;
|
||
case 5:
|
||
tempEintAmt = 0.6f;
|
||
break;
|
||
case 6:
|
||
tempEintAmt = 0.7f;
|
||
break;
|
||
case 7:
|
||
tempEintAmt = 0.8f;
|
||
break;
|
||
case 8:
|
||
tempEintAmt = 0.9f;
|
||
break;
|
||
case 9:
|
||
|
||
tempEintAmt = 1.0f;
|
||
break;
|
||
}
|
||
//Debug.LogError(windDrop.value);
|
||
tenkokuModule.weather_WindAmt = Mathf.Lerp(0.1f, 1.1f, tempEintAmt);
|
||
Debug.Log(tenkokuModule.weather_WindAmt);
|
||
|
||
}
|
||
|
||
public void SetWindDirection()
|
||
{
|
||
float tempWindDir = 0;
|
||
switch (windDir.value)
|
||
{
|
||
case 0:
|
||
tempWindDir = 0.125f;
|
||
break;
|
||
case 1:
|
||
tempWindDir = 0.25f;
|
||
break;
|
||
case 2:
|
||
tempWindDir = 0.375f;
|
||
break;
|
||
case 3:
|
||
tempWindDir = 0.5f;
|
||
break;
|
||
case 4:
|
||
tempWindDir = 0.625f;
|
||
break;
|
||
case 5:
|
||
tempWindDir = 0.75f;
|
||
break;
|
||
case 6:
|
||
tempWindDir = 0.875f;
|
||
break;
|
||
case 7:
|
||
tempWindDir = 1f;
|
||
break;
|
||
}
|
||
//Debug.LogError(windDir.value);
|
||
tenkokuModule.weather_WindDir = Mathf.Lerp(0.0f, 360.0f, tempWindDir);
|
||
}
|
||
|
||
|
||
|
||
|
||
|
||
}
|