104 lines
3.3 KiB
C#
104 lines
3.3 KiB
C#
using DefaultNamespace.Dto;
|
|
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;
|
|
|
|
/// <summary>
|
|
/// 仓位
|
|
/// </summary>
|
|
public class TakePosition : MonoBehaviour
|
|
{
|
|
/// <summary>
|
|
/// 仓位显示
|
|
/// </summary>
|
|
public Text takePositionText;
|
|
/// <summary>
|
|
///
|
|
/// </summary>
|
|
public TextMeshProUGUI takePositionTextTMP;
|
|
/// <summary>
|
|
/// 物资上架
|
|
/// </summary>
|
|
public Button takePositionButton;
|
|
/// <summary>
|
|
/// 是否已经上架
|
|
/// </summary>
|
|
private bool IsTake = false;
|
|
/// <summary>
|
|
/// 上架点位父物体
|
|
/// </summary>
|
|
public Transform TakePositionListParent;
|
|
/// <summary>
|
|
/// 上架点位
|
|
/// </summary>
|
|
public List<Transform> TakePositionList = new List<Transform>();
|
|
/// <summary>
|
|
/// 引导提示
|
|
/// </summary>
|
|
public GameObject guide;
|
|
|
|
// Start is called before the first frame update
|
|
void Start()
|
|
{
|
|
takePositionText = GetComponentInChildren<Text>();
|
|
takePositionTextTMP = GetComponentInChildren<TextMeshProUGUI>();
|
|
//不包含自身
|
|
|
|
takePositionButton = GetComponentInChildren<Button>();
|
|
if (TakePositionListParent != null)
|
|
{
|
|
//TakePositionList= TakePositionListParent.GetComponentsInChildren<Transform>().ToList();
|
|
TakePositionList = TakePositionListParent.GetComponentsInChildren<Transform>().ToList().Where(t => t != TakePositionListParent).ToList();
|
|
}
|
|
if (takePositionText != null)
|
|
{
|
|
takePositionText.text = transform.name;
|
|
}
|
|
if (GameManager.Instance.combinedClass.TargetLocation.Contains(transform.name.Split('-')[0]))
|
|
{
|
|
transform.name = GameManager.Instance.combinedClass.TargetLocation;
|
|
}
|
|
if (takePositionButton != null && takePositionTextTMP != null && TakePositionList.Count > 0)
|
|
{
|
|
takePositionButton.onClick.AddListener(() =>
|
|
{
|
|
if (!IsTake)
|
|
{
|
|
bool isTake = MotionFramework.MotionEngine.GetModule<ProcessManager>().HandleClick(transform.name);
|
|
if (isTake)
|
|
{
|
|
IsTake = true;
|
|
takePositionTextTMP.text = "物资已上架";
|
|
guide.SetActive(false);
|
|
Invoke(nameof(TakePositionShow), 2f);
|
|
StartCoroutine(TakePositionController.Instance.TakePosition(TakePositionList));
|
|
if (MotionEngine.GetModule<GlobalDataStorage>().ExamName.Contains("库存物资报废"))
|
|
{
|
|
TutorialGuideManager.Instance.TriggerNextGuide();
|
|
}
|
|
}
|
|
else
|
|
{
|
|
takePositionTextTMP.text = "物资上架失败";
|
|
}
|
|
}
|
|
});
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// 物资上架按钮隐藏
|
|
/// </summary>
|
|
public void TakePositionShow()
|
|
{
|
|
takePositionButton.gameObject.SetActive(false);
|
|
}
|
|
}
|