123 lines
3.0 KiB
C#
123 lines
3.0 KiB
C#
using MotionFramework;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using DefaultNamespace.ProcessMode;
|
|
using UnityEngine;
|
|
using UnityEngine.UI;
|
|
|
|
public class ToolManager : MonoBehaviour
|
|
{
|
|
//public GameObject toolPrefab; // 要生成的工具预制体
|
|
public Transform generateArea; // 生成区域的Transform
|
|
|
|
private GenerateArea generateAreaScript;
|
|
|
|
public GameObject ui;
|
|
public Button processBt;
|
|
/// <summary>
|
|
/// 放回背包按钮
|
|
/// </summary>
|
|
public Button PutBack;
|
|
public GameObject[] Tool;
|
|
|
|
bool inthis;
|
|
|
|
void Start()
|
|
{
|
|
|
|
//inthis = true;
|
|
generateAreaScript = generateArea.GetComponent<GenerateArea>();
|
|
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);
|
|
}
|
|
if (Tool[6].activeInHierarchy)
|
|
{
|
|
Tool[6].gameObject.SetActive(false);
|
|
}
|
|
});
|
|
processBt.onClick.AddListener(delegate
|
|
{
|
|
|
|
ui.SetActive(false);
|
|
});
|
|
MotionEngine.GetModule<ToolsPackManager>().OnStringEvent += HandleStringEvent;
|
|
|
|
}
|
|
private void UIEvent()
|
|
{
|
|
ui.SetActive(true);
|
|
}
|
|
|
|
|
|
|
|
private void HandleStringEvent(string message)
|
|
{
|
|
if (generateAreaScript.IsPlayerInArea())
|
|
{
|
|
if (message == "梯子")
|
|
{
|
|
Tool[0].gameObject.SetActive(true);
|
|
Ladder.instance.Init();
|
|
//Ladder.instance.smr.SetBlendShapeWeight(0, 0);
|
|
}
|
|
if (message == "工作证")
|
|
{
|
|
Tool[1].gameObject.SetActive(true);
|
|
}
|
|
if (message == "剥线钳")
|
|
{
|
|
Tool[2].gameObject.SetActive(true);
|
|
}
|
|
if (message == "验电笔")
|
|
{
|
|
Tool[3].gameObject.SetActive(true);
|
|
}
|
|
if (message == "螺丝刀")
|
|
{
|
|
Tool[4].gameObject.SetActive(true);
|
|
}
|
|
if (message == "绝缘胶带")
|
|
{
|
|
Tool[5].gameObject.SetActive(true);
|
|
}
|
|
|
|
if (message == "l型集中器")
|
|
{
|
|
Tool[6].gameObject.SetActive(true);
|
|
}
|
|
if (message == "盒装封印")
|
|
{
|
|
Tool[7].gameObject.SetActive(true);
|
|
}
|
|
|
|
Debug.Log("Received message: " + message);
|
|
}
|
|
} }
|
|
|