2024-06-19 00:07:27 +00:00
|
|
|
package funkin.ui.freeplay;
|
|
|
|
|
|
|
|
import flixel.FlxSprite;
|
|
|
|
import flixel.util.FlxSignal;
|
|
|
|
import funkin.util.assets.FlxAnimationUtil;
|
|
|
|
import funkin.graphics.adobeanimate.FlxAtlasSprite;
|
|
|
|
import funkin.audio.FunkinSound;
|
|
|
|
import flixel.util.FlxTimer;
|
|
|
|
import funkin.data.freeplay.player.PlayerRegistry;
|
|
|
|
import funkin.data.freeplay.player.PlayerData.PlayerFreeplayDJData;
|
|
|
|
import funkin.audio.FunkinSound;
|
|
|
|
import funkin.audio.FlxStreamSound;
|
|
|
|
|
|
|
|
class FreeplayDJ extends FlxAtlasSprite
|
|
|
|
{
|
|
|
|
// Represents the sprite's current status.
|
|
|
|
// Without state machines I would have driven myself crazy years ago.
|
2024-09-01 07:22:34 +00:00
|
|
|
// Made this PRIVATE so we can keep track of everything that can alter the state!
|
|
|
|
// Add a function to this class if you want to edit this value from outside.
|
|
|
|
private var currentState:FreeplayDJState = Intro;
|
2024-06-19 00:07:27 +00:00
|
|
|
|
|
|
|
// A callback activated when the intro animation finishes.
|
|
|
|
public var onIntroDone:FlxSignal = new FlxSignal();
|
|
|
|
|
|
|
|
// A callback activated when the idle easter egg plays.
|
|
|
|
public var onIdleEasterEgg:FlxSignal = new FlxSignal();
|
|
|
|
|
|
|
|
var seenIdleEasterEgg:Bool = false;
|
|
|
|
|
|
|
|
static final IDLE_EGG_PERIOD:Float = 60.0;
|
|
|
|
static final IDLE_CARTOON_PERIOD:Float = 120.0;
|
|
|
|
|
|
|
|
// Time since last special idle animation you.
|
|
|
|
var timeIdling:Float = 0;
|
|
|
|
|
|
|
|
final characterId:String = Constants.DEFAULT_CHARACTER;
|
|
|
|
final playableCharData:PlayerFreeplayDJData;
|
|
|
|
|
|
|
|
public function new(x:Float, y:Float, characterId:String)
|
|
|
|
{
|
|
|
|
this.characterId = characterId;
|
|
|
|
|
|
|
|
var playableChar = PlayerRegistry.instance.fetchEntry(characterId);
|
|
|
|
playableCharData = playableChar.getFreeplayDJData();
|
|
|
|
|
|
|
|
super(x, y, playableCharData.getAtlasPath());
|
|
|
|
|
2024-07-10 21:25:52 +00:00
|
|
|
onAnimationFrame.add(function(name, number) {
|
2024-06-19 00:07:27 +00:00
|
|
|
if (name == playableCharData.getAnimationPrefix('cartoon'))
|
|
|
|
{
|
|
|
|
if (number == playableCharData.getCartoonSoundClickFrame())
|
|
|
|
{
|
|
|
|
FunkinSound.playOnce(Paths.sound('remote_click'));
|
|
|
|
}
|
|
|
|
if (number == playableCharData.getCartoonSoundCartoonFrame())
|
|
|
|
{
|
|
|
|
runTvLogic();
|
|
|
|
}
|
|
|
|
}
|
2024-07-10 21:25:52 +00:00
|
|
|
});
|
2024-06-19 00:07:27 +00:00
|
|
|
|
|
|
|
FlxG.debugger.track(this);
|
|
|
|
FlxG.console.registerObject("dj", this);
|
|
|
|
|
2024-07-10 21:25:52 +00:00
|
|
|
onAnimationComplete.add(onFinishAnim);
|
2024-06-19 00:07:27 +00:00
|
|
|
|
|
|
|
FlxG.console.registerFunction("freeplayCartoon", function() {
|
|
|
|
currentState = Cartoon;
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
override public function listAnimations():Array<String>
|
|
|
|
{
|
|
|
|
var anims:Array<String> = [];
|
|
|
|
@:privateAccess
|
|
|
|
for (animKey in anim.symbolDictionary)
|
|
|
|
{
|
|
|
|
anims.push(animKey.name);
|
|
|
|
}
|
|
|
|
return anims;
|
|
|
|
}
|
|
|
|
|
|
|
|
var lowPumpLoopPoint:Int = 4;
|
|
|
|
|
|
|
|
public override function update(elapsed:Float):Void
|
|
|
|
{
|
|
|
|
super.update(elapsed);
|
|
|
|
|
|
|
|
switch (currentState)
|
|
|
|
{
|
|
|
|
case Intro:
|
|
|
|
// Play the intro animation then leave this state immediately.
|
|
|
|
var animPrefix = playableCharData.getAnimationPrefix('intro');
|
|
|
|
if (getCurrentAnimation() != animPrefix) playFlashAnimation(animPrefix, true);
|
|
|
|
timeIdling = 0;
|
|
|
|
case Idle:
|
|
|
|
// We are in this state the majority of the time.
|
|
|
|
var animPrefix = playableCharData.getAnimationPrefix('idle');
|
|
|
|
if (getCurrentAnimation() != animPrefix)
|
|
|
|
{
|
2024-07-10 21:25:52 +00:00
|
|
|
playFlashAnimation(animPrefix, true, false, true);
|
2024-06-19 00:07:27 +00:00
|
|
|
}
|
|
|
|
|
2024-08-28 10:11:01 +00:00
|
|
|
if (getCurrentAnimation() == animPrefix && this.isLoopComplete())
|
2024-06-19 00:07:27 +00:00
|
|
|
{
|
|
|
|
if (timeIdling >= IDLE_EGG_PERIOD && !seenIdleEasterEgg)
|
|
|
|
{
|
|
|
|
currentState = IdleEasterEgg;
|
|
|
|
}
|
|
|
|
else if (timeIdling >= IDLE_CARTOON_PERIOD)
|
|
|
|
{
|
|
|
|
currentState = Cartoon;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
timeIdling += elapsed;
|
2024-08-28 10:11:01 +00:00
|
|
|
case NewUnlock:
|
|
|
|
var animPrefix = playableCharData.getAnimationPrefix('newUnlock');
|
|
|
|
if (!hasAnimation(animPrefix))
|
|
|
|
{
|
|
|
|
currentState = Idle;
|
|
|
|
}
|
|
|
|
if (getCurrentAnimation() != animPrefix)
|
|
|
|
{
|
|
|
|
playFlashAnimation(animPrefix, true, false, true);
|
|
|
|
}
|
2024-06-19 00:07:27 +00:00
|
|
|
case Confirm:
|
|
|
|
var animPrefix = playableCharData.getAnimationPrefix('confirm');
|
|
|
|
if (getCurrentAnimation() != animPrefix) playFlashAnimation(animPrefix, false);
|
|
|
|
timeIdling = 0;
|
|
|
|
case FistPumpIntro:
|
2024-08-28 10:08:30 +00:00
|
|
|
var animPrefixA = playableCharData.getAnimationPrefix('fistPump');
|
|
|
|
var animPrefixB = playableCharData.getAnimationPrefix('loss');
|
|
|
|
|
|
|
|
if (getCurrentAnimation() == animPrefixA)
|
|
|
|
{
|
|
|
|
var endFrame = playableCharData.getFistPumpIntroEndFrame();
|
|
|
|
if (endFrame > -1 && anim.curFrame >= endFrame)
|
|
|
|
{
|
|
|
|
playFlashAnimation(animPrefixA, true, false, false, playableCharData.getFistPumpIntroStartFrame());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (getCurrentAnimation() == animPrefixB)
|
|
|
|
{
|
2024-09-11 23:37:32 +00:00
|
|
|
trace("Loss Intro");
|
2024-08-28 10:08:30 +00:00
|
|
|
var endFrame = playableCharData.getFistPumpIntroBadEndFrame();
|
|
|
|
if (endFrame > -1 && anim.curFrame >= endFrame)
|
|
|
|
{
|
|
|
|
playFlashAnimation(animPrefixB, true, false, false, playableCharData.getFistPumpIntroBadStartFrame());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
2024-06-19 00:07:27 +00:00
|
|
|
{
|
2024-08-28 10:08:30 +00:00
|
|
|
FlxG.log.warn("Unrecognized animation in FistPumpIntro: " + getCurrentAnimation());
|
2024-06-19 00:07:27 +00:00
|
|
|
}
|
2024-08-28 10:08:30 +00:00
|
|
|
|
2024-06-19 00:07:27 +00:00
|
|
|
case FistPump:
|
2024-08-28 10:08:30 +00:00
|
|
|
var animPrefixA = playableCharData.getAnimationPrefix('fistPump');
|
|
|
|
var animPrefixB = playableCharData.getAnimationPrefix('loss');
|
|
|
|
|
|
|
|
if (getCurrentAnimation() == animPrefixA)
|
|
|
|
{
|
|
|
|
var endFrame = playableCharData.getFistPumpLoopEndFrame();
|
|
|
|
if (endFrame > -1 && anim.curFrame >= endFrame)
|
|
|
|
{
|
|
|
|
playFlashAnimation(animPrefixA, true, false, false, playableCharData.getFistPumpLoopStartFrame());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (getCurrentAnimation() == animPrefixB)
|
|
|
|
{
|
2024-09-11 23:37:32 +00:00
|
|
|
trace("Loss GYATT");
|
2024-08-28 10:08:30 +00:00
|
|
|
var endFrame = playableCharData.getFistPumpLoopBadEndFrame();
|
|
|
|
if (endFrame > -1 && anim.curFrame >= endFrame)
|
|
|
|
{
|
|
|
|
playFlashAnimation(animPrefixB, true, false, false, playableCharData.getFistPumpLoopBadStartFrame());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
FlxG.log.warn("Unrecognized animation in FistPump: " + getCurrentAnimation());
|
|
|
|
}
|
2024-06-19 00:07:27 +00:00
|
|
|
|
|
|
|
case IdleEasterEgg:
|
|
|
|
var animPrefix = playableCharData.getAnimationPrefix('idleEasterEgg');
|
|
|
|
if (getCurrentAnimation() != animPrefix)
|
|
|
|
{
|
|
|
|
onIdleEasterEgg.dispatch();
|
|
|
|
playFlashAnimation(animPrefix, false);
|
|
|
|
seenIdleEasterEgg = true;
|
|
|
|
}
|
|
|
|
timeIdling = 0;
|
|
|
|
case Cartoon:
|
|
|
|
var animPrefix = playableCharData.getAnimationPrefix('cartoon');
|
2024-07-10 21:25:52 +00:00
|
|
|
if (animPrefix == null)
|
|
|
|
{
|
2024-06-20 20:17:53 +00:00
|
|
|
currentState = IdleEasterEgg;
|
2024-07-10 21:25:52 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2024-06-20 20:17:53 +00:00
|
|
|
if (getCurrentAnimation() != animPrefix) playFlashAnimation(animPrefix, true);
|
|
|
|
timeIdling = 0;
|
|
|
|
}
|
2024-06-19 00:07:27 +00:00
|
|
|
default:
|
|
|
|
// I shit myself.
|
|
|
|
}
|
|
|
|
|
2024-08-26 22:01:36 +00:00
|
|
|
#if FEATURE_DEBUG_FUNCTIONS
|
2024-06-19 00:07:27 +00:00
|
|
|
if (FlxG.keys.pressed.CONTROL)
|
|
|
|
{
|
|
|
|
if (FlxG.keys.justPressed.LEFT)
|
|
|
|
{
|
|
|
|
this.offsetX -= FlxG.keys.pressed.ALT ? 0.1 : (FlxG.keys.pressed.SHIFT ? 10.0 : 1.0);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (FlxG.keys.justPressed.RIGHT)
|
|
|
|
{
|
|
|
|
this.offsetX += FlxG.keys.pressed.ALT ? 0.1 : (FlxG.keys.pressed.SHIFT ? 10.0 : 1.0);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (FlxG.keys.justPressed.UP)
|
|
|
|
{
|
|
|
|
this.offsetY -= FlxG.keys.pressed.ALT ? 0.1 : (FlxG.keys.pressed.SHIFT ? 10.0 : 1.0);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (FlxG.keys.justPressed.DOWN)
|
|
|
|
{
|
|
|
|
this.offsetY += FlxG.keys.pressed.ALT ? 0.1 : (FlxG.keys.pressed.SHIFT ? 10.0 : 1.0);
|
|
|
|
}
|
|
|
|
|
2024-07-10 21:25:52 +00:00
|
|
|
if (FlxG.keys.justPressed.C)
|
2024-06-19 00:07:27 +00:00
|
|
|
{
|
|
|
|
currentState = (currentState == Idle ? Cartoon : Idle);
|
|
|
|
}
|
|
|
|
}
|
2024-07-10 21:25:52 +00:00
|
|
|
#end
|
2024-06-19 00:07:27 +00:00
|
|
|
}
|
|
|
|
|
2024-07-10 21:25:52 +00:00
|
|
|
function onFinishAnim(name:String):Void
|
2024-06-19 00:07:27 +00:00
|
|
|
{
|
2024-07-10 21:25:52 +00:00
|
|
|
// var name = anim.curSymbol.name;
|
2024-06-19 00:07:27 +00:00
|
|
|
|
|
|
|
if (name == playableCharData.getAnimationPrefix('intro'))
|
|
|
|
{
|
2024-08-28 10:11:01 +00:00
|
|
|
if (PlayerRegistry.instance.hasNewCharacter())
|
|
|
|
{
|
|
|
|
currentState = NewUnlock;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
currentState = Idle;
|
|
|
|
}
|
2024-06-19 00:07:27 +00:00
|
|
|
onIntroDone.dispatch();
|
|
|
|
}
|
|
|
|
else if (name == playableCharData.getAnimationPrefix('idle'))
|
|
|
|
{
|
|
|
|
// trace('Finished idle');
|
|
|
|
}
|
|
|
|
else if (name == playableCharData.getAnimationPrefix('confirm'))
|
|
|
|
{
|
|
|
|
// trace('Finished confirm');
|
|
|
|
}
|
|
|
|
else if (name == playableCharData.getAnimationPrefix('fistPump'))
|
|
|
|
{
|
|
|
|
// trace('Finished fist pump');
|
|
|
|
currentState = Idle;
|
|
|
|
}
|
|
|
|
else if (name == playableCharData.getAnimationPrefix('idleEasterEgg'))
|
|
|
|
{
|
|
|
|
// trace('Finished spook');
|
|
|
|
currentState = Idle;
|
|
|
|
}
|
|
|
|
else if (name == playableCharData.getAnimationPrefix('loss'))
|
|
|
|
{
|
|
|
|
// trace('Finished loss reaction');
|
|
|
|
currentState = Idle;
|
|
|
|
}
|
|
|
|
else if (name == playableCharData.getAnimationPrefix('cartoon'))
|
|
|
|
{
|
|
|
|
// trace('Finished cartoon');
|
|
|
|
|
|
|
|
var frame:Int = FlxG.random.bool(33) ? playableCharData.getCartoonLoopBlinkFrame() : playableCharData.getCartoonLoopFrame();
|
|
|
|
|
|
|
|
// Character switches channels when the video ends, or at a 10% chance each time his idle loops.
|
|
|
|
if (FlxG.random.bool(5))
|
|
|
|
{
|
|
|
|
frame = playableCharData.getCartoonChannelChangeFrame();
|
|
|
|
// boyfriend switches channel code?
|
|
|
|
// runTvLogic();
|
|
|
|
}
|
|
|
|
trace('Replay idle: ${frame}');
|
2024-08-28 10:11:01 +00:00
|
|
|
playFlashAnimation(playableCharData.getAnimationPrefix('cartoon'), true, false, false, frame);
|
2024-06-19 00:07:27 +00:00
|
|
|
// trace('Finished confirm');
|
|
|
|
}
|
2024-08-28 10:11:01 +00:00
|
|
|
else if (name == playableCharData.getAnimationPrefix('newUnlock'))
|
|
|
|
{
|
|
|
|
// Animation should loop.
|
|
|
|
}
|
|
|
|
else if (name == playableCharData.getAnimationPrefix('charSelect'))
|
|
|
|
{
|
|
|
|
onCharSelectComplete();
|
|
|
|
}
|
2024-06-19 00:07:27 +00:00
|
|
|
else
|
|
|
|
{
|
|
|
|
trace('Finished ${name}');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public function resetAFKTimer():Void
|
|
|
|
{
|
|
|
|
timeIdling = 0;
|
|
|
|
seenIdleEasterEgg = false;
|
|
|
|
}
|
|
|
|
|
2024-08-28 10:11:01 +00:00
|
|
|
/**
|
|
|
|
* Dynamic function, it's actually a variable you can reassign!
|
|
|
|
* `dj.onCharSelectComplete = function() {};`
|
|
|
|
*/
|
|
|
|
public dynamic function onCharSelectComplete():Void
|
|
|
|
{
|
|
|
|
trace('onCharSelectComplete()');
|
|
|
|
}
|
|
|
|
|
2024-06-19 00:07:27 +00:00
|
|
|
var offsetX:Float = 0.0;
|
|
|
|
var offsetY:Float = 0.0;
|
|
|
|
|
|
|
|
var cartoonSnd:Null<FunkinSound> = null;
|
|
|
|
|
|
|
|
public var playingCartoon:Bool = false;
|
|
|
|
|
|
|
|
public function runTvLogic()
|
|
|
|
{
|
|
|
|
if (cartoonSnd == null)
|
|
|
|
{
|
|
|
|
// tv is OFF, but getting turned on
|
|
|
|
FunkinSound.playOnce(Paths.sound('tv_on'), 1.0, function() {
|
|
|
|
loadCartoon();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// plays it smidge after the click
|
|
|
|
FunkinSound.playOnce(Paths.sound('channel_switch'), 1.0, function() {
|
|
|
|
cartoonSnd.destroy();
|
|
|
|
loadCartoon();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
// loadCartoon();
|
|
|
|
}
|
|
|
|
|
|
|
|
function loadCartoon()
|
|
|
|
{
|
|
|
|
cartoonSnd = FunkinSound.load(Paths.sound(getRandomFlashToon()), 1.0, false, true, true, function() {
|
2024-08-28 10:08:30 +00:00
|
|
|
playFlashAnimation(playableCharData.getAnimationPrefix('cartoon'), true, false, false, 60);
|
2024-06-19 00:07:27 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
// Fade out music to 40% volume over 1 second.
|
|
|
|
// This helps make the TV a bit more audible.
|
|
|
|
FlxG.sound.music.fadeOut(1.0, 0.1);
|
|
|
|
|
|
|
|
// Play the cartoon at a random time between the start and 5 seconds from the end.
|
|
|
|
cartoonSnd.time = FlxG.random.float(0, Math.max(cartoonSnd.length - (5 * Constants.MS_PER_SEC), 0.0));
|
|
|
|
}
|
|
|
|
|
|
|
|
final cartoonList:Array<String> = openfl.utils.Assets.list().filter(function(path) return path.startsWith("assets/sounds/cartoons/"));
|
|
|
|
|
|
|
|
function getRandomFlashToon():String
|
|
|
|
{
|
|
|
|
var randomFile = FlxG.random.getObject(cartoonList);
|
|
|
|
|
|
|
|
// Strip folder prefix
|
|
|
|
randomFile = randomFile.replace("assets/sounds/", "");
|
|
|
|
// Strip file extension
|
|
|
|
randomFile = randomFile.substring(0, randomFile.length - 4);
|
|
|
|
|
|
|
|
return randomFile;
|
|
|
|
}
|
|
|
|
|
|
|
|
public function confirm():Void
|
|
|
|
{
|
2024-09-11 10:00:06 +00:00
|
|
|
// We really don't want to play anything but the new character animation here.
|
|
|
|
if (PlayerRegistry.instance.hasNewCharacter())
|
|
|
|
{
|
|
|
|
currentState = NewUnlock;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2024-06-19 00:07:27 +00:00
|
|
|
currentState = Confirm;
|
|
|
|
}
|
|
|
|
|
2024-08-28 10:11:01 +00:00
|
|
|
public function toCharSelect():Void
|
|
|
|
{
|
2024-09-01 07:22:34 +00:00
|
|
|
if (hasAnimation(playableCharData.getAnimationPrefix('charSelect')))
|
2024-08-28 10:11:01 +00:00
|
|
|
{
|
|
|
|
currentState = CharSelect;
|
|
|
|
var animPrefix = playableCharData.getAnimationPrefix('charSelect');
|
|
|
|
playFlashAnimation(animPrefix, true, false, false, 0);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2024-09-04 01:14:57 +00:00
|
|
|
FlxG.log.warn("Freeplay character does not have 'charSelect' animation!");
|
2024-08-28 10:11:01 +00:00
|
|
|
currentState = Confirm;
|
|
|
|
// Call this immediately; otherwise, we get locked out of Character Select.
|
|
|
|
onCharSelectComplete();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-08-28 10:08:30 +00:00
|
|
|
public function fistPumpIntro():Void
|
2024-06-19 00:07:27 +00:00
|
|
|
{
|
2024-09-11 10:00:06 +00:00
|
|
|
// We really don't want to play anything but the new character animation here.
|
|
|
|
if (PlayerRegistry.instance.hasNewCharacter())
|
|
|
|
{
|
|
|
|
currentState = NewUnlock;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2024-06-19 00:07:27 +00:00
|
|
|
currentState = FistPumpIntro;
|
2024-08-28 10:08:30 +00:00
|
|
|
var animPrefix = playableCharData.getAnimationPrefix('fistPump');
|
|
|
|
playFlashAnimation(animPrefix, true, false, false, playableCharData.getFistPumpIntroStartFrame());
|
2024-06-19 00:07:27 +00:00
|
|
|
}
|
|
|
|
|
2024-08-28 10:08:30 +00:00
|
|
|
public function fistPump():Void
|
2024-06-19 00:07:27 +00:00
|
|
|
{
|
2024-09-11 10:00:06 +00:00
|
|
|
// We really don't want to play anything but the new character animation here.
|
|
|
|
if (PlayerRegistry.instance.hasNewCharacter())
|
|
|
|
{
|
|
|
|
currentState = NewUnlock;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2024-06-19 00:07:27 +00:00
|
|
|
currentState = FistPump;
|
2024-08-28 10:08:30 +00:00
|
|
|
var animPrefix = playableCharData.getAnimationPrefix('fistPump');
|
|
|
|
playFlashAnimation(animPrefix, true, false, false, playableCharData.getFistPumpLoopStartFrame());
|
|
|
|
}
|
|
|
|
|
|
|
|
public function fistPumpLossIntro():Void
|
|
|
|
{
|
2024-09-11 10:00:06 +00:00
|
|
|
// We really don't want to play anything but the new character animation here.
|
|
|
|
if (PlayerRegistry.instance.hasNewCharacter())
|
|
|
|
{
|
|
|
|
currentState = NewUnlock;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2024-08-28 10:08:30 +00:00
|
|
|
currentState = FistPumpIntro;
|
|
|
|
var animPrefix = playableCharData.getAnimationPrefix('loss');
|
|
|
|
playFlashAnimation(animPrefix, true, false, false, playableCharData.getFistPumpIntroBadStartFrame());
|
2024-06-19 00:07:27 +00:00
|
|
|
}
|
|
|
|
|
2024-08-28 10:08:30 +00:00
|
|
|
public function fistPumpLoss():Void
|
2024-06-19 00:07:27 +00:00
|
|
|
{
|
2024-09-11 10:00:06 +00:00
|
|
|
// We really don't want to play anything but the new character animation here.
|
|
|
|
if (PlayerRegistry.instance.hasNewCharacter())
|
|
|
|
{
|
|
|
|
currentState = NewUnlock;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2024-06-19 00:07:27 +00:00
|
|
|
currentState = FistPump;
|
2024-08-28 10:08:30 +00:00
|
|
|
var animPrefix = playableCharData.getAnimationPrefix('loss');
|
|
|
|
playFlashAnimation(animPrefix, true, false, false, playableCharData.getFistPumpLoopBadStartFrame());
|
2024-06-19 00:07:27 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
override public function getCurrentAnimation():String
|
|
|
|
{
|
|
|
|
if (this.anim == null || this.anim.curSymbol == null) return "";
|
|
|
|
return this.anim.curSymbol.name;
|
|
|
|
}
|
|
|
|
|
2024-07-10 21:25:52 +00:00
|
|
|
public function playFlashAnimation(id:String, Force:Bool = false, Reverse:Bool = false, Loop:Bool = false, Frame:Int = 0):Void
|
2024-06-19 00:07:27 +00:00
|
|
|
{
|
2024-07-10 21:25:52 +00:00
|
|
|
playAnimation(id, Force, Reverse, Loop, Frame);
|
2024-06-19 00:07:27 +00:00
|
|
|
applyAnimOffset();
|
|
|
|
}
|
|
|
|
|
|
|
|
function applyAnimOffset()
|
|
|
|
{
|
|
|
|
var AnimName = getCurrentAnimation();
|
2024-06-20 20:17:53 +00:00
|
|
|
var daOffset = playableCharData.getAnimationOffsetsByPrefix(AnimName);
|
2024-06-19 00:07:27 +00:00
|
|
|
if (daOffset != null)
|
|
|
|
{
|
|
|
|
var xValue = daOffset[0];
|
|
|
|
var yValue = daOffset[1];
|
|
|
|
if (AnimName == "Boyfriend DJ watchin tv OG")
|
|
|
|
{
|
|
|
|
xValue += offsetX;
|
|
|
|
yValue += offsetY;
|
|
|
|
}
|
|
|
|
|
2024-06-20 20:17:53 +00:00
|
|
|
trace('Successfully applied offset ($AnimName): ' + xValue + ', ' + yValue);
|
2024-06-19 00:07:27 +00:00
|
|
|
offset.set(xValue, yValue);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2024-06-20 20:17:53 +00:00
|
|
|
trace('No offset found ($AnimName), defaulting to: 0, 0');
|
2024-06-19 00:07:27 +00:00
|
|
|
offset.set(0, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
public override function destroy():Void
|
|
|
|
{
|
|
|
|
super.destroy();
|
|
|
|
|
|
|
|
if (cartoonSnd != null)
|
|
|
|
{
|
|
|
|
cartoonSnd.destroy();
|
|
|
|
cartoonSnd = null;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-08-28 10:08:30 +00:00
|
|
|
enum FreeplayDJState
|
2024-06-19 00:07:27 +00:00
|
|
|
{
|
2024-08-28 10:08:30 +00:00
|
|
|
/**
|
|
|
|
* Character enters the frame and transitions to Idle.
|
|
|
|
*/
|
2024-06-19 00:07:27 +00:00
|
|
|
Intro;
|
2024-08-28 10:08:30 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Character loops in idle.
|
|
|
|
*/
|
2024-06-19 00:07:27 +00:00
|
|
|
Idle;
|
2024-08-28 10:08:30 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Plays an easter egg animation after a period in Idle, then reverts to Idle.
|
|
|
|
*/
|
|
|
|
IdleEasterEgg;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Plays an elaborate easter egg animation. Does not revert until another animation is triggered.
|
|
|
|
*/
|
|
|
|
Cartoon;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Player has selected a song.
|
|
|
|
*/
|
2024-06-19 00:07:27 +00:00
|
|
|
Confirm;
|
2024-08-28 10:08:30 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Character preps to play the fist pump animation; plays after the Results screen.
|
|
|
|
* The actual frame label that gets played may vary based on the player's success.
|
|
|
|
*/
|
2024-06-19 00:07:27 +00:00
|
|
|
FistPumpIntro;
|
2024-08-28 10:08:30 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Character plays the fist pump animation.
|
|
|
|
* The actual frame label that gets played may vary based on the player's success.
|
|
|
|
*/
|
2024-06-19 00:07:27 +00:00
|
|
|
FistPump;
|
2024-08-28 10:11:01 +00:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Plays an animation to indicate that the player has a new unlock in Character Select.
|
|
|
|
* Overrides all idle animations as well as the fist pump. Only Confirm and CharSelect will override this.
|
|
|
|
*/
|
|
|
|
NewUnlock;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Plays an animation to transition to the Character Select screen.
|
|
|
|
*/
|
|
|
|
CharSelect;
|
2024-06-19 00:07:27 +00:00
|
|
|
}
|