130 lines
3.3 KiB
C#
130 lines
3.3 KiB
C#
using MotionFramework;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using DefaultNamespace.ProcessMode;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
/// <summary>
|
|
/// 点击背包中的物品显示物体
|
|
/// </summary>
|
|
public class DisplayKnapsackObjects : MonoBehaviour
|
|
{
|
|
public GameObject[] Tool;
|
|
|
|
public GameObject ui;
|
|
public Button processBt;
|
|
/// <summary>
|
|
/// 放回背包按钮
|
|
/// </summary>
|
|
public Button PutBack;
|
|
|
|
/// <summary>
|
|
/// 收回工具按钮
|
|
/// </summary>
|
|
public Button[] RetractToolBtn;
|
|
// Start is called before the first frame update
|
|
void Start()
|
|
{
|
|
MotionEngine.GetModule<ToolsPackManager>().OnStringEvent += HandleStringEvent;
|
|
MotionEngine.GetModule<AnimationProcessManager>().OnUIEvent += UIEvent;
|
|
|
|
|
|
PutBack.onClick.AddListener(() => {
|
|
//梯子
|
|
if (Tool[0].activeInHierarchy)
|
|
{
|
|
Tool[0].gameObject.SetActive(false);
|
|
Ladder.instance.closed();
|
|
}
|
|
//工作证
|
|
if (Tool[1].activeInHierarchy)
|
|
{
|
|
Tool[1].gameObject.SetActive(false);
|
|
}
|
|
//剥线钳
|
|
if (Tool[2].activeInHierarchy)
|
|
{
|
|
Tool[2].gameObject.SetActive(false);
|
|
}
|
|
//验电笔
|
|
if (Tool[3].activeInHierarchy)
|
|
{
|
|
Tool[3].gameObject.SetActive(false);
|
|
}
|
|
//螺丝刀
|
|
if (Tool[4].activeInHierarchy)
|
|
{
|
|
Tool[4].gameObject.SetActive(false);
|
|
}
|
|
//绝缘胶带
|
|
if (Tool[5].activeInHierarchy)
|
|
{
|
|
Tool[5].gameObject.SetActive(false);
|
|
}
|
|
//l型集中器
|
|
if (Tool[6].activeInHierarchy)
|
|
{
|
|
Tool[6].gameObject.SetActive(false);
|
|
}
|
|
});
|
|
processBt.onClick.AddListener(delegate
|
|
{
|
|
|
|
ui.SetActive(false);
|
|
});
|
|
}
|
|
|
|
private void UIEvent()
|
|
{
|
|
ui.SetActive(true);
|
|
}
|
|
|
|
|
|
private void HandleStringEvent(string message)
|
|
{
|
|
if (message == "梯子")
|
|
{
|
|
Tool[0].gameObject.SetActive(true);
|
|
Ladder.instance.Init();
|
|
}
|
|
if (message == "工作证")
|
|
{
|
|
Tool[1].gameObject.SetActive(true);
|
|
}
|
|
if (message == "剥线钳")
|
|
{
|
|
Tool[2].gameObject.SetActive(true);
|
|
RetractToolBtn[0].gameObject.SetActive(true);
|
|
}
|
|
if (message == "验电笔")
|
|
{
|
|
RetractToolBtn[1].gameObject.SetActive(true);
|
|
Tool[3].gameObject.SetActive(true);
|
|
}
|
|
if (message == "螺丝刀")
|
|
{
|
|
RetractToolBtn[2].gameObject.SetActive(true);
|
|
Tool[4].gameObject.SetActive(true);
|
|
}
|
|
if (message == "绝缘胶带")
|
|
{
|
|
RetractToolBtn[3].gameObject.SetActive(true);
|
|
Tool[5].gameObject.SetActive(true);
|
|
}
|
|
|
|
if (message == "l型集中器")
|
|
{
|
|
RetractToolBtn[4].gameObject.SetActive(true);
|
|
Tool[6].gameObject.SetActive(true);
|
|
}
|
|
if (message == "盒装封印")
|
|
{
|
|
RetractToolBtn[5].gameObject.SetActive(true);
|
|
Tool[7].gameObject.SetActive(true);
|
|
}
|
|
|
|
Debug.Log("Received message: " + message);
|
|
}
|
|
}
|