You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

62 lines
1.2 KiB

using SampleBehavirTree;
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEditor;
using UnityEngine;
public class SampleBehaviourTree : MonoBehaviour
{
private BehaviourNode root;
// Start is called before the first frame update
void Start()
{
root = CreatBehaviour();
ExcuteBehaviour();
}
// Update is called once per frame
void Update()
{
}
[ContextMenu("执行行为树")]
void ExcuteBehaviour()
{
StartCoroutine(c_ExcuteBehaviour());
}
IEnumerator c_ExcuteBehaviour()
{
yield return StartCoroutine(root.Execute());
}
public BehaviourNode CreatBehaviour()
{
var selector = new Selector();
var sequence_1 = new Sequence();
var condition1 = new condition_Behavir();
var action1 = new DebugTest();
action1.info = "测试行为树";
//添加条件
sequence_1.nodes.Add(condition1);
//添加行为
sequence_1.nodes.Add(action1);
//
selector.nodes.Add(sequence_1);
condition1.ctrlTrans = this.transform;
//不同类别Action 的参数配置
return selector;
}
}