Added Behavior Graph asset for Unity
This commit is contained in:
@@ -0,0 +1,66 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
namespace BehaviorTree
|
||||
{
|
||||
public class Tree : MonoBehaviour
|
||||
{
|
||||
private Node _rootNode;
|
||||
|
||||
private void OnEnable()
|
||||
{
|
||||
_rootNode = new Selector(new List<Node>{});
|
||||
Status status = _rootNode.Start();
|
||||
Debug.Log(status);
|
||||
|
||||
switch (status)
|
||||
{
|
||||
case Status.Success:
|
||||
break;
|
||||
case Status.Failure:
|
||||
break;
|
||||
case Status.Running:
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
}
|
||||
|
||||
private void OnDisable()
|
||||
{
|
||||
Status status = _rootNode?.End() ?? Status.Failure;
|
||||
|
||||
switch (status)
|
||||
{
|
||||
case Status.Success:
|
||||
break;
|
||||
case Status.Failure:
|
||||
break;
|
||||
case Status.Running:
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
|
||||
_rootNode = null;
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
Status status = _rootNode?.Update() ?? Status.Failure;
|
||||
|
||||
switch (status)
|
||||
{
|
||||
case Status.Success:
|
||||
break;
|
||||
case Status.Failure:
|
||||
break;
|
||||
case Status.Running:
|
||||
break;
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user