156 lines
6.6 KiB
C#
156 lines
6.6 KiB
C#
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using UnityEngine;
|
|
using UnityEngine.Playables;
|
|
|
|
namespace YHElectric
|
|
{
|
|
public class GameManager : MonoBehaviour
|
|
{
|
|
public static GameManager instance;
|
|
public PlayableDirector playableDirector;
|
|
public Dictionary<string, Transform> modelLocation = new Dictionary<string, Transform>();//模型定位字典
|
|
public GameObject uav;
|
|
public ThermalNightVisionImageEffect thermalNightVisionImageEffect;
|
|
public GameObject alarmEffect;
|
|
|
|
SkyUIController skyUIController;
|
|
private void Awake()
|
|
{
|
|
instance = this;
|
|
playableDirector.stopped += StopEvent;
|
|
}
|
|
private void Start()
|
|
{
|
|
StartCoroutine(DelayStopPlayable());
|
|
for (int i = 0; i < ModelLocation.instance.names.Length; i++)
|
|
{
|
|
modelLocation.Add(ModelLocation.instance.names[i], ModelLocation.instance.trans[i]);
|
|
}
|
|
|
|
Application.ExternalCall("SetRealWeather");
|
|
}
|
|
private void Update()
|
|
{
|
|
if (Input.GetKeyDown(KeyCode.T))
|
|
{
|
|
//string wa= { "resultcode":"200","reason":"successed!","result":{ "sk":{ "temp":"21","wind_direction":"南风","wind_strength":"2级","humidity":"80%","time":"12:33"},"today":{ "temperature":"19℃~22℃","weather":"多云转雷阵雨","weather_id":{ "fa":"01","fb":"04"},"wind":"南风4-5级","week":"星期一","city":"青岛","date_y":"2020年06月01日","dressing_index":"较舒适","dressing_advice":"建议着薄外套、开衫牛仔衫裤等服装。年老体弱者应适当添加衣物,宜着夹克衫、薄毛衣等。","uv_index":"弱","comfort_index":"","wash_index":"不宜","travel_index":"较适宜","exercise_index":"较适宜","drying_index":""},"future":[{"temperature":"19℃~22℃","weather":"多云转雷阵雨","weather_id":{"fa":"01","fb":"04"},"wind":"南风4-5级","week":"星期一","date":"20200601"},{"temperature":"18℃~26℃","weather":"多云","weather_id":{"fa":"01","fb":"01"},"wind":"北风3-5级","week":"星期二","date":"20200602"},{"temperature":"18℃~25℃","weather":"晴","weather_id":{"fa":"00","fb":"00"},"wind":"南风3-5级","week":"星期三","date":"20200603"},{"temperature":"20℃~26℃","weather":"晴","weather_id":{"fa":"00","fb":"00"},"wind":"东南风3-5级","week":"星期四","date":"20200604"},{"temperature":"19℃~25℃","weather":"晴转多云","weather_id":{"fa":"00","fb":"01"},"wind":"东风4-5级","week":"星期五","date":"20200605"},{"temperature":"18℃~25℃","weather":"晴","weather_id":{"fa":"00","fb":"00"},"wind":"南风3-5级","week":"星期六","date":"20200606"},{"temperature":"18℃~26℃","weather":"多云","weather_id":{"fa":"01","fb":"01"},"wind":"北风3-5级","week":"星期日","date":"20200607"}]},"error_code":0}
|
|
//SetRealWeather("duoyu");
|
|
}
|
|
//if (Input.GetKeyDown(KeyCode.Y))
|
|
//{
|
|
// ShowFloor("2");
|
|
//}
|
|
//if (Input.GetKeyDown(KeyCode.U))
|
|
//{
|
|
// ShowFloor("3");
|
|
//}
|
|
//if (Input.GetKeyDown(KeyCode.I))
|
|
//{
|
|
// ShowFloor("4");
|
|
//}
|
|
//if (Input.GetKeyDown(KeyCode.O))
|
|
//{
|
|
// LocationModel("cdz2");
|
|
//}
|
|
}
|
|
public void ShowFloor(string str)
|
|
{
|
|
FloorController.instance.ShowFloor1(int.Parse(str));
|
|
return;
|
|
}
|
|
IEnumerator DelayStopPlayable()
|
|
{
|
|
yield return new WaitForSeconds(1);
|
|
playableDirector.Pause();
|
|
}
|
|
void StopEvent(PlayableDirector playableDirector)
|
|
{
|
|
print("生产线动画结束");
|
|
}
|
|
bool uavEnable = false;
|
|
public void OpenUAV(string str)
|
|
{
|
|
uavEnable = !uavEnable;
|
|
if (uavEnable)//启用无人机
|
|
{
|
|
//OpenUAV();
|
|
//Application.ExternalCall("OpenUAV");
|
|
OpenUAV1();
|
|
}
|
|
else//关闭无人机
|
|
{
|
|
Application.ExternalCall("StopUAV");
|
|
CloseUAV();
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 开启无人机
|
|
/// </summary>
|
|
public void OpenUAV1()
|
|
{
|
|
uav.gameObject.SetActive(true);
|
|
//alarmEffect.SetActive(false);
|
|
CameraControl.isFollowUAV = true;
|
|
//H5Panel.browser.EvalJS("Callback(" + 5 + ")", "scripted command");
|
|
StartCoroutine(OpenUAVPerspective());
|
|
}
|
|
/// <summary>
|
|
/// 关闭无人机
|
|
/// </summary>
|
|
public void CloseUAV()
|
|
{
|
|
CameraControl.isFollowUAV = false;
|
|
CameraControl.isUAVFiew = false;
|
|
thermalNightVisionImageEffect.enabled = false;
|
|
uav.gameObject.SetActive(false);
|
|
StopCoroutine(OpenUAVPerspective());
|
|
StopCoroutine(DelayCreateAlarm());
|
|
//CameraOperate.instance.ResetRot();
|
|
//Camera.main.transform.position = startPos.position;
|
|
//Camera.main.transform.localEulerAngles = startPos.localEulerAngles;
|
|
//H5Panel.browser.EvalJS("Callback(" + 3 + ")", "scripted command");
|
|
//CameraOperate.operate = true;
|
|
}
|
|
/// <summary>
|
|
/// 开启无人机视角
|
|
/// </summary>
|
|
/// <returns></returns>
|
|
IEnumerator OpenUAVPerspective()
|
|
{
|
|
yield return new WaitForSeconds(10);
|
|
CameraControl.isUAVFiew = true;
|
|
CameraControl.isFollowUAV = false;
|
|
thermalNightVisionImageEffect.enabled = true;
|
|
}
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
/// <param name="name"></param>
|
|
public void LocationModel(string name)//cdz1 cdz2 cdz3 monitor_cd
|
|
{
|
|
CameraControl.instance.LocationModel(name);
|
|
}
|
|
public void ShowAlarmEffect()
|
|
{
|
|
StartCoroutine(DelayCreateAlarm());
|
|
}
|
|
public void ShowAlarm(string show)
|
|
{
|
|
bool isShow = bool.Parse(show);
|
|
alarmEffect.SetActive(isShow);
|
|
}
|
|
IEnumerator DelayCreateAlarm()
|
|
{
|
|
yield return new WaitForSeconds(4);
|
|
//alarmEffect.gameObject.SetActive(true);
|
|
}
|
|
public void SetRealWeather(string weather)
|
|
{
|
|
if(skyUIController==null)
|
|
skyUIController = GameObject.Find("UIRoot/FixedRoot/IndexPanel(Clone)/Bg/sky").GetComponent<SkyUIController>();
|
|
skyUIController.SetRealWeather(weather);
|
|
}
|
|
}
|
|
}
|