// ***********************************************************************
// Assembly : Game
// Author : Kimch
// Created : 2020-11-30
// Description :
// Last Modified By :
// Last Modified On :
// ***********************************************************************
//
//
// ***********************************************************************
using System.Collections;
using System.Collections.Generic;
#if BT_AI
using BehaviorDesigner.Runtime;
#endif
using UnityEngine;
namespace G
{
///
/// 类功能描述
///
public class Cha_AI : MonoBehaviour
{
#region Field
#endregion
#region Property
#if BT_AI
///
///
///
public BehaviorTree behaviorTree
{
get;
private set;
}
#endif
#endregion
#region Method
#if BT_AI
///
///
///
///
public void InitBehaviorTree(ExternalBehaviorTree externalBehaviorTree)
{
behaviorTree = this.gameObject.AddComponent();
behaviorTree.ExternalBehavior = externalBehaviorTree;
}
public void SetVariable(string name, SharedVariable value)
{
behaviorTree.SetVariable(name, value);
}
public void SetVariableValue(string name, object value)
{
behaviorTree.SetVariableValue(name, value);
}
public void StartAI()
{
if (behaviorTree)
StartCoroutine(nameof(AICoroutine));
}
public void StopAI()
{
}
private IEnumerator AICoroutine()
{
yield return new WaitForSeconds(0.1f);
while (true)
{
UpdateAI();
yield return new WaitForSeconds(0.5f);
}
}
private void UpdateAI()
{
BehaviorManager.instance.EnableBehavior(behaviorTree);
}
#endif
#endregion
#region Unity
// Use this for initialization
private void Start()
{
}
// Update is called once per frame
private void Update()
{
}
#endregion
}
}