2025-02-12 08:43:33 +08:00

550 lines
22 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using DG.Tweening.Core.Easing;
using Lylibs;
using UnityEngine;
using UnityEngine.Playables;
using UnityEngine.UI;
using ZXK.Framework;
using ZXK.UTility;
using ZXKFramework;
using UIBase = ZXK.Framework.UIBase;
/*******************************************************************************
*Create By CG
*Function 调试运行模式控制
*******************************************************************************/
namespace ZXK.BYSS
{
public class RunningPanel : UIBase
{
private List<string[]> _resultDatas = new List<string[]>();
//刚进入场景有个提示,此时后面出现蒙版不允许点击其他位置
private GameObject _maskPanel = null;
public WebGLDownLoadFile webGLDownLoadFile;
// public PracticeAndExamInSceneCtrl v;
private void OnEnable()
{
string hintStr = null;
foreach (HintModel.AppHintData item in AppManagement.Instance._HintData._AppHints)
{
if (item._AppName.Equals(EnumCtrl.GetEnumDescription(AppManagement.Instance._CurType)))
{
hintStr = item._TrainHints[3]._TrainHint;
}
}
_maskPanel = GetWedage("EnterMask_N");
_maskPanel.gameObject.SetActive(false);
//PopUpMng.PopToast("实训任务4", hintStr, "确定", () =>
//{
//});
//调整相机
if (AppManagement.Instance._CurType == EnumCtrl.Type.ZNYD)
{
Camera.main.transform.position = new Vector3(-0.34f, 2.08f, 5.8f);//调整相机位置
Vector3 eulerAngles = new Vector3(11.152f, -90.0f, 0f);
Quaternion rotation = Quaternion.Euler(eulerAngles);
Camera.main.transform.rotation = rotation;//调整相机角度
Camera.main.fieldOfView = 60f;//调整相机FOV
}
if (AppManagement.Instance._CurType == EnumCtrl.Type.QDCY)
{
Camera.main.transform.position = new Vector3(6.7f, 1.8f, 11.1f);//调整相机位置
Vector3 eulerAngles = new Vector3(30f, -90.0f, 0f);
Quaternion rotation = Quaternion.Euler(eulerAngles);
Camera.main.transform.rotation = rotation;//调整相机角度
Camera.main.fieldOfView = 60f;//调整相机FOV
}
///充气按钮被点击前的操作,设置最佳视角,设置被点击按钮闪烁
bool IsHave = UI_Manage.Instance.GetPanel("PracticeAndExamPanel")
.GetComponent<PracticeAndExamPanel>()._CurTrainExamSceneCtrl;
PracticeAndExamInSceneCtrl _practiceAndExamCtrl = UI_Manage.Instance.GetPanel("PracticeAndExamPanel")
.GetComponent<PracticeAndExamPanel>()._CurTrainExamSceneCtrl;
//关闭声音组件
_practiceAndExamCtrl._anmCtrl.CloseAudio();
if (IsHave)
{
//智能运动控制 运行模式特殊操作
if (AppManagement.Instance._CurType == EnumCtrl.Type.ZNYD)
{
_practiceAndExamCtrl.Set_ZNYD_Running();
} //材料分解 运行模式特殊操作
if (AppManagement.Instance._CurType == EnumCtrl.Type.CLFJ)
{
_practiceAndExamCtrl.Set_CLLFJ_RunningInitViewCameran();
}
//搬运输送模式 设备初始视角UI闪烁
if (AppManagement.Instance._CurType == EnumCtrl.Type.BYSS)
{
_practiceAndExamCtrl.Set_BYSS_Running();
}
}
HideBlackMask();
}
/// <summary>
/// 气动冲压模式调用
/// 显示黑色蒙版,然后消失
/// </summary>
public void QDCY_GetBlackMaskToHide()
{
GetWedage("BlackMask_N").GetComponent<Image>().gameObject.SetActive(true);
Invoke("HideBlackMask", 0.2f);
}
public void Set_xhby_StartText()
{
GetWedage("RuningTipTxt_N").GetComponent<Text>().text = "操作提示:请通过启动、停止按钮,依次观察设备的运作。";
}
//黑色蒙版显示
public void HideBlackMask()
{
GetWedage("BlackMask_N").GetComponent<Image>().gameObject.SetActive(false);
}
private void Start()
{
webGLDownLoadFile = transform.GetComponent<WebGLDownLoadFile>();
//材料分解模式,显示右下角按钮视图
if (AppManagement.Instance._CurType == EnumCtrl.Type.CLFJ)
{
var v = UI_Manage.Instance.GetPanel("PracticeAndExamPanel")
.GetComponent<PracticeAndExamPanel>()._CurTrainExamSceneCtrl;
if (v != null)
{
var raw = v.transform.GetComponentInChildren<LyRawImage>(true);
raw.Run();
}
}
//循环搬运机械手模式,显示右下角按钮视图
if (AppManagement.Instance._CurType == EnumCtrl.Type.XHBY)
{
var v = UI_Manage.Instance.GetPanel("PracticeAndExamPanel")
.GetComponent<PracticeAndExamPanel>()._CurTrainExamSceneCtrl;
//运行模式特殊设置
v.Set_XHBY_StartBtn_On();
if (v != null)
{
v._anmCtrl.BallShowInAnm(0);
var raw = v.transform.GetComponentInChildren<LyRawImage>(true);
raw.Run();
}
}
if (AppManagement.Instance._TrainExam == EnumCtrl.Model.Exam)
{
GetWedage("OverBtn_N").SetActive(true);
}
else// if (AppManagement.Instance._TrainExam == EnumCtrl.Model.Train)
{
GetWedage("OverBtn_N").SetActive(false);
}
//循环搬运提示设置
if (AppManagement.Instance._CurType == EnumCtrl.Type.XHBY)
{
GetWedage("RuningTipTxt_N").GetComponent<Text>().text = "操作提示:请点击复位按钮使设备回到初始状态。";
}
//材料分拣提示设置
if (AppManagement.Instance._CurType == EnumCtrl.Type.CLFJ)
{
GetWedage("RuningTipTxt_N").GetComponent<Text>().text = "操作提示:请通过启动、停止、急停和复位按钮、依次观察设备的运作。";
}
//气动冲压提示设置
if (AppManagement.Instance._CurType == EnumCtrl.Type.QDCY)
{
GetWedage("RuningTipTxt_N").GetComponent<Text>().text = "操作提示:请通过启动、停止按钮、依次观察设备的运作。";
}
//搬运输送 ,提示
if (AppManagement.Instance._CurType == EnumCtrl.Type.BYSS)
{
GetWedage("RuningTipTxt_N").GetComponent<Text>().text = "操作提示:请通过触摸屏将设备切换至全线状态之后点击启动、停止按钮、依次观察设备的运作。";
}
//智能运动控制 ,提示
if (AppManagement.Instance._CurType == EnumCtrl.Type.ZNYD)
{
GetWedage("RuningTipTxt_N").GetComponent<Text>().text = "操作提示:请点击触摸屏上启动按钮,停止按钮,依次观察设备的运作。";
}
//材料分解模块,内容设置
if (AppManagement.Instance._CurType == EnumCtrl.Type.CLFJ)
{
#region
GetWedage("RunModel_N").gameObject.SetActive(true);
PracticeAndExamInSceneCtrl _practiceAndExamCtrl = UI_Manage.Instance.GetPanel("PracticeAndExamPanel")
.GetComponent<PracticeAndExamPanel>()._CurTrainExamSceneCtrl;
GetWedage("ZhengZhuan_N").GetComponent<Toggle>().onValueChanged.RemoveAllListeners();
GetWedage("FanZhuan_N").GetComponent<Toggle>().onValueChanged.RemoveAllListeners();
GetWedage("ZhengZhuan_N").GetComponent<Toggle>().onValueChanged.AddListener((ist) =>
{
var v = _practiceAndExamCtrl._anmCtrl;
v.RunZhengBo();
_practiceAndExamCtrl.OnSetReSet();
_practiceAndExamCtrl.ShowLuoLiaoTa2_3(false);
GetWedage("BlackMask_N").GetComponent<Image>().gameObject.SetActive(true);
Invoke("HideBlackMask", 0.2f);
});
GetWedage("FanZhuan_N").GetComponent<Toggle>().onValueChanged.AddListener((ist) =>
{
var v = _practiceAndExamCtrl._anmCtrl;
v.RunDaoBo();
_practiceAndExamCtrl.OnSetReSet();
_practiceAndExamCtrl.ShowLuoLiaoTa2_3(true);
GetWedage("BlackMask_N").GetComponent<Image>().gameObject.SetActive(true);
Invoke("HideBlackMask", 0.2f);
});
GetWedage("ZhengZhuan_N").GetComponent<Toggle>().isOn = true;
GetWedage("FanZhuan_N").GetComponent<Toggle>().isOn = false;
var v = _practiceAndExamCtrl._anmCtrl;
v.RunZhengBo();
_practiceAndExamCtrl.OnSetReSet();
#endregion
}
else
{
GetWedage("RunModel_N").gameObject.SetActive(false);
}
//声音控制器播放
var practiceAndExamCtrl = UI_Manage.Instance.GetPanel("PracticeAndExamPanel")
.GetComponent<PracticeAndExamPanel>()._CurTrainExamSceneCtrl;
if (practiceAndExamCtrl.speakManager != null)
{
practiceAndExamCtrl.speakManager.PlayAudioCilp();
}
//最终成绩数据
AddEventListener("OverBtn_N", UIEventType.OnButtonClick, () =>
{
float curScore = 0;
foreach (DataItemModel itemValue in AppManagement.Instance._AppModel
.DataJDSBArray[EnumCtrl.GetEnumDescription(AppManagement.Instance._CurType)].Values)
{
string[] resultItem = new string[4];
for (int i = 0; i < itemValue.Tools.Length; i++)
{
resultItem[0] = $"{_resultDatas.Count + 1}、{itemValue.Hint}";
resultItem[1] = $"操作记录:{itemValue.RealityTools[0]}";
resultItem[2] = itemValue.RightImg;
resultItem[3] = $"标准参考答案:{itemValue.Tools[0]}";
if (itemValue.RealityTools[0].Equals(itemValue.Tools[0]))
{
curScore += itemValue.Score;
}
}
_resultDatas.Add(resultItem);
}
SetText("ScoreTxt_N",
(curScore + AppManagement.Instance._ConnectScore + AppManagement.Instance._GasScore).ToString());
Debug.Log(curScore+"分数1");
Debug.Log(AppManagement.Instance._ConnectScore + "分数2");
Debug.Log(AppManagement.Instance._GasScore + "分数3");
//报告得分
YiLiao.Main.BaoGaoController.Instance.StartStep();
YiLiao.Main.BaoGaoController.Instance.AddStep(new Step()
{
name = "设备组装得分",
state = "设备组装",
maxScore = 20,
score = curScore,
type = "设备组装"
});
YiLiao.Main.BaoGaoController.Instance.AddStep(new Step()
{
name = "设备接线得分",
state = "设备接线",
maxScore = 50,
score = AppManagement.Instance._ConnectScore,
type = "设备接线"
});
YiLiao.Main.BaoGaoController.Instance.AddStep(new Step()
{
name = "设备充气得分",
state = "设备充气",
maxScore = 30,
score = AppManagement.Instance._GasScore,
type = "设备充气"
});
GetWedage("ScoreUI_N").SetActive(true);
});
AddEventListener("LoadWord_N", UIEventType.OnButtonClick, () =>
{
YiLiao.Main.BaoGaoController.Instance.PostBaoGao();
#region
//web端下载功能
LabReprotData labReprotData = new LabReprotData() { };
switch (AppManagement.Instance._CurType)
{
case EnumCtrl.Type.XHBY:
labReprotData.Name_1 = _resultDatas[0][1];
labReprotData.image_1 = _resultDatas[0][2];
labReprotData.Name_2 = _resultDatas[1][1];
labReprotData.image_2 = _resultDatas[1][2];
labReprotData.Name_3 = _resultDatas[2][1];
labReprotData.image_3 = _resultDatas[2][2];
labReprotData.Name_4 = _resultDatas[3][1];
labReprotData.image_4 = _resultDatas[3][2];
labReprotData.Name_5 = _resultDatas[4][1];
labReprotData.image_5 = _resultDatas[4][2];
labReprotData.Name_6 = _resultDatas[5][1];
labReprotData.image_6 = _resultDatas[5][2];
labReprotData.Name_7 = _resultDatas[6][1];
labReprotData.image_7 = _resultDatas[6][2];
labReprotData.Name_8 = _resultDatas[7][1];
labReprotData.image_8 = _resultDatas[7][2];
labReprotData.Name_9 = _resultDatas[8][1];
labReprotData.image_9 = _resultDatas[8][2];
break;
case EnumCtrl.Type.QDCY:
labReprotData.Name_1 = _resultDatas[0][1];
labReprotData.image_1 = _resultDatas[0][2];
labReprotData.Name_2 = _resultDatas[1][1];
labReprotData.image_2 = _resultDatas[1][2];
labReprotData.Name_3 = _resultDatas[2][1];
labReprotData.image_3 = _resultDatas[2][2];
labReprotData.Name_4 = _resultDatas[3][1];
labReprotData.image_4 = _resultDatas[3][2];
labReprotData.Name_5 = _resultDatas[4][1];
labReprotData.image_5 = _resultDatas[4][2];
break;
case EnumCtrl.Type.CLFJ:
labReprotData.Name_1 = _resultDatas[0][1];
labReprotData.image_1 = _resultDatas[0][2];
labReprotData.Name_2 = _resultDatas[1][1];
labReprotData.image_2 = _resultDatas[1][2];
labReprotData.Name_3 = _resultDatas[2][1];
labReprotData.image_3 = _resultDatas[2][2];
labReprotData.Name_4 = _resultDatas[3][1];
labReprotData.image_4 = _resultDatas[3][2];
labReprotData.Name_5 = _resultDatas[4][1];
labReprotData.image_5 = _resultDatas[4][2];
labReprotData.Name_6 = _resultDatas[5][1];
labReprotData.image_6 = _resultDatas[5][2];
labReprotData.Name_7 = _resultDatas[6][1];
labReprotData.image_7 = _resultDatas[6][2];
labReprotData.Name_8 = _resultDatas[7][1];
labReprotData.image_8 = _resultDatas[7][2];
break;
case EnumCtrl.Type.ZNYD:
labReprotData.Name_1 = _resultDatas[0][1];
labReprotData.image_1 = _resultDatas[0][2];
labReprotData.Name_2 = _resultDatas[1][1];
labReprotData.image_2 = _resultDatas[1][2];
labReprotData.Name_3 = _resultDatas[2][1];
labReprotData.image_3 = _resultDatas[2][2];
labReprotData.Name_4 = _resultDatas[3][1];
labReprotData.image_4 = _resultDatas[3][2];
labReprotData.Name_5 = _resultDatas[4][1];
labReprotData.image_5 = _resultDatas[4][2];
labReprotData.Name_6 = _resultDatas[5][1];
labReprotData.image_6 = _resultDatas[5][2];
break;
case EnumCtrl.Type.BYSS:
labReprotData.Name_1 = _resultDatas[0][1];
labReprotData.image_1 = _resultDatas[0][2];
labReprotData.Name_2 = _resultDatas[1][1];
labReprotData.image_2 = _resultDatas[1][2];
labReprotData.Name_3 = _resultDatas[2][1];
labReprotData.image_3 = _resultDatas[2][2];
labReprotData.Name_4 = _resultDatas[3][1];
labReprotData.image_4 = _resultDatas[3][2];
labReprotData.Name_5 = _resultDatas[4][1];
labReprotData.image_5 = _resultDatas[4][2];
labReprotData.Name_6 = _resultDatas[5][1];
labReprotData.image_6 = _resultDatas[5][2];
labReprotData.Name_7 = _resultDatas[6][1];
labReprotData.image_7 = _resultDatas[6][2];
labReprotData.Name_8 = _resultDatas[7][1];
labReprotData.image_8 = _resultDatas[7][2];
labReprotData.Name_9 = _resultDatas[8][1];
labReprotData.image_9 = _resultDatas[8][2];
labReprotData.Name_10 = _resultDatas[9][1];
labReprotData.image_10 = _resultDatas[9][2];
labReprotData.Name_11 = _resultDatas[10][1];
labReprotData.image_11 = _resultDatas[10][2];
labReprotData.Name_12 = _resultDatas[11][1];
labReprotData.image_12 = _resultDatas[11][2];
labReprotData.Name_13 = _resultDatas[12][1];
labReprotData.image_13 = _resultDatas[12][2];
break;
}
#endregion
#if UNITY_EDITOR || UNITY_STANDALONE
string savePath = FolderBrowserHelper.GetPathFromWindowsExplorer();
if (!string.IsNullOrEmpty(savePath))
{
GetWedage("ScoreUI_N").SetActive(false);
List<string> contains = new List<string>();
for (int i = 0; i < _resultDatas.Count; i++)
{
for (int j = 0; j < _resultDatas[i].Length; j++)
{
contains.Add(_resultDatas[i][j]);
}
}
string rec = null;
switch (AppManagement.Instance._CurType)
{
case EnumCtrl.Type.None:
break;
case EnumCtrl.Type.XHBY:
rec = System.IO.Path.Combine(Application.streamingAssetsPath +
ConstCtrl.DATA_ResultTemplate_PATH_XHBY);
break;
case EnumCtrl.Type.QDCY:
rec = System.IO.Path.Combine(Application.streamingAssetsPath +
ConstCtrl.DATA_ResultTemplate_PATH_QDCY);
break;
case EnumCtrl.Type.CLFJ:
rec = System.IO.Path.Combine(Application.streamingAssetsPath +
ConstCtrl.DATA_ResultTemplate_PATH_CLFJ);
break;
case EnumCtrl.Type.ZNYD:
rec = System.IO.Path.Combine(Application.streamingAssetsPath +
ConstCtrl.DATA_ResultTemplate_PATH_ZNYD);
break;
case EnumCtrl.Type.BYSS:
rec = System.IO.Path.Combine(Application.streamingAssetsPath +
ConstCtrl.DATA_ResultTemplate_PATH_BYSS);
break;
default:
break;
}
string filePath = System.IO.Path.Combine(savePath, System.IO.Path.GetFileName(rec));
//OfficeMng.InsertParagraphsInWord(rec, filePath, 1, contains.ToArray());
filePath = FileHandle.CheckFile(filePath, true);
OfficeMng.InsertParagraphsInWord(rec, filePath, "1、模拟组装", contains.ToArray());
//pc下载word文档
PopUpMng.PopConBox("打开文件", $"文件已经保存在\"{filePath}\",是否直接打开", "打开",
() => { FolderBrowserHelper.OpenFolder(filePath); });
}
#elif UNITY_WEBGL
webGLDownLoadFile.Download(labReprotData);
#endif
});
AddEventListener("ExitBtn_N", UIEventType.OnButtonClick,
() => { GetWedage("ScoreUI_N").SetActive(false); });
}
}
}