From f2b4dbe75161286d67f066d7e1ff1296795e0d49 Mon Sep 17 00:00:00 2001 From: Eric Myllyoja Date: Mon, 28 Feb 2022 23:04:55 -0500 Subject: [PATCH] Pyro test --- source/Character.hx | 2 ++ source/FreeplayState.hx | 7 +++--- source/Note.hx | 17 ++++++++++++-- source/PlayState.hx | 48 ++++++++++++++++++++++++++++++-------- source/SongLoad.hx | 4 ++++ source/play/stage/Stage.hx | 16 +++++++++++++ 6 files changed, 78 insertions(+), 16 deletions(-) diff --git a/source/Character.hx b/source/Character.hx index 999dcbe54..dbf62d1ed 100644 --- a/source/Character.hx +++ b/source/Character.hx @@ -725,6 +725,8 @@ class Character extends FlxSprite public function playAnim(AnimName:String, Force:Bool = false, Reversed:Bool = false, Frame:Int = 0):Void { + if (animation == null) + return; animation.play(AnimName, Force, Reversed, Frame); var daOffset = animOffsets.get(AnimName); diff --git a/source/FreeplayState.hx b/source/FreeplayState.hx index 719178bfd..58a163b08 100644 --- a/source/FreeplayState.hx +++ b/source/FreeplayState.hx @@ -78,6 +78,7 @@ class FreeplayState extends MusicBeatSubstate #if debug isDebug = true; addSong('Test', 1, 'bf-pixel'); + addSong('Pyro', 4, 'bf'); #end var initSonglist = CoolUtil.coolTextFile(Paths.txt('freeplaySonglist')); @@ -517,10 +518,8 @@ class FreeplayState extends MusicBeatSubstate if (controls.BACK) { FlxG.sound.play(Paths.sound('cancelMenu')); - - close(); - - // FlxG.switchState(new MainMenuState()); + // close(); + FlxG.switchState(new MainMenuState()); } if (accepted) diff --git a/source/Note.hx b/source/Note.hx index f7434087a..8617578fe 100644 --- a/source/Note.hx +++ b/source/Note.hx @@ -117,6 +117,7 @@ class Note extends FlxSprite var daStage:String = PlayState.curStageId; + // TODO: Make this logic more generic switch (daStage) { case 'school' | 'schoolEvil': @@ -288,18 +289,20 @@ typedef RawNoteData = var noteData:NoteType; var sustainLength:Float; var altNote:Bool; + var noteKind:NoteKind; } @:forward abstract NoteData(RawNoteData) { - public function new(strumTime = 0.0, noteData:NoteType = 0, sustainLength = 0.0, altNote = false) + public function new(strumTime = 0.0, noteData:NoteType = 0, sustainLength = 0.0, altNote = false, noteKind = NORMAL) { this = { strumTime: strumTime, noteData: noteData, sustainLength: sustainLength, - altNote: altNote + altNote: altNote, + noteKind: noteKind } } @@ -456,3 +459,13 @@ enum abstract NoteColor(NoteType) from Int to Int from NoteType } } } + +enum abstract NoteKind(String) from String to String +{ + var NORMAL = "normal"; + var PYRO_LIGHT = "pyro_light"; + var PYRO_KICK = "pyro_kick"; + var PYRO_TOSS = "pyro_toss"; + var PYRO_COCK = "pyro_cock"; // lol + var PYRO_SHOOT = "pyro_shoot"; +} diff --git a/source/PlayState.hx b/source/PlayState.hx index a0a693645..fd10a8f37 100644 --- a/source/PlayState.hx +++ b/source/PlayState.hx @@ -84,7 +84,9 @@ class PlayState extends MusicBeatState private var curSong:String = ""; private var gfSpeed:Int = 1; - private var health:Float = 1; + + public static var health:Float = 1; + private var healthDisplay:Float = 1; private var combo:Int = 0; @@ -156,6 +158,9 @@ class PlayState extends MusicBeatState { initCameras(); + // Starting health. + health = 1; + persistentUpdate = true; persistentDraw = true; @@ -171,11 +176,11 @@ class PlayState extends MusicBeatState switch (SONG.song.toLowerCase()) { case 'senpai': - dialogue = CoolUtil.coolTextFile(Paths.txt('senpai/senpaiDialogue')); + dialogue = CoolUtil.coolTextFile(Paths.txt('songs/senpai/senpaiDialogue')); case 'roses': - dialogue = CoolUtil.coolTextFile(Paths.txt('roses/rosesDialogue')); + dialogue = CoolUtil.coolTextFile(Paths.txt('songs/roses/rosesDialogue')); case 'thorns': - dialogue = CoolUtil.coolTextFile(Paths.txt('thorns/thornsDialogue')); + dialogue = CoolUtil.coolTextFile(Paths.txt('songs/thorns/thornsDialogue')); } #if discord_rpc @@ -400,6 +405,10 @@ class PlayState extends MusicBeatState curStageId = 'mallEvil'; loadStage(curStageId); + case 'pyro': + curStageId = 'pyro'; + loadStage(curStageId); + case 'senpai' | 'roses': curStageId = 'school'; @@ -1348,10 +1357,17 @@ class PlayState extends MusicBeatState gf.dance(); if (swagCounter % 2 == 0) { - if (!boyfriend.animation.curAnim.name.startsWith("sing")) - boyfriend.playAnim('idle'); - if (!dad.animation.curAnim.name.startsWith("sing")) - dad.dance(); + if (boyfriend.animation != null) + { + if (!boyfriend.animation.curAnim.name.startsWith("sing")) + boyfriend.playAnim('idle'); + } + + if (dad.animation != null) + { + if (!dad.animation.curAnim.name.startsWith("sing")) + dad.dance(); + } } else if (dad.curCharacter == 'spooky' && !dad.animation.curAnim.name.startsWith("sing")) dad.dance(); @@ -1510,8 +1526,9 @@ class PlayState extends MusicBeatState oldNote = null; var swagNote:Note = new Note(daStrumTime, daNoteData, oldNote); - swagNote.data.sustainLength = songNotes.sustainLength; - swagNote.data.altNote = songNotes.altNote; + swagNote.data = songNotes; + // swagNote.data.sustainLength = songNotes.sustainLength; + // swagNote.data.altNote = songNotes.altNote; swagNote.scrollFactor.set(0, 0); var susLength:Float = swagNote.data.sustainLength; @@ -2127,8 +2144,13 @@ class PlayState extends MusicBeatState } else if (daNote.tooLate || daNote.wasGoodHit) { + // TODO: Why the hell is the noteMiss logic in two different places? if (daNote.tooLate) { + if (curStage != null) + { + curStage.onNoteMiss(daNote); + } health -= 0.0775; vocals.volume = 0; killCombo(); @@ -2341,6 +2363,12 @@ class PlayState extends MusicBeatState health += healthMulti; + // TODO: Redo note hit logic to make sure this always gets called + if (curStage != null) + { + curStage.onNoteHit(daNote); + } + if (isSick) { var noteSplash:NoteSplash = grpNoteSplashes.recycle(NoteSplash); diff --git a/source/SongLoad.hx b/source/SongLoad.hx index 179857065..0d50bf8fc 100644 --- a/source/SongLoad.hx +++ b/source/SongLoad.hx @@ -188,6 +188,10 @@ class SongLoad noteStuff[sectionIndex].sectionNotes[noteIndex].noteData = arrayDipshit[1]; noteStuff[sectionIndex].sectionNotes[noteIndex].sustainLength = arrayDipshit[2]; noteStuff[sectionIndex].sectionNotes[noteIndex].altNote = arrayDipshit[3]; + if (arrayDipshit.length >= 5) + { + noteStuff[sectionIndex].sectionNotes[noteIndex].noteKind = arrayDipshit[4]; + } } else if (noteDataArray != null) { diff --git a/source/play/stage/Stage.hx b/source/play/stage/Stage.hx index a78985a4b..fbb1ed053 100644 --- a/source/play/stage/Stage.hx +++ b/source/play/stage/Stage.hx @@ -188,6 +188,22 @@ class Stage extends FlxSpriteGroup implements IHook // trace('Stage.onUpdate(${elapsed})'); } + /** + * A function that gets called when the player hits a note. + */ + public function onNoteHit(note:Note):Void + { + // Override me in your scripted stage to perform custom behavior! + } + + /** + * A function that gets called when the player hits a note. + */ + public function onNoteMiss(note:Note):Void + { + // Override me in your scripted stage to perform custom behavior! + } + /** * Adjusts the position and other properties of the soon-to-be child of this sprite group. * Private helper to avoid duplicate code in `add()` and `insert()`.