416 lines
12 KiB
C#
416 lines
12 KiB
C#
using DefaultNamespace.ProcessMode;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using DefaultNamespace;
|
|
using Framework.Manager;
|
|
using MotionFramework;
|
|
using TMPro;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
using static InterfaceManager;
|
|
/// <summary>
|
|
/// 物资控制中心
|
|
/// </summary>
|
|
public class MaterialCenter : MonoBehaviour
|
|
{
|
|
/// <summary>
|
|
/// 单例
|
|
/// </summary>
|
|
public static MaterialCenter Instance;
|
|
/// <summary>
|
|
/// 物资检查
|
|
/// </summary>
|
|
public GameObject panelMaterialInspection;
|
|
/// <summary>
|
|
/// 物资检查按钮
|
|
/// </summary>
|
|
public Button btnMaterialInspection;
|
|
/// <summary>
|
|
/// 物资配套资料
|
|
/// </summary>
|
|
public Toggle[] toggles;
|
|
/// <summary>
|
|
/// 应收物资数量输入框
|
|
/// </summary>
|
|
public TMP_InputField inputQuantityReceivableMaterials;
|
|
/// <summary>
|
|
/// 应收物资单位显示
|
|
/// </summary>
|
|
public TextMeshProUGUI TextInputQuantityReceivableMaterials;
|
|
/// <summary>
|
|
/// 应收物资数量爆保存按钮
|
|
/// </summary>
|
|
public Button btnQuantityReceivableMaterials;
|
|
/// <summary>
|
|
/// 物资检查附件按钮
|
|
/// </summary>
|
|
public Button btnCheckAttachments;
|
|
/// <summary>
|
|
/// 物资卡片
|
|
/// </summary>
|
|
public Button btnMaterialCard;
|
|
/// <summary>
|
|
/// 物资卡片
|
|
/// </summary>
|
|
public MaterialCard PanelMaterialCard;
|
|
/// <summary>
|
|
/// 悬挂物资卡片
|
|
/// </summary>
|
|
public Button btnHangMaterialCard;
|
|
/// <summary>
|
|
/// 关闭物资检查面板
|
|
/// </summary>
|
|
public Button btnClosePanelMaterialInspection;
|
|
/// <summary>
|
|
/// 地磅检查按钮
|
|
/// </summary>
|
|
public Button WeighCheckbt;
|
|
/// <summary>
|
|
/// 地磅检查完毕保存按钮
|
|
/// </summary>
|
|
public Button WeighChecksavebt;
|
|
/// <summary>
|
|
/// 卸货按钮
|
|
/// </summary>
|
|
public Button Unload;
|
|
/// <summary>
|
|
/// 地磅检查面板
|
|
/// </summary>
|
|
public GameObject WeighChecksPanel;
|
|
/// <summary>
|
|
/// 地磅检查toggle
|
|
/// </summary>
|
|
public List<Toggle> choosetoggle;
|
|
|
|
|
|
public Button btupload;
|
|
|
|
public GameObject plane1;
|
|
|
|
private void Awake()
|
|
{
|
|
Instance = this;
|
|
//在场景中找出隐藏的PanelMaterialInspection的Transform
|
|
panelMaterialInspection = FindHiddenPanel("PanelMaterialInspection");
|
|
btnMaterialInspection = FindObjectByName<Button>("btnMaterialInspection");
|
|
btnClosePanelMaterialInspection = FindObjectByName<Button>("btnClosePanelMaterialInspection");
|
|
|
|
WeighCheckbt = FindObjectByName<Button>("btnWeighbridgeInspection");
|
|
Unload = FindObjectByName<Button>("btnUnload");
|
|
WeighChecksavebt = FindObjectByName<Button>("btnCheckWeigh");
|
|
WeighChecksPanel = FindHiddenPanel("地磅检查");
|
|
choosetoggle = WeighChecksPanel.GetComponentsInChildren<Toggle>().ToList();
|
|
|
|
inputQuantityReceivableMaterials = FindObjectByName<TMP_InputField>("inputQuantityReceivableMaterials");
|
|
TextInputQuantityReceivableMaterials = FindObjectByName<TextMeshProUGUI>("TextInputQuantityReceivableMaterials");
|
|
btnQuantityReceivableMaterials = FindObjectByName<Button>("btnSaveQuantityReceivableMaterials");
|
|
btnCheckAttachments = FindObjectByName<Button>("btnCheckAttachments");
|
|
btnMaterialCard = FindObjectByName<Button>("btnMaterialCard");
|
|
PanelMaterialCard = FindObjectByName<MaterialCard>("PanelMaterialCard");
|
|
btnHangMaterialCard = FindObjectByName<Button>("btnHangMaterialCard");
|
|
if (panelMaterialInspection != null)
|
|
{
|
|
toggles = panelMaterialInspection.GetComponentsInChildren<Toggle>();
|
|
}
|
|
}
|
|
|
|
// Start is called before the first frame update
|
|
void Start()
|
|
{
|
|
SetupButtonListeners();
|
|
InitializeUI();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 设置所有按钮监听器
|
|
/// </summary>
|
|
private void SetupButtonListeners()
|
|
{
|
|
SetupWeighCheckButton();
|
|
SetupMaterialInspectionButton();
|
|
SetupClosePanelButton();
|
|
SetupQuantityButton();
|
|
SetupCheckAttachmentsButton();
|
|
SetupWeighCheckSaveButton();
|
|
SetupUnloadButton();
|
|
SetupMaterialCardButtons();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 设置称重检查按钮
|
|
/// </summary>
|
|
private void SetupWeighCheckButton()
|
|
{
|
|
if (WeighCheckbt != null)
|
|
{
|
|
WeighCheckbt.onClick.AddListener(() =>
|
|
{
|
|
LoadTriggerNextGuide(WeighCheckbt.name);
|
|
});
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 设置物资检查按钮
|
|
/// </summary>
|
|
private void SetupMaterialInspectionButton()
|
|
{
|
|
if (panelMaterialInspection != null && btnMaterialInspection != null)
|
|
{
|
|
btnMaterialInspection.onClick.AddListener(() =>
|
|
{
|
|
HandleMaterialInspectionClick();
|
|
});
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 处理物资检查按钮点击
|
|
/// </summary>
|
|
private void HandleMaterialInspectionClick()
|
|
{
|
|
if (MotionEngine.GetModule<GlobalDataStorage>().ExamName.Contains("库存物资报废"))
|
|
{
|
|
plane1.SetActive(true);
|
|
}
|
|
else
|
|
{
|
|
panelMaterialInspection.SetActive(true);
|
|
}
|
|
LoadTriggerNextGuide(btnMaterialInspection.name);
|
|
}
|
|
|
|
/// <summary>
|
|
/// 设置关闭面板按钮
|
|
/// </summary>
|
|
private void SetupClosePanelButton()
|
|
{
|
|
if (btnClosePanelMaterialInspection != null)
|
|
{
|
|
btnClosePanelMaterialInspection.onClick.AddListener(() =>
|
|
{
|
|
panelMaterialInspection.SetActive(false);
|
|
if (btnCheckAttachments != null && btnCheckAttachments.gameObject.activeSelf)
|
|
{
|
|
LoadTriggerNextGuide("关闭");
|
|
}
|
|
else
|
|
{
|
|
LoadTriggerNextGuide(panelMaterialInspection.name);
|
|
}
|
|
});
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 设置数量清点按钮
|
|
/// </summary>
|
|
private void SetupQuantityButton()
|
|
{
|
|
if (inputQuantityReceivableMaterials != null && btnQuantityReceivableMaterials != null)
|
|
{
|
|
btnQuantityReceivableMaterials.onClick.AddListener(() =>
|
|
{
|
|
MotionFramework.MotionEngine.GetModule<ProcessManager>().HandleClick(inputQuantityReceivableMaterials.text);
|
|
btnQuantityReceivableMaterials.gameObject.SetActive(false);
|
|
LoadTriggerNextGuide(btnQuantityReceivableMaterials.name);
|
|
});
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 设置检查附件按钮
|
|
/// </summary>
|
|
private void SetupCheckAttachmentsButton()
|
|
{
|
|
if (btnCheckAttachments != null && toggles != null && toggles.Length > 5)
|
|
{
|
|
btnCheckAttachments.onClick.AddListener(() =>
|
|
{
|
|
HandleCheckAttachmentsClick();
|
|
});
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 处理检查附件按钮点击
|
|
/// </summary>
|
|
private void HandleCheckAttachmentsClick()
|
|
{
|
|
List<string> toggleValues = GetToggleValues();
|
|
var processManager = MotionFramework.MotionEngine.GetModule<ProcessManager>();
|
|
if (IsTeachingOrPreviewMode(processManager))
|
|
{
|
|
if (processManager.HandleClick(toggleValues))
|
|
{
|
|
btnCheckAttachments.gameObject.SetActive(false);
|
|
LoadTriggerNextGuide(btnCheckAttachments.name);
|
|
}
|
|
}
|
|
else
|
|
{
|
|
MotionEngine.GetModule<ProcessManager>().HandleClick(toggleValues);
|
|
btnCheckAttachments.gameObject.SetActive(false);
|
|
LoadTriggerNextGuide(btnCheckAttachments.name);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取Toggle值列表
|
|
/// </summary>
|
|
private List<string> GetToggleValues()
|
|
{
|
|
return new List<string>
|
|
{
|
|
toggles[0].isOn ? "true" : "false",
|
|
toggles[1].isOn ? "true" : "false",
|
|
toggles[2].isOn ? "true" : "false",
|
|
toggles[3].isOn ? "true" : "false",
|
|
toggles[4].isOn ? "true" : "false",
|
|
toggles[5].isOn ? "true" : "false"
|
|
};
|
|
}
|
|
|
|
/// <summary>
|
|
/// 检查是否为教学模式或课程预览模式
|
|
/// </summary>
|
|
private bool IsTeachingOrPreviewMode(ProcessManager processManager)
|
|
{
|
|
return processManager._currentMode == ProcessMode.教学模式 ||
|
|
processManager._currentMode == ProcessMode.课程预览;
|
|
}
|
|
|
|
/// <summary>
|
|
/// 设置称重检查保存按钮
|
|
/// </summary>
|
|
private void SetupWeighCheckSaveButton()
|
|
{
|
|
if (WeighChecksavebt != null)
|
|
{
|
|
WeighChecksavebt.onClick.AddListener(() =>
|
|
{
|
|
HandleWeighCheckSaveClick();
|
|
});
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 处理称重检查保存按钮点击
|
|
/// </summary>
|
|
private void HandleWeighCheckSaveClick()
|
|
{
|
|
List<string> toggleValues = GetWeighCheckToggleValues();
|
|
if (MotionFramework.MotionEngine.GetModule<ProcessManager>().HandleClick(toggleValues))
|
|
{
|
|
WeighChecksPanel.SetActive(false);
|
|
if (MotionEngine.GetModule<GlobalDataStorage>().ExamName.Contains("库存物资报废"))
|
|
{
|
|
TutorialGuideManager.Instance.HideGuide();
|
|
}
|
|
else
|
|
{
|
|
LoadTriggerNextGuide(WeighChecksavebt.name);
|
|
}
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 获取称重检查Toggle值列表
|
|
/// </summary>
|
|
private List<string> GetWeighCheckToggleValues()
|
|
{
|
|
return new List<string>
|
|
{
|
|
choosetoggle[0].isOn ? "true" : "false",
|
|
choosetoggle[1].isOn ? "true" : "false",
|
|
choosetoggle[2].isOn ? "true" : "false",
|
|
choosetoggle[3].isOn ? "true" : "false"
|
|
};
|
|
}
|
|
|
|
/// <summary>
|
|
/// 设置卸货按钮
|
|
/// </summary>
|
|
private void SetupUnloadButton()
|
|
{
|
|
if (Unload != null)
|
|
{
|
|
Unload.onClick.AddListener(() =>
|
|
{
|
|
CarMoverToWeigh.Instance.IsUnload = true;
|
|
MotionFramework.MotionEngine.GetModule<ProcessManager>().HandleClick("true");
|
|
UI_Tips.instance.ShowPanel("卸货成功!", true);
|
|
WeighBridgeCheck.instance.weightips.SetActive(true);
|
|
LoadTriggerNextGuide("关闭");
|
|
});
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 设置物料卡按钮
|
|
/// </summary>
|
|
private void SetupMaterialCardButtons()
|
|
{
|
|
SetupMaterialCardButton();
|
|
SetupHangMaterialCardButton();
|
|
}
|
|
|
|
/// <summary>
|
|
/// 设置物料卡按钮
|
|
/// </summary>
|
|
private void SetupMaterialCardButton()
|
|
{
|
|
if (btnMaterialCard != null && PanelMaterialCard != null)
|
|
{
|
|
btnMaterialCard.onClick.AddListener(() =>
|
|
{
|
|
PanelMaterialCard.gameObject.SetActive(true);
|
|
LoadTriggerNextGuide(btnMaterialCard.name);
|
|
});
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 设置悬挂物料卡按钮
|
|
/// </summary>
|
|
private void SetupHangMaterialCardButton()
|
|
{
|
|
if (btnHangMaterialCard != null)
|
|
{
|
|
btnHangMaterialCard.onClick.AddListener(() =>
|
|
{
|
|
PanelMaterialCard.HangModerController(btnHangMaterialCard.name);
|
|
StartCoroutine(WaitEnable(btnHangMaterialCard, 1.5f));
|
|
});
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 初始化UI
|
|
/// </summary>
|
|
private void InitializeUI()
|
|
{
|
|
if (TextInputQuantityReceivableMaterials != null)
|
|
{
|
|
CombinedClass combinedClass = GameManager.Instance.combinedClass;
|
|
if (combinedClass != null)
|
|
{
|
|
TextInputQuantityReceivableMaterials.text = combinedClass.materialUnit;
|
|
}
|
|
}
|
|
}
|
|
/// <summary>
|
|
/// 添加按钮点击完后延迟后才能再点
|
|
/// </summary>
|
|
/// <param name="bt"></param>
|
|
/// <param name="time"></param>
|
|
/// <returns></returns>
|
|
IEnumerator WaitEnable(Button bt, float time)
|
|
{
|
|
bt.enabled = false;
|
|
yield return new WaitForSeconds(time);
|
|
bt.enabled = true;
|
|
}
|
|
}
|