1
0
Fork 0
mirror of https://github.com/ninjamuffin99/Funkin.git synced 2025-01-26 22:56:48 +00:00

WEEK SCORE SHIT

This commit is contained in:
Cameron Taylor 2020-11-06 02:56:45 -08:00
parent 4a715a86a0
commit c2b17d4e3e
4 changed files with 42 additions and 3 deletions

View file

@ -21,6 +21,21 @@ class Highscore
setScore(daSong, score); setScore(daSong, score);
} }
public static function saveWeekScore(week:Int = 1, score:Int = 0, ?diff:Int = 0):Void
{
NGio.postScore(score, "Week " + week);
var daWeek:String = formatSong('week' + week, diff);
if (songScores.exists(daWeek))
{
if (songScores.get(daWeek) < score)
setScore(daWeek, score);
}
else
setScore(daWeek, score);
}
/** /**
* YOU SHOULD FORMAT SONG WITH formatSong() BEFORE TOSSING IN SONG VARIABLE * YOU SHOULD FORMAT SONG WITH formatSong() BEFORE TOSSING IN SONG VARIABLE
*/ */
@ -52,6 +67,14 @@ class Highscore
return songScores.get(formatSong(song, diff)); return songScores.get(formatSong(song, diff));
} }
public static function getWeekScore(week:Int, diff:Int):Int
{
if (!songScores.exists(formatSong('week' + week, diff)))
setScore(formatSong('week' + week, diff), 0);
return songScores.get(formatSong('week' + week, diff));
}
public static function load():Void public static function load():Void
{ {
if (FlxG.save.data.songScores != null) if (FlxG.save.data.songScores != null)

View file

@ -37,6 +37,7 @@ class PlayState extends MusicBeatState
public static var curLevel:String = 'Tutorial'; public static var curLevel:String = 'Tutorial';
public static var SONG:SwagSong; public static var SONG:SwagSong;
public static var isStoryMode:Bool = false; public static var isStoryMode:Bool = false;
public static var storyWeek:Int = 0;
public static var storyPlaylist:Array<String> = []; public static var storyPlaylist:Array<String> = [];
public static var storyDifficulty:Int = 1; public static var storyDifficulty:Int = 1;
@ -83,6 +84,8 @@ class PlayState extends MusicBeatState
var talking:Bool = true; var talking:Bool = true;
var songScore:Int = 0; var songScore:Int = 0;
public static var campaignScore:Int = 0;
override public function create() override public function create()
{ {
// var gameCam:FlxCamera = FlxG.camera; // var gameCam:FlxCamera = FlxG.camera;
@ -825,6 +828,8 @@ class PlayState extends MusicBeatState
if (isStoryMode) if (isStoryMode)
{ {
campaignScore += songScore;
storyPlaylist.remove(storyPlaylist[0]); storyPlaylist.remove(storyPlaylist[0]);
if (storyPlaylist.length <= 0) if (storyPlaylist.length <= 0)
@ -836,6 +841,7 @@ class PlayState extends MusicBeatState
StoryMenuState.weekUnlocked[1] = true; StoryMenuState.weekUnlocked[1] = true;
NGio.unlockMedal(60961); NGio.unlockMedal(60961);
Highscore.saveWeekScore(storyWeek, campaignScore, storyDifficulty);
FlxG.save.data.weekUnlocked = StoryMenuState.weekUnlocked; FlxG.save.data.weekUnlocked = StoryMenuState.weekUnlocked;
FlxG.save.flush(); FlxG.save.flush();

View file

@ -5,6 +5,7 @@ import flixel.FlxSprite;
import flixel.graphics.frames.FlxAtlasFrames; import flixel.graphics.frames.FlxAtlasFrames;
import flixel.group.FlxGroup.FlxTypedGroup; import flixel.group.FlxGroup.FlxTypedGroup;
import flixel.group.FlxGroup; import flixel.group.FlxGroup;
import flixel.math.FlxMath;
import flixel.text.FlxText; import flixel.text.FlxText;
import flixel.tweens.FlxTween; import flixel.tweens.FlxTween;
import flixel.util.FlxTimer; import flixel.util.FlxTimer;
@ -149,7 +150,7 @@ class StoryMenuState extends MusicBeatState
txtTracklist.color = 0xFFe55777; txtTracklist.color = 0xFFe55777;
add(txtTracklist); add(txtTracklist);
// add(rankText); // add(rankText);
// add(scoreText); add(scoreText);
updateText(); updateText();
@ -159,7 +160,9 @@ class StoryMenuState extends MusicBeatState
override function update(elapsed:Float) override function update(elapsed:Float)
{ {
// scoreText.setFormat('VCR OSD Mono', 32); // scoreText.setFormat('VCR OSD Mono', 32);
// scoreText.text = "Score SHIT"; lerpScore = Math.floor(FlxMath.lerp(lerpScore, intendedScore, 0.5));
scoreText.text = "WEEK SCORE:" + lerpScore;
// FlxG.watch.addQuick('font', scoreText.font); // FlxG.watch.addQuick('font', scoreText.font);
difficultySelectors.visible = weekUnlocked[curWeek]; difficultySelectors.visible = weekUnlocked[curWeek];
@ -244,6 +247,7 @@ class StoryMenuState extends MusicBeatState
PlayState.storyDifficulty = curDifficulty; PlayState.storyDifficulty = curDifficulty;
PlayState.SONG = Song.loadFromJson(PlayState.storyPlaylist[0].toLowerCase() + diffic, PlayState.storyPlaylist[0].toLowerCase()); PlayState.SONG = Song.loadFromJson(PlayState.storyPlaylist[0].toLowerCase() + diffic, PlayState.storyPlaylist[0].toLowerCase());
PlayState.storyWeek = curWeek;
new FlxTimer().start(1, function(tmr:FlxTimer) new FlxTimer().start(1, function(tmr:FlxTimer)
{ {
if (FlxG.sound.music != null) if (FlxG.sound.music != null)
@ -281,10 +285,14 @@ class StoryMenuState extends MusicBeatState
// USING THESE WEIRD VALUES SO THAT IT DOESNT FLOAT UP // USING THESE WEIRD VALUES SO THAT IT DOESNT FLOAT UP
sprDifficulty.y = leftArrow.y - 15; sprDifficulty.y = leftArrow.y - 15;
intendedScore = Highscore.getWeekScore(curWeek, curDifficulty);
FlxTween.tween(sprDifficulty, {y: leftArrow.y + 15, alpha: 1}, 0.07); FlxTween.tween(sprDifficulty, {y: leftArrow.y + 15, alpha: 1}, 0.07);
} }
var lerpScore:Int = 0;
var intendedScore:Int = 0;
function changeWeek(change:Int = 0):Void function changeWeek(change:Int = 0):Void
{ {
curWeek += change; curWeek += change;
@ -329,5 +337,7 @@ class StoryMenuState extends MusicBeatState
txtTracklist.screenCenter(X); txtTracklist.screenCenter(X);
txtTracklist.x -= FlxG.width * 0.35; txtTracklist.x -= FlxG.width * 0.35;
intendedScore = Highscore.getWeekScore(curWeek, curDifficulty);
} }
} }

View file

@ -74,7 +74,7 @@ class TitleState extends MusicBeatState
} }
#if SKIP_TO_PLAYSTATE #if SKIP_TO_PLAYSTATE
FlxG.switchState(new FreeplayState()); FlxG.switchState(new StoryMenuState());
#else #else
startIntro(); startIntro();
#end #end