| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533 | using DG.Tweening;using System;using System.Collections;using System.Collections.Generic;using System.Threading.Tasks;using UnityAsync;using UnityEngine;using UnityEngine.UI;using WaitUntil = UnityAsync.WaitUntil;[System.Serializable]public enum YJType{    YELLOW,    ORANGE,    RED}[Serializable]public class SchedulingPlan{    public float max_water_level;    public string max_water_level_unit;    public string max_water_level_time;    public float flood_peak_flow_rate;    public string flood_peak_flow_rate_unit;    public float intercepted_flood_volume;    public string intercepted_flood_volume_unit;    public int peak_reduction_rate;    public float final_water_level;    public string final_water_level_unit;}[Serializable]public class SchedulingResults{    public float inflow_peak;    public string inflow_peak_unit;    public float outflow_total;    public string outflow_total_unit;    public float initial_water_level;    public string initial_water_level_unit;    public float target_water_level;    public string target_water_level_unit;}[Serializable]public class RiskInformation{    public string warning_level;    public float submerged_area;    public string submerged_area_unit;    public float submerged_farmland_area;    public string submerged_farmland_area_unit;    public float affected_population;    public string affected_population_unit;    public float submerged_area_gdp;    public string submerged_area_gdp_unit;    public float flood_loss;    public string flood_loss_unit;}[Serializable]public class PersonnelSupport{    public int id;    public string person;    public string unit;    public string position;    public string phone;}[Serializable]public class MaterialSupport{    public int id;    public string type;    public int quantity;    public string unit;    public string person_in_charge;    public string region;}[Serializable]public class Data{    public SchedulingPlan scheduling_plan;    public SchedulingResults scheduling_results;    public RiskInformation risk_information;    public List<PersonnelSupport> personnel_support;    public List<MaterialSupport> material_support;}[Serializable]public class SchedulingData{    public int id;    public string scheduling_name;    public Data data;}public class XHDDLayer : YZTRootLayer{    public RectTransform qxhddContent;    public RectTransform xhddContent;    public Button enterBtn;    public Button exitBtn;    public Button playBtn;    public List<Text> threeStepBtns = new List<Text>();    public Dropdown yjDropdown;    public Button[] yjButtons;    public YJType yJType;    public string[,] allYAContent = new string[3, 3];    bool playing = false;    float currentTime = 0;    [Header("UpLeft")]    public Text ddNameText;    public Text zuigaoshuiweiText;    public Text zuigaoshuiweishijianText;    public Text hongfengliusuText;    public Text lanxuhongliangText;    public Text xuefenglvText;    public Text moqishuiweiText;    [Header("MiddleLeft")]    public Text rukuhongfengText;    public Text qitiaoshuiweiText;    public Text chukuzongliuliangText;    public Text mubiaoshuiweiText;    [Header("DownLeft")]    public RectTransform rkzyContent;    public GameObject rkzyPrefab;    [Header("UpRight")]    public Text fengxiandengjiText;    public Text yanmomianjiText;    public Text yanmogengdiText;    public Text yingxiangrenkouText;    public Text gDPText;    public Text hongshuisunshiText;    [Header("MiddleRight")]    public RectTransform rybzContent;    public GameObject rybzPrefab;    [Header("DownRight")]    public RectTransform wzbzContent;    public GameObject wzbzPrefab;    // Start is called before the first frame update    void Start()    {        InitYAContent();        InitButton();        InitUpLeft();        InitMiddleLeft();        InitDownLeft();        InitUpRight();        InitMiddleRight();        InitDownRight();    }    private void OnEnable()    {        CameraManager.SwitchCamera(0);        StaticLod.instance.OnFoucusStatic(1);    }    private void InitUpLeft()    {        ddNameText.text = GlobalData.schedulingData.scheduling_name;        zuigaoshuiweiText.text = $"{GlobalData.schedulingData.data.scheduling_plan.max_water_level} <size=12><color=#A5BBE2>m</color></size>";        zuigaoshuiweishijianText.text = $"{GlobalData.schedulingData.data.scheduling_plan.max_water_level_time}";        hongfengliusuText.text = $"{GlobalData.schedulingData.data.scheduling_plan.flood_peak_flow_rate} <size=12><color=#A5BBE2>m³/s</color></size>";        lanxuhongliangText.text = $"{GlobalData.schedulingData.data.scheduling_plan.intercepted_flood_volume} <size=12><color=#A5BBE2>m³/s</color></size>";        xuefenglvText.text = $"{GlobalData.schedulingData.data.scheduling_plan.peak_reduction_rate} <size=12><color=#A5BBE2>%</color></size>";        moqishuiweiText.text = $"{GlobalData.schedulingData.data.scheduling_plan.final_water_level} <size=12><color=#A5BBE2>m</color></size>";    }    private void InitMiddleLeft()    {        rukuhongfengText.text = $"{GlobalData.schedulingData.data.scheduling_results.inflow_peak} <size=14><color=#A5BBE2>m³/s</color></size>";        qitiaoshuiweiText.text = $"{GlobalData.schedulingData.data.scheduling_results.outflow_total} <size=14><color=#A5BBE2>m</color></size>";        chukuzongliuliangText.text = $"{GlobalData.schedulingData.data.scheduling_results.initial_water_level} <size=14><color=#A5BBE2>m³/s</color></size>";        mubiaoshuiweiText.text = $"{GlobalData.schedulingData.data.scheduling_results.target_water_level} <size=14><color=#A5BBE2>m</color></size>";    }    private async Task InitDownLeft()    {        await new WaitUntil(() =>        {            return GlobalData.allServerMovePlans.Count > 0;        });        for (int i = 0; i < GlobalData.allServerMovePlans.Count; i++)        {            GameObject obj = Instantiate(rkzyPrefab);            obj.transform.SetParent(rkzyContent);            obj.transform.localScale = Vector3.one;            obj.transform.GetChild(0).GetComponent<Text>().text = i.ToString();            obj.transform.GetChild(1).GetComponent<Text>().text = GlobalData.allServerMovePlans[i].from;            obj.transform.GetChild(2).GetComponent<Text>().text = GlobalData.allServerMovePlans[i].to;            obj.transform.GetChild(3).GetComponent<Text>().text = CoordinateConverter.Haversine(GlobalData.allServerMovePlans[i].fromLttd, GlobalData.allServerMovePlans[i].fromLong, GlobalData.allServerMovePlans[i].toLttd, GlobalData.allServerMovePlans[i].toLong).ToString("0.00") + "km";            obj.transform.GetChild(4).GetComponent<Text>().text = GlobalData.allServerMovePlans[i].manNum.ToString();        }    }    private void InitUpRight()    {        fengxiandengjiText.text = $"{GlobalData.schedulingData.data.risk_information.warning_level} <size=14><color=#A5BFE2>级</color></size>";        yanmomianjiText.text = $"{GlobalData.schedulingData.data.risk_information.submerged_area} <size=14><color=#A5BFE2>k㎡</color></size>";        yanmogengdiText.text = $"{GlobalData.schedulingData.data.risk_information.submerged_farmland_area} <size=14><color=#A5BFE2>h㎡</color></size>";        yingxiangrenkouText.text = $"{GlobalData.schedulingData.data.risk_information.affected_population} <size=14><color=#A5BFE2>万人</color></size>";        gDPText.text = $"{GlobalData.schedulingData.data.risk_information.submerged_area_gdp} <size=14><color=#A5BFE2>亿元</color></size>";        hongshuisunshiText.text = $"{GlobalData.schedulingData.data.risk_information.flood_loss} <size=14><color=#A5BFE2>亿元</color></size>";    }    private void InitMiddleRight()    {        for (int i = 0; i < GlobalData.schedulingData.data.personnel_support.Count; i++)        {            GameObject obj = Instantiate(rybzPrefab);            obj.transform.SetParent(rybzContent);            obj.transform.localScale = Vector3.one;            obj.transform.GetChild(0).GetComponent<Text>().text = GlobalData.schedulingData.data.personnel_support[i].id.ToString();            obj.transform.GetChild(1).GetComponent<Text>().text = GlobalData.schedulingData.data.personnel_support[i].person;            obj.transform.GetChild(2).GetComponent<Text>().text = GlobalData.schedulingData.data.personnel_support[i].unit;            obj.transform.GetChild(3).GetComponent<Text>().text = GlobalData.schedulingData.data.personnel_support[i].position.ToString();            obj.transform.GetChild(4).GetComponent<Text>().text = GlobalData.schedulingData.data.personnel_support[i].phone.ToString();        }    }    private void InitDownRight()    {        for (int i = 0; i < GlobalData.schedulingData.data.material_support.Count; i++)        {            GameObject obj = Instantiate(wzbzPrefab);            obj.transform.SetParent(wzbzContent);            obj.transform.localScale = Vector3.one;            obj.transform.GetChild(0).GetComponent<Text>().text = GlobalData.schedulingData.data.material_support[i].id.ToString();            obj.transform.GetChild(1).GetComponent<Text>().text = GlobalData.schedulingData.data.material_support[i].type;            obj.transform.GetChild(2).GetComponent<Text>().text = GlobalData.schedulingData.data.material_support[i].quantity.ToString() + GlobalData.schedulingData.data.material_support[i].unit.ToString();            obj.transform.GetChild(3).GetComponent<Text>().text = GlobalData.schedulingData.data.material_support[i].unit.ToString();            obj.transform.GetChild(4).GetComponent<Text>().text = GlobalData.schedulingData.data.material_support[i].person_in_charge.ToString();            obj.transform.GetChild(5).GetComponent<Text>().text = GlobalData.schedulingData.data.material_support[i].region.ToString();        }    }    public override void OnUILeave()    {        base.OnUILeave();        AllRestore();    }    void InitYAContent()    {        allYAContent[0, 0] = "当预报洪水将达到或超过蓄滞洪区启用标准时(套口进洪闸的设防水位为32m),发布黄色预警,做好运用准备。";        allYAContent[0, 1] = "分洪前线指挥部及其下设七个责任组责任人和成员迅速进入运用准备状态,服从前指的统一调度。";        allYAContent[0, 2] = "分蓄洪区内各个乡镇、村组确定1名领导专门负责承担警报发布和传递任务。警报一经发布,各项避洪工作必须迅速及时,不得有误。";        allYAContent[1, 0] = "当需要区内人员转移时,发布橙色预警,开始实施分蓄洪区内居民转移、清场等工作。";        allYAContent[1, 1] = "人员转移时机根据荆江河段及城陵矶附近地区实时水情、防洪工程情况和区内人员转移所需时间等确定。";        allYAContent[1, 2] = "采取电视、广播、电话、传真、汽笛、敲锣、挂旗、报警器、鸣枪或挨户通知等一切可能的形式迅速向分洪区传播分洪转移命令。";        allYAContent[2, 0] = "当决定启用蓄滞洪区时,发布红色警报。";        allYAContent[2, 1] = "开启套口进洪闸或实施上车湾口门爆破,开始分蓄洪。";        allYAContent[2, 2] = "红色警报期持续至具备返迁条件时为止。";    }    void InitButton()    {        enterBtn.onClick.AddListener(() =>        {            qxhddContent.gameObject.SetActive(false);            xhddContent.gameObject.SetActive(true);        });        exitBtn.onClick.AddListener(() =>        {            qxhddContent.gameObject.SetActive(true);            xhddContent.gameObject.SetActive(false);            playBtn.interactable = true;            playing = false;            AllRestore();        });        for (int i = 0; i < yjButtons.Length; i++)        {            int temp = i;            yjButtons[i].onClick.AddListener(() =>            {                if (!playing)                {                    ClearAllText();                }                for (int j = 0; j < yjButtons.Length; j++)                {                    yjButtons[j].GetComponent<CanvasGroup>().alpha = 0.2f;                }                yjButtons[temp].GetComponent<CanvasGroup>().alpha = 1f;                yJType = (YJType)temp;                yjDropdown.value = temp;            });        }        playBtn.onClick.AddListener(() =>        {            ClearAllText();            playing = true;            playBtn.interactable = false;            currentTime = 0;            ControlYJ();        });    }    void AllRestore()    {        TimeLineControl.instance.transform.GetChild(1).GetChild(1).localPosition = Vector3.zero;        TimeLineControl.instance.transform.GetChild(0).gameObject.SetActive(false);        Material material = TimeLineControl.instance.transform.GetChild(1).GetChild(0).GetComponent<MeshRenderer>().material;        material.SetFloat("_ClipLength", 1);        currentTime = 0;    }    void ClearAllText()    {        for (int i = 0; i < threeStepBtns.Count; i++)        {            threeStepBtns[i].text = "";        }    }    async void ControlYJ()    {        switch (yJType)        {            case YJType.YELLOW:                TimeLineControl.instance.transform.GetChild(1).GetChild(1).localPosition = Vector3.zero;                threeStepBtns[0].text = allYAContent[(int)yJType, 0];                await new WaitUntil(() =>                {                    return currentTime > 1;                });                if (!playing)                {                    playBtn.interactable = true;                    return;                }                StaticLod.instance.OnFoucusStatic("Bird1");                await new WaitUntil(() =>                {                    return currentTime > 3;                });                if (!playing)                {                    playBtn.interactable = true;                    return;                }                TimeLineControl.instance.transform.GetChild(1).GetChild(1).DOLocalMove(new Vector3(0, 0, 31.2f), 12.0f);                await new WaitUntil(() =>                {                    return currentTime > 14;                });                if (!playing)                {                    playBtn.interactable = true;                    return;                }                threeStepBtns[1].text = allYAContent[(int)yJType, 1];                StaticLod.instance.OnFoucusStatic("Bird2");                await new WaitUntil(() =>                {                    return currentTime > 17;                });                if (!playing)                {                    playBtn.interactable = true;                    return;                }                threeStepBtns[2].text = allYAContent[(int)yJType, 2];                playBtn.interactable = true;                break;            case YJType.ORANGE:                TimeLineControl.instance.transform.GetChild(1).GetChild(1).localPosition = new Vector3(0, 0, 31.2f);                TimeLineControl.instance.transform.GetChild(0).gameObject.SetActive(false);                threeStepBtns[0].text = allYAContent[(int)yJType, 0];                await new WaitUntil(() =>                {                    return currentTime > 1;                });                if (!playing)                {                    playBtn.interactable = true;                    return;                }                StaticLod.instance.OnFoucusStatic("Bird2");                await new WaitUntil(() =>                {                    return currentTime > 3;                });                if (!playing)                {                    playBtn.interactable = true;                    return;                }                TimeLineControl.instance.transform.GetChild(0).gameObject.SetActive(true);                await new WaitUntil(() =>                {                    return currentTime > 11;                });                if (!playing)                {                    playBtn.interactable = true;                    return;                }                threeStepBtns[1].text = allYAContent[(int)yJType, 1];                StaticLod.instance.OnFoucusStatic("Bird3");                await new WaitUntil(() =>                {                    return currentTime > 14;                });                if (!playing)                {                    playBtn.interactable = true;                    return;                }                threeStepBtns[2].text = allYAContent[(int)yJType, 2];                playBtn.interactable = true;                break;            case YJType.RED:                Material material = TimeLineControl.instance.transform.GetChild(1).GetChild(0).GetComponent<MeshRenderer>().material;                TimeLineControl.instance.transform.GetChild(0).gameObject.SetActive(false);                material.SetFloat("_ClipLength", 1);                TimeLineControl.instance.transform.GetChild(1).GetChild(1).localPosition = new Vector3(0, 0, 31.2f);                TimeLineControl.instance.transform.GetChild(2).GetChild(0).gameObject.SetActive(false);                threeStepBtns[0].text = allYAContent[(int)yJType, 0];                await new WaitUntil(() =>                {                    return currentTime > 1;                });                if (!playing)                {                    playBtn.interactable = true;                    return;                }                StaticLod.instance.OnFoucusStatic("Bird2");                await new WaitUntil(() =>                {                    return currentTime > 4;                });                if (!playing)                {                    playBtn.interactable = true;                    return;                }                StaticLod.instance.OnFoucusStatic("Bird4");                ActionInstance._Instance.ModelAni_On?.Invoke();                await new WaitUntil(() =>                {                    return currentTime > 5.2;                });                TimeLineControl.instance.transform.GetChild(2).GetChild(0).gameObject.SetActive(true);                if (!playing)                {                    playBtn.interactable = true;                    return;                }                await new WaitUntil(() =>                {                    return currentTime > 5.7;                });                material.SetFloat("_ClipLength", 0.981f);                if (!playing)                {                    playBtn.interactable = true;                    return;                }                threeStepBtns[1].text = allYAContent[(int)yJType, 1];                await new WaitUntil(() =>                {                    return currentTime > 7.7;                });                if (!playing)                {                    playBtn.interactable = true;                    return;                }                StaticLod.instance.OnFoucusStatic("Bird5");                DOTween.To(() => material.GetFloat("_ClipLength"), x => material.SetFloat("_ClipLength", x), 0.881f, 4f);                await new WaitUntil(() =>                {                    return currentTime > 12.7;                });                if (!playing)                {                    playBtn.interactable = true;                    return;                }                StaticLod.instance.OnFoucusStatic("Bird3");                DOTween.To(() => material.GetFloat("_ClipLength"), x => material.SetFloat("_ClipLength", x), 0.1f, 6f);                await new WaitUntil(() =>                {                    return currentTime > 18.7;                });                if (!playing)                {                    playBtn.interactable = true;                    return;                }                threeStepBtns[2].text = allYAContent[(int)yJType, 2];                playBtn.interactable = true;                break;        }    }    // Update is called once per frame    void Update()    {        currentTime += Time.deltaTime;    }}
 |