2023-11-07 04:04:22 -05:00
|
|
|
package funkin.play.components;
|
2022-02-16 16:31:20 -05:00
|
|
|
|
|
|
|
import flixel.FlxSprite;
|
|
|
|
import flixel.group.FlxGroup.FlxTypedGroup;
|
|
|
|
import flixel.tweens.FlxTween;
|
2024-03-02 23:49:27 -05:00
|
|
|
import flixel.util.FlxDirection;
|
2024-02-22 18:55:24 -05:00
|
|
|
import funkin.graphics.FunkinSprite;
|
2022-03-08 03:13:53 -05:00
|
|
|
import funkin.play.PlayState;
|
2024-03-13 21:47:15 -04:00
|
|
|
import funkin.util.TimerUtil;
|
2024-06-19 23:47:11 -04:00
|
|
|
import funkin.util.EaseUtil;
|
2024-07-13 15:45:58 -04:00
|
|
|
import openfl.utils.Assets;
|
2024-07-16 13:53:12 -04:00
|
|
|
import funkin.data.notestyle.NoteStyleRegistry;
|
|
|
|
import funkin.play.notes.notestyle.NoteStyle;
|
2022-02-16 16:31:20 -05:00
|
|
|
|
2024-07-28 17:10:32 -04:00
|
|
|
@:nullSafety
|
2024-06-19 23:47:11 -04:00
|
|
|
class PopUpStuff extends FlxTypedGroup<FunkinSprite>
|
2022-02-16 16:31:20 -05:00
|
|
|
{
|
2024-07-13 15:45:58 -04:00
|
|
|
/**
|
2024-07-28 17:10:32 -04:00
|
|
|
* The current note style to use. This determines which graphics to display.
|
|
|
|
* For example, Week 6 uses the `pixel` note style, and mods can create their own.
|
2024-07-13 15:45:58 -04:00
|
|
|
*/
|
2024-07-28 17:10:32 -04:00
|
|
|
var noteStyle:NoteStyle;
|
2024-07-17 16:19:18 -04:00
|
|
|
|
2024-07-28 17:10:32 -04:00
|
|
|
override public function new(noteStyle:NoteStyle)
|
2023-01-22 22:25:45 -05:00
|
|
|
{
|
|
|
|
super();
|
2024-07-16 13:53:12 -04:00
|
|
|
|
2024-07-28 17:10:32 -04:00
|
|
|
this.noteStyle = noteStyle;
|
2024-07-13 15:45:58 -04:00
|
|
|
}
|
|
|
|
|
2024-07-28 17:10:32 -04:00
|
|
|
public function displayRating(daRating:Null<String>)
|
2023-01-22 22:25:45 -05:00
|
|
|
{
|
2024-02-22 18:55:24 -05:00
|
|
|
if (daRating == null) daRating = "good";
|
2023-01-22 22:25:45 -05:00
|
|
|
|
2024-07-28 17:10:32 -04:00
|
|
|
var rating:Null<FunkinSprite> = noteStyle.buildJudgementSprite(daRating);
|
|
|
|
if (rating == null) return;
|
|
|
|
|
|
|
|
rating.zIndex = 1000;
|
2023-01-22 22:25:45 -05:00
|
|
|
|
2024-07-28 17:10:32 -04:00
|
|
|
rating.x = (FlxG.width * 0.474);
|
|
|
|
rating.x -= rating.width / 2;
|
|
|
|
rating.y = (FlxG.camera.height * 0.45 - 60);
|
|
|
|
rating.y -= rating.height / 2;
|
2023-01-22 22:25:45 -05:00
|
|
|
|
2024-07-28 17:10:32 -04:00
|
|
|
var offsets = noteStyle.getJudgementSpriteOffsets(daRating);
|
|
|
|
rating.x += offsets[0];
|
|
|
|
rating.y += offsets[1];
|
2024-02-22 18:55:24 -05:00
|
|
|
|
2023-01-22 22:25:45 -05:00
|
|
|
rating.acceleration.y = 550;
|
|
|
|
rating.velocity.y -= FlxG.random.int(140, 175);
|
|
|
|
rating.velocity.x -= FlxG.random.int(0, 10);
|
|
|
|
|
|
|
|
add(rating);
|
|
|
|
|
2024-07-28 17:10:32 -04:00
|
|
|
var fadeEase = noteStyle.isJudgementSpritePixel(daRating) ? EaseUtil.stepped(2) : null;
|
2024-04-08 22:56:28 -04:00
|
|
|
|
2023-01-22 22:25:45 -05:00
|
|
|
FlxTween.tween(rating, {alpha: 0}, 0.2,
|
|
|
|
{
|
2023-06-08 16:30:45 -04:00
|
|
|
onComplete: function(tween:FlxTween) {
|
2023-01-22 22:25:45 -05:00
|
|
|
remove(rating, true);
|
|
|
|
rating.destroy();
|
|
|
|
},
|
2024-06-19 23:47:11 -04:00
|
|
|
startDelay: Conductor.instance.beatLengthMs * 0.001,
|
|
|
|
ease: fadeEase
|
2023-01-22 22:25:45 -05:00
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2024-07-28 17:10:32 -04:00
|
|
|
public function displayCombo(combo:Int = 0):Void
|
2023-01-22 22:25:45 -05: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;
|
2024-07-28 17:10:32 -04:00
|
|
|
for (digit in seperatedScore)
|
2023-01-22 22:25:45 -05:00
|
|
|
{
|
2024-07-28 17:10:32 -04:00
|
|
|
var numScore:Null<FunkinSprite> = noteStyle.buildComboNumSprite(digit);
|
|
|
|
if (numScore == null) continue;
|
2023-01-22 22:25:45 -05:00
|
|
|
|
2024-07-28 17:10:32 -04:00
|
|
|
numScore.x = (FlxG.width * 0.507) - (36 * daLoop) - 65;
|
|
|
|
trace('numScore($daLoop) = ${numScore.x}');
|
|
|
|
numScore.y = (FlxG.camera.height * 0.44);
|
|
|
|
|
|
|
|
var offsets = noteStyle.getComboNumSpriteOffsets(digit);
|
|
|
|
numScore.x += offsets[0];
|
|
|
|
numScore.y += offsets[1];
|
2023-01-22 22:25:45 -05:00
|
|
|
|
2024-04-08 22:56:28 -04:00
|
|
|
numScore.acceleration.y = FlxG.random.int(250, 300);
|
|
|
|
numScore.velocity.y -= FlxG.random.int(130, 150);
|
2023-01-22 22:25:45 -05:00
|
|
|
numScore.velocity.x = FlxG.random.float(-5, 5);
|
|
|
|
|
|
|
|
add(numScore);
|
|
|
|
|
2024-07-28 17:10:32 -04:00
|
|
|
var fadeEase = noteStyle.isComboNumSpritePixel(digit) ? EaseUtil.stepped(2) : null;
|
|
|
|
|
2023-01-22 22:25:45 -05:00
|
|
|
FlxTween.tween(numScore, {alpha: 0}, 0.2,
|
|
|
|
{
|
2023-06-08 16:30:45 -04:00
|
|
|
onComplete: function(tween:FlxTween) {
|
2023-01-22 22:25:45 -05:00
|
|
|
remove(numScore, true);
|
|
|
|
numScore.destroy();
|
|
|
|
},
|
2024-06-19 23:47:11 -04:00
|
|
|
startDelay: Conductor.instance.beatLengthMs * 0.002,
|
|
|
|
ease: fadeEase
|
2023-01-22 22:25:45 -05:00
|
|
|
});
|
|
|
|
|
|
|
|
daLoop++;
|
|
|
|
}
|
2024-07-13 15:45:58 -04:00
|
|
|
}
|
2022-02-16 16:31:20 -05:00
|
|
|
}
|