2022-03-08 03:13:53 -05:00
|
|
|
package funkin.play;
|
2022-02-18 16:29:29 -05:00
|
|
|
|
2022-03-23 01:18:23 -04:00
|
|
|
import funkin.play.character.BaseCharacter;
|
2022-02-18 16:29:29 -05:00
|
|
|
import flixel.FlxSprite;
|
|
|
|
|
2022-03-23 01:18:23 -04:00
|
|
|
class Fighter extends BaseCharacter
|
2022-02-18 16:29:29 -05:00
|
|
|
{
|
2023-01-22 22:25:45 -05:00
|
|
|
public function new(?x:Float = 0, ?y:Float = 0, ?char:String = "pico-fighter")
|
|
|
|
{
|
2023-02-21 20:58:15 -05:00
|
|
|
super(char, Custom);
|
2023-01-22 22:25:45 -05:00
|
|
|
this.x = x;
|
|
|
|
this.y = y;
|
2022-02-18 16:29:29 -05:00
|
|
|
|
2023-02-21 20:58:15 -05:00
|
|
|
animation.finishCallback = function(anim:String) {
|
2023-01-22 22:25:45 -05:00
|
|
|
switch anim
|
|
|
|
{
|
|
|
|
case "punch low" | "punch high" | "block" | 'dodge':
|
|
|
|
dance(true);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
2022-02-18 16:29:29 -05:00
|
|
|
|
2023-01-22 22:25:45 -05:00
|
|
|
public var actions:Array<ACTIONS> = [PUNCH, BLOCK, DODGE];
|
2022-02-18 16:29:29 -05:00
|
|
|
|
2023-01-22 22:25:45 -05:00
|
|
|
public function doSomething(?forceAction:ACTIONS)
|
|
|
|
{
|
|
|
|
var daAction:ACTIONS = FlxG.random.getObject(actions);
|
2022-02-18 16:29:29 -05:00
|
|
|
|
2023-01-22 22:25:45 -05:00
|
|
|
if (forceAction != null) daAction = forceAction;
|
2022-02-18 16:29:29 -05:00
|
|
|
|
2023-01-22 22:25:45 -05:00
|
|
|
switch (daAction)
|
|
|
|
{
|
|
|
|
case PUNCH:
|
|
|
|
punch();
|
|
|
|
case BLOCK:
|
|
|
|
block();
|
|
|
|
case DODGE:
|
|
|
|
dodge();
|
|
|
|
}
|
|
|
|
}
|
2022-02-18 16:29:29 -05:00
|
|
|
|
2023-01-22 22:25:45 -05:00
|
|
|
public var curAction:ACTIONS = DODGE;
|
2022-02-18 16:29:29 -05:00
|
|
|
|
2023-01-22 22:25:45 -05:00
|
|
|
function dodge()
|
|
|
|
{
|
|
|
|
playAnimation('dodge');
|
|
|
|
curAction = DODGE;
|
|
|
|
}
|
2022-02-18 16:29:29 -05:00
|
|
|
|
2023-01-22 22:25:45 -05:00
|
|
|
public function block()
|
|
|
|
{
|
|
|
|
playAnimation('block');
|
|
|
|
curAction = BLOCK;
|
|
|
|
}
|
2022-02-18 16:29:29 -05:00
|
|
|
|
2023-01-22 22:25:45 -05:00
|
|
|
public function punch()
|
|
|
|
{
|
|
|
|
curAction = PUNCH;
|
|
|
|
playAnimation('punch ' + (FlxG.random.bool() ? "low" : "high"));
|
|
|
|
}
|
2022-02-18 16:29:29 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
enum ACTIONS
|
|
|
|
{
|
2023-01-22 22:25:45 -05:00
|
|
|
DODGE;
|
|
|
|
BLOCK;
|
|
|
|
PUNCH;
|
2022-02-18 16:29:29 -05:00
|
|
|
}
|