more week 7 stuff
This commit is contained in:
@@ -125,6 +125,7 @@ class ChartingState extends MusicBeatState
|
||||
_song = {
|
||||
song: 'Test',
|
||||
notes: [],
|
||||
noteTypes: [],
|
||||
bpm: 150,
|
||||
needsVoices: true,
|
||||
player1: 'bf',
|
||||
|
||||
@@ -70,7 +70,7 @@ class Character extends FlxSprite implements IBeatReceiver implements IOffsetCom
|
||||
|
||||
var event = new DirectionAnimEvent('${anims[direction]}$suffix', direction, suffix, Reversed, Frame);
|
||||
script.call("onPlaySingAnim", [event]);
|
||||
if (!event.cancelled) playAnim(event.animName, event.force, event.reversed, event.frame, SING);
|
||||
if (!event.cancelled) playAnim(event.animName, event.force, SING, event.reversed, event.frame);
|
||||
}
|
||||
|
||||
public function new(x:Float, y:Float, ?character:String = "bf", ?isPlayer:Bool = false)
|
||||
@@ -334,9 +334,9 @@ class Character extends FlxSprite implements IBeatReceiver implements IOffsetCom
|
||||
// hardcode custom dance animations here
|
||||
default:
|
||||
if (isDanceLeftDanceRight) {
|
||||
playAnim((danced = !danced) ? 'danceLeft' : 'danceRight');
|
||||
playAnim((danced = !danced) ? 'danceLeft' : 'danceRight', DANCE);
|
||||
} else
|
||||
playAnim('idle');
|
||||
playAnim('idle', DANCE);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -348,9 +348,20 @@ class Character extends FlxSprite implements IBeatReceiver implements IOffsetCom
|
||||
|
||||
public function beatHit(curBeat:Int) {
|
||||
script.call("beatHit", [curBeat]);
|
||||
if (danceOnBeat && (lastHit + (Conductor.stepCrochet * holdTime) < Conductor.songPosition) || animation.curAnim == null || (!animation.curAnim.name.startsWith("sing") && animation.curAnim.finished))
|
||||
dance();
|
||||
if (danceOnBeat) {
|
||||
switch(lastAnimContext) {
|
||||
case SING | MISS:
|
||||
if (lastHit + (Conductor.stepCrochet * holdTime) < Conductor.songPosition)
|
||||
dance();
|
||||
case DANCE:
|
||||
dance();
|
||||
default:
|
||||
if (animation.curAnim == null || animation.curAnim.finished)
|
||||
dance();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public function stepHit(curStep:Int) {
|
||||
script.call("stepHit", [curStep]);
|
||||
// nothing
|
||||
@@ -382,7 +393,8 @@ class Character extends FlxSprite implements IBeatReceiver implements IOffsetCom
|
||||
super.draw();
|
||||
}
|
||||
|
||||
public function playAnim(AnimName:String, Force:Bool = false, Reversed:Bool = false, Frame:Int = 0, Context:PlayAnimContext = NONE):Void
|
||||
public var lastAnimContext:PlayAnimContext = DANCE;
|
||||
public function playAnim(AnimName:String, Force:Bool = false, Context:PlayAnimContext = NONE, Reversed:Bool = false, Frame:Int = 0):Void
|
||||
{
|
||||
var event = new PlayAnimEvent(AnimName, Force, Reversed, Frame, Context);
|
||||
|
||||
@@ -400,25 +412,10 @@ class Character extends FlxSprite implements IBeatReceiver implements IOffsetCom
|
||||
|
||||
offset.set(globalOffset.x * (isPlayer != playerOffsets ? 1 : -1), -globalOffset.y);
|
||||
|
||||
if (event.context != DANCE)
|
||||
if (event.context == SING || event.context == MISS)
|
||||
lastHit = Conductor.songPosition;
|
||||
|
||||
if (curCharacter == 'gf')
|
||||
{
|
||||
if (event.animName == 'singLEFT')
|
||||
{
|
||||
danced = true;
|
||||
}
|
||||
else if (event.animName == 'singRIGHT')
|
||||
{
|
||||
danced = false;
|
||||
}
|
||||
|
||||
if (event.animName == 'singUP' || event.animName == 'singDOWN')
|
||||
{
|
||||
danced = !danced;
|
||||
}
|
||||
}
|
||||
lastAnimContext = event.context;
|
||||
}
|
||||
|
||||
public override function destroy() {
|
||||
|
||||
@@ -25,7 +25,10 @@ class NoteGroup extends FlxTypedGroup<Note> {
|
||||
__loopSprite = null;
|
||||
while(i < length) {
|
||||
__loopSprite = members[i];
|
||||
if (__loopSprite == null || !__loopSprite.exists || !__loopSprite.active) continue;
|
||||
if (__loopSprite == null || !__loopSprite.exists || !__loopSprite.active) {
|
||||
i++;
|
||||
continue;
|
||||
}
|
||||
if (__loopSprite.strumTime - Conductor.songPosition > 1500)
|
||||
break;
|
||||
__loopSprite.update(elapsed);
|
||||
@@ -44,7 +47,10 @@ class NoteGroup extends FlxTypedGroup<Note> {
|
||||
__currentlyLooping = true;
|
||||
while(i < length) {
|
||||
__loopSprite = members[i];
|
||||
if (__loopSprite == null || !__loopSprite.exists || !__loopSprite.visible) continue;
|
||||
if (__loopSprite == null || !__loopSprite.exists || !__loopSprite.visible) {
|
||||
i++;
|
||||
continue;
|
||||
}
|
||||
if (__loopSprite.strumTime - Conductor.songPosition > 1500) break;
|
||||
__loopSprite.draw();
|
||||
i++;
|
||||
@@ -63,7 +69,10 @@ class NoteGroup extends FlxTypedGroup<Note> {
|
||||
|
||||
while(i < length) {
|
||||
__loopSprite = members[i];
|
||||
if (__loopSprite == null || !__loopSprite.exists) continue;
|
||||
if (__loopSprite == null || !__loopSprite.exists) {
|
||||
i++;
|
||||
continue;
|
||||
}
|
||||
if (__loopSprite.strumTime - Conductor.songPosition > 1500) break;
|
||||
noteFunc(__loopSprite);
|
||||
i++;
|
||||
|
||||
@@ -267,7 +267,7 @@ class PlayState extends MusicBeatState
|
||||
cpuStrums = new FlxTypedGroup<Strum>();
|
||||
add(strumLineNotes);
|
||||
|
||||
generateSong(SONG.song);
|
||||
generateSong(SONG);
|
||||
|
||||
if (prevCamFollow != null)
|
||||
{
|
||||
@@ -451,22 +451,9 @@ class PlayState extends MusicBeatState
|
||||
|
||||
public var debugNum:Int = 0;
|
||||
|
||||
private function generateSong(dataPath:String, ?songData:SwagSong):Void
|
||||
{
|
||||
if (songData == null) songData = SONG;
|
||||
|
||||
Conductor.changeBPM(songData.bpm);
|
||||
|
||||
curSong = songData.song;
|
||||
|
||||
inst = FlxG.sound.load(Paths.inst(PlayState.SONG.song));
|
||||
vocals = new FlxSound();
|
||||
if (SONG.needsVoices)
|
||||
vocals.loadEmbedded(Paths.voices(PlayState.SONG.song));
|
||||
FlxG.sound.list.add(vocals);
|
||||
|
||||
notes = new NoteGroup();
|
||||
add(notes);
|
||||
public function generateNotes(songData:SwagSong) {
|
||||
if (songData == null) return;
|
||||
if (songData.noteTypes == null) songData.noteTypes = [];
|
||||
|
||||
var noteData:Array<SwagSection> = songData.notes;
|
||||
var playerCounter:Int = 0;
|
||||
@@ -489,10 +476,12 @@ class PlayState extends MusicBeatState
|
||||
var gottaHitNote:Bool = daNoteData >= 4 ? !section.mustHitSection : section.mustHitSection;
|
||||
|
||||
if (songNotes.length > 2) {
|
||||
if (songNotes[3] is Int)
|
||||
daNoteType = songNotes[3];
|
||||
if (songNotes[3] is Int)
|
||||
daNoteType = addNoteType(songData.noteTypes[Std.int(songNotes[3])-1], songNotes[3] == 0);
|
||||
else if (songNotes[3] is String)
|
||||
daNoteType = addNoteType(songNotes[3]);
|
||||
} else {
|
||||
daNoteType = addNoteType(songData.noteTypes[daNoteType-1], daNoteType == 0);
|
||||
}
|
||||
|
||||
var swagNote:Note;
|
||||
@@ -523,11 +512,37 @@ class PlayState extends MusicBeatState
|
||||
daBeats += 1;
|
||||
}
|
||||
notes.sortNotes();
|
||||
}
|
||||
private function generateSong(?songData:SwagSong):Void
|
||||
{
|
||||
if (songData == null) songData = SONG;
|
||||
|
||||
Conductor.changeBPM(songData.bpm);
|
||||
|
||||
curSong = songData.song;
|
||||
|
||||
inst = FlxG.sound.load(Paths.inst(PlayState.SONG.song));
|
||||
vocals = new FlxSound();
|
||||
if (SONG.needsVoices)
|
||||
vocals.loadEmbedded(Paths.voices(PlayState.SONG.song));
|
||||
FlxG.sound.list.add(vocals);
|
||||
|
||||
notes = new NoteGroup();
|
||||
add(notes);
|
||||
|
||||
generateNotes(songData);
|
||||
|
||||
generatedMusic = true;
|
||||
}
|
||||
|
||||
public function addNoteType(name:String):Int {
|
||||
public function addNoteType(name:String, addAsDefaultIfUnknown:Bool = false):Int {
|
||||
if (name == null) {
|
||||
if (addAsDefaultIfUnknown)
|
||||
return 0;
|
||||
else
|
||||
name = "Unknown";
|
||||
}
|
||||
|
||||
for(k=>e in noteTypesArray)
|
||||
if (e == name) return k;
|
||||
noteTypesArray.push(name);
|
||||
@@ -1162,13 +1177,13 @@ class PlayState extends MusicBeatState
|
||||
switch (note.strumID)
|
||||
{
|
||||
case 0:
|
||||
boyfriend.playAnim('singLEFTmiss', true);
|
||||
boyfriend.playAnim('singLEFTmiss', true, MISS);
|
||||
case 1:
|
||||
boyfriend.playAnim('singDOWNmiss', true);
|
||||
boyfriend.playAnim('singDOWNmiss', true, MISS);
|
||||
case 2:
|
||||
boyfriend.playAnim('singUPmiss', true);
|
||||
boyfriend.playAnim('singUPmiss', true, MISS);
|
||||
case 3:
|
||||
boyfriend.playAnim('singRIGHTmiss', true);
|
||||
boyfriend.playAnim('singRIGHTmiss', true, MISS);
|
||||
}
|
||||
deleteNote(note);
|
||||
}
|
||||
@@ -1304,7 +1319,7 @@ class PlayState extends MusicBeatState
|
||||
event.character.playSingAnim(event.direction, event.animSuffix);
|
||||
}
|
||||
|
||||
(event.player ? playerStrums : cpuStrums).forEach(function(str:Strum) {
|
||||
if (!event.strumGlowCancelled) (event.player ? playerStrums : cpuStrums).forEach(function(str:Strum) {
|
||||
if (str.ID == Math.abs(note.strumID)) {
|
||||
str.press(note.strumTime);
|
||||
}
|
||||
|
||||
@@ -156,8 +156,11 @@ class StageSprite extends FlxSprite implements IBeatReceiver {
|
||||
}
|
||||
|
||||
public function beatHit(curBeat:Int) {
|
||||
if (beatAnims.length > 0)
|
||||
animation.play(beatAnims[FlxMath.wrap(curBeat, 0, beatAnims.length-1)]);
|
||||
if (beatAnims.length > 0) {
|
||||
var anim = beatAnims[FlxMath.wrap(curBeat, 0, beatAnims.length-1)];
|
||||
if (anim != null && anim != "null" && anim != "none")
|
||||
animation.play(anim);
|
||||
}
|
||||
|
||||
}
|
||||
public function stepHit(curBeat:Int) {}
|
||||
|
||||
@@ -43,7 +43,6 @@ class ModsFolderLibrary extends AssetLibrary implements ModsAssetLibrary {
|
||||
}
|
||||
|
||||
public override function getAudioBuffer(id:String):AudioBuffer {
|
||||
trace(id);
|
||||
if (__isCacheValid(LimeAssets.cache.audio, id)) {
|
||||
trace("CACHE FOUND!!");
|
||||
return LimeAssets.cache.audio.get('$libName:$id');
|
||||
|
||||
@@ -5,6 +5,7 @@ import funkin.game.Character;
|
||||
|
||||
class NoteHitEvent extends CancellableEvent {
|
||||
@:dox(hide) public var animCancelled:Bool = false;
|
||||
@:dox(hide) public var strumGlowCancelled:Bool = false;
|
||||
@:dox(hide) public var deleteNote:Bool = true;
|
||||
@:dox(hide) public var unmuteVocals:Bool = true;
|
||||
@:dox(hide) public var enableCamZooming:Bool = true;
|
||||
@@ -166,4 +167,13 @@ class NoteHitEvent extends CancellableEvent {
|
||||
}
|
||||
@:dox(hide)
|
||||
public function cancelLastSustainHit() {preventLastSustainHit();}
|
||||
|
||||
/**
|
||||
* Prevents the strum from glowing after this note has been pressed.
|
||||
*/
|
||||
public function preventStrumGlow() {
|
||||
strumGlowCancelled = true;
|
||||
}
|
||||
@:dox(hide)
|
||||
public function cancelStrumGlow() {preventStrumGlow();}
|
||||
}
|
||||
@@ -1,5 +1,6 @@
|
||||
package funkin.system;
|
||||
|
||||
import haxe.Json;
|
||||
import funkin.menus.StoryMenuState.WeekData;
|
||||
import flixel.graphics.frames.FlxAtlasFrames;
|
||||
import flixel.system.FlxAssets.FlxGraphicAsset;
|
||||
@@ -23,9 +24,7 @@ using StringTools;
|
||||
|
||||
class CoolUtil
|
||||
{
|
||||
public static var difficultyArray:Array<String> = ['EASY', "NORMAL", "HARD"];
|
||||
|
||||
/**
|
||||
/*
|
||||
* Returns `v` if not null, `defaultValue` otherwise.
|
||||
* @param v The value
|
||||
* @param defaultValue The default value
|
||||
@@ -35,6 +34,13 @@ class CoolUtil
|
||||
return (v == null || isNaN(v)) ? defaultValue : v;
|
||||
}
|
||||
|
||||
public static function parseJson(assetPath:String) {
|
||||
return Json.parse(Assets.getText(assetPath));
|
||||
}
|
||||
|
||||
public inline static function parseJsonString(str:String)
|
||||
return Json.parse(str);
|
||||
|
||||
public static function isNaN(v:Dynamic) {
|
||||
if (v is Float || v is Int)
|
||||
return Math.isNaN(cast(v, Float));
|
||||
|
||||
@@ -15,6 +15,7 @@ typedef SwagSong =
|
||||
var needsVoices:Bool;
|
||||
var speed:Float;
|
||||
var stage:String;
|
||||
var noteTypes:Array<String>;
|
||||
|
||||
var player1:String;
|
||||
var player2:String;
|
||||
|
||||
Reference in New Issue
Block a user