Merge pull request #159 from BeastlyGabi/patch-1
Fix Score being increased while "showRating" is disabled and on sustains
This commit is contained in:
@@ -16,9 +16,13 @@ final class NoteHitEvent extends CancellableEvent {
|
||||
*/
|
||||
public var misses:Bool = true;
|
||||
/**
|
||||
* Whenever a miss should be added.
|
||||
* Whether this hit increases combo.
|
||||
*/
|
||||
public var countAsCombo:Bool = true;
|
||||
/**
|
||||
* Whether this hit increases the score
|
||||
*/
|
||||
public var countScore:Bool = true;
|
||||
/**
|
||||
* Whenever ratings should be shown or not.
|
||||
*/
|
||||
@@ -170,4 +174,4 @@ final class NoteHitEvent extends CancellableEvent {
|
||||
characters = [char];
|
||||
return char;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1456,81 +1456,21 @@ class PlayState extends MusicBeatState
|
||||
scripts.event("onNoteHit", event);
|
||||
|
||||
if (!event.cancelled) {
|
||||
if (event.accuracy != null) {
|
||||
accuracyPressedNotes++;
|
||||
totalAccuracyAmount += event.accuracy;
|
||||
|
||||
updateRating();
|
||||
}
|
||||
if (event.countAsCombo) combo++;
|
||||
|
||||
if (event.showRating || (event.showRating == null && event.player && !note.isSustainNote))
|
||||
{
|
||||
songScore += score;
|
||||
|
||||
var separatedScore:String = Std.string(combo).addZeros(3);
|
||||
|
||||
if (combo == 0 || combo >= 10) {
|
||||
if (combo >= 10) {
|
||||
var comboSpr:FlxSprite = comboGroup.recycleLoop(FlxSprite).loadAnimatedGraphic(Paths.image('${event.ratingPrefix}combo${event.ratingSuffix}'));
|
||||
comboSpr.resetSprite(comboGroup.x, comboGroup.y);
|
||||
comboSpr.acceleration.y = 600;
|
||||
comboSpr.velocity.y -= 150;
|
||||
comboSpr.velocity.x += FlxG.random.int(1, 10);
|
||||
|
||||
comboSpr.scale.set(event.ratingScale, event.ratingScale);
|
||||
comboSpr.antialiasing = event.ratingAntialiasing;
|
||||
|
||||
comboSpr.updateHitbox();
|
||||
|
||||
FlxTween.tween(comboSpr, {alpha: 0}, 0.2, {
|
||||
onComplete: function(tween:FlxTween)
|
||||
{
|
||||
comboSpr.visible = comboSpr.active = false;
|
||||
},
|
||||
startDelay: Conductor.crochet * 0.001
|
||||
});
|
||||
}
|
||||
for (i in 0...separatedScore.length)
|
||||
{
|
||||
var numScore:FlxSprite = comboGroup.recycleLoop(FlxSprite).loadAnimatedGraphic(Paths.image('${event.ratingPrefix}num${separatedScore.charAt(i)}${event.ratingSuffix}'));
|
||||
numScore.resetSprite(comboGroup.x + (43 * i) - 90, comboGroup.y + 80);
|
||||
numScore.antialiasing = event.numAntialiasing;
|
||||
numScore.scale.set(event.numScale, event.numScale);
|
||||
numScore.updateHitbox();
|
||||
|
||||
numScore.acceleration.y = FlxG.random.int(200, 300);
|
||||
numScore.velocity.y -= FlxG.random.int(140, 160);
|
||||
numScore.velocity.x = FlxG.random.float(-5, 5);
|
||||
|
||||
FlxTween.tween(numScore, {alpha: 0}, 0.2, {
|
||||
onComplete: function(tween:FlxTween)
|
||||
{
|
||||
numScore.visible = numScore.active = false;
|
||||
},
|
||||
startDelay: Conductor.crochet * 0.002
|
||||
});
|
||||
}
|
||||
if (!note.isSustainNote) {
|
||||
if (event.countScore) songScore += event.score;
|
||||
if (event.accuracy != null) {
|
||||
accuracyPressedNotes++;
|
||||
totalAccuracyAmount += event.accuracy;
|
||||
updateRating();
|
||||
}
|
||||
if (event.countAsCombo) combo++;
|
||||
|
||||
if (event.showRating || (event.showRating == null && event.player))
|
||||
{
|
||||
displayCombo(event);
|
||||
displayRating(daRating, event);
|
||||
ratingNum += 1;
|
||||
}
|
||||
|
||||
var rating:FlxSprite = comboGroup.recycleLoop(FlxSprite);
|
||||
rating.resetSprite(comboGroup.x + -40, comboGroup.y + -60);
|
||||
rating.loadAnimatedGraphic(Paths.image('${event.ratingPrefix}$daRating${event.ratingSuffix}'));
|
||||
rating.acceleration.y = 550;
|
||||
rating.velocity.y -= FlxG.random.int(140, 175);
|
||||
rating.velocity.x -= FlxG.random.int(0, 10);
|
||||
rating.scale.set(event.ratingScale, event.ratingScale);
|
||||
rating.antialiasing = event.ratingAntialiasing;
|
||||
rating.updateHitbox();
|
||||
|
||||
FlxTween.tween(rating, {alpha: 0}, 0.2, {
|
||||
startDelay: Conductor.crochet * 0.001,
|
||||
onComplete: function(tween:FlxTween) {
|
||||
rating.visible = rating.active = false;
|
||||
}
|
||||
});
|
||||
|
||||
ratingNum += 1;
|
||||
}
|
||||
|
||||
if (strumLine != null) strumLine.addHealth(event.healthGain);
|
||||
@@ -1558,6 +1498,78 @@ class PlayState extends MusicBeatState
|
||||
if (event.deleteNote && !note.isSustainNote) strumLine.deleteNote(note);
|
||||
}
|
||||
|
||||
public function displayRating(myRating:String, ?evt:NoteHitEvent = null):Void {
|
||||
var pre:String = evt != null ? evt.ratingPrefix : "";
|
||||
var suf:String = evt != null ? evt.ratingSuffix : "";
|
||||
|
||||
var rating:FlxSprite = comboGroup.recycleLoop(FlxSprite);
|
||||
rating.resetSprite(comboGroup.x + -40, comboGroup.y + -60);
|
||||
rating.loadAnimatedGraphic(Paths.image('${pre}${myRating}${suf}'));
|
||||
rating.acceleration.y = 550;
|
||||
rating.velocity.y -= FlxG.random.int(140, 175);
|
||||
rating.velocity.x -= FlxG.random.int(0, 10);
|
||||
rating.scale.set(event.ratingScale, event.ratingScale);
|
||||
rating.antialiasing = event.ratingAntialiasing;
|
||||
rating.updateHitbox();
|
||||
|
||||
FlxTween.tween(rating, {alpha: 0}, 0.2, {
|
||||
startDelay: Conductor.crochet * 0.001,
|
||||
onComplete: function(tween:FlxTween) {
|
||||
rating.kill();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public function displayCombo(?evt:NoteHitEvent = null):Void {
|
||||
var pre:String = evt != null ? evt.ratingPrefix : "";
|
||||
var suf:String = evt != null ? evt.ratingSuffix : "";
|
||||
|
||||
var separatedScore:String = Std.string(combo).addZeros(3);
|
||||
|
||||
if (combo == 0 || combo >= 10) {
|
||||
if (combo >= 10) {
|
||||
var comboSpr:FlxSprite = comboGroup.recycleLoop(FlxSprite).loadAnimatedGraphic(Paths.image('${pre}combo${suf}'));
|
||||
comboSpr.resetSprite(comboGroup.x, comboGroup.y);
|
||||
comboSpr.acceleration.y = 600;
|
||||
comboSpr.velocity.y -= 150;
|
||||
comboSpr.velocity.x += FlxG.random.int(1, 10);
|
||||
|
||||
comboSpr.scale.set(event.ratingScale, event.ratingScale);
|
||||
comboSpr.antialiasing = event.ratingAntialiasing;
|
||||
comboSpr.updateHitbox();
|
||||
|
||||
FlxTween.tween(comboSpr, {alpha: 0}, 0.2, {
|
||||
onComplete: function(tween:FlxTween)
|
||||
{
|
||||
comboSpr.kill();
|
||||
},
|
||||
startDelay: Conductor.crochet * 0.001
|
||||
});
|
||||
}
|
||||
|
||||
for (i in 0...separatedScore.length)
|
||||
{
|
||||
var numScore:FlxSprite = comboGroup.recycleLoop(FlxSprite).loadAnimatedGraphic(Paths.image('${pre}num${separatedScore.charAt(i)}${suf}'));
|
||||
numScore.resetSprite(comboGroup.x + (43 * i) - 90, comboGroup.y + 80);
|
||||
numScore.antialiasing = event.numAntialiasing;
|
||||
numScore.scale.set(event.numScale, event.numScale);
|
||||
numScore.updateHitbox();
|
||||
|
||||
numScore.acceleration.y = FlxG.random.int(200, 300);
|
||||
numScore.velocity.y -= FlxG.random.int(140, 160);
|
||||
numScore.velocity.x = FlxG.random.float(-5, 5);
|
||||
|
||||
FlxTween.tween(numScore, {alpha: 0}, 0.2, {
|
||||
onComplete: function(tween:FlxTween)
|
||||
{
|
||||
numScore.kill();
|
||||
},
|
||||
startDelay: Conductor.crochet * 0.002
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public inline function deleteNote(note:Note)
|
||||
if (note.strumLine != null)
|
||||
note.strumLine.deleteNote(note);
|
||||
@@ -1726,4 +1738,4 @@ typedef PlayStateTransitionData = {
|
||||
var camFollowX:Float;
|
||||
var camFollowY:Float;
|
||||
var camZoom:Float;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user