46 lines
1.2 KiB
C#
46 lines
1.2 KiB
C#
|
|
using NodeCanvas.DialogueTrees;
|
|
using NodeCanvas.Framework;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using Unity.VisualScripting;
|
|
using UnityEngine;
|
|
|
|
namespace Ether
|
|
{
|
|
public enum NPCFunctionType
|
|
{
|
|
Dialogue,
|
|
}
|
|
|
|
[RequireComponent(typeof(Rigidbody2D))]
|
|
public class NPCController : MonoBehaviour
|
|
{
|
|
Blackboard blackboard;
|
|
private DialogueTreeController dialogueTree;
|
|
|
|
private Canvas NPCCanvas;
|
|
|
|
private Transform NPCFunction;
|
|
|
|
private void Start()
|
|
{
|
|
dialogueTree = GetComponent<DialogueTreeController>();
|
|
blackboard = GetComponent<Blackboard>();
|
|
NPCCanvas = transform.Find("NPCCanvas").GetComponent<Canvas>();
|
|
NPCFunction = NPCCanvas.transform.Find("NPCFunction");
|
|
|
|
ButtonEx dialogueBtn = NPCFunction.Find("DialogueBtn").GetComponent<ButtonEx>();
|
|
dialogueBtn.OnClick.AddListener(() =>
|
|
{
|
|
blackboard.SetVariableValue("state", 2);
|
|
});
|
|
}
|
|
|
|
public void SetNPCFunction(bool isShow, NPCFunctionType type = NPCFunctionType.Dialogue)
|
|
{
|
|
NPCFunction.gameObject.SetActive(isShow);
|
|
}
|
|
}
|
|
}
|