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
|
|
|
{
|
|
|
|
public function new(?x:Float = 0, ?y:Float = 0, ?char:String = "pico-fighter")
|
|
|
|
{
|
2022-03-23 01:18:23 -04:00
|
|
|
super(char);
|
|
|
|
this.x = x;
|
|
|
|
this.y = y;
|
2022-02-18 16:29:29 -05:00
|
|
|
|
|
|
|
animation.finishCallback = function(anim:String)
|
|
|
|
{
|
|
|
|
switch anim
|
|
|
|
{
|
|
|
|
case "punch low" | "punch high" | "block" | 'dodge':
|
2022-03-23 01:18:23 -04:00
|
|
|
dance(true);
|
2022-02-18 16:29:29 -05:00
|
|
|
}
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
public var actions:Array<ACTIONS> = [PUNCH, BLOCK, DODGE];
|
|
|
|
|
|
|
|
public function doSomething(?forceAction:ACTIONS)
|
|
|
|
{
|
|
|
|
var daAction:ACTIONS = FlxG.random.getObject(actions);
|
|
|
|
|
|
|
|
if (forceAction != null)
|
|
|
|
daAction = forceAction;
|
|
|
|
|
|
|
|
switch (daAction)
|
|
|
|
{
|
|
|
|
case PUNCH:
|
|
|
|
punch();
|
|
|
|
case BLOCK:
|
|
|
|
block();
|
|
|
|
case DODGE:
|
|
|
|
dodge();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public var curAction:ACTIONS = DODGE;
|
|
|
|
|
|
|
|
function dodge()
|
|
|
|
{
|
2022-03-23 01:18:23 -04:00
|
|
|
playAnimation('dodge');
|
2022-02-18 16:29:29 -05:00
|
|
|
curAction = DODGE;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function block()
|
|
|
|
{
|
2022-03-23 01:18:23 -04:00
|
|
|
playAnimation('block');
|
2022-02-18 16:29:29 -05:00
|
|
|
curAction = BLOCK;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function punch()
|
|
|
|
{
|
|
|
|
curAction = PUNCH;
|
2022-03-23 01:18:23 -04:00
|
|
|
playAnimation('punch ' + (FlxG.random.bool() ? "low" : "high"));
|
2022-02-18 16:29:29 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
enum ACTIONS
|
|
|
|
{
|
|
|
|
DODGE;
|
|
|
|
BLOCK;
|
|
|
|
PUNCH;
|
|
|
|
}
|