2020-10-27 10:35:23 +00:00
|
|
|
package;
|
|
|
|
|
|
|
|
import flixel.FlxG;
|
|
|
|
import flixel.FlxObject;
|
|
|
|
import flixel.FlxSubState;
|
|
|
|
import flixel.math.FlxPoint;
|
2020-10-28 07:03:32 +00:00
|
|
|
import flixel.util.FlxColor;
|
|
|
|
import flixel.util.FlxTimer;
|
2021-04-04 04:37:57 +00:00
|
|
|
import haxe.display.Display.Package;
|
2021-04-09 15:38:09 +00:00
|
|
|
import ui.PreferencesMenu;
|
2020-10-27 10:35:23 +00:00
|
|
|
|
2020-10-28 09:26:33 +00:00
|
|
|
class GameOverSubstate extends MusicBeatSubstate
|
2020-10-27 10:35:23 +00:00
|
|
|
{
|
|
|
|
var bf:Boyfriend;
|
|
|
|
var camFollow:FlxObject;
|
|
|
|
|
2021-01-30 12:16:51 +00:00
|
|
|
var stageSuffix:String = "";
|
2021-03-18 18:15:54 +00:00
|
|
|
var randomGameover:Int = 1;
|
2020-11-01 09:55:02 +00:00
|
|
|
|
2020-10-27 10:35:23 +00:00
|
|
|
public function new(x:Float, y:Float)
|
|
|
|
{
|
2021-01-30 12:16:51 +00:00
|
|
|
var daStage = PlayState.curStage;
|
|
|
|
var daBf:String = '';
|
|
|
|
switch (daStage)
|
|
|
|
{
|
2021-04-11 16:41:23 +00:00
|
|
|
case 'school' | 'schoolEvil':
|
2021-02-02 10:46:17 +00:00
|
|
|
stageSuffix = '-pixel';
|
|
|
|
daBf = 'bf-pixel-dead';
|
2021-01-30 12:16:51 +00:00
|
|
|
default:
|
|
|
|
daBf = 'bf';
|
|
|
|
}
|
|
|
|
|
2021-04-04 04:37:57 +00:00
|
|
|
var daSong = PlayState.SONG.song.toLowerCase();
|
|
|
|
|
|
|
|
switch (daSong)
|
|
|
|
{
|
|
|
|
case 'stress':
|
|
|
|
daBf = 'bf-holding-gf-dead';
|
|
|
|
}
|
|
|
|
|
2020-10-27 10:35:23 +00:00
|
|
|
super();
|
|
|
|
|
2020-10-28 09:26:33 +00:00
|
|
|
Conductor.songPosition = 0;
|
|
|
|
|
2021-01-30 12:16:51 +00:00
|
|
|
bf = new Boyfriend(x, y, daBf);
|
2020-10-27 10:35:23 +00:00
|
|
|
add(bf);
|
|
|
|
|
|
|
|
camFollow = new FlxObject(bf.getGraphicMidpoint().x, bf.getGraphicMidpoint().y, 1, 1);
|
|
|
|
add(camFollow);
|
|
|
|
|
2021-02-08 21:34:48 +00:00
|
|
|
FlxG.sound.play(Paths.sound('fnf_loss_sfx' + stageSuffix));
|
2020-10-28 09:26:33 +00:00
|
|
|
Conductor.changeBPM(100);
|
2020-10-27 10:35:23 +00:00
|
|
|
|
|
|
|
// FlxG.camera.followLerp = 1;
|
|
|
|
// FlxG.camera.focusOn(FlxPoint.get(FlxG.width / 2, FlxG.height / 2));
|
|
|
|
FlxG.camera.scroll.set();
|
|
|
|
FlxG.camera.target = null;
|
|
|
|
|
|
|
|
bf.playAnim('firstDeath');
|
2021-03-18 18:15:54 +00:00
|
|
|
|
2021-04-09 15:38:09 +00:00
|
|
|
var randomCensor:Array<Int> = [];
|
|
|
|
|
|
|
|
if (PreferencesMenu.getPref('censor-naughty'))
|
|
|
|
randomCensor = [1, 3, 8, 13, 17, 21];
|
|
|
|
|
|
|
|
randomGameover = FlxG.random.int(1, 25, randomCensor);
|
2020-10-27 10:35:23 +00:00
|
|
|
}
|
|
|
|
|
2021-03-18 18:15:54 +00:00
|
|
|
var playingDeathSound:Bool = false;
|
|
|
|
|
2020-10-27 10:35:23 +00:00
|
|
|
override function update(elapsed:Float)
|
|
|
|
{
|
2021-04-19 17:11:30 +00:00
|
|
|
// makes the lerp non-dependant on the framerate
|
|
|
|
FlxG.camera.followLerp = CoolUtil.camLerpShit(0.01);
|
|
|
|
|
2020-10-27 10:35:23 +00:00
|
|
|
super.update(elapsed);
|
|
|
|
|
2020-11-01 07:58:20 +00:00
|
|
|
if (controls.ACCEPT)
|
2020-10-28 07:03:32 +00:00
|
|
|
{
|
|
|
|
endBullshit();
|
|
|
|
}
|
|
|
|
|
2020-11-01 07:58:20 +00:00
|
|
|
if (controls.BACK)
|
|
|
|
{
|
2021-04-09 20:37:54 +00:00
|
|
|
PlayState.deathCounter = 0;
|
|
|
|
PlayState.seenCutscene = false;
|
2020-11-01 07:58:20 +00:00
|
|
|
FlxG.sound.music.stop();
|
|
|
|
|
|
|
|
if (PlayState.isStoryMode)
|
|
|
|
FlxG.switchState(new StoryMenuState());
|
|
|
|
else
|
|
|
|
FlxG.switchState(new FreeplayState());
|
|
|
|
}
|
|
|
|
|
2021-04-11 16:41:23 +00:00
|
|
|
#if debug
|
|
|
|
if (FlxG.keys.justPressed.EIGHT)
|
|
|
|
FlxG.switchState(new AnimationDebug(bf.curCharacter));
|
|
|
|
#end
|
|
|
|
|
2020-10-27 10:35:23 +00:00
|
|
|
if (bf.animation.curAnim.name == 'firstDeath' && bf.animation.curAnim.curFrame == 12)
|
|
|
|
{
|
2021-04-19 17:11:30 +00:00
|
|
|
FlxG.camera.follow(camFollow, LOCKON, CoolUtil.camLerpShit(0.01));
|
2020-10-27 10:35:23 +00:00
|
|
|
}
|
|
|
|
|
2021-03-18 18:15:54 +00:00
|
|
|
switch (PlayState.storyWeek)
|
2020-10-27 10:35:23 +00:00
|
|
|
{
|
2021-03-18 18:15:54 +00:00
|
|
|
case 7:
|
|
|
|
if (bf.animation.curAnim.name == 'firstDeath' && bf.animation.curAnim.finished && !playingDeathSound)
|
|
|
|
{
|
|
|
|
playingDeathSound = true;
|
2021-04-18 09:25:44 +00:00
|
|
|
|
|
|
|
bf.startedDeath = true;
|
|
|
|
coolStartDeath(0.2);
|
|
|
|
|
2021-03-18 18:15:54 +00:00
|
|
|
FlxG.sound.play(Paths.sound('jeffGameover/jeffGameover-' + randomGameover), 1, false, null, true, function()
|
|
|
|
{
|
2021-04-19 08:43:21 +00:00
|
|
|
if (!isEnding)
|
|
|
|
FlxG.sound.music.fadeIn(4, 0.2, 1);
|
2021-03-18 18:15:54 +00:00
|
|
|
});
|
|
|
|
}
|
|
|
|
default:
|
|
|
|
if (bf.animation.curAnim.name == 'firstDeath' && bf.animation.curAnim.finished)
|
|
|
|
{
|
|
|
|
bf.startedDeath = true;
|
|
|
|
coolStartDeath();
|
|
|
|
}
|
2020-10-27 10:35:23 +00:00
|
|
|
}
|
2020-10-28 09:26:33 +00:00
|
|
|
|
|
|
|
if (FlxG.sound.music.playing)
|
|
|
|
{
|
|
|
|
Conductor.songPosition = FlxG.sound.music.time;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-18 09:25:44 +00:00
|
|
|
private function coolStartDeath(?vol:Float = 1):Void
|
2021-03-18 18:15:54 +00:00
|
|
|
{
|
2021-04-19 08:43:21 +00:00
|
|
|
if (!isEnding)
|
|
|
|
FlxG.sound.playMusic(Paths.music('gameOver' + stageSuffix), vol);
|
2021-03-18 18:15:54 +00:00
|
|
|
}
|
|
|
|
|
2020-10-28 09:26:33 +00:00
|
|
|
override function beatHit()
|
|
|
|
{
|
|
|
|
super.beatHit();
|
|
|
|
|
|
|
|
FlxG.log.add('beat');
|
2020-10-27 10:35:23 +00:00
|
|
|
}
|
2020-10-28 07:03:32 +00:00
|
|
|
|
|
|
|
var isEnding:Bool = false;
|
|
|
|
|
|
|
|
function endBullshit():Void
|
|
|
|
{
|
|
|
|
if (!isEnding)
|
|
|
|
{
|
|
|
|
isEnding = true;
|
|
|
|
bf.playAnim('deathConfirm', true);
|
|
|
|
FlxG.sound.music.stop();
|
2021-02-08 21:34:48 +00:00
|
|
|
FlxG.sound.play(Paths.music('gameOverEnd' + stageSuffix));
|
2020-10-28 07:03:32 +00:00
|
|
|
new FlxTimer().start(0.7, function(tmr:FlxTimer)
|
|
|
|
{
|
|
|
|
FlxG.camera.fade(FlxColor.BLACK, 2, false, function()
|
|
|
|
{
|
2021-02-09 18:07:05 +00:00
|
|
|
LoadingState.loadAndSwitchState(new PlayState());
|
2020-10-28 07:03:32 +00:00
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
2020-10-27 10:35:23 +00:00
|
|
|
}
|