-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathFrontBackSideToSide.cs
127 lines (114 loc) · 4.14 KB
/
FrontBackSideToSide.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
114
115
116
117
118
119
120
121
122
123
124
125
126
127
// by MDS
using UnityEngine;
namespace HutongGames.PlayMaker.Actions
{
[ActionCategory(ActionCategory.Vector3)]
[Tooltip("Gets a position relative to a target object or position.")]
public class FrontBackSideToSide : FsmStateAction
{
public FsmGameObject target;
public FsmVector3 targetV3;
public enum locale { Front, Back, Right, Left, Up, Down }
public locale theLocation;
public FsmBool random;
public FsmFloat distanceMultiplier;
public FsmVector3 location;
public bool everyFrame;
private int eValue;
public override void Reset()
{
everyFrame = false;
}
public override void OnEnter()
{
DoFrontBackS();
if (!everyFrame)
{
Finish();
}
}
public override void OnUpdate()
{
DoFrontBackS();
}
void DoFrontBackS()
{
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;
}
}
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;
}
}
}
}
}