2020-10-03 02:50:15 -04:00
|
|
|
package;
|
|
|
|
|
|
|
|
import flixel.FlxSprite;
|
2020-10-04 02:42:58 -04:00
|
|
|
import flixel.graphics.frames.FlxAtlasFrames;
|
2021-01-25 04:18:44 -05:00
|
|
|
import flixel.math.FlxMath;
|
2020-10-03 02:50:15 -04:00
|
|
|
import flixel.util.FlxColor;
|
2021-01-25 04:18:44 -05:00
|
|
|
import polymod.format.ParseRules.TargetSignatureElement;
|
2020-10-03 02:50:15 -04:00
|
|
|
|
2021-02-02 00:48:22 -05:00
|
|
|
using StringTools;
|
|
|
|
|
2020-10-03 02:50:15 -04:00
|
|
|
class Note extends FlxSprite
|
|
|
|
{
|
|
|
|
public var strumTime:Float = 0;
|
|
|
|
|
|
|
|
public var mustPress:Bool = false;
|
|
|
|
public var noteData:Int = 0;
|
2020-10-03 13:36:39 -04:00
|
|
|
public var canBeHit:Bool = false;
|
|
|
|
public var tooLate:Bool = false;
|
|
|
|
public var wasGoodHit:Bool = false;
|
|
|
|
public var prevNote:Note;
|
2020-10-03 02:50:15 -04:00
|
|
|
|
2020-10-18 20:59:53 -04:00
|
|
|
public var sustainLength:Float = 0;
|
2020-10-19 21:59:00 -04:00
|
|
|
public var isSustainNote:Bool = false;
|
2020-10-18 20:59:53 -04:00
|
|
|
|
2020-10-03 15:32:15 -04:00
|
|
|
public var noteScore:Float = 1;
|
|
|
|
|
2020-10-04 04:38:21 -04:00
|
|
|
public static var swagWidth:Float = 160 * 0.7;
|
2020-10-13 22:12:31 -04:00
|
|
|
public static var PURP_NOTE:Int = 0;
|
|
|
|
public static var GREEN_NOTE:Int = 2;
|
|
|
|
public static var BLUE_NOTE:Int = 1;
|
|
|
|
public static var RED_NOTE:Int = 3;
|
2020-10-04 04:38:21 -04:00
|
|
|
|
2020-10-19 21:59:00 -04:00
|
|
|
public function new(strumTime:Float, noteData:Int, ?prevNote:Note, ?sustainNote:Bool = false)
|
2020-10-03 02:50:15 -04:00
|
|
|
{
|
|
|
|
super();
|
|
|
|
|
2020-10-06 21:56:14 -04:00
|
|
|
if (prevNote == null)
|
|
|
|
prevNote = this;
|
|
|
|
|
2020-10-05 01:13:12 -04:00
|
|
|
this.prevNote = prevNote;
|
2020-10-19 21:59:00 -04:00
|
|
|
isSustainNote = sustainNote;
|
2020-10-05 01:13:12 -04:00
|
|
|
|
2020-10-04 04:38:21 -04:00
|
|
|
x += 50;
|
2020-11-10 21:07:56 -05:00
|
|
|
// MAKE SURE ITS DEFINITELY OFF SCREEN?
|
|
|
|
y -= 2000;
|
2020-10-03 02:50:15 -04:00
|
|
|
this.strumTime = strumTime;
|
2020-10-03 13:36:39 -04:00
|
|
|
|
2020-10-03 02:50:15 -04:00
|
|
|
this.noteData = noteData;
|
|
|
|
|
2021-01-25 04:18:44 -05:00
|
|
|
var daStage:String = PlayState.curStage;
|
2020-10-04 02:42:58 -04:00
|
|
|
|
2021-01-25 04:18:44 -05:00
|
|
|
switch (daStage)
|
|
|
|
{
|
|
|
|
case 'school':
|
2021-02-08 16:34:48 -05:00
|
|
|
loadGraphic(Paths.image('weeb/pixelUI/arrows-pixels'), true, 17, 17);
|
2021-01-25 04:18:44 -05:00
|
|
|
|
|
|
|
animation.add('greenScroll', [6]);
|
|
|
|
animation.add('redScroll', [7]);
|
|
|
|
animation.add('blueScroll', [5]);
|
|
|
|
animation.add('purpleScroll', [4]);
|
|
|
|
|
|
|
|
if (isSustainNote)
|
|
|
|
{
|
2021-02-08 16:34:48 -05:00
|
|
|
loadGraphic(Paths.image('weeb/pixelUI/arrowEnds'), true, 7, 6);
|
2021-01-25 04:18:44 -05:00
|
|
|
|
|
|
|
animation.add('purpleholdend', [4]);
|
|
|
|
animation.add('greenholdend', [6]);
|
|
|
|
animation.add('redholdend', [7]);
|
|
|
|
animation.add('blueholdend', [5]);
|
|
|
|
|
|
|
|
animation.add('purplehold', [0]);
|
|
|
|
animation.add('greenhold', [2]);
|
|
|
|
animation.add('redhold', [3]);
|
|
|
|
animation.add('bluehold', [1]);
|
|
|
|
}
|
|
|
|
|
|
|
|
setGraphicSize(Std.int(width * PlayState.daPixelZoom));
|
|
|
|
updateHitbox();
|
|
|
|
|
2021-02-02 00:48:22 -05:00
|
|
|
case 'schoolEvil': // COPY PASTED CUZ I AM LAZY
|
2021-02-08 16:34:48 -05:00
|
|
|
loadGraphic(Paths.image('weeb/pixelUI/arrows-pixels'), true, 17, 17);
|
2021-02-02 00:48:22 -05:00
|
|
|
|
|
|
|
animation.add('greenScroll', [6]);
|
|
|
|
animation.add('redScroll', [7]);
|
|
|
|
animation.add('blueScroll', [5]);
|
|
|
|
animation.add('purpleScroll', [4]);
|
|
|
|
|
|
|
|
if (isSustainNote)
|
|
|
|
{
|
2021-02-08 16:34:48 -05:00
|
|
|
loadGraphic(Paths.image('weeb/pixelUI/arrowEnds'), true, 7, 6);
|
2021-02-02 00:48:22 -05:00
|
|
|
|
|
|
|
animation.add('purpleholdend', [4]);
|
|
|
|
animation.add('greenholdend', [6]);
|
|
|
|
animation.add('redholdend', [7]);
|
|
|
|
animation.add('blueholdend', [5]);
|
|
|
|
|
|
|
|
animation.add('purplehold', [0]);
|
|
|
|
animation.add('greenhold', [2]);
|
|
|
|
animation.add('redhold', [3]);
|
|
|
|
animation.add('bluehold', [1]);
|
|
|
|
}
|
|
|
|
|
|
|
|
setGraphicSize(Std.int(width * PlayState.daPixelZoom));
|
|
|
|
updateHitbox();
|
|
|
|
|
2021-01-25 04:18:44 -05:00
|
|
|
default:
|
2021-02-08 16:34:48 -05:00
|
|
|
frames = Paths.getSparrowAtlas('NOTE_assets');
|
2020-10-05 01:13:12 -04:00
|
|
|
|
2021-01-25 04:18:44 -05:00
|
|
|
animation.addByPrefix('greenScroll', 'green0');
|
|
|
|
animation.addByPrefix('redScroll', 'red0');
|
|
|
|
animation.addByPrefix('blueScroll', 'blue0');
|
|
|
|
animation.addByPrefix('purpleScroll', 'purple0');
|
2020-10-05 01:13:12 -04:00
|
|
|
|
2021-01-25 04:18:44 -05:00
|
|
|
animation.addByPrefix('purpleholdend', 'pruple end hold');
|
|
|
|
animation.addByPrefix('greenholdend', 'green hold end');
|
|
|
|
animation.addByPrefix('redholdend', 'red hold end');
|
|
|
|
animation.addByPrefix('blueholdend', 'blue hold end');
|
|
|
|
|
|
|
|
animation.addByPrefix('purplehold', 'purple hold piece');
|
|
|
|
animation.addByPrefix('greenhold', 'green hold piece');
|
|
|
|
animation.addByPrefix('redhold', 'red hold piece');
|
|
|
|
animation.addByPrefix('bluehold', 'blue hold piece');
|
|
|
|
|
|
|
|
setGraphicSize(Std.int(width * 0.7));
|
|
|
|
updateHitbox();
|
|
|
|
antialiasing = true;
|
|
|
|
}
|
2020-10-03 02:50:15 -04:00
|
|
|
|
2020-10-13 05:36:45 -04:00
|
|
|
switch (noteData)
|
2020-10-03 02:50:15 -04:00
|
|
|
{
|
2020-10-13 05:36:45 -04:00
|
|
|
case 0:
|
|
|
|
x += swagWidth * 0;
|
|
|
|
animation.play('purpleScroll');
|
2020-10-03 02:50:15 -04:00
|
|
|
case 1:
|
2020-10-13 05:36:45 -04:00
|
|
|
x += swagWidth * 1;
|
|
|
|
animation.play('blueScroll');
|
|
|
|
case 2:
|
2020-10-03 13:36:39 -04:00
|
|
|
x += swagWidth * 2;
|
2020-10-04 04:38:21 -04:00
|
|
|
animation.play('greenScroll');
|
2020-10-13 05:36:45 -04:00
|
|
|
case 3:
|
2020-10-03 13:36:39 -04:00
|
|
|
x += swagWidth * 3;
|
2020-10-04 04:38:21 -04:00
|
|
|
animation.play('redScroll');
|
2020-10-03 02:50:15 -04:00
|
|
|
}
|
|
|
|
|
2020-10-24 05:36:50 -04:00
|
|
|
// trace(prevNote);
|
2020-10-05 01:13:12 -04:00
|
|
|
|
2020-10-19 21:59:00 -04:00
|
|
|
if (isSustainNote && prevNote != null)
|
2020-10-03 15:32:15 -04:00
|
|
|
{
|
|
|
|
noteScore * 0.2;
|
2020-10-03 02:50:15 -04:00
|
|
|
alpha = 0.6;
|
2020-10-05 01:13:12 -04:00
|
|
|
|
|
|
|
x += width / 2;
|
|
|
|
|
|
|
|
switch (noteData)
|
|
|
|
{
|
2020-10-19 21:59:00 -04:00
|
|
|
case 2:
|
2020-10-05 01:13:12 -04:00
|
|
|
animation.play('greenholdend');
|
2020-10-19 21:59:00 -04:00
|
|
|
case 3:
|
2020-10-05 01:13:12 -04:00
|
|
|
animation.play('redholdend');
|
2020-10-19 21:59:00 -04:00
|
|
|
case 1:
|
2020-10-05 01:13:12 -04:00
|
|
|
animation.play('blueholdend');
|
2020-10-19 21:59:00 -04:00
|
|
|
case 0:
|
2020-10-05 01:13:12 -04:00
|
|
|
animation.play('purpleholdend');
|
|
|
|
}
|
|
|
|
|
|
|
|
updateHitbox();
|
|
|
|
|
|
|
|
x -= width / 2;
|
|
|
|
|
2021-02-02 00:48:22 -05:00
|
|
|
if (PlayState.curStage.startsWith('school'))
|
2021-02-01 05:52:10 -05:00
|
|
|
x += 30;
|
|
|
|
|
2020-10-19 21:59:00 -04:00
|
|
|
if (prevNote.isSustainNote)
|
2020-10-05 01:13:12 -04:00
|
|
|
{
|
|
|
|
switch (prevNote.noteData)
|
|
|
|
{
|
2020-10-19 21:59:00 -04:00
|
|
|
case 2:
|
2020-10-05 01:13:12 -04:00
|
|
|
prevNote.animation.play('greenhold');
|
2020-10-19 21:59:00 -04:00
|
|
|
case 3:
|
2020-10-05 01:13:12 -04:00
|
|
|
prevNote.animation.play('redhold');
|
2020-10-19 21:59:00 -04:00
|
|
|
case 1:
|
2020-10-05 01:13:12 -04:00
|
|
|
prevNote.animation.play('bluehold');
|
2020-10-19 21:59:00 -04:00
|
|
|
case 0:
|
2020-10-05 01:13:12 -04:00
|
|
|
prevNote.animation.play('purplehold');
|
|
|
|
}
|
|
|
|
|
|
|
|
prevNote.offset.y = -19;
|
2021-01-25 04:18:44 -05:00
|
|
|
prevNote.scale.y *= (2.25 * FlxMath.roundDecimal(PlayState.SONG.speed, 1));
|
2020-10-05 01:13:12 -04:00
|
|
|
// prevNote.setGraphicSize();
|
|
|
|
}
|
2020-10-03 15:32:15 -04:00
|
|
|
}
|
2020-10-03 02:50:15 -04:00
|
|
|
}
|
2020-10-03 13:36:39 -04:00
|
|
|
|
|
|
|
override function update(elapsed:Float)
|
|
|
|
{
|
|
|
|
super.update(elapsed);
|
|
|
|
|
|
|
|
if (mustPress)
|
|
|
|
{
|
2020-10-28 22:47:10 -04:00
|
|
|
// The * 0.5 us so that its easier to hit them too late, instead of too early
|
2020-10-03 13:36:39 -04:00
|
|
|
if (strumTime > Conductor.songPosition - Conductor.safeZoneOffset
|
2020-10-28 22:47:10 -04:00
|
|
|
&& strumTime < Conductor.songPosition + (Conductor.safeZoneOffset * 0.5))
|
2020-10-03 13:36:39 -04:00
|
|
|
{
|
|
|
|
canBeHit = true;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
canBeHit = false;
|
|
|
|
|
|
|
|
if (strumTime < Conductor.songPosition - Conductor.safeZoneOffset)
|
|
|
|
tooLate = true;
|
|
|
|
}
|
|
|
|
else
|
2020-10-04 02:42:58 -04:00
|
|
|
{
|
2020-10-03 13:36:39 -04:00
|
|
|
canBeHit = false;
|
|
|
|
|
2020-10-04 02:42:58 -04:00
|
|
|
if (strumTime <= Conductor.songPosition)
|
|
|
|
{
|
|
|
|
wasGoodHit = true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (tooLate)
|
|
|
|
{
|
|
|
|
if (alpha > 0.3)
|
|
|
|
alpha = 0.3;
|
|
|
|
}
|
2020-10-03 13:36:39 -04:00
|
|
|
}
|
2020-10-03 02:50:15 -04:00
|
|
|
}
|