-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathPlayerCharacter.hx
183 lines (138 loc) · 4.14 KB
/
PlayerCharacter.hx
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
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
package ;
import flixel.FlxBasic;
import flixel.FlxG;
import flixel.FlxObject;
import flixel.util.FlxColor;
import AbilityBase;
import Controller;
import UIFrame;
import WorldWideKeys;
class PlayerConstants
{
public inline static var kSpeed : Int = 150;
public inline static var kMaxSpeed : Int = 200;
public inline static var kRunSpeed : Int = 300;
public inline static var kRunMax : Int = 400;
public inline static var kJump : Int = 200;
public inline static var kHoverUp : Int = 250;
}
/**
* ...
* @author ...
*/
class PlayerCharacter extends AbilityBase
{
var _controller : Controller = null;
var _reincarnateButton : ActionButton = null;
//var _skillScreen : abilitySelectMenu = new abilitySelectMenu();
var _inSkillMenu : Bool = false;
public function new(X:Float=0, Y:Float=0, controls:Controller)
{
super(X, Y);
PhasesThroughWalls = false;
_controller = controls;
_reincarnateButton = _controller.SetButton(WorldWideKeys.Reincarnate, null, TOGGLE);
SetMove(new MoveProfile(WALK, PlayerConstants.kSpeed, PlayerConstants.kMaxSpeed));
<<<<<<< HEAD
AbilitySet(WALLJUMP, HOVER, null);
=======
AbilitySet(WALLJUMP, CLIMB, null);
>>>>>>> origin/master
makeGraphic(30,30, FlxColor.SALMON);
}
/**
* Add an ability to the character's list. This doesn't, presently, check to make
* sure that abilities aren't tied to the same trigger, so watch out!
* @param newSkill The AbilityDirectory name of the new skill to add
* @param triggerCheck When the ability should be triggered. Use Permanent
* to make it always triggered.
*/
override function addAbility(newSkill : AbilityDirectory,
triggerCheck : Void -> Bool,
?baseStrength : Int = 0,
?maxStrength : Int = 0) : Void
{
// If a specific baseStrength or maxStrength are entered...
if ((baseStrength != 0) || (maxStrength != 0))
{
// Use them.
super.addAbility(newSkill, triggerCheck, baseStrength, maxStrength);
}
// Otherwise, use defaults from the constants list.
else
{
switch (newSkill)
{
case RUN:
super.addAbility(RUN, triggerCheck,
PlayerConstants.kRunSpeed, PlayerConstants.kRunMax);
case CLIMB:
super.addAbility(CLIMB, triggerCheck,
PlayerConstants.kSpeed, PlayerConstants.kMaxSpeed);
case JUMP:
super.addAbility(JUMP, triggerCheck, PlayerConstants.kJump);
case WALLJUMP:
super.addAbility(WALLJUMP, triggerCheck, PlayerConstants.kJump);
case HOVER:
super.addAbility(HOVER, triggerCheck, PlayerConstants.kHoverUp);
// For abilities that don't require strengths, just call the super.
default:
super.addAbility(newSkill, triggerCheck);
}
}
}
override public function moveCheck() : Void
{
MoveDirection = _controller.GetDirection();
super.moveCheck();
}
public function AbilitySet (primeAbility : AbilityDirectory,
secondAbility : AbilityDirectory,
passives : Array<AbilityDirectory>) : Void
{
var _actionOneButton = _controller.SetButton(WorldWideKeys.ActionOne, null, KeyStyle.HOLD);
var _actionTwoButton = _controller.SetButton(WorldWideKeys.ActionTwo, null, KeyStyle.HOLD);
ClearAbilities();
addAbility(primeAbility, _actionOneButton.GetKeyInput);
addAbility(secondAbility, _actionTwoButton.GetKeyInput);
if (passives != null)
{
for (ability in passives)
{
addAbility(ability, Permanent);
}
}
}
/**
* Update the character.
*/
override public function update() : Void
{
_inSkillMenu = _reincarnateButton.GetKeyInput();
// If in ability-swapping mode, only update that and not the player character.
if (_inSkillMenu)
{
//_skillScreen.update();
// If skillScreen finishes
//if (_skillScreen.Finished)
//{
//SetMove(_skillScreen.Movement);
//AbilitySet(_skillScreen.AbilityOne, _skillScreen.AbilityTwo, _skillScreen.Passives);
//_inSkillMenu = false;
//}
}
// Otherwise, perform a standard update.
else
{
super.update();
//_inSkillMenu = _reincarnateButton.GetKeyInput();
}
}
/**
* Destroy this character.
*/
override public function destroy():Void
{
super.destroy();
}
}