1
0
Fork 0
mirror of https://github.com/ninjamuffin99/Funkin.git synced 2024-12-30 16:56:47 +00:00
Funkin/source/funkin/play/Fighter.hx

71 lines
1.1 KiB
Haxe
Raw Normal View History

package funkin.play;
2022-03-23 05:18:23 +00:00
import funkin.play.character.BaseCharacter;
import flixel.FlxSprite;
2022-03-23 05:18:23 +00:00
class Fighter extends BaseCharacter
{
public function new(?x:Float = 0, ?y:Float = 0, ?char:String = "pico-fighter")
{
2022-03-23 05:18:23 +00:00
super(char);
this.x = x;
this.y = y;
animation.finishCallback = function(anim:String)
{
switch anim
{
case "punch low" | "punch high" | "block" | 'dodge':
2022-03-23 05:18:23 +00:00
dance(true);
}
};
}
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 05:18:23 +00:00
playAnimation('dodge');
curAction = DODGE;
}
public function block()
{
2022-03-23 05:18:23 +00:00
playAnimation('block');
curAction = BLOCK;
}
public function punch()
{
curAction = PUNCH;
2022-03-23 05:18:23 +00:00
playAnimation('punch ' + (FlxG.random.bool() ? "low" : "high"));
}
}
enum ACTIONS
{
DODGE;
BLOCK;
PUNCH;
}