-
-
Notifications
You must be signed in to change notification settings - Fork 115
/
Copy pathDecoratorRepeatWithWait.cs
45 lines (38 loc) · 1.39 KB
/
DecoratorRepeatWithWait.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
using CleverCrow.Fluid.BTs.Tasks;
using CleverCrow.Fluid.BTs.Trees;
using UnityEngine;
namespace CleverCrow.Fluid.BTs.Samples {
public class DecoratorRepeatWithWait : MonoBehaviour {
[SerializeField]
private BehaviorTree _tree;
[Tooltip("Setting to success will cause the task to succeed")]
[SerializeField]
private bool _isTaskSuccess;
void Start () {
_tree = new BehaviorTreeBuilder(gameObject)
.RepeatForever()
.Parallel()
.Sequence()
.Do(() => TaskStatus.Success)
.WaitTime()
.Do(() => TaskStatus.Success)
.WaitTime()
.End()
.Sequence("Repeat until success is checked")
.Do(() => TaskStatus.Success)
.RepeatUntilSuccess()
.Sequence()
.WaitTime()
.Do(() => _isTaskSuccess ? TaskStatus.Success : TaskStatus.Failure)
.End()
.End()
.End()
.End()
.End()
.Build();
}
void Update () {
_tree.Tick();
}
}
}