using DefaultNamespace;
using DefaultNamespace.ProcessMode;
using Framework.Manager;
using MotionFramework;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using UnityEngine;
using UnityEngine.UI;
using static InterfaceManager;
///
/// 存储区控制脚本
///
public class TakePositionController : MonoBehaviour
{
public static TakePositionController Instance;
///
/// 物资码放
///
public Button btnMaterialStacking;
///
/// 物资码放完毕_确定按钮高亮提示
///
public Transform btnMaterialStackingHighlightObj;
///
/// 上架点位
///
public List TakePositionList = new List();
///
/// 上架点位列表
///
public List takePositionList = new List();
///
/// 箭头
///
public List Arrorow = new List();
public GameObject btnShangjia;
private void Awake()
{
Instance = this;
btnMaterialStacking = FindObjectByName("btnMaterialStacking");
btnMaterialStackingHighlightObj = FindObjectByName("btnMaterialStackingHighlightObj");
}
// Start is called before the first frame update
void Start()
{
if (btnMaterialStacking != null)
{
btnMaterialStacking.onClick.AddListener(() =>
{
btnMaterialStacking.enabled = false;
StartCoroutine(MaterialStacking());
});
}
takePositionList = transform.GetComponentsInChildren().ToList();
if (GameManager.Instance.combinedClass.TargetLocation != "")
{
for (int i = 0; i < takePositionList.Count; i++)
{
//目标点位
string targetLocation = GameManager.Instance.combinedClass.TargetLocation.Split('-')[0];
if (takePositionList[i].name.Contains(targetLocation))
{
takePositionList[i].GetComponentInChildren().text = GameManager.Instance.combinedClass.TargetLocation;
}
}
}
}
///
/// 物资上架
///
///
public IEnumerator TakePosition(List goods)
{
TakePositionList = goods;
List checkGoods = ModerController.Instance.checkGoods;
checkGoods.ForEach(x => x.OnShelve());
yield return new WaitForSeconds(1);
if (TakePositionList.Count > checkGoods.Count)
{
for (int i = 0; i < checkGoods.Count; i++)
{
if (checkGoods[i].name.Contains("电力电缆"))
{
switch (i)
{
case 0:
checkGoods[i].transform.position = TakePositionList[6].position;
checkGoods[i].transform.eulerAngles = TakePositionList[6].eulerAngles;
checkGoods[i].gameObject.SetActive(true);
break;
case 1:
checkGoods[i].transform.position = TakePositionList[14].position;
checkGoods[i].transform.eulerAngles = TakePositionList[14].eulerAngles;
checkGoods[i].gameObject.SetActive(true);
break;
case 2:
checkGoods[i].transform.position = TakePositionList[18].position;
checkGoods[i].transform.eulerAngles = TakePositionList[18].eulerAngles;
checkGoods[i].gameObject.SetActive(true);
break;
case 3:
checkGoods[i].transform.position = TakePositionList[26].position;
checkGoods[i].transform.eulerAngles = TakePositionList[26].eulerAngles;
checkGoods[i].gameObject.SetActive(true);
break;
case 4:
checkGoods[i].transform.position = TakePositionList[2].position;
checkGoods[i].transform.eulerAngles = TakePositionList[2].eulerAngles;
checkGoods[i].gameObject.SetActive(true);
break;
case 5:
checkGoods[i].transform.position = TakePositionList[12].position;
checkGoods[i].transform.eulerAngles = TakePositionList[12].eulerAngles;
checkGoods[i].gameObject.SetActive(true);
break;
}
}
else
{
checkGoods[i].transform.position = TakePositionList[i].position;
checkGoods[i].transform.eulerAngles = TakePositionList[i].eulerAngles;
checkGoods[i].gameObject.SetActive(true);
}
}
}
if (MotionEngine.GetModule().ExamName.Contains("不可用办理实物退库") ||
MotionEngine.GetModule().ExamName.Contains("废旧物资入库"))
{
btnMaterialStacking.transform.parent.gameObject.SetActive(false);
}
else
{
btnMaterialStacking.transform.parent.gameObject.SetActive(true);
}
}
///
/// 物资码放
///
///
private IEnumerator MaterialStacking()
{
yield return new WaitForSeconds(0.1f);
List materialList = new List();
List checkGoods = ModerController.Instance.checkGoods;
for (int i = 0; i < checkGoods.Count; i++)
{
string isTask = checkGoods[i].IsTask ? "true" : "false";
materialList.Add(isTask);
}
yield return new WaitForSeconds(0.1f);
if (!MotionEngine.GetModule().ExamName.Contains("库存物资报废流程"))
{
bool IsTask = MotionFramework.MotionEngine.GetModule().HandleClick(materialList);
}
btnMaterialStacking.transform.parent.gameObject.SetActive(false);
checkGoods.ForEach(x => x.OnGoodsCode());
if (MotionEngine.GetModule().ExamName.Contains("到货验收入库") ||
MotionEngine.GetModule().ExamName.Contains("调拨物资入库") ||
MotionEngine.GetModule().ExamName.Contains("退料物资入库") ||
MotionEngine.GetModule().ExamName.Contains("办理实物退库") ||
MotionEngine.GetModule().ExamName.Contains("退出退役代保管入库"))
{
TutorialGuideManager.Instance.TriggerNextGuide();
}
else
{
TutorialGuideManager.Instance.ShowMaskdon_tNext();
}
btnMaterialStacking.enabled = true;
}
public void Shangjia()
{
if (MotionFramework.MotionEngine.GetModule()._currentMode == ProcessMode.教学模式 ||
MotionFramework.MotionEngine.GetModule()._currentMode == ProcessMode.课程预览)
{
if (MotionEngine.GetModule().ExamName.Contains("代保管物资出库"))
{
btnShangjia.SetActive(true);
}
}
}
public void Xiajia()
{
if (MotionFramework.MotionEngine.GetModule()._currentMode == ProcessMode.教学模式 ||
MotionFramework.MotionEngine.GetModule()._currentMode == ProcessMode.课程预览)
{
if (MotionEngine.GetModule().ExamName.Contains("代保管物资出库"))
{
btnShangjia.SetActive(false);
}
}
}
///
/// 物资码放 显示引导(外部调用)
///
public void GuideShow()
{
if (MotionFramework.MotionEngine.GetModule()._currentMode == ProcessMode.教学模式 ||
MotionFramework.MotionEngine.GetModule()._currentMode == ProcessMode.课程预览)
{
//获取当前目标点位
//string guideName = GameManager.Instance.combinedClass.TargetLocation;
string guideName = GameManager.Instance.combinedClass.TargetLocation.Split('-')[0];
TakePosition takePosition = takePositionList.Find(x => x.name.Contains(guideName));
//TakePosition takePosition = takePositionList.Find(x => x.name.Contains(guideName));
if (takePosition != null)
{
takePosition.guide.SetActive(true);
}
for (int i = 0; i < Arrorow.Count; i++)
{
if (Arrorow[i].name.Contains(guideName))
{
Arrorow[i].SetActive(true);
}
}
btnMaterialStackingHighlightObj.gameObject.SetActive(true);
}
}
}