IndieGame/client/Assets/Scripts/Component/NPC/NPCController.cs

46 lines
1.2 KiB
C#
Raw Normal View History

2024-10-11 10:12:15 +08:00

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);
}
}
}