-
Notifications
You must be signed in to change notification settings - Fork 9
/
Copy pathsuperFlanker.cs
113 lines (102 loc) · 3.53 KB
/
superFlanker.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
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
using UnityEngine;
using BehaviorDesigner.Runtime;
using BehaviorDesigner.Runtime.Tasks;
public class superFlanker : Action
{
public SharedGameObject target;
public SharedVector3 targetV3;
public enum locale { Front, Back, Right, Left, Up, Down }
public locale theLocation;
public SharedBool random;
public SharedFloat distanceMultiplier;
public SharedVector3 location;
public bool everyFrame;
private int eValue;
public override void OnReset()
{
target = null;
targetV3 = null;
location = null;
}
public override TaskStatus OnUpdate()
{
if (target.Value != null)
{
Transform targetTrans = target.Value.gameObject.transform;
Vector3 targetPos = target.Value.gameObject.transform.position;
if (random.Value == true)
{
eValue = Random.Range(0, 6);
} else
{
eValue = (int)theLocation;
}
switch (eValue)
{
case 0:
//front
location.Value = targetPos + targetTrans.forward * distanceMultiplier.Value;
break;
case 1:
//back
location.Value = targetPos + -targetTrans.forward * distanceMultiplier.Value;
break;
case 2:
//right
location.Value = targetPos + targetTrans.right * distanceMultiplier.Value;
break;
case 3:
//left
location.Value = targetPos + -targetTrans.right * distanceMultiplier.Value;
break;
case 4:
//up
location.Value = targetPos + targetTrans.up * distanceMultiplier.Value;
break;
case 5:
//down
location.Value = targetPos + -targetTrans.up * distanceMultiplier.Value;
break;
}
return TaskStatus.Success;
}
else
{
if (random.Value == true)
{
eValue = Random.Range(0, 6);
} else
{
eValue = (int)theLocation;
}
switch (eValue)
{
case 0:
//front
location.Value = targetV3.Value + Vector3.forward * distanceMultiplier.Value;
break;
case 1:
//back
location.Value = targetV3.Value + Vector3.back * distanceMultiplier.Value;
break;
case 2:
//right
location.Value = targetV3.Value + Vector3.right * distanceMultiplier.Value;
break;
case 3:
//left
location.Value = targetV3.Value + Vector3.left * distanceMultiplier.Value;
break;
case 4:
//up
location.Value = targetV3.Value + Vector3.up * distanceMultiplier.Value;
break;
case 5:
//down
location.Value = targetV3.Value + Vector3.down * distanceMultiplier.Value;
break;
}
return TaskStatus.Success;
}
}
}