forked from super-jenius/Untold
-
Notifications
You must be signed in to change notification settings - Fork 0
/
AnimationTier.as
133 lines (117 loc) · 3.54 KB
/
AnimationTier.as
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
128
129
130
131
132
133
// Apply animations/emotes to characters or NPCs
import com.GameInterface.Game.Character;
class AnimationTier extends BaseTier
{
public var m_Animations:Array;
public var m_AnimTarget:String;
public var m_TargetQty:Number;
public var m_PlayField:Number;
public var m_X:Number;
public var m_Y:Number;
public var m_Z:Number;
public var m_Distance:Number; // distance from X,Z
public var m_yDistance:Number; // distance from Y
public var m_AnimTargets:Object;
public var m_AnimNo:Number;
public function AnimationTier()
{
m_SkipPrev = true;
m_NoBell = true;
}
public function LoadXML(tierNode:XMLNode)
{
ULog.Info("AnimationTier.LoadXML()");
// Set targets
this.SetTarget(tierNode.attributes.animTarget, tierNode.attributes.targetQty);
// Set location for NPCs to target
this.SetLocation(tierNode.attributes.playField, tierNode.attributes.x, tierNode.attributes.y, tierNode.attributes.z,
tierNode.attributes.distance, tierNode.attributes.yDistance);
// Add animation
for (var i = 0; i < tierNode.childNodes.length; i++) {
var animNode:XMLNode = tierNode.childNodes[i];
if (animNode) {
var animName:String = animNode.attributes.name;
var duration:Number = Number(animNode.attributes.duration);
this.AddAnimation(animName, duration);
}
}
ULog.Info("AnimationTier.LoadXML(): Complete");
}
public function SetTarget(animTarget:String, targetQty:Number)
{
m_AnimTarget = animTarget.toLowerCase();
m_TargetQty = targetQty;
}
public function SetLocation(playField:Number, x:Number, y:Number, z:Number, distance:Number, yDistance:Number)
{
//ULog.Info("AnimationTier.SetLocation(): playField=" + playField.toString() + ", x=" + x.toString() + ", y=" + y.toString() + ", z=" + z.toString());
m_PlayField = playField;
m_X = x;
m_Y = y;
m_Z = z;
m_Distance = distance;
m_yDistance = yDistance;
}
public function AddAnimation(animName:String, duration:Number)
{
if (m_Animations == undefined) {
m_Animations = new Array();
}
m_Animations.push([animName, duration]);
}
public function StartTier()
{
ULog.Info("AnimationTier.StartTier()");
this.SelectTargets();
if (m_AnimTargets != undefined) {
m_AnimNo = 0;
this.ProcessAnimations();
}
// End tier as soon as animations are started
this.EndTier();
}
public function SelectTargets()
{
// Select targets for animations
m_AnimTargets = new Object();
var selector:Selector = new Selector();
switch (m_AnimTarget)
{
case undefined:
break;
case "player" :
m_AnimTargets["player"] = selector.SelectPlayer();
break;
case "target" :
m_AnimTargets["target"] = selector.SelectFriendlyTarget();
break;
default :
selector.SetLocation(m_PlayField, m_X, m_Y, m_Z, m_Distance, m_yDistance);
m_AnimTargets = selector.SelectNPCs(m_AnimTarget, m_TargetQty);
break;
}
}
public function ProcessAnimations()
{
ULog.Info("AnimationTier.ProcessAnimations()");
var currentAnim = m_Animations[m_AnimNo];
if (currentAnim != undefined) {
var animName:String = currentAnim[0];
var duration:Number = currentAnim[1];
if (isNaN(duration) == true)
{
duration = 0;
}
var target:Character;
for (var prop in m_AnimTargets) {
target = m_AnimTargets[prop];
ULog.Info("AnimationTier.ProcessAnimations(): prop=" + prop + " target=" + target.GetName() + " animName=" + animName + " duration=" + duration);
target.SetBaseAnim(animName);
}
}
m_AnimNo++;
if (m_AnimNo < m_Animations.length) {
_global.setTimeout(this, "ProcessAnimations", (duration * 1000));
}
}
}