2023-11-07 09:04:22 +00:00
|
|
|
package funkin.play.components;
|
2022-02-16 21:31:20 +00:00
|
|
|
|
|
|
|
import flixel.FlxSprite;
|
|
|
|
import flixel.group.FlxGroup.FlxTypedGroup;
|
|
|
|
import flixel.tweens.FlxTween;
|
2024-03-03 04:49:27 +00:00
|
|
|
import flixel.util.FlxDirection;
|
2024-02-22 23:55:24 +00:00
|
|
|
import funkin.graphics.FunkinSprite;
|
2022-03-08 08:13:53 +00:00
|
|
|
import funkin.play.PlayState;
|
2024-03-14 01:47:15 +00:00
|
|
|
import funkin.util.TimerUtil;
|
2024-06-20 03:47:11 +00:00
|
|
|
import funkin.util.EaseUtil;
|
2022-02-16 21:31:20 +00:00
|
|
|
|
2024-06-20 03:47:11 +00:00
|
|
|
class PopUpStuff extends FlxTypedGroup<FunkinSprite>
|
2022-02-16 21:31:20 +00:00
|
|
|
{
|
2024-04-09 02:56:28 +00:00
|
|
|
public var offsets:Array<Int> = [0, 0];
|
|
|
|
|
2023-01-23 03:25:45 +00:00
|
|
|
override public function new()
|
|
|
|
{
|
|
|
|
super();
|
|
|
|
}
|
|
|
|
|
2024-06-20 03:47:11 +00:00
|
|
|
public function displayRating(daRating:String):Void
|
2023-01-23 03:25:45 +00:00
|
|
|
{
|
2024-03-14 01:47:15 +00:00
|
|
|
var perfStart:Float = TimerUtil.start();
|
2023-01-23 03:25:45 +00:00
|
|
|
|
2024-02-22 23:55:24 +00:00
|
|
|
if (daRating == null) daRating = "good";
|
2023-01-23 03:25:45 +00:00
|
|
|
|
|
|
|
var ratingPath:String = daRating;
|
|
|
|
|
|
|
|
if (PlayState.instance.currentStageId.startsWith('school')) ratingPath = "weeb/pixelUI/" + ratingPath + "-pixel";
|
|
|
|
|
2024-03-13 01:34:50 +00:00
|
|
|
var rating:FunkinSprite = FunkinSprite.create(0, 0, ratingPath);
|
2024-02-22 23:55:24 +00:00
|
|
|
rating.scrollFactor.set(0.2, 0.2);
|
|
|
|
|
|
|
|
rating.zIndex = 1000;
|
2024-04-09 02:56:28 +00:00
|
|
|
rating.x = (FlxG.width * 0.474) + offsets[0];
|
2024-02-29 02:19:21 +00:00
|
|
|
// rating.x -= FlxG.camera.scroll.x * 0.2;
|
2024-04-09 02:56:28 +00:00
|
|
|
rating.y = (FlxG.camera.height * 0.45 - 60) + offsets[1];
|
2023-01-23 03:25:45 +00:00
|
|
|
rating.acceleration.y = 550;
|
|
|
|
rating.velocity.y -= FlxG.random.int(140, 175);
|
|
|
|
rating.velocity.x -= FlxG.random.int(0, 10);
|
|
|
|
|
|
|
|
add(rating);
|
|
|
|
|
2024-06-20 03:47:11 +00:00
|
|
|
var fadeEase = null;
|
|
|
|
|
2023-01-23 03:25:45 +00:00
|
|
|
if (PlayState.instance.currentStageId.startsWith('school'))
|
|
|
|
{
|
2024-04-29 01:21:44 +00:00
|
|
|
rating.setGraphicSize(Std.int(rating.width * Constants.PIXEL_ART_SCALE * 0.7));
|
2023-06-25 16:36:00 +00:00
|
|
|
rating.antialiasing = false;
|
2024-06-20 03:47:11 +00:00
|
|
|
rating.pixelPerfectRender = true;
|
|
|
|
rating.pixelPerfectPosition = true;
|
|
|
|
fadeEase = EaseUtil.stepped(2);
|
2023-01-23 03:25:45 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2024-04-09 02:56:28 +00:00
|
|
|
rating.setGraphicSize(Std.int(rating.width * 0.65));
|
2023-01-23 03:25:45 +00:00
|
|
|
rating.antialiasing = true;
|
|
|
|
}
|
|
|
|
rating.updateHitbox();
|
|
|
|
|
2024-04-09 02:56:28 +00:00
|
|
|
rating.x -= rating.width / 2;
|
|
|
|
rating.y -= rating.height / 2;
|
|
|
|
|
2023-01-23 03:25:45 +00:00
|
|
|
FlxTween.tween(rating, {alpha: 0}, 0.2,
|
|
|
|
{
|
2023-06-08 20:30:45 +00:00
|
|
|
onComplete: function(tween:FlxTween) {
|
2023-01-23 03:25:45 +00:00
|
|
|
remove(rating, true);
|
|
|
|
rating.destroy();
|
|
|
|
},
|
2024-06-20 03:47:11 +00:00
|
|
|
startDelay: Conductor.instance.beatLengthMs * 0.001,
|
|
|
|
ease: fadeEase
|
2023-01-23 03:25:45 +00:00
|
|
|
});
|
2024-02-22 23:55:24 +00:00
|
|
|
|
2024-03-14 01:47:15 +00:00
|
|
|
trace('displayRating took: ${TimerUtil.seconds(perfStart)}');
|
2023-01-23 03:25:45 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
public function displayCombo(?combo:Int = 0):Int
|
|
|
|
{
|
2024-03-14 01:47:15 +00:00
|
|
|
var perfStart:Float = TimerUtil.start();
|
2024-02-22 23:55:24 +00:00
|
|
|
|
2023-01-23 03:25:45 +00:00
|
|
|
if (combo == null) combo = 0;
|
|
|
|
|
|
|
|
var pixelShitPart1:String = "";
|
|
|
|
var pixelShitPart2:String = '';
|
|
|
|
|
|
|
|
if (PlayState.instance.currentStageId.startsWith('school'))
|
|
|
|
{
|
|
|
|
pixelShitPart1 = 'weeb/pixelUI/';
|
|
|
|
pixelShitPart2 = '-pixel';
|
|
|
|
}
|
2024-03-13 01:34:50 +00:00
|
|
|
var comboSpr:FunkinSprite = FunkinSprite.create(pixelShitPart1 + 'combo' + pixelShitPart2);
|
2024-04-09 02:56:28 +00:00
|
|
|
comboSpr.y = (FlxG.camera.height * 0.44) + offsets[1];
|
|
|
|
comboSpr.x = (FlxG.width * 0.507) + offsets[0];
|
2024-02-29 02:19:21 +00:00
|
|
|
// comboSpr.x -= FlxG.camera.scroll.x * 0.2;
|
2023-01-23 03:25:45 +00:00
|
|
|
|
|
|
|
comboSpr.acceleration.y = 600;
|
|
|
|
comboSpr.velocity.y -= 150;
|
|
|
|
comboSpr.velocity.x += FlxG.random.int(1, 10);
|
|
|
|
|
2024-04-01 17:05:16 +00:00
|
|
|
// add(comboSpr);
|
2023-01-23 03:25:45 +00:00
|
|
|
|
2024-06-20 03:47:11 +00:00
|
|
|
var fadeEase = null;
|
|
|
|
|
2023-01-23 03:25:45 +00:00
|
|
|
if (PlayState.instance.currentStageId.startsWith('school'))
|
|
|
|
{
|
2024-06-20 03:47:11 +00:00
|
|
|
comboSpr.setGraphicSize(Std.int(comboSpr.width * Constants.PIXEL_ART_SCALE * 1));
|
2023-06-25 16:36:00 +00:00
|
|
|
comboSpr.antialiasing = false;
|
2024-06-20 03:47:11 +00:00
|
|
|
comboSpr.pixelPerfectRender = true;
|
|
|
|
comboSpr.pixelPerfectPosition = true;
|
|
|
|
fadeEase = EaseUtil.stepped(2);
|
2023-01-23 03:25:45 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
comboSpr.setGraphicSize(Std.int(comboSpr.width * 0.7));
|
|
|
|
comboSpr.antialiasing = true;
|
|
|
|
}
|
|
|
|
comboSpr.updateHitbox();
|
|
|
|
|
|
|
|
FlxTween.tween(comboSpr, {alpha: 0}, 0.2,
|
|
|
|
{
|
2023-06-08 20:30:45 +00:00
|
|
|
onComplete: function(tween:FlxTween) {
|
2023-01-23 03:25:45 +00:00
|
|
|
remove(comboSpr, true);
|
|
|
|
comboSpr.destroy();
|
|
|
|
},
|
2024-06-20 03:47:11 +00:00
|
|
|
startDelay: Conductor.instance.beatLengthMs * 0.001,
|
|
|
|
ease: fadeEase
|
2023-01-23 03:25:45 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
var seperatedScore:Array<Int> = [];
|
|
|
|
var tempCombo:Int = combo;
|
|
|
|
|
|
|
|
while (tempCombo != 0)
|
|
|
|
{
|
|
|
|
seperatedScore.push(tempCombo % 10);
|
|
|
|
tempCombo = Std.int(tempCombo / 10);
|
|
|
|
}
|
|
|
|
while (seperatedScore.length < 3)
|
|
|
|
seperatedScore.push(0);
|
|
|
|
|
|
|
|
// seperatedScore.reverse();
|
|
|
|
|
|
|
|
var daLoop:Int = 1;
|
|
|
|
for (i in seperatedScore)
|
|
|
|
{
|
2024-03-13 01:34:50 +00:00
|
|
|
var numScore:FunkinSprite = FunkinSprite.create(0, comboSpr.y, pixelShitPart1 + 'num' + Std.int(i) + pixelShitPart2);
|
2023-01-23 03:25:45 +00:00
|
|
|
|
|
|
|
if (PlayState.instance.currentStageId.startsWith('school'))
|
|
|
|
{
|
2024-06-20 03:47:11 +00:00
|
|
|
numScore.setGraphicSize(Std.int(numScore.width * Constants.PIXEL_ART_SCALE * 1));
|
2023-06-25 16:36:00 +00:00
|
|
|
numScore.antialiasing = false;
|
2024-06-20 03:47:11 +00:00
|
|
|
numScore.pixelPerfectRender = true;
|
|
|
|
numScore.pixelPerfectPosition = true;
|
2023-01-23 03:25:45 +00:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2024-04-09 02:56:28 +00:00
|
|
|
numScore.setGraphicSize(Std.int(numScore.width * 0.45));
|
2023-06-25 16:36:00 +00:00
|
|
|
numScore.antialiasing = true;
|
2023-01-23 03:25:45 +00:00
|
|
|
}
|
|
|
|
numScore.updateHitbox();
|
|
|
|
|
2024-04-09 02:56:28 +00:00
|
|
|
numScore.x = comboSpr.x - (36 * daLoop) - 65; //- 90;
|
|
|
|
numScore.acceleration.y = FlxG.random.int(250, 300);
|
|
|
|
numScore.velocity.y -= FlxG.random.int(130, 150);
|
2023-01-23 03:25:45 +00:00
|
|
|
numScore.velocity.x = FlxG.random.float(-5, 5);
|
|
|
|
|
|
|
|
add(numScore);
|
|
|
|
|
|
|
|
FlxTween.tween(numScore, {alpha: 0}, 0.2,
|
|
|
|
{
|
2023-06-08 20:30:45 +00:00
|
|
|
onComplete: function(tween:FlxTween) {
|
2023-01-23 03:25:45 +00:00
|
|
|
remove(numScore, true);
|
|
|
|
numScore.destroy();
|
|
|
|
},
|
2024-06-20 03:47:11 +00:00
|
|
|
startDelay: Conductor.instance.beatLengthMs * 0.002,
|
|
|
|
ease: fadeEase
|
2023-01-23 03:25:45 +00:00
|
|
|
});
|
|
|
|
|
|
|
|
daLoop++;
|
|
|
|
}
|
|
|
|
|
2024-03-14 01:47:15 +00:00
|
|
|
trace('displayCombo took: ${TimerUtil.seconds(perfStart)}');
|
2024-02-22 23:55:24 +00:00
|
|
|
|
2023-01-23 03:25:45 +00:00
|
|
|
return combo;
|
|
|
|
}
|
2022-02-16 21:31:20 +00:00
|
|
|
}
|