Tz2/Assets/Zion/Scripts/CheckGoods.cs

305 lines
8.7 KiB
C#

using DefaultNamespace.ProcessMode;
using Framework.Manager;
using HighlightPlus;
using System.Collections;
using System.Collections.Generic;
using DefaultNamespace;
using MotionFramework;
using UnityEngine;
using UnityEngine.EventSystems;
using UnityEngine.UI;
using static InterfaceManager;
public class CheckGoods : MonoBehaviour
{
[Header("物资_品类一致")] public GameObject objPLGood;
[Header("物资_品类不一致")] public GameObject objPLBad;
[Header("物资_厂家一致")] public GameObject objCJGood;
[Header("物资_厂家不一致")] public GameObject objCJBad;
[Header("物资_好")] public GameObject objGood;
[Header("物资_坏")] public GameObject objBad;
[Header("坏物资组")] public List<GameObject> objBadlist;
//指向箭头
[Header("UI_指向箭头")] public GameObject arrowObj;
//指向箭头
[Header("UI_指向箭头")] public GameObject arrowObj2;
//界面
public GameObject UI;
/// <summary>
/// 标牌
/// </summary>
[Header("UI_标牌")] public Transform scutcheon;
/// <summary>
/// 标牌2
/// </summary>
[Header("UI_标牌")] public Transform scutcheon2;
/// <summary>
/// 一致品类UI高度
/// </summary>
public float PosYGood;
/// <summary>
/// 不一致品类UI高度
/// </summary>
public float PosYBad;
/// <summary>
/// 物资_品类一致
/// </summary>
public Toggle TogPLGood, TogPLBad;
/// <summary>
/// 物资_品类一致
/// </summary>
public Transform HighlightObjTogPLGood, HighlightObjTogPLBad;
/// <summary>
/// 物资_厂家一致
/// </summary>
public Toggle TogCJGood, TogCJBad;
/// <summary>
/// 物资_厂家一致
/// </summary>
public Transform HighlightObjTogCJGood, HighlightObjTogCJBad;
/// <summary>
/// 物资_好
/// </summary>
public Toggle TogGood, TogBad;
/// <summary>
/// 物资_好
/// </summary>
public Transform HighlightObjTogGood, HighlightObjTogBad;
/// <summary>
/// 关闭按钮
/// </summary>
public Button btnClose;
public Button btnClose1;
/// <summary>
///
/// </summary>
public Button btnOpen;
/// <summary>
/// 是否完成检查
/// </summary>
public bool isCheckCompleted;
/// <summary>
/// 物品的BoxCollider
/// </summary>
private BoxCollider boxCollider;
/// <summary>
/// 是否码放完毕
/// </summary>
public bool IsTask;
/// <summary>
/// 厂家
/// </summary>
public Text Manufacturer;
/// <summary>
/// 高亮插件
/// </summary>
public HighlightEffect highlightEffect;
public GameObject plane1;
public GameObject plane2;
public Toggle tog1;
public Toggle tog2;
// Start is called before the first frame update
// void Start()
// {
// Init();
// }
public void Init()
{
// //物资品类是否一致
// objPLGood.SetActive(true); //一致
// objPLBad.SetActive(false); //不一致
// //物资厂家是否一致
// objCJGood.SetActive(true); //一致
// objCJBad.SetActive(false); //不一致
// //物资是否好
// objGood.SetActive(true); //好
// objBad.SetActive(false); //坏
boxCollider = GetComponent<BoxCollider>();
highlightEffect = GetComponent<HighlightEffect>();
if (boxCollider != null)
boxCollider.enabled = false;
//检查外观
//标牌高度调节
if (MotionEngine.GetModule<GlobalDataStorage>().ExamName == "领用出库")
{
UI = plane2;
}
//scutcheon.transform.localPosition = new Vector3(0, PosYGood, 0);
// if (objPLGood.activeSelf)
// scutcheon.transform.localPosition = new Vector3(0, PosYGood, 0);
// else if (objPLBad.activeSelf)
// scutcheon.transform.localPosition = new Vector3(0, PosYBad, 0);
LookTrans.Instance.TransAddTransform(UI.transform.parent);
if (scutcheon2 != null)
{
LookTrans.Instance.TransAddTransform(scutcheon2);
}
btnOpen.onClick.AddListener(() =>
{
UI.SetActive(true);
arrowObj.SetActive(false);
});
btnClose.onClick.AddListener(() =>
{
List<string> list = new List<string>();
//list.Add(TogPLGood.isOn.ToString());
//list.Add(TogPLBad.isOn.ToString());
//MotionEngine.GetModule<ProcessManager>().HandleClick(list);
UI.SetActive(false);
isCheckCompleted = true;
ModerController.Instance.CheckGoodsCheckCompleted();
HighlightObjTogPLGood.gameObject.SetActive(false);
HighlightObjTogPLBad.gameObject.SetActive(false);
HighlightObjTogCJGood.gameObject.SetActive(false);
HighlightObjTogCJBad.gameObject.SetActive(false);
HighlightObjTogGood.gameObject.SetActive(false);
HighlightObjTogBad.gameObject.SetActive(false);
});
if (btnClose1 != null)
{
btnClose1.onClick.AddListener(() =>
{
List<string> list = new List<string>();
list.Add(tog1.isOn.ToString());
list.Add(tog2.isOn.ToString());
if (MotionEngine.GetModule<ProcessManager>().HandleClick(list))
{
UI.SetActive(false);
isCheckCompleted = true;
TutorialGuideManager.Instance.NextGuideIn();
}
});
}
}
/// <summary>
/// 完成上架
/// </summary>
public void OnShelve()
{
scutcheon.gameObject.SetActive(false);
if (boxCollider != null)
boxCollider.enabled = true;
gameObject.SetActive(false);
}
/// <summary>
/// 外部调用,电力电缆使用
/// </summary>
public void CheckOut()
{
ModerController.Instance.CheckGoodsCheckCompleted();
}
private void OnMouseDown()
{
//鼠标在UI上return
if (EventSystem.current.IsPointerOverGameObject())
return;
transform.localEulerAngles = transform.localEulerAngles + new Vector3(0, 90, 0);
IsTask = !IsTask;
highlightEffect.SetHighlighted(!IsTask);
}
//物资码放完毕
public void OnGoodsCode()
{
if (boxCollider != null)
boxCollider.enabled = false;
}
/// <summary>
/// 品类一致
/// </summary>
/// <param name="_name"></param>
public void PLCJ(string pl, string cj, string obj)
{
if (pl == "一致")
{
objPLGood.SetActive(true);
objPLBad.SetActive(false);
if (MotionFramework.MotionEngine.GetModule<ProcessManager>()._currentMode == ProcessMode. && TutorialGuideManager.Instance)
{
HighlightObjTogPLGood.gameObject.SetActive(true);
}
}
else
{
objPLGood.SetActive(false);
objPLBad.SetActive(true);
if (MotionFramework.MotionEngine.GetModule<ProcessManager>()._currentMode == ProcessMode. && TutorialGuideManager.Instance)
{
HighlightObjTogPLBad.gameObject.SetActive(true);
}
}
if (cj == "一致")
{
objCJGood.SetActive(true);
objCJBad.SetActive(false);
if (MotionFramework.MotionEngine.GetModule<ProcessManager>()._currentMode == ProcessMode. && TutorialGuideManager.Instance)
{
HighlightObjTogCJGood.gameObject.SetActive(true);
}
}
else
{
objCJGood.SetActive(false);
objCJBad.SetActive(true);
if (MotionFramework.MotionEngine.GetModule<ProcessManager>()._currentMode == ProcessMode. && TutorialGuideManager.Instance)
{
HighlightObjTogCJBad.gameObject.SetActive(true);
}
}
if (obj == "完好")
{
objGood.SetActive(true);
objBad.SetActive(false);
if (MotionFramework.MotionEngine.GetModule<ProcessManager>()._currentMode == ProcessMode. && TutorialGuideManager.Instance)
{
HighlightObjTogGood.gameObject.SetActive(true);
}
}
else
{
// objGood.SetActive(false);
// objBad.SetActive(true);
if (MotionFramework.MotionEngine.GetModule<ProcessManager>()._currentMode == ProcessMode. && TutorialGuideManager.Instance)
{
HighlightObjTogBad.gameObject.SetActive(true);
}
}
}
}