2022-03-08 08:13:53 +00:00
|
|
|
package funkin;
|
2021-07-15 00:32:09 +00:00
|
|
|
|
|
|
|
import flixel.FlxSprite;
|
|
|
|
import flixel.group.FlxGroup.FlxTypedGroup;
|
|
|
|
import flixel.group.FlxSpriteGroup.FlxTypedSpriteGroup;
|
2021-07-15 22:45:25 +00:00
|
|
|
import flixel.util.FlxTimer;
|
2021-07-15 00:32:09 +00:00
|
|
|
|
2023-06-15 04:12:35 +00:00
|
|
|
class ComboMilestone extends FlxTypedSpriteGroup<FlxSprite>
|
2021-07-15 00:32:09 +00:00
|
|
|
{
|
2023-01-23 03:25:45 +00:00
|
|
|
var effectStuff:FlxSprite;
|
|
|
|
|
|
|
|
var wasComboSetup:Bool = false;
|
|
|
|
var daCombo:Int = 0;
|
|
|
|
|
2023-06-15 04:12:35 +00:00
|
|
|
var grpNumbers:FlxTypedGroup<ComboMilestoneNumber>;
|
2023-01-23 03:25:45 +00:00
|
|
|
|
|
|
|
var onScreenTime:Float = 0;
|
|
|
|
|
|
|
|
public function new(x:Float, y:Float, daCombo:Int = 0)
|
|
|
|
{
|
|
|
|
super(x, y);
|
|
|
|
|
|
|
|
this.daCombo = daCombo;
|
|
|
|
|
|
|
|
effectStuff = new FlxSprite(0, 0);
|
2023-06-15 04:12:35 +00:00
|
|
|
effectStuff.frames = Paths.getSparrowAtlas('comboMilestone');
|
2023-01-23 03:25:45 +00:00
|
|
|
effectStuff.animation.addByPrefix('funny', 'NOTE COMBO animation', 24, false);
|
|
|
|
effectStuff.animation.play('funny');
|
2023-06-08 20:30:45 +00:00
|
|
|
effectStuff.animation.finishCallback = function(nameThing) {
|
2023-01-23 03:25:45 +00:00
|
|
|
kill();
|
|
|
|
};
|
|
|
|
effectStuff.setGraphicSize(Std.int(effectStuff.width * 0.7));
|
|
|
|
add(effectStuff);
|
|
|
|
|
2023-06-15 04:12:35 +00:00
|
|
|
grpNumbers = new FlxTypedGroup<ComboMilestoneNumber>();
|
2023-01-23 03:25:45 +00:00
|
|
|
// add(grpNumbers);
|
|
|
|
}
|
|
|
|
|
|
|
|
public function forceFinish():Void
|
|
|
|
{
|
|
|
|
if (onScreenTime < 0.9)
|
|
|
|
{
|
2023-06-15 04:12:35 +00:00
|
|
|
new FlxTimer().start((Conductor.beatLengthMs / 1000) * 0.25, function(tmr) {
|
2023-01-23 03:25:45 +00:00
|
|
|
forceFinish();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
else
|
|
|
|
effectStuff.animation.play('funny', true, false, 18);
|
|
|
|
}
|
|
|
|
|
|
|
|
override function update(elapsed:Float)
|
|
|
|
{
|
|
|
|
onScreenTime += elapsed;
|
|
|
|
|
|
|
|
if (effectStuff.animation.curAnim.curFrame == 17) effectStuff.animation.pause();
|
|
|
|
|
|
|
|
if (effectStuff.animation.curAnim.curFrame == 2 && !wasComboSetup)
|
|
|
|
{
|
|
|
|
setupCombo(daCombo);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (effectStuff.animation.curAnim.curFrame == 18)
|
|
|
|
{
|
2023-06-15 04:12:35 +00:00
|
|
|
grpNumbers.forEach(function(spr:ComboMilestoneNumber) {
|
2023-01-23 03:25:45 +00:00
|
|
|
spr.animation.reset();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
if (effectStuff.animation.curAnim.curFrame == 20)
|
|
|
|
{
|
2023-06-15 04:12:35 +00:00
|
|
|
grpNumbers.forEach(function(spr:ComboMilestoneNumber) {
|
2023-01-23 03:25:45 +00:00
|
|
|
spr.kill();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
super.update(elapsed);
|
|
|
|
}
|
|
|
|
|
|
|
|
function setupCombo(daCombo:Int)
|
|
|
|
{
|
|
|
|
FlxG.sound.play(Paths.sound('comboSound'));
|
|
|
|
|
|
|
|
wasComboSetup = true;
|
|
|
|
var loopNum:Int = 0;
|
|
|
|
|
|
|
|
while (daCombo > 0)
|
|
|
|
{
|
2023-06-15 04:12:35 +00:00
|
|
|
var comboNumber:ComboMilestoneNumber = new ComboMilestoneNumber(450 - (100 * loopNum), 20 + 14 * loopNum, daCombo % 10);
|
2023-01-23 03:25:45 +00:00
|
|
|
comboNumber.setGraphicSize(Std.int(comboNumber.width * 0.7));
|
|
|
|
grpNumbers.add(comboNumber);
|
|
|
|
add(comboNumber);
|
|
|
|
|
|
|
|
loopNum += 1;
|
|
|
|
|
|
|
|
daCombo = Math.floor(daCombo / 10);
|
|
|
|
}
|
|
|
|
}
|
2021-07-15 00:32:09 +00:00
|
|
|
}
|
|
|
|
|
2023-06-15 04:12:35 +00:00
|
|
|
class ComboMilestoneNumber extends FlxSprite
|
2021-07-15 00:32:09 +00:00
|
|
|
{
|
2023-01-23 03:25:45 +00:00
|
|
|
public function new(x:Float, y:Float, digit:Int)
|
|
|
|
{
|
|
|
|
super(x - 20, y);
|
|
|
|
|
|
|
|
var stringNum:String = Std.string(digit);
|
2023-06-15 04:12:35 +00:00
|
|
|
frames = Paths.getSparrowAtlas('comboMilestoneNumbers');
|
2023-01-23 03:25:45 +00:00
|
|
|
animation.addByPrefix(stringNum, stringNum, 24, false);
|
|
|
|
animation.play(stringNum);
|
|
|
|
updateHitbox();
|
|
|
|
}
|
|
|
|
|
|
|
|
var shiftedX:Bool = false;
|
|
|
|
|
|
|
|
override function update(elapsed:Float)
|
|
|
|
{
|
|
|
|
if (animation.curAnim.curFrame == 2 && !shiftedX)
|
|
|
|
{
|
|
|
|
shiftedX = true;
|
|
|
|
x += 20;
|
|
|
|
}
|
|
|
|
|
|
|
|
super.update(elapsed);
|
|
|
|
}
|
2021-07-15 00:32:09 +00:00
|
|
|
}
|