2022-03-08 03:13:53 -05:00
|
|
|
package funkin.play;
|
2020-10-03 02:50:15 -04:00
|
|
|
|
2020-10-25 16:51:06 -04:00
|
|
|
import flixel.FlxCamera;
|
2020-10-04 02:42:58 -04:00
|
|
|
import flixel.FlxObject;
|
2020-10-03 02:50:15 -04:00
|
|
|
import flixel.FlxSprite;
|
|
|
|
import flixel.FlxState;
|
2020-10-09 17:24:20 -04:00
|
|
|
import flixel.FlxSubState;
|
2022-04-18 19:36:09 -04:00
|
|
|
import flixel.addons.transition.FlxTransitionableState;
|
2021-04-07 20:19:49 -04:00
|
|
|
import flixel.group.FlxGroup;
|
2020-10-05 05:48:30 -04:00
|
|
|
import flixel.math.FlxMath;
|
2021-01-16 17:21:06 -05:00
|
|
|
import flixel.math.FlxRect;
|
2020-10-03 02:50:15 -04:00
|
|
|
import flixel.text.FlxText;
|
2020-10-05 14:24:51 -04:00
|
|
|
import flixel.tweens.FlxEase;
|
2020-10-03 15:32:15 -04:00
|
|
|
import flixel.tweens.FlxTween;
|
2020-10-05 16:32:41 -04:00
|
|
|
import flixel.ui.FlxBar;
|
2020-10-04 02:42:58 -04:00
|
|
|
import flixel.util.FlxColor;
|
2020-10-05 01:13:12 -04:00
|
|
|
import flixel.util.FlxSort;
|
2020-10-03 15:32:15 -04:00
|
|
|
import flixel.util.FlxTimer;
|
2022-04-18 20:39:41 -04:00
|
|
|
import funkin.Section.SwagSection;
|
|
|
|
import funkin.SongLoad.SwagSong;
|
2022-03-09 10:29:03 -05:00
|
|
|
import funkin.charting.ChartingState;
|
2022-03-11 01:30:01 -05:00
|
|
|
import funkin.modding.events.ScriptEvent;
|
|
|
|
import funkin.modding.events.ScriptEventDispatcher;
|
2022-07-24 00:49:54 -04:00
|
|
|
import funkin.play.GameOverSubstate;
|
2022-03-25 22:30:37 -04:00
|
|
|
import funkin.play.HealthIcon;
|
2022-04-18 20:39:41 -04:00
|
|
|
import funkin.play.Strumline.StrumlineArrow;
|
|
|
|
import funkin.play.Strumline.StrumlineStyle;
|
|
|
|
import funkin.play.character.BaseCharacter;
|
|
|
|
import funkin.play.character.CharacterData;
|
2022-09-24 15:02:10 -04:00
|
|
|
import funkin.play.event.SongEvent;
|
2022-07-06 21:49:42 -04:00
|
|
|
import funkin.play.scoring.Scoring;
|
2022-09-22 06:34:03 -04:00
|
|
|
import funkin.play.song.Song;
|
|
|
|
import funkin.play.song.SongData.SongNoteData;
|
|
|
|
import funkin.play.song.SongData.SongPlayableChar;
|
|
|
|
import funkin.play.song.SongValidator;
|
2022-03-08 03:13:53 -05:00
|
|
|
import funkin.play.stage.Stage;
|
|
|
|
import funkin.play.stage.StageData;
|
|
|
|
import funkin.ui.PopUpStuff;
|
|
|
|
import funkin.ui.PreferencesMenu;
|
2022-04-29 23:46:41 -04:00
|
|
|
import funkin.ui.stageBuildShit.StageOffsetSubstate;
|
2022-03-11 01:30:01 -05:00
|
|
|
import funkin.util.Constants;
|
|
|
|
import funkin.util.SortUtil;
|
2022-03-09 10:29:03 -05:00
|
|
|
import lime.ui.Haptic;
|
2020-10-03 02:50:15 -04:00
|
|
|
|
2020-10-04 02:42:58 -04:00
|
|
|
using StringTools;
|
|
|
|
|
2021-03-22 10:09:46 -04:00
|
|
|
#if discord_rpc
|
2021-03-21 16:29:47 -04:00
|
|
|
import Discord.DiscordClient;
|
|
|
|
#end
|
|
|
|
|
2022-08-16 20:26:34 -04:00
|
|
|
class PlayState extends MusicBeatState
|
2020-10-03 02:50:15 -04:00
|
|
|
{
|
2022-03-11 01:30:01 -05:00
|
|
|
/**
|
|
|
|
* STATIC VARIABLES
|
|
|
|
* Static variables should be used for information that must be persisted between states or between resets,
|
|
|
|
* such as the active song or song playlist.
|
|
|
|
*/
|
|
|
|
/**
|
|
|
|
* The currently active PlayState.
|
|
|
|
* Since there is only one PlayState in existance at a time, we can use a singleton.
|
|
|
|
*/
|
|
|
|
public static var instance:PlayState = null;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The currently active song. Includes data about what stage should be used, what characters,
|
|
|
|
* and the notes to be played.
|
|
|
|
*/
|
|
|
|
public static var currentSong:SwagSong = null;
|
|
|
|
|
2022-09-22 06:34:03 -04:00
|
|
|
public static var currentSong_NEW:Song = null;
|
|
|
|
|
2022-03-11 01:30:01 -05:00
|
|
|
/**
|
|
|
|
* Whether the game is currently in Story Mode. If false, we are in Free Play Mode.
|
|
|
|
*/
|
2020-10-31 21:11:14 -04:00
|
|
|
public static var isStoryMode:Bool = false;
|
2022-03-11 01:30:01 -05:00
|
|
|
|
|
|
|
/**
|
|
|
|
* Whether the game is currently in Practice Mode.
|
|
|
|
* If true, player will not lose gain or lose score from notes.
|
|
|
|
*/
|
|
|
|
public static var isPracticeMode:Bool = false;
|
|
|
|
|
2022-03-13 14:36:03 -04:00
|
|
|
/**
|
|
|
|
* Whether the game is currently in a cutscene, and gameplay should be stopped.
|
|
|
|
*/
|
|
|
|
public static var isInCutscene:Bool = false;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Whether the game is currently in the countdown before the song resumes.
|
|
|
|
*/
|
|
|
|
public static var isInCountdown:Bool = false;
|
|
|
|
|
2022-03-21 00:19:05 -04:00
|
|
|
/**
|
|
|
|
* Gets set to true when the PlayState needs to reset (player opted to restart or died).
|
|
|
|
* Gets disabled once resetting happens.
|
|
|
|
*/
|
|
|
|
public static var needsReset:Bool = false;
|
|
|
|
|
2022-03-11 01:30:01 -05:00
|
|
|
/**
|
|
|
|
* The current "Blueball Counter" to display in the pause menu.
|
|
|
|
* Resets when you beat a song or go back to the main menu.
|
|
|
|
*/
|
2021-03-04 14:30:35 -05:00
|
|
|
public static var deathCounter:Int = 0;
|
2020-10-31 21:11:14 -04:00
|
|
|
|
2022-03-13 14:36:03 -04:00
|
|
|
/**
|
|
|
|
* The default camera zoom level. The camera lerps back to this after zooming in.
|
|
|
|
* Defaults to 1.05 but may be larger or smaller depending on the current stage.
|
|
|
|
*/
|
|
|
|
public static var defaultCameraZoom:Float = 1.05;
|
|
|
|
|
2022-03-11 01:30:01 -05:00
|
|
|
/**
|
|
|
|
* Used to persist the position of the `cameraFollowPosition` between resets.
|
|
|
|
*/
|
|
|
|
private static var previousCameraFollowPoint:FlxObject = null;
|
2020-10-03 13:36:39 -04:00
|
|
|
|
2022-03-11 01:30:01 -05:00
|
|
|
/**
|
|
|
|
* PUBLIC INSTANCE VARIABLES
|
|
|
|
* Public instance variables should be used for information that must be reset or dereferenced
|
|
|
|
* every time the state is reset, such as the currently active stage, but may need to be accessed externally.
|
|
|
|
*/
|
|
|
|
/**
|
|
|
|
* The currently active Stage. This is the object containing all the props.
|
|
|
|
*/
|
|
|
|
public var currentStage:Stage = null;
|
2020-10-03 02:50:15 -04:00
|
|
|
|
2022-09-22 06:34:03 -04:00
|
|
|
public var currentChart(get, null):SongDifficulty;
|
|
|
|
|
2021-09-24 10:56:05 -04:00
|
|
|
/**
|
2022-03-11 01:30:01 -05:00
|
|
|
* The internal ID of the currently active Stage.
|
|
|
|
* Used to retrieve the data required to build the `currentStage`.
|
2021-09-24 10:56:05 -04:00
|
|
|
*/
|
2022-03-11 01:30:01 -05:00
|
|
|
public var currentStageId:String = '';
|
2021-09-24 10:56:05 -04:00
|
|
|
|
2022-03-11 01:30:01 -05:00
|
|
|
/**
|
|
|
|
* The player's current health.
|
|
|
|
* The default maximum health is 2.0, and the default starting health is 1.0.
|
|
|
|
*/
|
|
|
|
public var health:Float = 1;
|
2020-10-03 02:50:15 -04:00
|
|
|
|
2022-03-21 00:19:05 -04:00
|
|
|
/**
|
|
|
|
* The player's current score.
|
|
|
|
*/
|
|
|
|
public var songScore:Int = 0;
|
|
|
|
|
2022-03-13 14:36:03 -04:00
|
|
|
/**
|
|
|
|
* An empty FlxObject contained in the scene.
|
|
|
|
* The current gameplay camera will be centered on this object. Tween its position to move the camera smoothly.
|
2022-03-17 01:40:08 -04:00
|
|
|
*
|
2022-03-29 21:56:04 -04:00
|
|
|
* This is an FlxSprite for two reasons:
|
|
|
|
* 1. It needs to be an object in the scene for the camera to be configured to follow it.
|
|
|
|
* 2. It needs to be an FlxSprite to allow a graphic (optionally, for debug purposes) to be drawn on it.
|
2022-03-13 14:36:03 -04:00
|
|
|
*/
|
2022-03-25 22:30:37 -04:00
|
|
|
public var cameraFollowPoint:FlxSprite = new FlxSprite(0, 0);
|
2022-03-13 14:36:03 -04:00
|
|
|
|
2022-03-11 01:30:01 -05:00
|
|
|
/**
|
|
|
|
* PRIVATE INSTANCE VARIABLES
|
|
|
|
* Private instance variables should be used for information that must be reset or dereferenced
|
|
|
|
* every time the state is reset, but should not be accessed externally.
|
|
|
|
*/
|
|
|
|
/**
|
|
|
|
* The Array containing the notes that are not currently on the screen.
|
|
|
|
* The `update()` function regularly shifts these out to add new notes to the screen.
|
|
|
|
*/
|
|
|
|
private var inactiveNotes:Array<Note>;
|
2020-10-03 15:32:15 -04:00
|
|
|
|
2022-09-24 15:02:10 -04:00
|
|
|
private var songEvents:Array<SongEvent>;
|
|
|
|
|
2022-03-11 01:30:01 -05:00
|
|
|
/**
|
|
|
|
* If true, the player is allowed to pause the game.
|
|
|
|
* Disabled during the ending of a song.
|
|
|
|
*/
|
|
|
|
private var mayPauseGame:Bool = true;
|
2022-02-16 16:31:20 -05:00
|
|
|
|
2022-03-08 03:13:53 -05:00
|
|
|
/**
|
2022-03-11 01:30:01 -05:00
|
|
|
* The displayed value of the player's health.
|
|
|
|
* Used to provide smooth animations based on linear interpolation of the player's health.
|
2022-03-08 03:13:53 -05:00
|
|
|
*/
|
2022-03-11 01:30:01 -05:00
|
|
|
private var healthLerp:Float = 1;
|
2022-03-08 03:13:53 -05:00
|
|
|
|
2022-09-22 06:34:03 -04:00
|
|
|
/**
|
|
|
|
* Forcibly disables all update logic while the game moves back to the Menu state.
|
|
|
|
* This is used only when a critical error occurs and the game cannot continue.
|
|
|
|
*/
|
|
|
|
private var criticalFailure:Bool = false;
|
|
|
|
|
2022-02-16 16:31:20 -05:00
|
|
|
/**
|
2022-03-11 01:30:01 -05:00
|
|
|
* RENDER OBJECTS
|
2022-02-16 16:31:20 -05:00
|
|
|
*/
|
2022-03-11 01:30:01 -05:00
|
|
|
/**
|
|
|
|
* The SpriteGroup containing the notes that are currently on the screen or are about to be on the screen.
|
|
|
|
*/
|
|
|
|
private var activeNotes:FlxTypedGroup<Note> = null;
|
2020-10-04 02:42:58 -04:00
|
|
|
|
2022-03-11 01:30:01 -05:00
|
|
|
/**
|
|
|
|
* The FlxText which displays the current score.
|
|
|
|
*/
|
|
|
|
private var scoreText:FlxText;
|
2020-10-05 05:48:30 -04:00
|
|
|
|
2022-03-11 01:30:01 -05:00
|
|
|
/**
|
|
|
|
* The bar which displays the player's health.
|
|
|
|
* Dynamically updated based on the value of `healthLerp` (which is based on `health`).
|
|
|
|
*/
|
2022-03-26 22:18:26 -04:00
|
|
|
public var healthBar:FlxBar;
|
2022-02-28 23:04:55 -05:00
|
|
|
|
2022-03-11 01:30:01 -05:00
|
|
|
/**
|
|
|
|
* The background image used for the health bar.
|
|
|
|
* Emma says the image is slightly skewed so I'm leaving it as an image instead of a `createGraphic`.
|
|
|
|
*/
|
|
|
|
public var healthBarBG:FlxSprite;
|
2022-02-28 23:04:55 -05:00
|
|
|
|
2022-03-26 22:18:26 -04:00
|
|
|
/**
|
|
|
|
* The health icon representing the player.
|
|
|
|
*/
|
|
|
|
public var iconP1:HealthIcon;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The health icon representing the opponent.
|
|
|
|
*/
|
|
|
|
public var iconP2:HealthIcon;
|
|
|
|
|
2022-03-11 01:30:01 -05:00
|
|
|
/**
|
|
|
|
* The sprite group containing active player's strumline notes.
|
|
|
|
*/
|
|
|
|
public var playerStrumline:Strumline;
|
2020-10-05 08:55:39 -04:00
|
|
|
|
2022-03-11 01:30:01 -05:00
|
|
|
/**
|
|
|
|
* The sprite group containing opponent's strumline notes.
|
|
|
|
*/
|
|
|
|
public var enemyStrumline:Strumline;
|
|
|
|
|
2022-03-13 14:36:03 -04:00
|
|
|
/**
|
|
|
|
* The camera which contains, and controls visibility of, the user interface elements.
|
|
|
|
*/
|
|
|
|
public var camHUD:FlxCamera;
|
|
|
|
|
|
|
|
/**
|
|
|
|
* The camera which contains, and controls visibility of, the stage and characters.
|
|
|
|
*/
|
|
|
|
public var camGame:FlxCamera;
|
|
|
|
|
2022-03-11 01:30:01 -05:00
|
|
|
/**
|
|
|
|
* PROPERTIES
|
|
|
|
*/
|
|
|
|
/**
|
|
|
|
* If a substate is rendering over the PlayState, it is paused and normal update logic is skipped.
|
|
|
|
* Examples include:
|
|
|
|
* - The Pause screen is open.
|
|
|
|
* - The Game Over screen is open.
|
|
|
|
* - The Chart Editor screen is open.
|
|
|
|
*/
|
|
|
|
private var isGamePaused(get, never):Bool;
|
|
|
|
|
|
|
|
function get_isGamePaused():Bool
|
|
|
|
{
|
|
|
|
// Note: If there is a substate which requires the game to act unpaused,
|
|
|
|
// this should be changed to include something like `&& Std.isOfType()`
|
|
|
|
return this.subState != null;
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO: Reorganize these variables (maybe there should be a separate class like Conductor just to hold them?)
|
|
|
|
public static var storyWeek:Int = 0;
|
|
|
|
public static var storyPlaylist:Array<String> = [];
|
|
|
|
public static var storyDifficulty:Int = 1;
|
2022-09-22 06:34:03 -04:00
|
|
|
public static var storyDifficulty_NEW:String = "normal";
|
2022-03-11 01:30:01 -05:00
|
|
|
public static var seenCutscene:Bool = false;
|
|
|
|
public static var campaignScore:Int = 0;
|
|
|
|
|
|
|
|
private var vocals:VoicesGroup;
|
|
|
|
private var vocalsFinished:Bool = false;
|
2020-10-05 16:32:41 -04:00
|
|
|
|
2022-03-11 01:30:01 -05:00
|
|
|
private var camZooming:Bool = false;
|
|
|
|
private var gfSpeed:Int = 1;
|
|
|
|
private var combo:Int = 0;
|
2020-10-05 14:24:51 -04:00
|
|
|
private var generatedMusic:Bool = false;
|
2020-10-23 19:12:38 -04:00
|
|
|
private var startingSong:Bool = false;
|
2022-03-13 14:36:03 -04:00
|
|
|
|
2021-09-21 15:39:30 -04:00
|
|
|
var dialogue:Array<String>;
|
2020-10-31 21:11:14 -04:00
|
|
|
var talking:Bool = true;
|
2021-09-21 15:39:30 -04:00
|
|
|
var doof:DialogueBox;
|
2021-04-10 01:49:57 -04:00
|
|
|
var grpNoteSplashes:FlxTypedGroup<NoteSplash>;
|
2022-03-11 01:30:01 -05:00
|
|
|
var comboPopUps:PopUpStuff;
|
|
|
|
var perfectMode:Bool = false;
|
|
|
|
var previousFrameTime:Int = 0;
|
|
|
|
var songTime:Float = 0;
|
2021-02-02 02:35:35 -05:00
|
|
|
|
2021-03-22 10:09:46 -04:00
|
|
|
#if discord_rpc
|
2021-02-27 16:59:18 -05:00
|
|
|
// Discord RPC variables
|
|
|
|
var storyDifficultyText:String = "";
|
|
|
|
var iconRPC:String = "";
|
|
|
|
var songLength:Float = 0;
|
2021-02-27 18:23:50 -05:00
|
|
|
var detailsText:String = "";
|
|
|
|
var detailsPausedText:String = "";
|
2021-02-27 16:59:18 -05:00
|
|
|
#end
|
|
|
|
|
2020-10-03 02:50:15 -04:00
|
|
|
override public function create()
|
|
|
|
{
|
2022-03-11 01:30:01 -05:00
|
|
|
super.create();
|
|
|
|
|
2022-09-22 06:34:03 -04:00
|
|
|
if (currentSong == null && currentSong_NEW == null)
|
2022-07-22 16:11:18 -04:00
|
|
|
{
|
2022-09-22 06:34:03 -04:00
|
|
|
criticalFailure = true;
|
|
|
|
|
2022-07-22 16:11:18 -04:00
|
|
|
lime.app.Application.current.window.alert("There was a critical error while accessing the selected song. Click OK to return to the main menu.",
|
|
|
|
"Error loading PlayState");
|
2022-07-06 21:49:42 -04:00
|
|
|
FlxG.switchState(new MainMenuState());
|
2022-08-27 02:02:29 -04:00
|
|
|
return;
|
2022-07-06 21:49:42 -04:00
|
|
|
}
|
|
|
|
|
2022-03-08 03:13:53 -05:00
|
|
|
instance = this;
|
|
|
|
|
2022-09-24 15:02:10 -04:00
|
|
|
if (currentSong_NEW != null)
|
|
|
|
{
|
|
|
|
// TODO: Do this in the loading state.
|
|
|
|
currentSong_NEW.cacheCharts(true);
|
|
|
|
}
|
|
|
|
|
2022-03-26 22:18:26 -04:00
|
|
|
// Displays the camera follow point as a sprite for debug purposes.
|
|
|
|
// TODO: Put this on a toggle?
|
|
|
|
cameraFollowPoint.makeGraphic(8, 8, 0xFF00FF00);
|
2022-03-29 21:56:04 -04:00
|
|
|
cameraFollowPoint.visible = false;
|
2022-03-25 22:30:37 -04:00
|
|
|
cameraFollowPoint.zIndex = 1000000;
|
|
|
|
|
2022-03-11 01:30:01 -05:00
|
|
|
// Reduce physics accuracy (who cares!!!) to improve animation quality.
|
|
|
|
FlxG.fixedTimestep = false;
|
2020-10-26 05:16:05 -04:00
|
|
|
|
2022-03-11 01:30:01 -05:00
|
|
|
// This state receives update() even when a substate is active.
|
|
|
|
this.persistentUpdate = true;
|
|
|
|
// This state receives draw calls even when a substate is active.
|
|
|
|
this.persistentDraw = true;
|
2022-02-28 23:04:55 -05:00
|
|
|
|
2022-03-13 14:36:03 -04:00
|
|
|
// Stop any pre-existing music.
|
|
|
|
if (FlxG.sound.music != null)
|
|
|
|
FlxG.sound.music.stop();
|
|
|
|
|
|
|
|
// Prepare the current song to be played.
|
2022-09-22 06:34:03 -04:00
|
|
|
if (currentChart != null)
|
|
|
|
{
|
|
|
|
currentChart.cacheInst();
|
|
|
|
currentChart.cacheVocals();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
FlxG.sound.cache(Paths.inst(currentSong.song));
|
|
|
|
FlxG.sound.cache(Paths.voices(currentSong.song));
|
|
|
|
}
|
2022-03-13 14:36:03 -04:00
|
|
|
|
|
|
|
// Initialize stage stuff.
|
|
|
|
initCameras();
|
|
|
|
|
2022-09-22 06:34:03 -04:00
|
|
|
if (currentSong == null && currentSong_NEW == null)
|
|
|
|
{
|
2022-03-11 01:30:01 -05:00
|
|
|
currentSong = SongLoad.loadFromJson('tutorial');
|
2022-09-22 06:34:03 -04:00
|
|
|
}
|
2020-10-13 04:37:19 -04:00
|
|
|
|
2022-09-22 06:34:03 -04:00
|
|
|
if (currentSong_NEW != null)
|
|
|
|
{
|
2022-12-08 19:33:47 -05:00
|
|
|
Conductor.mapTimeChanges(currentChart.timeChanges);
|
2022-09-22 06:34:03 -04:00
|
|
|
// Conductor.bpm = currentChart.getStartingBPM();
|
2020-10-30 19:47:19 -04:00
|
|
|
|
2022-09-22 06:34:03 -04:00
|
|
|
// TODO: Support for dialog.
|
|
|
|
}
|
|
|
|
else
|
2020-10-31 21:11:14 -04:00
|
|
|
{
|
2022-09-22 06:34:03 -04:00
|
|
|
Conductor.mapBPMChanges(currentSong);
|
|
|
|
// Conductor.bpm = currentSong.bpm;
|
|
|
|
|
|
|
|
switch (currentSong.song.toLowerCase())
|
|
|
|
{
|
|
|
|
case 'senpai':
|
|
|
|
dialogue = CoolUtil.coolTextFile(Paths.txt('songs/senpai/senpaiDialogue'));
|
|
|
|
case 'roses':
|
|
|
|
dialogue = CoolUtil.coolTextFile(Paths.txt('songs/roses/rosesDialogue'));
|
|
|
|
case 'thorns':
|
|
|
|
dialogue = CoolUtil.coolTextFile(Paths.txt('songs/thorns/thornsDialogue'));
|
|
|
|
}
|
2020-10-31 21:11:14 -04:00
|
|
|
}
|
|
|
|
|
2022-09-24 01:28:39 -04:00
|
|
|
Conductor.update(-5000);
|
|
|
|
|
2021-11-23 15:00:10 -05:00
|
|
|
if (dialogue != null)
|
|
|
|
{
|
|
|
|
doof = new DialogueBox(false, dialogue);
|
|
|
|
doof.scrollFactor.set();
|
|
|
|
doof.finishThing = startCountdown;
|
|
|
|
doof.cameras = [camHUD];
|
|
|
|
}
|
|
|
|
|
2022-03-13 14:36:03 -04:00
|
|
|
// Once the song is loaded, we can continue and initialize the stage.
|
|
|
|
|
2022-03-26 22:18:26 -04:00
|
|
|
var healthBarYPos:Float = PreferencesMenu.getPref('downscroll') ? FlxG.height * 0.1 : FlxG.height * 0.9;
|
|
|
|
healthBarBG = new FlxSprite(0, healthBarYPos).loadGraphic(Paths.image('healthBar'));
|
|
|
|
healthBarBG.screenCenter(X);
|
|
|
|
healthBarBG.scrollFactor.set(0, 0);
|
|
|
|
add(healthBarBG);
|
|
|
|
|
|
|
|
healthBar = new FlxBar(healthBarBG.x + 4, healthBarBG.y + 4, RIGHT_TO_LEFT, Std.int(healthBarBG.width - 8), Std.int(healthBarBG.height - 8), this,
|
|
|
|
'healthLerp', 0, 2);
|
|
|
|
healthBar.scrollFactor.set();
|
2022-10-26 01:14:29 -04:00
|
|
|
healthBar.createFilledBar(Constants.COLOR_HEALTH_BAR_RED, Constants.COLOR_HEALTH_BAR_GREEN);
|
2022-03-26 22:18:26 -04:00
|
|
|
add(healthBar);
|
|
|
|
|
2022-03-13 14:36:03 -04:00
|
|
|
initStage();
|
|
|
|
initCharacters();
|
|
|
|
#if discord_rpc
|
|
|
|
initDiscord();
|
|
|
|
#end
|
2021-11-23 15:00:10 -05:00
|
|
|
|
2022-03-17 01:40:08 -04:00
|
|
|
// Configure camera follow point.
|
|
|
|
if (previousCameraFollowPoint != null)
|
|
|
|
{
|
|
|
|
cameraFollowPoint.setPosition(previousCameraFollowPoint.x, previousCameraFollowPoint.y);
|
|
|
|
previousCameraFollowPoint = null;
|
|
|
|
}
|
|
|
|
add(cameraFollowPoint);
|
|
|
|
|
2022-02-16 16:31:20 -05:00
|
|
|
comboPopUps = new PopUpStuff();
|
|
|
|
add(comboPopUps);
|
|
|
|
|
2021-11-23 15:00:10 -05:00
|
|
|
grpNoteSplashes = new FlxTypedGroup<NoteSplash>();
|
|
|
|
|
|
|
|
var noteSplash:NoteSplash = new NoteSplash(100, 100, 0);
|
|
|
|
grpNoteSplashes.add(noteSplash);
|
|
|
|
noteSplash.alpha = 0.1;
|
|
|
|
|
|
|
|
add(grpNoteSplashes);
|
|
|
|
|
2022-09-22 06:34:03 -04:00
|
|
|
if (currentSong_NEW != null)
|
|
|
|
{
|
|
|
|
generateSong_NEW();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
generateSong();
|
|
|
|
}
|
2021-11-23 15:00:10 -05:00
|
|
|
|
2022-03-11 01:30:01 -05:00
|
|
|
resetCamera();
|
2021-11-23 15:00:10 -05:00
|
|
|
|
|
|
|
FlxG.worldBounds.set(0, 0, FlxG.width, FlxG.height);
|
|
|
|
|
2022-03-11 01:30:01 -05:00
|
|
|
scoreText = new FlxText(healthBarBG.x + healthBarBG.width - 190, healthBarBG.y + 30, 0, "", 20);
|
|
|
|
scoreText.setFormat(Paths.font("vcr.ttf"), 16, FlxColor.WHITE, RIGHT, FlxTextBorderStyle.OUTLINE, FlxColor.BLACK);
|
|
|
|
scoreText.scrollFactor.set();
|
|
|
|
add(scoreText);
|
2021-11-23 15:00:10 -05:00
|
|
|
|
2022-03-11 01:30:01 -05:00
|
|
|
// Attach the groups to the HUD camera so they are rendered independent of the stage.
|
2021-11-23 15:00:10 -05:00
|
|
|
grpNoteSplashes.cameras = [camHUD];
|
2022-03-11 01:30:01 -05:00
|
|
|
activeNotes.cameras = [camHUD];
|
2021-11-23 15:00:10 -05:00
|
|
|
healthBar.cameras = [camHUD];
|
|
|
|
healthBarBG.cameras = [camHUD];
|
|
|
|
iconP1.cameras = [camHUD];
|
|
|
|
iconP2.cameras = [camHUD];
|
2022-03-11 01:30:01 -05:00
|
|
|
scoreText.cameras = [camHUD];
|
2022-03-21 00:19:05 -04:00
|
|
|
leftWatermarkText.cameras = [camHUD];
|
|
|
|
rightWatermarkText.cameras = [camHUD];
|
2021-11-23 15:00:10 -05:00
|
|
|
|
|
|
|
// if (SONG.song == 'South')
|
|
|
|
// FlxG.camera.alpha = 0.7;
|
|
|
|
// UI_camera.zoom = 1;
|
|
|
|
|
|
|
|
// cameras = [FlxG.cameras.list[1]];
|
|
|
|
startingSong = true;
|
|
|
|
|
|
|
|
if (isStoryMode && !seenCutscene)
|
|
|
|
{
|
|
|
|
seenCutscene = true;
|
|
|
|
|
2022-03-11 01:30:01 -05:00
|
|
|
switch (currentSong.song.toLowerCase())
|
2021-11-23 15:00:10 -05:00
|
|
|
{
|
|
|
|
case "winter-horrorland":
|
2022-03-13 14:36:03 -04:00
|
|
|
VanillaCutscenes.playHorrorStartCutscene();
|
2021-11-23 15:00:10 -05:00
|
|
|
case 'senpai' | 'roses' | 'thorns':
|
|
|
|
schoolIntro(doof); // doof is assumed to be non-null, lol!
|
|
|
|
case 'ugh':
|
2022-03-13 14:36:03 -04:00
|
|
|
VanillaCutscenes.playUghCutscene();
|
2021-11-23 15:00:10 -05:00
|
|
|
case 'stress':
|
2022-03-13 14:36:03 -04:00
|
|
|
VanillaCutscenes.playStressCutscene();
|
2021-11-23 15:00:10 -05:00
|
|
|
case 'guns':
|
2022-03-13 14:36:03 -04:00
|
|
|
VanillaCutscenes.playGunsCutscene();
|
2021-11-23 15:00:10 -05:00
|
|
|
default:
|
2022-03-14 20:48:45 -04:00
|
|
|
// VanillaCutscenes will call startCountdown later.
|
|
|
|
// TODO: Alternatively: make a song script that allows startCountdown to be called,
|
|
|
|
// then cancels the countdown, hides the strumline, plays the cutscene,
|
|
|
|
// then calls Countdown.performCountdown()
|
2021-11-23 15:00:10 -05:00
|
|
|
startCountdown();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-03-11 01:30:01 -05:00
|
|
|
startCountdown();
|
2021-11-23 15:00:10 -05:00
|
|
|
}
|
2022-03-13 14:36:03 -04:00
|
|
|
|
2022-03-14 20:48:45 -04:00
|
|
|
#if debug
|
2022-03-13 14:36:03 -04:00
|
|
|
this.rightWatermarkText.text = Constants.VERSION;
|
2022-03-14 20:48:45 -04:00
|
|
|
#end
|
2021-11-23 15:00:10 -05:00
|
|
|
}
|
|
|
|
|
2022-09-22 06:34:03 -04:00
|
|
|
function get_currentChart():SongDifficulty
|
|
|
|
{
|
|
|
|
if (currentSong_NEW == null || storyDifficulty_NEW == null)
|
|
|
|
return null;
|
|
|
|
return currentSong_NEW.getDifficulty(storyDifficulty_NEW);
|
|
|
|
}
|
|
|
|
|
2022-03-11 01:30:01 -05:00
|
|
|
/**
|
2022-03-13 14:36:03 -04:00
|
|
|
* Initializes the game and HUD cameras.
|
2022-03-11 01:30:01 -05:00
|
|
|
*/
|
2021-11-23 15:00:10 -05:00
|
|
|
function initCameras()
|
|
|
|
{
|
2022-03-13 14:36:03 -04:00
|
|
|
// Configure the default camera zoom level.
|
|
|
|
defaultCameraZoom = FlxCamera.defaultZoom * 1.05;
|
2021-11-23 15:00:10 -05:00
|
|
|
|
|
|
|
camGame = new SwagCamera();
|
|
|
|
camHUD = new FlxCamera();
|
|
|
|
camHUD.bgColor.alpha = 0;
|
|
|
|
|
|
|
|
FlxG.cameras.reset(camGame);
|
|
|
|
FlxG.cameras.add(camHUD, false);
|
|
|
|
}
|
|
|
|
|
2022-03-06 03:33:12 -05:00
|
|
|
function initStage()
|
2021-11-23 15:00:10 -05:00
|
|
|
{
|
2022-09-22 06:34:03 -04:00
|
|
|
if (currentSong_NEW != null)
|
|
|
|
{
|
|
|
|
initStage_NEW();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-03-01 11:29:01 -05:00
|
|
|
// TODO: Move stageId to the song file.
|
2022-03-11 01:30:01 -05:00
|
|
|
switch (currentSong.song.toLowerCase())
|
2020-10-31 21:11:14 -04:00
|
|
|
{
|
2021-03-07 01:59:22 -05:00
|
|
|
case 'spookeez' | 'monster' | 'south':
|
2022-03-11 01:30:01 -05:00
|
|
|
currentStageId = "spookyMansion";
|
2021-03-07 01:59:22 -05:00
|
|
|
case 'pico' | 'blammed' | 'philly':
|
2022-03-11 01:30:01 -05:00
|
|
|
currentStageId = 'phillyTrain';
|
2021-03-07 01:59:22 -05:00
|
|
|
case "milf" | 'satin-panties' | 'high':
|
2022-03-11 01:30:01 -05:00
|
|
|
currentStageId = 'limoRide';
|
2021-03-07 01:59:22 -05:00
|
|
|
case "cocoa" | 'eggnog':
|
2022-03-11 01:30:01 -05:00
|
|
|
currentStageId = 'mallXmas';
|
2021-03-07 01:59:22 -05:00
|
|
|
case 'winter-horrorland':
|
2022-03-11 01:30:01 -05:00
|
|
|
currentStageId = 'mallEvil';
|
2022-07-22 16:11:18 -04:00
|
|
|
case 'senpai' | 'roses':
|
|
|
|
currentStageId = 'school';
|
2022-07-06 21:49:42 -04:00
|
|
|
case "darnell" | "lit-up" | "2hot":
|
2022-09-03 22:21:54 -04:00
|
|
|
currentStageId = 'phillyStreets';
|
|
|
|
// currentStageId = 'pyro';
|
|
|
|
case "blazin":
|
|
|
|
currentStageId = 'phillyBlazin';
|
|
|
|
// currentStageId = 'pyro';
|
2022-02-28 23:04:55 -05:00
|
|
|
case 'pyro':
|
2022-03-11 01:30:01 -05:00
|
|
|
currentStageId = 'pyro';
|
2021-03-07 01:59:22 -05:00
|
|
|
case 'thorns':
|
2022-03-11 01:30:01 -05:00
|
|
|
currentStageId = 'schoolEvil';
|
2021-03-07 15:34:21 -05:00
|
|
|
case 'guns' | 'stress' | 'ugh':
|
2022-03-11 01:30:01 -05:00
|
|
|
currentStageId = 'tankmanBattlefield';
|
2021-03-07 01:59:22 -05:00
|
|
|
default:
|
2022-03-11 01:30:01 -05:00
|
|
|
currentStageId = "mainStage";
|
2020-10-31 21:11:14 -04:00
|
|
|
}
|
2022-03-11 01:30:01 -05:00
|
|
|
// Loads the relevant stage based on its ID.
|
|
|
|
loadStage(currentStageId);
|
2021-11-23 15:00:10 -05:00
|
|
|
}
|
2020-10-05 16:55:48 -04:00
|
|
|
|
2022-09-22 06:34:03 -04:00
|
|
|
function initStage_NEW()
|
|
|
|
{
|
|
|
|
if (currentChart == null)
|
|
|
|
{
|
|
|
|
trace('Song difficulty could not be loaded.');
|
|
|
|
}
|
|
|
|
|
|
|
|
if (currentChart.stage != null && currentChart.stage != '')
|
|
|
|
{
|
|
|
|
currentStageId = currentChart.stage;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
currentStageId = SongValidator.DEFAULT_STAGE;
|
|
|
|
}
|
|
|
|
|
|
|
|
loadStage(currentStageId);
|
|
|
|
}
|
|
|
|
|
2021-11-23 15:00:10 -05:00
|
|
|
function initCharacters()
|
|
|
|
{
|
2022-09-22 06:34:03 -04:00
|
|
|
if (currentSong_NEW != null)
|
|
|
|
{
|
|
|
|
initCharacters_NEW();
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2022-03-26 22:18:26 -04:00
|
|
|
iconP1 = new HealthIcon(currentSong.player1, 0);
|
|
|
|
iconP1.y = healthBar.y - (iconP1.height / 2);
|
|
|
|
add(iconP1);
|
|
|
|
|
|
|
|
iconP2 = new HealthIcon(currentSong.player2, 1);
|
|
|
|
iconP2.y = healthBar.y - (iconP2.height / 2);
|
|
|
|
add(iconP2);
|
|
|
|
|
2022-03-17 01:40:08 -04:00
|
|
|
//
|
|
|
|
// GIRLFRIEND
|
|
|
|
//
|
|
|
|
|
|
|
|
// TODO: Tie the GF version to the song data, not the stage ID or the current player.
|
2021-01-14 23:33:12 -05:00
|
|
|
var gfVersion:String = 'gf';
|
|
|
|
|
2022-03-11 01:30:01 -05:00
|
|
|
switch (currentStageId)
|
2021-01-19 21:09:47 -05:00
|
|
|
{
|
2022-07-06 21:49:42 -04:00
|
|
|
case 'pyro' | 'phillyStreets':
|
|
|
|
gfVersion = 'nene';
|
2022-09-03 22:21:54 -04:00
|
|
|
case 'blazin':
|
|
|
|
gfVersion = '';
|
2022-03-06 02:37:38 -05:00
|
|
|
case 'limoRide':
|
2021-01-19 21:09:47 -05:00
|
|
|
gfVersion = 'gf-car';
|
2022-03-06 02:37:38 -05:00
|
|
|
case 'mallXmas' | 'mallEvil':
|
2021-01-20 04:03:49 -05:00
|
|
|
gfVersion = 'gf-christmas';
|
2021-04-21 22:17:00 -04:00
|
|
|
case 'school' | 'schoolEvil':
|
2021-02-02 00:48:22 -05:00
|
|
|
gfVersion = 'gf-pixel';
|
2022-03-06 02:37:38 -05:00
|
|
|
case 'tankmanBattlefield':
|
2021-04-09 22:49:25 -04:00
|
|
|
gfVersion = 'gf-tankmen';
|
2021-01-19 21:09:47 -05:00
|
|
|
}
|
|
|
|
|
2022-03-11 01:30:01 -05:00
|
|
|
if (currentSong.player1 == "pico")
|
2021-09-14 17:12:11 -04:00
|
|
|
gfVersion = "nene";
|
|
|
|
|
2022-03-11 01:30:01 -05:00
|
|
|
if (currentSong.song.toLowerCase() == 'stress')
|
2021-03-13 20:53:57 -05:00
|
|
|
gfVersion = 'pico-speaker';
|
|
|
|
|
2022-03-21 00:19:05 -04:00
|
|
|
if (currentSong.song.toLowerCase() == 'tutorial')
|
|
|
|
gfVersion = '';
|
|
|
|
|
|
|
|
//
|
|
|
|
// GIRLFRIEND
|
|
|
|
//
|
|
|
|
var girlfriend:BaseCharacter = CharacterDataParser.fetchCharacter(gfVersion);
|
|
|
|
|
|
|
|
if (girlfriend != null)
|
2021-03-13 20:53:57 -05:00
|
|
|
{
|
2022-03-21 00:19:05 -04:00
|
|
|
girlfriend.characterType = CharacterType.GF;
|
|
|
|
girlfriend.scrollFactor.set(0.95, 0.95);
|
|
|
|
if (gfVersion == 'pico-speaker')
|
|
|
|
{
|
|
|
|
girlfriend.x -= 50;
|
|
|
|
girlfriend.y -= 200;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else if (gfVersion != '')
|
|
|
|
{
|
|
|
|
trace('WARNING: Could not load girlfriend character with ID ${gfVersion}, skipping...');
|
2021-03-13 20:53:57 -05:00
|
|
|
}
|
|
|
|
|
2022-03-17 01:40:08 -04:00
|
|
|
//
|
|
|
|
// DAD
|
|
|
|
//
|
2022-03-21 00:19:05 -04:00
|
|
|
var dad:BaseCharacter = CharacterDataParser.fetchCharacter(currentSong.player2);
|
2020-10-03 02:50:15 -04:00
|
|
|
|
2022-03-21 00:19:05 -04:00
|
|
|
if (dad != null)
|
|
|
|
{
|
|
|
|
dad.characterType = CharacterType.DAD;
|
|
|
|
}
|
2020-10-31 21:11:14 -04:00
|
|
|
|
2022-03-11 01:30:01 -05:00
|
|
|
switch (currentSong.player2)
|
2020-10-18 20:59:53 -04:00
|
|
|
{
|
2020-10-23 19:12:38 -04:00
|
|
|
case 'gf':
|
2020-10-31 21:11:14 -04:00
|
|
|
if (isStoryMode)
|
|
|
|
{
|
2022-03-17 01:40:08 -04:00
|
|
|
cameraFollowPoint.x += 600;
|
2020-10-31 21:11:14 -04:00
|
|
|
tweenCamIn();
|
|
|
|
}
|
2022-03-17 01:40:08 -04:00
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// BOYFRIEND
|
|
|
|
//
|
2022-03-21 00:19:05 -04:00
|
|
|
var boyfriend:BaseCharacter = CharacterDataParser.fetchCharacter(currentSong.player1);
|
|
|
|
|
|
|
|
if (boyfriend != null)
|
2022-03-17 01:40:08 -04:00
|
|
|
{
|
2022-03-21 00:19:05 -04:00
|
|
|
boyfriend.characterType = CharacterType.BF;
|
2022-03-17 01:40:08 -04:00
|
|
|
}
|
2020-10-03 02:50:15 -04:00
|
|
|
|
2022-03-11 01:30:01 -05:00
|
|
|
if (currentStage != null)
|
2022-02-23 16:49:54 -05:00
|
|
|
{
|
|
|
|
// We're using Eric's stage handler.
|
|
|
|
// Characters get added to the stage, not the main scene.
|
2022-07-22 16:11:18 -04:00
|
|
|
if (girlfriend != null)
|
|
|
|
{
|
2022-07-06 21:49:42 -04:00
|
|
|
currentStage.addCharacter(girlfriend, GF);
|
|
|
|
}
|
|
|
|
|
2022-07-22 16:11:18 -04:00
|
|
|
if (boyfriend != null)
|
|
|
|
{
|
2022-07-06 21:49:42 -04:00
|
|
|
currentStage.addCharacter(boyfriend, BF);
|
|
|
|
}
|
2022-02-25 02:02:06 -05:00
|
|
|
|
2022-07-22 16:11:18 -04:00
|
|
|
if (dad != null)
|
|
|
|
{
|
2022-07-06 21:49:42 -04:00
|
|
|
currentStage.addCharacter(dad, DAD);
|
|
|
|
// Camera starts at dad.
|
|
|
|
cameraFollowPoint.setPosition(dad.cameraFocusPoint.x, dad.cameraFocusPoint.y);
|
|
|
|
}
|
2022-03-29 21:56:04 -04:00
|
|
|
|
2022-02-25 02:02:06 -05:00
|
|
|
// Redo z-indexes.
|
2022-03-11 01:30:01 -05:00
|
|
|
currentStage.refresh();
|
2022-02-23 16:49:54 -05:00
|
|
|
}
|
2020-10-23 19:12:38 -04:00
|
|
|
}
|
|
|
|
|
2022-09-22 06:34:03 -04:00
|
|
|
function initCharacters_NEW()
|
|
|
|
{
|
|
|
|
if (currentSong_NEW == null || currentChart == null)
|
|
|
|
{
|
|
|
|
trace('Song difficulty could not be loaded.');
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO: Switch playable character by manipulating this value.
|
|
|
|
// TODO: How to choose which one to use for story mode?
|
2022-10-26 01:14:29 -04:00
|
|
|
|
|
|
|
var playableChars = currentChart.getPlayableChars();
|
2022-09-22 06:34:03 -04:00
|
|
|
var currentPlayer = 'bf';
|
|
|
|
|
2022-10-26 01:14:29 -04:00
|
|
|
if (playableChars.length == 0)
|
|
|
|
{
|
|
|
|
trace('WARNING: No playable characters found for this song.');
|
|
|
|
}
|
|
|
|
else if (playableChars.indexOf(currentPlayer) == -1)
|
|
|
|
{
|
|
|
|
currentPlayer = playableChars[0];
|
|
|
|
}
|
|
|
|
|
2022-09-22 06:34:03 -04:00
|
|
|
var currentCharData:SongPlayableChar = currentChart.getPlayableChar(currentPlayer);
|
|
|
|
|
|
|
|
//
|
|
|
|
// GIRLFRIEND
|
|
|
|
//
|
|
|
|
var girlfriend:BaseCharacter = CharacterDataParser.fetchCharacter(currentCharData.girlfriend);
|
|
|
|
|
|
|
|
if (girlfriend != null)
|
|
|
|
{
|
|
|
|
girlfriend.characterType = CharacterType.GF;
|
|
|
|
}
|
|
|
|
else if (currentCharData.girlfriend != '')
|
|
|
|
{
|
|
|
|
trace('WARNING: Could not load girlfriend character with ID ${currentCharData.girlfriend}, skipping...');
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Chosen GF was '' so we don't load one.
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// DAD
|
|
|
|
//
|
|
|
|
var dad:BaseCharacter = CharacterDataParser.fetchCharacter(currentCharData.opponent);
|
|
|
|
|
|
|
|
if (dad != null)
|
|
|
|
{
|
|
|
|
dad.characterType = CharacterType.DAD;
|
|
|
|
}
|
|
|
|
|
|
|
|
// TODO: Cut out this code/make it generic.
|
|
|
|
switch (currentCharData.opponent)
|
|
|
|
{
|
|
|
|
case 'gf':
|
|
|
|
if (isStoryMode)
|
|
|
|
{
|
|
|
|
cameraFollowPoint.x += 600;
|
|
|
|
tweenCamIn();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// OPPONENT HEALTH ICON
|
|
|
|
//
|
|
|
|
iconP2 = new HealthIcon(currentCharData.opponent, 1);
|
|
|
|
iconP2.y = healthBar.y - (iconP2.height / 2);
|
|
|
|
add(iconP2);
|
|
|
|
|
|
|
|
//
|
|
|
|
// BOYFRIEND
|
|
|
|
//
|
|
|
|
var boyfriend:BaseCharacter = CharacterDataParser.fetchCharacter(currentPlayer);
|
|
|
|
|
|
|
|
if (boyfriend != null)
|
|
|
|
{
|
|
|
|
boyfriend.characterType = CharacterType.BF;
|
|
|
|
}
|
|
|
|
|
|
|
|
//
|
|
|
|
// PLAYER HEALTH ICON
|
|
|
|
//
|
|
|
|
iconP1 = new HealthIcon(currentPlayer, 0);
|
|
|
|
iconP1.y = healthBar.y - (iconP1.height / 2);
|
|
|
|
add(iconP1);
|
|
|
|
|
|
|
|
//
|
|
|
|
// ADD CHARACTERS TO SCENE
|
|
|
|
//
|
|
|
|
|
|
|
|
if (currentStage != null)
|
|
|
|
{
|
|
|
|
// Characters get added to the stage, not the main scene.
|
|
|
|
if (girlfriend != null)
|
|
|
|
{
|
|
|
|
currentStage.addCharacter(girlfriend, GF);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (boyfriend != null)
|
|
|
|
{
|
|
|
|
currentStage.addCharacter(boyfriend, BF);
|
|
|
|
}
|
|
|
|
|
|
|
|
if (dad != null)
|
|
|
|
{
|
|
|
|
currentStage.addCharacter(dad, DAD);
|
|
|
|
// Camera starts at dad.
|
|
|
|
cameraFollowPoint.setPosition(dad.cameraFocusPoint.x, dad.cameraFocusPoint.y);
|
|
|
|
}
|
|
|
|
|
|
|
|
// Rearrange by z-indexes.
|
|
|
|
currentStage.refresh();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-02-26 09:06:49 -05:00
|
|
|
/**
|
|
|
|
* Removes any references to the current stage, then clears the stage cache,
|
|
|
|
* then reloads all the stages.
|
|
|
|
*
|
|
|
|
* This is useful for when you want to edit a stage without reloading the whole game.
|
|
|
|
* Reloading works on both the JSON and the HXC, if applicable.
|
2022-03-06 03:33:12 -05:00
|
|
|
*
|
|
|
|
* Call this by pressing F5 on a debug build.
|
2022-02-26 09:06:49 -05:00
|
|
|
*/
|
2022-03-21 00:19:05 -04:00
|
|
|
override function debug_refreshModules()
|
2022-02-26 09:06:49 -05:00
|
|
|
{
|
|
|
|
// Remove the current stage. If the stage gets deleted while it's still in use,
|
|
|
|
// it'll probably crash the game or something.
|
2022-03-11 01:30:01 -05:00
|
|
|
if (this.currentStage != null)
|
2022-02-26 09:06:49 -05:00
|
|
|
{
|
2022-03-11 01:30:01 -05:00
|
|
|
remove(currentStage);
|
|
|
|
var event:ScriptEvent = new ScriptEvent(ScriptEvent.DESTROY, false);
|
|
|
|
ScriptEventDispatcher.callEvent(currentStage, event);
|
|
|
|
currentStage = null;
|
2022-02-26 09:06:49 -05:00
|
|
|
}
|
|
|
|
|
2022-03-21 00:19:05 -04:00
|
|
|
super.debug_refreshModules();
|
2022-02-26 09:06:49 -05:00
|
|
|
}
|
|
|
|
|
2022-04-29 23:46:41 -04:00
|
|
|
/**
|
|
|
|
* Pauses music and vocals easily.
|
|
|
|
*/
|
|
|
|
public function pauseMusic()
|
|
|
|
{
|
|
|
|
FlxG.sound.music.pause();
|
|
|
|
vocals.pause();
|
|
|
|
}
|
|
|
|
|
2022-02-23 16:49:54 -05:00
|
|
|
/**
|
|
|
|
* Loads stage data from cache, assembles the props,
|
|
|
|
* and adds it to the state.
|
|
|
|
* @param id
|
|
|
|
*/
|
|
|
|
function loadStage(id:String)
|
|
|
|
{
|
2022-03-11 01:30:01 -05:00
|
|
|
currentStage = StageDataParser.fetchStage(id);
|
2022-02-23 16:49:54 -05:00
|
|
|
|
2022-03-11 01:30:01 -05:00
|
|
|
if (currentStage != null)
|
2022-02-23 16:49:54 -05:00
|
|
|
{
|
|
|
|
// Actually create and position the sprites.
|
2022-03-11 01:30:01 -05:00
|
|
|
var event:ScriptEvent = new ScriptEvent(ScriptEvent.CREATE, false);
|
|
|
|
ScriptEventDispatcher.callEvent(currentStage, event);
|
2022-02-23 16:49:54 -05:00
|
|
|
|
|
|
|
// Apply camera zoom.
|
2022-05-07 12:45:49 -04:00
|
|
|
defaultCameraZoom = currentStage.camZoom;
|
2022-02-23 16:49:54 -05:00
|
|
|
|
|
|
|
// Add the stage to the scene.
|
2022-03-11 01:30:01 -05:00
|
|
|
this.add(currentStage);
|
2022-02-23 16:49:54 -05:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-03-18 20:26:17 -04:00
|
|
|
function initDiscord():Void
|
|
|
|
{
|
2021-03-22 10:09:46 -04:00
|
|
|
#if discord_rpc
|
2021-04-10 01:49:57 -04:00
|
|
|
storyDifficultyText = difficultyString();
|
2022-03-11 01:30:01 -05:00
|
|
|
iconRPC = currentSong.player2;
|
2021-03-18 20:26:17 -04:00
|
|
|
|
|
|
|
// To avoid having duplicate images in Discord assets
|
|
|
|
switch (iconRPC)
|
|
|
|
{
|
|
|
|
case 'senpai-angry':
|
|
|
|
iconRPC = 'senpai';
|
|
|
|
case 'monster-christmas':
|
|
|
|
iconRPC = 'monster';
|
|
|
|
case 'mom-car':
|
|
|
|
iconRPC = 'mom';
|
|
|
|
}
|
|
|
|
|
|
|
|
// String that contains the mode defined here so it isn't necessary to call changePresence for each mode
|
|
|
|
detailsText = isStoryMode ? "Story Mode: Week " + storyWeek : "Freeplay";
|
|
|
|
detailsPausedText = "Paused - " + detailsText;
|
|
|
|
|
|
|
|
// Updating Discord Rich Presence.
|
2022-03-11 01:30:01 -05:00
|
|
|
DiscordClient.changePresence(detailsText, currentSong.song + " (" + storyDifficultyText + ")", iconRPC);
|
2021-03-18 20:26:17 -04:00
|
|
|
#end
|
|
|
|
}
|
|
|
|
|
2021-02-01 01:50:30 -05:00
|
|
|
function schoolIntro(?dialogueBox:DialogueBox):Void
|
2021-01-25 04:18:44 -05:00
|
|
|
{
|
|
|
|
var black:FlxSprite = new FlxSprite(-100, -100).makeGraphic(FlxG.width * 2, FlxG.height * 2, FlxColor.BLACK);
|
|
|
|
black.scrollFactor.set();
|
|
|
|
add(black);
|
|
|
|
|
2021-02-02 05:46:17 -05:00
|
|
|
var red:FlxSprite = new FlxSprite(-100, -100).makeGraphic(FlxG.width * 2, FlxG.height * 2, 0xFFff1b31);
|
|
|
|
red.scrollFactor.set();
|
|
|
|
|
|
|
|
var senpaiEvil:FlxSprite = new FlxSprite();
|
2021-02-08 16:34:48 -05:00
|
|
|
senpaiEvil.frames = Paths.getSparrowAtlas('weeb/senpaiCrazy');
|
2021-02-02 05:46:17 -05:00
|
|
|
senpaiEvil.animation.addByPrefix('idle', 'Senpai Pre Explosion', 24, false);
|
2022-03-11 01:30:01 -05:00
|
|
|
senpaiEvil.setGraphicSize(Std.int(senpaiEvil.width * Constants.PIXEL_ART_SCALE));
|
2021-02-12 01:20:20 -05:00
|
|
|
senpaiEvil.scrollFactor.set();
|
2021-02-02 05:46:17 -05:00
|
|
|
senpaiEvil.updateHitbox();
|
|
|
|
senpaiEvil.screenCenter();
|
2021-04-14 21:56:42 -04:00
|
|
|
senpaiEvil.x += senpaiEvil.width / 5;
|
|
|
|
|
2022-03-11 01:30:01 -05:00
|
|
|
if (currentSong.song.toLowerCase() == 'roses' || currentSong.song.toLowerCase() == 'thorns')
|
2021-02-02 05:46:17 -05:00
|
|
|
{
|
2021-02-02 04:13:28 -05:00
|
|
|
remove(black);
|
|
|
|
|
2022-03-11 01:30:01 -05:00
|
|
|
if (currentSong.song.toLowerCase() == 'thorns')
|
2021-02-02 05:46:17 -05:00
|
|
|
{
|
|
|
|
add(red);
|
2021-04-14 21:56:42 -04:00
|
|
|
camHUD.visible = false;
|
2021-02-02 05:46:17 -05:00
|
|
|
}
|
2021-04-21 22:17:00 -04:00
|
|
|
else
|
|
|
|
FlxG.sound.play(Paths.sound('ANGRY'));
|
|
|
|
// moved senpai angry noise in here to clean up cutscene switch case lol
|
2021-02-02 05:46:17 -05:00
|
|
|
}
|
|
|
|
|
2021-01-25 04:18:44 -05:00
|
|
|
new FlxTimer().start(0.3, function(tmr:FlxTimer)
|
|
|
|
{
|
|
|
|
black.alpha -= 0.15;
|
|
|
|
|
|
|
|
if (black.alpha > 0)
|
|
|
|
tmr.reset(0.3);
|
|
|
|
else
|
|
|
|
{
|
2021-02-01 01:50:30 -05:00
|
|
|
if (dialogueBox != null)
|
|
|
|
{
|
2022-03-13 14:36:03 -04:00
|
|
|
isInCutscene = true;
|
2021-02-02 05:46:17 -05:00
|
|
|
|
2022-03-11 01:30:01 -05:00
|
|
|
if (currentSong.song.toLowerCase() == 'thorns')
|
2021-02-02 05:46:17 -05:00
|
|
|
{
|
|
|
|
add(senpaiEvil);
|
|
|
|
senpaiEvil.alpha = 0;
|
|
|
|
new FlxTimer().start(0.3, function(swagTimer:FlxTimer)
|
|
|
|
{
|
|
|
|
senpaiEvil.alpha += 0.15;
|
|
|
|
if (senpaiEvil.alpha < 1)
|
|
|
|
swagTimer.reset();
|
|
|
|
else
|
|
|
|
{
|
|
|
|
senpaiEvil.animation.play('idle');
|
2021-02-08 16:34:48 -05:00
|
|
|
FlxG.sound.play(Paths.sound('Senpai_Dies'), 1, false, null, true, function()
|
2021-02-02 05:46:17 -05:00
|
|
|
{
|
|
|
|
remove(senpaiEvil);
|
|
|
|
remove(red);
|
|
|
|
FlxG.camera.fade(FlxColor.WHITE, 0.01, true, function()
|
|
|
|
{
|
|
|
|
add(dialogueBox);
|
2021-04-14 21:56:42 -04:00
|
|
|
camHUD.visible = true;
|
2021-02-02 05:46:17 -05:00
|
|
|
}, true);
|
|
|
|
});
|
|
|
|
new FlxTimer().start(3.2, function(deadTime:FlxTimer)
|
|
|
|
{
|
|
|
|
FlxG.camera.fade(FlxColor.WHITE, 1.6, false);
|
|
|
|
});
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
else
|
|
|
|
add(dialogueBox);
|
2021-02-01 01:50:30 -05:00
|
|
|
}
|
|
|
|
else
|
|
|
|
startCountdown();
|
|
|
|
|
2021-01-25 04:18:44 -05:00
|
|
|
remove(black);
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2020-10-05 14:24:51 -04:00
|
|
|
function startSong():Void
|
|
|
|
{
|
2022-07-14 19:03:42 -04:00
|
|
|
dispatchEvent(new ScriptEvent(ScriptEvent.SONG_START));
|
|
|
|
|
2020-12-10 00:41:31 -05:00
|
|
|
startingSong = false;
|
|
|
|
|
2020-10-24 05:19:13 -04:00
|
|
|
previousFrameTime = FlxG.game.ticks;
|
|
|
|
|
2022-03-11 01:30:01 -05:00
|
|
|
if (!isGamePaused)
|
2021-09-24 10:56:05 -04:00
|
|
|
{
|
2021-11-02 10:28:26 -04:00
|
|
|
// if (FlxG.sound.music != null)
|
|
|
|
// FlxG.sound.music.play(true);
|
|
|
|
// else
|
2022-09-22 06:34:03 -04:00
|
|
|
if (currentChart != null)
|
|
|
|
{
|
|
|
|
currentChart.playInst(1.0, false);
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
FlxG.sound.playMusic(Paths.inst(currentSong.song), 1, false);
|
|
|
|
}
|
2021-09-24 10:56:05 -04:00
|
|
|
}
|
|
|
|
|
2020-10-31 21:11:14 -04:00
|
|
|
FlxG.sound.music.onComplete = endSong;
|
2022-09-24 01:28:39 -04:00
|
|
|
trace('Playing vocals...');
|
2020-10-05 14:24:51 -04:00
|
|
|
vocals.play();
|
2021-02-27 16:59:18 -05:00
|
|
|
|
2021-03-22 10:09:46 -04:00
|
|
|
#if discord_rpc
|
2021-02-27 16:59:18 -05:00
|
|
|
// Song duration in a float, useful for the time left feature
|
|
|
|
songLength = FlxG.sound.music.length;
|
|
|
|
|
|
|
|
// Updating Discord Rich Presence (with Time Left)
|
2022-03-11 01:30:01 -05:00
|
|
|
DiscordClient.changePresence(detailsText, currentSong.song + " (" + storyDifficultyText + ")", iconRPC, true, songLength);
|
2021-02-27 16:59:18 -05:00
|
|
|
#end
|
2020-10-05 14:24:51 -04:00
|
|
|
}
|
|
|
|
|
2021-03-29 13:24:49 -04:00
|
|
|
private function generateSong():Void
|
2020-10-03 02:50:15 -04:00
|
|
|
{
|
2020-10-04 02:42:58 -04:00
|
|
|
// FlxG.log.add(ChartParser.parse());
|
|
|
|
|
2022-09-22 06:34:03 -04:00
|
|
|
Conductor.forceBPM(currentSong.bpm);
|
2020-10-04 02:42:58 -04:00
|
|
|
|
2022-03-11 01:30:01 -05:00
|
|
|
currentSong.song = currentSong.song;
|
2020-10-05 05:48:30 -04:00
|
|
|
|
2022-03-11 01:30:01 -05:00
|
|
|
if (currentSong.needsVoices)
|
2022-12-08 19:33:47 -05:00
|
|
|
vocals = VoicesGroup.build(currentSong.song, currentSong.voiceList);
|
2020-10-14 04:30:54 -04:00
|
|
|
else
|
2022-12-08 19:33:47 -05:00
|
|
|
vocals = VoicesGroup.build(currentSong.song, null);
|
2020-10-14 04:30:54 -04:00
|
|
|
|
2021-09-20 11:50:52 -04:00
|
|
|
vocals.members[0].onComplete = function()
|
2021-04-09 16:37:54 -04:00
|
|
|
{
|
2021-04-08 08:17:21 -04:00
|
|
|
vocalsFinished = true;
|
|
|
|
};
|
2020-10-03 02:50:15 -04:00
|
|
|
|
2022-09-24 01:28:39 -04:00
|
|
|
trace(vocals);
|
|
|
|
|
2022-03-11 01:30:01 -05:00
|
|
|
activeNotes = new FlxTypedGroup<Note>();
|
|
|
|
activeNotes.zIndex = 1000;
|
|
|
|
add(activeNotes);
|
2020-10-03 02:50:15 -04:00
|
|
|
|
2021-09-24 10:56:05 -04:00
|
|
|
regenNoteData();
|
|
|
|
|
|
|
|
generatedMusic = true;
|
|
|
|
}
|
|
|
|
|
2022-09-22 06:34:03 -04:00
|
|
|
private function generateSong_NEW():Void
|
|
|
|
{
|
|
|
|
if (currentChart == null)
|
|
|
|
{
|
|
|
|
trace('Song difficulty could not be loaded.');
|
|
|
|
}
|
|
|
|
|
|
|
|
Conductor.forceBPM(currentChart.getStartingBPM());
|
|
|
|
|
|
|
|
// TODO: Fix grouped vocals
|
|
|
|
vocals = currentChart.buildVocals();
|
|
|
|
vocals.members[0].onComplete = function()
|
|
|
|
{
|
|
|
|
vocalsFinished = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
// Create the rendered note group.
|
|
|
|
activeNotes = new FlxTypedGroup<Note>();
|
|
|
|
activeNotes.zIndex = 1000;
|
|
|
|
add(activeNotes);
|
|
|
|
|
|
|
|
regenNoteData_NEW();
|
|
|
|
|
|
|
|
generatedMusic = true;
|
|
|
|
}
|
|
|
|
|
2021-09-24 10:56:05 -04:00
|
|
|
function regenNoteData():Void
|
|
|
|
{
|
|
|
|
// make unspawn notes shit def empty
|
2022-03-11 01:30:01 -05:00
|
|
|
inactiveNotes = [];
|
2021-09-24 10:56:05 -04:00
|
|
|
|
2022-03-11 01:30:01 -05:00
|
|
|
activeNotes.forEach(function(nt)
|
2021-09-24 10:56:05 -04:00
|
|
|
{
|
2021-12-06 22:35:14 -05:00
|
|
|
nt.followsTime = false;
|
2021-12-06 22:39:03 -05:00
|
|
|
FlxTween.tween(nt, {y: FlxG.height + nt.y}, 0.5, {
|
2021-12-06 22:35:14 -05:00
|
|
|
ease: FlxEase.expoIn,
|
|
|
|
onComplete: function(twn)
|
|
|
|
{
|
|
|
|
nt.kill();
|
2022-03-11 01:30:01 -05:00
|
|
|
activeNotes.remove(nt, true);
|
2021-12-06 22:35:14 -05:00
|
|
|
nt.destroy();
|
|
|
|
}
|
|
|
|
});
|
2021-09-24 10:56:05 -04:00
|
|
|
});
|
|
|
|
|
2020-10-24 05:19:13 -04:00
|
|
|
var noteData:Array<SwagSection>;
|
2020-10-04 02:42:58 -04:00
|
|
|
|
2020-10-13 04:37:19 -04:00
|
|
|
// NEW SHIT
|
2021-12-06 17:49:05 -05:00
|
|
|
noteData = SongLoad.getSong();
|
2020-10-13 04:37:19 -04:00
|
|
|
|
2020-10-16 07:03:10 -04:00
|
|
|
for (section in noteData)
|
2020-10-03 02:50:15 -04:00
|
|
|
{
|
2020-10-18 20:59:53 -04:00
|
|
|
for (songNotes in section.sectionNotes)
|
2020-10-16 07:03:10 -04:00
|
|
|
{
|
2022-01-21 17:23:12 -05:00
|
|
|
var daStrumTime:Float = songNotes.strumTime;
|
2022-09-07 19:07:08 -04:00
|
|
|
// TODO: Replace 4 with strumlineSize
|
2022-01-21 17:23:12 -05:00
|
|
|
var daNoteData:Int = Std.int(songNotes.noteData % 4);
|
2020-10-17 21:47:59 -04:00
|
|
|
var gottaHitNote:Bool = section.mustHitSection;
|
|
|
|
|
2022-03-18 12:28:25 -04:00
|
|
|
if (songNotes.highStakes) // noteData > 3
|
2020-10-17 21:47:59 -04:00
|
|
|
gottaHitNote = !section.mustHitSection;
|
2020-10-13 04:37:19 -04:00
|
|
|
|
2020-10-16 07:03:10 -04:00
|
|
|
var oldNote:Note;
|
2022-03-11 01:30:01 -05:00
|
|
|
if (inactiveNotes.length > 0)
|
|
|
|
oldNote = inactiveNotes[Std.int(inactiveNotes.length - 1)];
|
2020-10-16 07:03:10 -04:00
|
|
|
else
|
|
|
|
oldNote = null;
|
2020-10-05 01:13:12 -04:00
|
|
|
|
2022-05-03 13:02:37 -04:00
|
|
|
var strumlineStyle:StrumlineStyle = NORMAL;
|
|
|
|
|
|
|
|
// TODO: Put this in the chart or something?
|
|
|
|
switch (currentStageId)
|
|
|
|
{
|
|
|
|
case 'school':
|
|
|
|
strumlineStyle = PIXEL;
|
|
|
|
case 'schoolEvil':
|
|
|
|
strumlineStyle = PIXEL;
|
|
|
|
}
|
|
|
|
|
|
|
|
var swagNote:Note = new Note(daStrumTime, daNoteData, oldNote, false, strumlineStyle);
|
2022-04-18 19:36:09 -04:00
|
|
|
// swagNote.data = songNotes;
|
|
|
|
swagNote.data.sustainLength = songNotes.sustainLength;
|
2022-07-06 21:49:42 -04:00
|
|
|
swagNote.data.noteKind = songNotes.noteKind;
|
2020-10-16 07:03:10 -04:00
|
|
|
swagNote.scrollFactor.set(0, 0);
|
2020-10-03 02:50:15 -04:00
|
|
|
|
2022-01-22 16:53:38 -05:00
|
|
|
var susLength:Float = swagNote.data.sustainLength;
|
2020-10-19 21:59:00 -04:00
|
|
|
|
|
|
|
susLength = susLength / Conductor.stepCrochet;
|
2022-03-11 01:30:01 -05:00
|
|
|
inactiveNotes.push(swagNote);
|
2020-10-05 05:48:30 -04:00
|
|
|
|
2021-08-01 21:29:34 -04:00
|
|
|
for (susNote in 0...Math.round(susLength))
|
2020-10-19 21:59:00 -04:00
|
|
|
{
|
2022-03-11 01:30:01 -05:00
|
|
|
oldNote = inactiveNotes[Std.int(inactiveNotes.length - 1)];
|
2020-10-19 21:59:00 -04:00
|
|
|
|
2022-05-03 13:02:37 -04:00
|
|
|
var sustainNote:Note = new Note(daStrumTime + (Conductor.stepCrochet * susNote) + Conductor.stepCrochet, daNoteData, oldNote, true,
|
|
|
|
strumlineStyle);
|
2022-07-06 21:49:42 -04:00
|
|
|
sustainNote.data.noteKind = songNotes.noteKind;
|
2020-10-19 21:59:00 -04:00
|
|
|
sustainNote.scrollFactor.set();
|
2022-03-11 01:30:01 -05:00
|
|
|
inactiveNotes.push(sustainNote);
|
2020-10-19 21:59:00 -04:00
|
|
|
|
|
|
|
sustainNote.mustPress = gottaHitNote;
|
|
|
|
|
|
|
|
if (sustainNote.mustPress)
|
|
|
|
sustainNote.x += FlxG.width / 2; // general offset
|
|
|
|
}
|
|
|
|
|
2022-09-07 19:07:08 -04:00
|
|
|
// TODO: Replace 4 with strumlineSize
|
2020-10-17 21:47:59 -04:00
|
|
|
swagNote.mustPress = gottaHitNote;
|
2020-10-03 02:50:15 -04:00
|
|
|
|
2020-10-16 07:03:10 -04:00
|
|
|
if (swagNote.mustPress)
|
2022-09-03 22:21:54 -04:00
|
|
|
{
|
|
|
|
if (playerStrumline != null)
|
|
|
|
{
|
|
|
|
swagNote.x = playerStrumline.getArrow(swagNote.data.noteData).x;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
swagNote.x += FlxG.width / 2; // general offset
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (enemyStrumline != null)
|
|
|
|
{
|
|
|
|
swagNote.x = enemyStrumline.getArrow(swagNote.data.noteData).x;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-09-07 19:07:08 -04:00
|
|
|
// swagNote.x += FlxG.width / 2; // general offset
|
2022-09-03 22:21:54 -04:00
|
|
|
}
|
|
|
|
}
|
2020-10-03 02:50:15 -04:00
|
|
|
}
|
|
|
|
}
|
2020-10-05 05:48:30 -04:00
|
|
|
|
2022-03-11 01:30:01 -05:00
|
|
|
inactiveNotes.sort(function(a:Note, b:Note):Int
|
2020-10-04 04:38:21 -04:00
|
|
|
{
|
2022-03-11 01:30:01 -05:00
|
|
|
return SortUtil.byStrumtime(FlxSort.ASCENDING, a, b);
|
|
|
|
});
|
2020-10-04 04:38:21 -04:00
|
|
|
}
|
|
|
|
|
2022-09-22 06:34:03 -04:00
|
|
|
function regenNoteData_NEW():Void
|
|
|
|
{
|
2022-09-24 15:02:10 -04:00
|
|
|
// Reset song events.
|
|
|
|
songEvents = currentChart.getEvents();
|
|
|
|
SongEventHandler.resetEvents(songEvents);
|
|
|
|
|
2022-09-22 06:34:03 -04:00
|
|
|
// Destroy inactive notes.
|
|
|
|
inactiveNotes = [];
|
|
|
|
|
|
|
|
// Destroy active notes.
|
|
|
|
activeNotes.forEach(function(nt)
|
|
|
|
{
|
|
|
|
nt.followsTime = false;
|
|
|
|
FlxTween.tween(nt, {y: FlxG.height + nt.y}, 0.5, {
|
|
|
|
ease: FlxEase.expoIn,
|
|
|
|
onComplete: function(twn)
|
|
|
|
{
|
|
|
|
nt.kill();
|
|
|
|
activeNotes.remove(nt, true);
|
|
|
|
nt.destroy();
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
var noteData:Array<SongNoteData> = currentChart.notes;
|
|
|
|
|
|
|
|
var oldNote:Note = null;
|
|
|
|
for (songNote in noteData)
|
|
|
|
{
|
|
|
|
var mustHitNote:Bool = songNote.getMustHitNote();
|
|
|
|
|
|
|
|
// TODO: Put this in the chart or something?
|
|
|
|
var strumlineStyle:StrumlineStyle = null;
|
|
|
|
switch (currentStageId)
|
|
|
|
{
|
|
|
|
case 'school':
|
|
|
|
strumlineStyle = PIXEL;
|
|
|
|
case 'schoolEvil':
|
|
|
|
strumlineStyle = PIXEL;
|
|
|
|
default:
|
|
|
|
strumlineStyle = NORMAL;
|
|
|
|
}
|
|
|
|
|
|
|
|
var newNote:Note = new Note(songNote.time, songNote.data, oldNote, false, strumlineStyle);
|
|
|
|
newNote.mustPress = mustHitNote;
|
|
|
|
newNote.data.sustainLength = songNote.length;
|
|
|
|
newNote.data.noteKind = songNote.kind;
|
|
|
|
newNote.scrollFactor.set(0, 0);
|
|
|
|
|
|
|
|
// Note positioning.
|
|
|
|
// TODO: Make this more robust.
|
|
|
|
if (newNote.mustPress)
|
|
|
|
{
|
|
|
|
if (playerStrumline != null)
|
|
|
|
{
|
|
|
|
// Align with the strumline arrow.
|
|
|
|
newNote.x = playerStrumline.getArrow(songNote.getDirection()).x;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Assume strumline position.
|
|
|
|
newNote.x += FlxG.width / 2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (enemyStrumline != null)
|
|
|
|
{
|
|
|
|
newNote.x = enemyStrumline.getArrow(songNote.getDirection()).x;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// newNote.x += 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
inactiveNotes.push(newNote);
|
|
|
|
|
|
|
|
oldNote = newNote;
|
|
|
|
|
|
|
|
// Generate X sustain notes.
|
|
|
|
var sustainSections = Math.round(songNote.length / Conductor.stepCrochet);
|
|
|
|
for (noteIndex in 0...sustainSections)
|
|
|
|
{
|
|
|
|
var noteTimeOffset:Float = Conductor.stepCrochet + (Conductor.stepCrochet * noteIndex);
|
|
|
|
var sustainNote:Note = new Note(songNote.time + noteTimeOffset, songNote.data, oldNote, true, strumlineStyle);
|
|
|
|
sustainNote.mustPress = mustHitNote;
|
|
|
|
sustainNote.data.noteKind = songNote.kind;
|
|
|
|
sustainNote.scrollFactor.set(0, 0);
|
|
|
|
|
|
|
|
if (sustainNote.mustPress)
|
|
|
|
{
|
|
|
|
if (playerStrumline != null)
|
|
|
|
{
|
|
|
|
// Align with the strumline arrow.
|
|
|
|
sustainNote.x = playerStrumline.getArrow(songNote.getDirection()).x;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// Assume strumline position.
|
|
|
|
sustainNote.x += FlxG.width / 2;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
if (enemyStrumline != null)
|
|
|
|
{
|
|
|
|
sustainNote.x = enemyStrumline.getArrow(songNote.getDirection()).x;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
// newNote.x += 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
inactiveNotes.push(sustainNote);
|
|
|
|
|
|
|
|
oldNote = sustainNote;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
// Sorting is an expensive operation.
|
|
|
|
// Assume it was done in the chart file.
|
|
|
|
/**
|
|
|
|
inactiveNotes.sort(function(a:Note, b:Note):Int
|
|
|
|
{
|
|
|
|
return SortUtil.byStrumtime(FlxSort.ASCENDING, a, b);
|
|
|
|
});
|
|
|
|
**/
|
|
|
|
}
|
|
|
|
|
2020-10-31 21:11:14 -04:00
|
|
|
function tweenCamIn():Void
|
|
|
|
{
|
2021-08-21 20:45:03 -04:00
|
|
|
FlxTween.tween(FlxG.camera, {zoom: 1.3 * FlxCamera.defaultZoom}, (Conductor.stepCrochet * 4 / 1000), {ease: FlxEase.elasticInOut});
|
2020-10-31 21:11:14 -04:00
|
|
|
}
|
|
|
|
|
2021-03-22 10:09:46 -04:00
|
|
|
#if discord_rpc
|
2021-02-27 18:49:53 -05:00
|
|
|
override public function onFocus():Void
|
|
|
|
{
|
2021-04-08 12:45:59 -04:00
|
|
|
if (health > 0 && !paused && FlxG.autoPause)
|
2021-02-27 18:49:53 -05:00
|
|
|
{
|
|
|
|
if (Conductor.songPosition > 0.0)
|
2022-03-11 01:30:01 -05:00
|
|
|
DiscordClient.changePresence(detailsText, currentSong.song + " (" + storyDifficultyText + ")", iconRPC, true,
|
|
|
|
songLength - Conductor.songPosition);
|
2021-02-27 18:49:53 -05:00
|
|
|
else
|
2022-03-11 01:30:01 -05:00
|
|
|
DiscordClient.changePresence(detailsText, currentSong.song + " (" + storyDifficultyText + ")", iconRPC);
|
2021-02-27 18:49:53 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
super.onFocus();
|
|
|
|
}
|
2021-03-18 19:12:39 -04:00
|
|
|
|
2021-02-27 18:49:53 -05:00
|
|
|
override public function onFocusLost():Void
|
|
|
|
{
|
2021-04-08 12:45:59 -04:00
|
|
|
if (health > 0 && !paused && FlxG.autoPause)
|
2022-03-11 01:30:01 -05:00
|
|
|
DiscordClient.changePresence(detailsPausedText, currentSong.song + " (" + storyDifficultyText + ")", iconRPC);
|
2021-02-27 18:49:53 -05:00
|
|
|
|
|
|
|
super.onFocusLost();
|
|
|
|
}
|
2021-03-22 10:09:46 -04:00
|
|
|
#end
|
2021-02-27 18:49:53 -05:00
|
|
|
|
2020-12-13 01:42:48 -05:00
|
|
|
function resyncVocals():Void
|
|
|
|
{
|
2022-10-07 00:37:21 -04:00
|
|
|
if (_exiting || vocals == null)
|
2021-04-09 16:37:54 -04:00
|
|
|
return;
|
2020-12-13 01:42:48 -05:00
|
|
|
|
2021-04-08 08:17:21 -04:00
|
|
|
vocals.pause();
|
2022-10-07 00:37:21 -04:00
|
|
|
|
2020-12-13 01:42:48 -05:00
|
|
|
FlxG.sound.music.play();
|
2022-09-22 06:34:03 -04:00
|
|
|
Conductor.update(FlxG.sound.music.time + Conductor.offset);
|
2021-04-08 08:17:21 -04:00
|
|
|
|
|
|
|
if (vocalsFinished)
|
2021-04-09 16:37:54 -04:00
|
|
|
return;
|
2021-04-08 08:17:21 -04:00
|
|
|
|
2021-09-08 16:28:30 -04:00
|
|
|
vocals.time = FlxG.sound.music.time;
|
2020-12-13 01:42:48 -05:00
|
|
|
vocals.play();
|
|
|
|
}
|
|
|
|
|
2020-10-03 02:50:15 -04:00
|
|
|
override public function update(elapsed:Float)
|
|
|
|
{
|
2022-03-11 01:30:01 -05:00
|
|
|
super.update(elapsed);
|
|
|
|
|
2022-09-22 06:34:03 -04:00
|
|
|
if (criticalFailure)
|
|
|
|
return;
|
|
|
|
|
2022-04-29 23:46:41 -04:00
|
|
|
if (FlxG.keys.justPressed.U)
|
|
|
|
{
|
2022-08-24 05:44:22 -04:00
|
|
|
// hack for HaxeUI generation, doesn't work unless persistentUpdate is false at state creation!!
|
|
|
|
persistentUpdate = false;
|
2022-04-29 23:46:41 -04:00
|
|
|
openSubState(new StageOffsetSubstate());
|
|
|
|
}
|
|
|
|
|
2022-03-11 01:30:01 -05:00
|
|
|
updateHealthBar();
|
2022-03-14 20:48:45 -04:00
|
|
|
updateScoreText();
|
2021-09-24 11:21:34 -04:00
|
|
|
|
2021-09-24 11:51:15 -04:00
|
|
|
if (needsReset)
|
2021-08-10 02:40:47 -04:00
|
|
|
{
|
2022-03-21 00:19:05 -04:00
|
|
|
dispatchEvent(new ScriptEvent(ScriptEvent.SONG_RETRY));
|
|
|
|
|
2022-03-11 01:30:01 -05:00
|
|
|
resetCamera();
|
2021-09-24 11:51:15 -04:00
|
|
|
|
|
|
|
persistentUpdate = true;
|
|
|
|
persistentDraw = true;
|
|
|
|
|
2021-09-24 10:56:05 -04:00
|
|
|
startingSong = true;
|
|
|
|
|
|
|
|
FlxG.sound.music.pause();
|
2021-09-24 11:51:15 -04:00
|
|
|
vocals.pause();
|
|
|
|
|
2021-09-24 10:56:05 -04:00
|
|
|
FlxG.sound.music.time = 0;
|
2022-03-09 18:57:36 -05:00
|
|
|
|
2022-07-06 21:49:42 -04:00
|
|
|
currentStage.resetStage();
|
|
|
|
|
2022-09-22 06:34:03 -04:00
|
|
|
// Delete all notes and reset the arrays.
|
|
|
|
if (currentChart != null)
|
|
|
|
{
|
|
|
|
regenNoteData_NEW();
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
regenNoteData();
|
|
|
|
}
|
|
|
|
|
2021-09-24 11:21:34 -04:00
|
|
|
health = 1;
|
2022-03-21 00:19:05 -04:00
|
|
|
songScore = 0;
|
2022-06-09 22:28:58 -04:00
|
|
|
combo = 0;
|
2022-03-13 14:36:03 -04:00
|
|
|
Countdown.performCountdown(currentStageId.startsWith('school'));
|
2021-09-24 10:56:05 -04:00
|
|
|
|
2021-09-24 11:51:15 -04:00
|
|
|
needsReset = false;
|
2021-08-10 02:40:47 -04:00
|
|
|
}
|
2021-09-27 22:30:38 -04:00
|
|
|
|
|
|
|
#if !debug
|
|
|
|
perfectMode = false;
|
|
|
|
#else
|
|
|
|
if (FlxG.keys.justPressed.H)
|
|
|
|
camHUD.visible = !camHUD.visible;
|
2020-12-22 20:55:03 -05:00
|
|
|
#end
|
|
|
|
|
2021-03-17 13:33:26 -04:00
|
|
|
// do this BEFORE super.update() so songPosition is accurate
|
|
|
|
if (startingSong)
|
|
|
|
{
|
2022-03-13 14:36:03 -04:00
|
|
|
if (isInCountdown)
|
2021-03-17 13:33:26 -04:00
|
|
|
{
|
2022-03-13 14:36:03 -04:00
|
|
|
Conductor.songPosition += elapsed * 1000;
|
2021-03-17 13:33:26 -04:00
|
|
|
if (Conductor.songPosition >= 0)
|
|
|
|
startSong();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2021-09-22 21:09:28 -04:00
|
|
|
if (Paths.SOUND_EXT == 'mp3')
|
|
|
|
Conductor.offset = -13; // DO NOT FORGET TO REMOVE THE HARDCODE! WHEN I MAKE BETTER OFFSET SYSTEM!
|
|
|
|
|
2022-09-22 06:34:03 -04:00
|
|
|
Conductor.update(FlxG.sound.music.time + Conductor.offset);
|
2021-03-17 13:33:26 -04:00
|
|
|
|
2022-03-11 01:30:01 -05:00
|
|
|
if (!isGamePaused)
|
2021-03-17 13:33:26 -04:00
|
|
|
{
|
|
|
|
songTime += FlxG.game.ticks - previousFrameTime;
|
|
|
|
previousFrameTime = FlxG.game.ticks;
|
|
|
|
|
|
|
|
// Interpolation type beat
|
|
|
|
if (Conductor.lastSongPos != Conductor.songPosition)
|
|
|
|
{
|
|
|
|
songTime = (songTime + Conductor.songPosition) / 2;
|
|
|
|
Conductor.lastSongPos = Conductor.songPosition;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-08-22 16:54:22 -04:00
|
|
|
var androidPause:Bool = false;
|
|
|
|
|
|
|
|
#if android
|
|
|
|
androidPause = FlxG.android.justPressed.BACK;
|
|
|
|
#end
|
|
|
|
|
2022-03-13 14:36:03 -04:00
|
|
|
if ((controls.PAUSE || androidPause) && isInCountdown && mayPauseGame)
|
2020-10-09 17:24:20 -04:00
|
|
|
{
|
2022-03-29 21:56:04 -04:00
|
|
|
var event = new PauseScriptEvent(FlxG.random.bool(1 / 1000));
|
2020-10-09 17:24:20 -04:00
|
|
|
|
2022-03-29 21:56:04 -04:00
|
|
|
dispatchEvent(event);
|
|
|
|
|
|
|
|
if (!event.eventCanceled)
|
2021-03-13 22:41:12 -05:00
|
|
|
{
|
2022-07-22 16:11:18 -04:00
|
|
|
// Pause updates while the substate is open, preventing the game state from advancing.
|
2022-03-29 21:56:04 -04:00
|
|
|
persistentUpdate = false;
|
2022-07-06 21:49:42 -04:00
|
|
|
// Enable drawing while the substate is open, allowing the game state to be shown behind the pause menu.
|
2022-03-29 21:56:04 -04:00
|
|
|
persistentDraw = true;
|
2021-03-18 19:12:39 -04:00
|
|
|
|
2022-03-29 21:56:04 -04:00
|
|
|
// There is a 1/1000 change to use a special pause menu.
|
|
|
|
// This prevents the player from resuming, but that's the point.
|
|
|
|
// It's a reference to Gitaroo Man, which doesn't let you pause the game.
|
|
|
|
if (event.gitaroo)
|
|
|
|
{
|
|
|
|
FlxG.switchState(new GitarooPause());
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
var boyfriendPos = currentStage.getBoyfriend().getScreenPosition();
|
|
|
|
var pauseSubState = new PauseSubState(boyfriendPos.x, boyfriendPos.y);
|
|
|
|
openSubState(pauseSubState);
|
|
|
|
pauseSubState.camera = camHUD;
|
|
|
|
boyfriendPos.put();
|
|
|
|
}
|
|
|
|
|
|
|
|
#if discord_rpc
|
|
|
|
DiscordClient.changePresence(detailsPausedText, currentSong.song + " (" + storyDifficultyText + ")", iconRPC);
|
|
|
|
#end
|
|
|
|
}
|
2020-10-09 17:24:20 -04:00
|
|
|
}
|
|
|
|
|
2022-07-06 21:49:42 -04:00
|
|
|
#if debug
|
|
|
|
// 1: End the song immediately.
|
|
|
|
if (FlxG.keys.justPressed.ONE)
|
|
|
|
endSong();
|
|
|
|
|
|
|
|
// 2: Gain 10% health.
|
|
|
|
if (FlxG.keys.justPressed.TWO)
|
|
|
|
health += 0.1 * 2.0;
|
|
|
|
|
|
|
|
// 3: Lose 5% health.
|
|
|
|
if (FlxG.keys.justPressed.THREE)
|
|
|
|
health -= 0.05 * 2.0;
|
|
|
|
#end
|
|
|
|
|
|
|
|
// 7: Move to the charter.
|
2020-11-06 21:17:27 -05:00
|
|
|
if (FlxG.keys.justPressed.SEVEN)
|
2020-10-13 21:44:07 -04:00
|
|
|
{
|
2020-11-06 21:17:27 -05:00
|
|
|
FlxG.switchState(new ChartingState());
|
2021-02-27 19:06:30 -05:00
|
|
|
|
2021-03-22 10:09:46 -04:00
|
|
|
#if discord_rpc
|
2021-02-27 19:06:30 -05:00
|
|
|
DiscordClient.changePresence("Chart Editor", null, null, true);
|
|
|
|
#end
|
2020-10-13 21:44:07 -04:00
|
|
|
}
|
|
|
|
|
2022-07-06 21:49:42 -04:00
|
|
|
// 8: Move to the offset editor.
|
2021-09-10 10:07:55 -04:00
|
|
|
if (FlxG.keys.justPressed.EIGHT)
|
2022-03-08 03:13:53 -05:00
|
|
|
FlxG.switchState(new funkin.ui.animDebugShit.DebugBoundingState());
|
2021-09-10 10:07:55 -04:00
|
|
|
|
2022-07-06 21:49:42 -04:00
|
|
|
// 9: Toggle the old icon.
|
2021-04-21 22:17:00 -04:00
|
|
|
if (FlxG.keys.justPressed.NINE)
|
2022-03-25 22:30:37 -04:00
|
|
|
iconP1.toggleOldIcon();
|
2021-04-21 22:17:00 -04:00
|
|
|
|
2020-11-02 01:46:37 -05:00
|
|
|
#if debug
|
2022-08-31 02:24:09 -04:00
|
|
|
// PAGEUP: Skip forward one section.
|
|
|
|
// SHIFT+PAGEUP: Skip forward ten sections.
|
2021-04-21 09:07:36 -04:00
|
|
|
if (FlxG.keys.justPressed.PAGEUP)
|
2022-08-31 02:24:09 -04:00
|
|
|
changeSection(FlxG.keys.pressed.SHIFT ? 10 : 1);
|
|
|
|
// PAGEDOWN: Skip backward one section. Doesn't replace notes.
|
|
|
|
// SHIFT+PAGEDOWN: Skip backward ten sections.
|
2021-04-21 09:07:36 -04:00
|
|
|
if (FlxG.keys.justPressed.PAGEDOWN)
|
2022-08-31 02:24:09 -04:00
|
|
|
changeSection(FlxG.keys.pressed.SHIFT ? -10 : -1);
|
2020-11-02 01:46:37 -05:00
|
|
|
#end
|
2020-10-04 02:42:58 -04:00
|
|
|
|
2022-07-06 21:49:42 -04:00
|
|
|
if (health > 2.0)
|
|
|
|
health = 2.0;
|
|
|
|
if (health < 0.0)
|
|
|
|
health = 0.0;
|
|
|
|
|
2022-04-29 23:46:41 -04:00
|
|
|
if (camZooming && subState == null)
|
2020-10-05 05:48:30 -04:00
|
|
|
{
|
2022-03-13 14:36:03 -04:00
|
|
|
FlxG.camera.zoom = FlxMath.lerp(defaultCameraZoom, FlxG.camera.zoom, 0.95);
|
2021-08-21 20:45:03 -04:00
|
|
|
camHUD.zoom = FlxMath.lerp(1 * FlxCamera.defaultZoom, camHUD.zoom, 0.95);
|
2020-10-05 05:48:30 -04:00
|
|
|
}
|
|
|
|
|
2022-09-24 01:28:39 -04:00
|
|
|
FlxG.watch.addQuick("beatShit", Conductor.currentBeat);
|
|
|
|
FlxG.watch.addQuick("stepShit", Conductor.currentStep);
|
2022-05-29 21:40:13 -04:00
|
|
|
if (currentStage != null)
|
|
|
|
{
|
|
|
|
FlxG.watch.addQuick("bfAnim", currentStage.getBoyfriend().getCurrentAnimation());
|
|
|
|
}
|
2022-03-29 21:56:04 -04:00
|
|
|
FlxG.watch.addQuick("songPos", Conductor.songPosition);
|
2021-02-11 17:06:26 -05:00
|
|
|
|
2022-09-22 06:34:03 -04:00
|
|
|
if (currentSong != null && currentSong.song == 'Fresh')
|
2020-10-05 05:48:30 -04:00
|
|
|
{
|
2022-09-24 01:28:39 -04:00
|
|
|
switch (Conductor.currentBeat)
|
2020-10-05 08:55:39 -04:00
|
|
|
{
|
|
|
|
case 16:
|
|
|
|
camZooming = true;
|
|
|
|
gfSpeed = 2;
|
|
|
|
case 48:
|
|
|
|
gfSpeed = 1;
|
|
|
|
case 80:
|
|
|
|
gfSpeed = 2;
|
|
|
|
case 112:
|
|
|
|
gfSpeed = 1;
|
2020-10-05 18:29:59 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2022-03-13 14:36:03 -04:00
|
|
|
if (!isInCutscene && !_exiting)
|
2020-12-02 12:28:28 -05:00
|
|
|
{
|
2021-03-30 12:43:07 -04:00
|
|
|
// RESET = Quick Game Over Screen
|
|
|
|
if (controls.RESET)
|
|
|
|
{
|
|
|
|
health = 0;
|
|
|
|
trace("RESET = True");
|
|
|
|
}
|
2020-11-05 05:08:40 -05:00
|
|
|
|
2021-03-30 12:43:07 -04:00
|
|
|
#if CAN_CHEAT // brandon's a pussy
|
|
|
|
if (controls.CHEAT)
|
|
|
|
{
|
|
|
|
health += 1;
|
|
|
|
trace("User is cheating!");
|
|
|
|
}
|
|
|
|
#end
|
2020-11-05 05:08:40 -05:00
|
|
|
|
2022-03-11 01:30:01 -05:00
|
|
|
if (health <= 0 && !isPracticeMode)
|
2021-03-30 12:43:07 -04:00
|
|
|
{
|
2021-09-24 11:51:15 -04:00
|
|
|
vocals.pause();
|
|
|
|
FlxG.sound.music.pause();
|
2020-10-30 19:47:19 -04:00
|
|
|
|
2021-03-30 12:43:07 -04:00
|
|
|
deathCounter += 1;
|
2021-03-04 14:30:35 -05:00
|
|
|
|
2022-03-21 00:19:05 -04:00
|
|
|
dispatchEvent(new ScriptEvent(ScriptEvent.GAME_OVER));
|
|
|
|
|
2022-07-06 21:49:42 -04:00
|
|
|
// Disable updates, preventing animations in the background from playing.
|
|
|
|
persistentUpdate = false;
|
|
|
|
#if debug
|
2022-07-22 16:11:18 -04:00
|
|
|
if (FlxG.keys.pressed.THREE)
|
|
|
|
{
|
2022-07-06 21:49:42 -04:00
|
|
|
// TODO: Change the key or delete this?
|
|
|
|
// In debug builds, pressing 3 to kill the player makes the background transparent.
|
|
|
|
persistentDraw = true;
|
2022-07-22 16:11:18 -04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-07-06 21:49:42 -04:00
|
|
|
#end
|
|
|
|
persistentDraw = false;
|
|
|
|
#if debug
|
|
|
|
}
|
|
|
|
#end
|
|
|
|
|
|
|
|
var gameOverSubstate = new GameOverSubstate();
|
|
|
|
openSubState(gameOverSubstate);
|
2020-10-30 19:47:19 -04:00
|
|
|
|
2021-03-30 12:43:07 -04:00
|
|
|
#if discord_rpc
|
|
|
|
// Game Over doesn't get his own variable because it's only used here
|
2022-03-11 01:30:01 -05:00
|
|
|
DiscordClient.changePresence("Game Over - " + detailsText, currentSong.song + " (" + storyDifficultyText + ")", iconRPC);
|
2021-03-30 12:43:07 -04:00
|
|
|
#end
|
|
|
|
}
|
2020-10-05 18:29:59 -04:00
|
|
|
}
|
|
|
|
|
2022-03-11 01:30:01 -05:00
|
|
|
while (inactiveNotes[0] != null && inactiveNotes[0].data.strumTime - Conductor.songPosition < 1800 / SongLoad.getSpeed())
|
2020-10-05 05:48:30 -04:00
|
|
|
{
|
2022-03-11 01:30:01 -05:00
|
|
|
var dunceNote:Note = inactiveNotes[0];
|
|
|
|
activeNotes.add(dunceNote);
|
2020-10-05 06:25:14 -04:00
|
|
|
|
2022-03-11 01:30:01 -05:00
|
|
|
inactiveNotes.shift();
|
2020-10-05 05:48:30 -04:00
|
|
|
}
|
2020-10-03 02:50:15 -04:00
|
|
|
|
2022-03-25 22:30:37 -04:00
|
|
|
if (generatedMusic && playerStrumline != null)
|
2020-10-03 02:50:15 -04:00
|
|
|
{
|
2022-03-11 01:30:01 -05:00
|
|
|
activeNotes.forEachAlive(function(daNote:Note)
|
2020-10-04 02:42:58 -04:00
|
|
|
{
|
2021-04-20 11:55:42 -04:00
|
|
|
if ((PreferencesMenu.getPref('downscroll') && daNote.y < -daNote.height)
|
|
|
|
|| (!PreferencesMenu.getPref('downscroll') && daNote.y > FlxG.height))
|
2020-10-04 02:42:58 -04:00
|
|
|
{
|
2020-10-05 14:24:51 -04:00
|
|
|
daNote.active = false;
|
|
|
|
daNote.visible = false;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
daNote.visible = true;
|
|
|
|
daNote.active = true;
|
2020-10-04 02:42:58 -04:00
|
|
|
}
|
|
|
|
|
2022-03-14 20:48:45 -04:00
|
|
|
var strumLineMid = playerStrumline.y + Note.swagWidth / 2;
|
2021-12-06 22:35:14 -05:00
|
|
|
|
|
|
|
if (daNote.followsTime)
|
2022-01-22 16:53:38 -05:00
|
|
|
daNote.y = (Conductor.songPosition - daNote.data.strumTime) * (0.45 * FlxMath.roundDecimal(SongLoad.getSpeed(),
|
|
|
|
2) * daNote.noteSpeedMulti);
|
2021-03-30 21:02:12 -04:00
|
|
|
|
2021-03-30 18:10:15 -04:00
|
|
|
if (PreferencesMenu.getPref('downscroll'))
|
2021-03-30 21:02:12 -04:00
|
|
|
{
|
2022-03-14 20:48:45 -04:00
|
|
|
daNote.y += playerStrumline.y;
|
2021-03-31 13:11:05 -04:00
|
|
|
if (daNote.isSustainNote)
|
2021-03-30 21:02:12 -04:00
|
|
|
{
|
2021-03-31 13:11:05 -04:00
|
|
|
if (daNote.animation.curAnim.name.endsWith("end") && daNote.prevNote != null)
|
|
|
|
daNote.y += daNote.prevNote.height;
|
|
|
|
else
|
2021-04-14 22:24:32 -04:00
|
|
|
daNote.y += daNote.height / 2;
|
2021-03-30 21:02:12 -04:00
|
|
|
|
2021-03-31 13:11:05 -04:00
|
|
|
if ((!daNote.mustPress || (daNote.wasGoodHit || (daNote.prevNote.wasGoodHit && !daNote.canBeHit)))
|
2021-03-31 15:41:45 -04:00
|
|
|
&& daNote.y - daNote.offset.y * daNote.scale.y + daNote.height >= strumLineMid)
|
2021-03-31 13:11:05 -04:00
|
|
|
{
|
2021-08-01 21:29:34 -04:00
|
|
|
applyClipRect(daNote);
|
2021-03-31 13:11:05 -04:00
|
|
|
}
|
2021-03-30 21:02:12 -04:00
|
|
|
}
|
|
|
|
}
|
2021-03-30 18:10:15 -04:00
|
|
|
else
|
2021-03-30 21:02:12 -04:00
|
|
|
{
|
2021-12-06 22:35:14 -05:00
|
|
|
if (daNote.followsTime)
|
2022-03-14 20:48:45 -04:00
|
|
|
daNote.y = playerStrumline.y - daNote.y;
|
2021-03-31 00:25:41 -04:00
|
|
|
if (daNote.isSustainNote
|
|
|
|
&& (!daNote.mustPress || (daNote.wasGoodHit || (daNote.prevNote.wasGoodHit && !daNote.canBeHit)))
|
2021-03-30 21:02:12 -04:00
|
|
|
&& daNote.y + daNote.offset.y * daNote.scale.y <= strumLineMid)
|
|
|
|
{
|
2021-08-01 21:29:34 -04:00
|
|
|
applyClipRect(daNote);
|
2021-03-30 21:02:12 -04:00
|
|
|
}
|
2021-02-13 17:39:31 -05:00
|
|
|
}
|
|
|
|
|
2022-03-21 00:19:05 -04:00
|
|
|
if (!daNote.mustPress && daNote.wasGoodHit && !daNote.tooLate)
|
2020-10-05 14:24:51 -04:00
|
|
|
{
|
2022-09-22 06:34:03 -04:00
|
|
|
if (currentSong != null && currentSong.song != 'Tutorial')
|
2020-11-02 01:46:37 -05:00
|
|
|
camZooming = true;
|
|
|
|
|
2022-06-09 22:28:58 -04:00
|
|
|
var event:NoteScriptEvent = new NoteScriptEvent(ScriptEvent.NOTE_HIT, daNote, combo, true);
|
2022-03-21 00:19:05 -04:00
|
|
|
dispatchEvent(event);
|
2021-01-17 04:16:02 -05:00
|
|
|
|
2022-03-21 00:19:05 -04:00
|
|
|
// Calling event.cancelEvent() in a module should force the CPU to miss the note.
|
|
|
|
// This is useful for cool shit, including but not limited to:
|
|
|
|
// - Making the AI ignore notes which are hazardous.
|
|
|
|
// - Making the AI miss notes on purpose for aesthetic reasons.
|
|
|
|
if (event.eventCanceled)
|
2021-01-17 04:16:02 -05:00
|
|
|
{
|
2022-03-21 00:19:05 -04:00
|
|
|
daNote.tooLate = true;
|
2021-01-17 04:16:02 -05:00
|
|
|
}
|
2022-03-21 00:19:05 -04:00
|
|
|
else
|
2020-10-05 14:24:51 -04:00
|
|
|
{
|
2022-03-21 00:19:05 -04:00
|
|
|
// Volume of DAD.
|
2022-09-22 06:34:03 -04:00
|
|
|
if (currentSong != null && currentSong.needsVoices)
|
2022-03-21 00:19:05 -04:00
|
|
|
vocals.volume = 1;
|
2020-10-05 14:24:51 -04:00
|
|
|
}
|
|
|
|
}
|
2020-10-05 01:13:12 -04:00
|
|
|
|
2020-10-26 05:16:05 -04:00
|
|
|
// WIP interpolation shit? Need to fix the pause issue
|
2021-11-29 22:12:18 -05:00
|
|
|
// daNote.y = (strumLine.y - (songTime - daNote.strumTime) * (0.45 * SONG.speed[SongLoad.curDiff]));
|
2020-10-05 06:25:14 -04:00
|
|
|
|
2021-04-20 11:55:42 -04:00
|
|
|
// removing this so whether the note misses or not is entirely up to Note class
|
|
|
|
// var noteMiss:Bool = daNote.y < -daNote.height;
|
2021-03-30 18:10:15 -04:00
|
|
|
|
2021-04-20 11:55:42 -04:00
|
|
|
// if (PreferencesMenu.getPref('downscroll'))
|
2021-06-05 00:01:15 -04:00
|
|
|
// noteMiss = daNote.y > FlxG.height;
|
2021-03-30 18:10:15 -04:00
|
|
|
|
2021-04-20 16:25:38 -04:00
|
|
|
if (daNote.isSustainNote && daNote.wasGoodHit)
|
|
|
|
{
|
|
|
|
if ((!PreferencesMenu.getPref('downscroll') && daNote.y < -daNote.height)
|
|
|
|
|| (PreferencesMenu.getPref('downscroll') && daNote.y > FlxG.height))
|
|
|
|
{
|
|
|
|
daNote.active = false;
|
|
|
|
daNote.visible = false;
|
|
|
|
|
|
|
|
daNote.kill();
|
2022-03-11 01:30:01 -05:00
|
|
|
activeNotes.remove(daNote, true);
|
2021-04-20 16:25:38 -04:00
|
|
|
daNote.destroy();
|
|
|
|
}
|
|
|
|
}
|
2022-03-21 00:19:05 -04:00
|
|
|
if (daNote.wasGoodHit)
|
2020-10-05 14:24:51 -04:00
|
|
|
{
|
2021-02-19 19:22:23 -05:00
|
|
|
daNote.active = false;
|
|
|
|
daNote.visible = false;
|
2020-10-05 06:25:14 -04:00
|
|
|
|
2021-02-19 19:22:23 -05:00
|
|
|
daNote.kill();
|
2022-03-11 01:30:01 -05:00
|
|
|
activeNotes.remove(daNote, true);
|
2021-02-19 19:22:23 -05:00
|
|
|
daNote.destroy();
|
2020-10-05 14:24:51 -04:00
|
|
|
}
|
2022-03-21 00:19:05 -04:00
|
|
|
|
|
|
|
if (daNote.tooLate)
|
|
|
|
{
|
|
|
|
noteMiss(daNote);
|
|
|
|
}
|
2020-10-05 14:24:51 -04:00
|
|
|
});
|
|
|
|
}
|
2020-10-05 06:25:14 -04:00
|
|
|
|
2022-09-24 15:02:10 -04:00
|
|
|
if (songEvents != null && songEvents.length > 0)
|
|
|
|
{
|
|
|
|
var songEventsToActivate:Array<SongEvent> = SongEventHandler.queryEvents(songEvents, Conductor.songPosition);
|
|
|
|
|
|
|
|
if (songEventsToActivate.length > 0)
|
|
|
|
trace('[EVENTS] Found ${songEventsToActivate.length} event(s) to activate.');
|
|
|
|
|
|
|
|
SongEventHandler.activateEvents(songEventsToActivate);
|
|
|
|
}
|
|
|
|
|
2022-03-13 14:36:03 -04:00
|
|
|
if (!isInCutscene)
|
2022-03-14 20:48:45 -04:00
|
|
|
keyShit(true);
|
2020-10-03 13:36:39 -04:00
|
|
|
}
|
|
|
|
|
2021-08-01 21:29:34 -04:00
|
|
|
function applyClipRect(daNote:Note):Void
|
|
|
|
{
|
|
|
|
// clipRect is applied to graphic itself so use frame Heights
|
|
|
|
var swagRect:FlxRect = new FlxRect(0, 0, daNote.frameWidth, daNote.frameHeight);
|
2022-03-14 20:48:45 -04:00
|
|
|
var strumLineMid = playerStrumline.y + Note.swagWidth / 2;
|
2021-08-01 21:29:34 -04:00
|
|
|
|
|
|
|
if (PreferencesMenu.getPref('downscroll'))
|
|
|
|
{
|
|
|
|
swagRect.height = (strumLineMid - daNote.y) / daNote.scale.y;
|
|
|
|
swagRect.y = daNote.frameHeight - swagRect.height;
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
swagRect.y = (strumLineMid - daNote.y) / daNote.scale.y;
|
|
|
|
swagRect.height -= swagRect.y;
|
|
|
|
}
|
|
|
|
|
|
|
|
daNote.clipRect = swagRect;
|
|
|
|
}
|
|
|
|
|
2021-04-21 09:07:36 -04:00
|
|
|
#if debug
|
2022-07-06 21:49:42 -04:00
|
|
|
/**
|
|
|
|
* Jumps forward or backward a number of sections in the song.
|
|
|
|
* Accounts for BPM changes, does not prevent death from skipped notes.
|
|
|
|
* @param sec
|
|
|
|
*/
|
2021-04-21 09:07:36 -04:00
|
|
|
function changeSection(sec:Int):Void
|
|
|
|
{
|
|
|
|
FlxG.sound.music.pause();
|
|
|
|
|
2022-09-24 01:28:39 -04:00
|
|
|
// BPM might change between the current and target section but IDGAF
|
|
|
|
FlxG.sound.music.time = Conductor.songPosition + (sec * 4 * (1000 * 60 / Conductor.bpm));
|
2022-09-22 06:34:03 -04:00
|
|
|
|
2022-09-26 17:18:19 -04:00
|
|
|
Conductor.update();
|
2021-04-21 09:07:36 -04:00
|
|
|
resyncVocals();
|
|
|
|
}
|
|
|
|
#end
|
|
|
|
|
2020-10-31 21:11:14 -04:00
|
|
|
function endSong():Void
|
|
|
|
{
|
2022-07-14 19:03:42 -04:00
|
|
|
dispatchEvent(new ScriptEvent(ScriptEvent.SONG_END));
|
|
|
|
|
2021-04-09 16:37:54 -04:00
|
|
|
seenCutscene = false;
|
2021-03-04 14:30:35 -05:00
|
|
|
deathCounter = 0;
|
2022-03-11 01:30:01 -05:00
|
|
|
mayPauseGame = false;
|
2021-01-20 04:03:49 -05:00
|
|
|
FlxG.sound.music.volume = 0;
|
|
|
|
vocals.volume = 0;
|
2022-09-24 01:28:39 -04:00
|
|
|
if (currentSong != null && currentSong.validScore)
|
2020-12-04 12:32:35 -05:00
|
|
|
{
|
2022-03-11 01:30:01 -05:00
|
|
|
Highscore.saveScore(currentSong.song, songScore, storyDifficulty);
|
2020-12-04 12:32:35 -05:00
|
|
|
}
|
2020-11-01 04:55:02 -05:00
|
|
|
|
2020-10-31 21:11:14 -04:00
|
|
|
if (isStoryMode)
|
|
|
|
{
|
2020-11-06 21:17:27 -05:00
|
|
|
campaignScore += songScore;
|
|
|
|
|
2020-10-31 21:11:14 -04:00
|
|
|
storyPlaylist.remove(storyPlaylist[0]);
|
|
|
|
|
|
|
|
if (storyPlaylist.length <= 0)
|
|
|
|
{
|
2021-02-08 16:34:48 -05:00
|
|
|
FlxG.sound.playMusic(Paths.music('freakyMenu'));
|
2020-11-01 14:16:22 -05:00
|
|
|
|
2021-02-12 01:20:20 -05:00
|
|
|
transIn = FlxTransitionableState.defaultTransIn;
|
|
|
|
transOut = FlxTransitionableState.defaultTransOut;
|
|
|
|
|
2022-03-11 01:30:01 -05:00
|
|
|
switch (storyWeek)
|
2021-04-10 02:53:23 -04:00
|
|
|
{
|
|
|
|
case 7:
|
|
|
|
FlxG.switchState(new VideoState());
|
|
|
|
default:
|
|
|
|
FlxG.switchState(new StoryMenuState());
|
|
|
|
}
|
2020-10-31 21:11:14 -04:00
|
|
|
|
2020-12-04 12:36:28 -05:00
|
|
|
// if ()
|
2020-12-11 17:22:22 -05:00
|
|
|
StoryMenuState.weekUnlocked[Std.int(Math.min(storyWeek + 1, StoryMenuState.weekUnlocked.length - 1))] = true;
|
2020-11-01 14:16:22 -05:00
|
|
|
|
2022-03-11 01:30:01 -05:00
|
|
|
if (currentSong.validScore)
|
2020-12-04 12:36:28 -05:00
|
|
|
{
|
|
|
|
NGio.unlockMedal(60961);
|
|
|
|
Highscore.saveWeekScore(storyWeek, campaignScore, storyDifficulty);
|
|
|
|
}
|
2020-11-01 04:55:02 -05:00
|
|
|
|
2020-11-01 14:16:22 -05:00
|
|
|
FlxG.save.data.weekUnlocked = StoryMenuState.weekUnlocked;
|
|
|
|
FlxG.save.flush();
|
2020-10-31 21:11:14 -04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
|
|
|
var difficulty:String = "";
|
|
|
|
|
|
|
|
if (storyDifficulty == 0)
|
|
|
|
difficulty = '-easy';
|
|
|
|
|
|
|
|
if (storyDifficulty == 2)
|
2020-11-10 13:08:18 -05:00
|
|
|
difficulty = '-hard';
|
2020-10-31 21:11:14 -04:00
|
|
|
|
2020-11-07 16:59:25 -05:00
|
|
|
trace('LOADING NEXT SONG');
|
2021-04-10 01:49:57 -04:00
|
|
|
trace(storyPlaylist[0].toLowerCase() + difficulty);
|
2020-11-07 16:59:25 -05:00
|
|
|
|
2021-04-14 20:18:59 -04:00
|
|
|
FlxTransitionableState.skipNextTransIn = true;
|
|
|
|
FlxTransitionableState.skipNextTransOut = true;
|
|
|
|
|
|
|
|
FlxG.sound.music.stop();
|
|
|
|
vocals.stop();
|
|
|
|
|
2022-03-11 01:30:01 -05:00
|
|
|
if (currentSong.song.toLowerCase() == 'eggnog')
|
2021-01-20 04:03:49 -05:00
|
|
|
{
|
|
|
|
var blackShit:FlxSprite = new FlxSprite(-FlxG.width * FlxG.camera.zoom,
|
|
|
|
-FlxG.height * FlxG.camera.zoom).makeGraphic(FlxG.width * 3, FlxG.height * 3, FlxColor.BLACK);
|
|
|
|
blackShit.scrollFactor.set();
|
|
|
|
add(blackShit);
|
|
|
|
camHUD.visible = false;
|
2022-03-13 14:36:03 -04:00
|
|
|
isInCutscene = true;
|
2021-01-20 04:03:49 -05:00
|
|
|
|
2021-04-18 05:26:52 -04:00
|
|
|
FlxG.sound.play(Paths.sound('Lights_Shut_off'), function()
|
|
|
|
{
|
2021-04-14 20:18:59 -04:00
|
|
|
// no camFollow so it centers on horror tree
|
2022-03-11 01:30:01 -05:00
|
|
|
currentSong = SongLoad.loadFromJson(storyPlaylist[0].toLowerCase() + difficulty, storyPlaylist[0]);
|
2021-04-14 20:18:59 -04:00
|
|
|
LoadingState.loadAndSwitchState(new PlayState());
|
|
|
|
});
|
2021-01-20 04:03:49 -05:00
|
|
|
}
|
2021-04-14 20:18:59 -04:00
|
|
|
else
|
|
|
|
{
|
2022-03-11 01:30:01 -05:00
|
|
|
previousCameraFollowPoint = cameraFollowPoint;
|
2021-01-20 04:03:49 -05:00
|
|
|
|
2022-03-11 01:30:01 -05:00
|
|
|
currentSong = SongLoad.loadFromJson(storyPlaylist[0].toLowerCase() + difficulty, storyPlaylist[0]);
|
2021-04-14 20:18:59 -04:00
|
|
|
LoadingState.loadAndSwitchState(new PlayState());
|
|
|
|
}
|
2020-10-31 21:11:14 -04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2020-12-26 21:46:22 -05:00
|
|
|
trace('WENT BACK TO FREEPLAY??');
|
2021-04-10 01:49:57 -04:00
|
|
|
// unloadAssets();
|
2020-10-31 21:11:14 -04:00
|
|
|
FlxG.switchState(new FreeplayState());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2021-04-20 14:38:07 -04:00
|
|
|
// gives score and pops up rating
|
2021-03-26 03:51:39 -04:00
|
|
|
private function popUpScore(strumtime:Float, daNote:Note):Void
|
2020-10-03 15:32:15 -04:00
|
|
|
{
|
2020-10-18 20:59:53 -04:00
|
|
|
var noteDiff:Float = Math.abs(strumtime - Conductor.songPosition);
|
2022-03-23 01:18:23 -04:00
|
|
|
// boyfriend.playAnimation('hey');
|
2020-10-30 19:47:19 -04:00
|
|
|
vocals.volume = 1;
|
2020-10-04 02:42:58 -04:00
|
|
|
|
2022-02-16 16:57:08 -05:00
|
|
|
var isSick:Bool = false;
|
2022-07-06 21:49:42 -04:00
|
|
|
var score = Scoring.scoreNote(noteDiff, PBOT1);
|
|
|
|
var daRating = Scoring.judgeNote(noteDiff, PBOT1);
|
|
|
|
var healthMulti:Float = daNote.lowStakes ? 0.002 : 0.033;
|
2021-09-22 15:09:32 -04:00
|
|
|
|
2021-09-08 13:28:11 -04:00
|
|
|
if (noteDiff > Note.HIT_WINDOW * Note.BAD_THRESHOLD)
|
2020-10-18 20:59:53 -04:00
|
|
|
{
|
2021-09-22 15:09:32 -04:00
|
|
|
healthMulti *= 0; // no health on shit note
|
2020-10-18 20:59:53 -04:00
|
|
|
}
|
2021-09-08 13:28:11 -04:00
|
|
|
else if (noteDiff > Note.HIT_WINDOW * Note.GOOD_THRESHOLD)
|
2020-10-18 20:59:53 -04:00
|
|
|
{
|
2021-09-22 15:33:30 -04:00
|
|
|
healthMulti *= 0.2;
|
2020-10-18 20:59:53 -04:00
|
|
|
}
|
2021-09-08 13:28:11 -04:00
|
|
|
else if (noteDiff > Note.HIT_WINDOW * Note.SICK_THRESHOLD)
|
2020-10-18 20:59:53 -04:00
|
|
|
{
|
2021-09-22 16:04:34 -04:00
|
|
|
healthMulti *= 0.78;
|
2021-03-26 03:51:39 -04:00
|
|
|
}
|
2022-02-16 16:57:08 -05:00
|
|
|
else
|
|
|
|
isSick = true;
|
2021-03-26 03:51:39 -04:00
|
|
|
|
2021-09-22 15:09:32 -04:00
|
|
|
health += healthMulti;
|
|
|
|
|
2021-03-26 03:51:39 -04:00
|
|
|
if (isSick)
|
|
|
|
{
|
2021-04-10 01:49:57 -04:00
|
|
|
var noteSplash:NoteSplash = grpNoteSplashes.recycle(NoteSplash);
|
2022-01-22 16:57:49 -05:00
|
|
|
noteSplash.setupNoteSplash(daNote.x, daNote.y, daNote.data.noteData);
|
2021-04-10 01:49:57 -04:00
|
|
|
// new NoteSplash(daNote.x, daNote.y, daNote.noteData);
|
|
|
|
grpNoteSplashes.add(noteSplash);
|
2020-10-18 20:59:53 -04:00
|
|
|
}
|
|
|
|
|
2021-04-09 22:49:25 -04:00
|
|
|
// Only add the score if you're not on practice mode
|
2022-03-11 01:30:01 -05:00
|
|
|
if (!isPracticeMode)
|
2021-04-09 22:49:25 -04:00
|
|
|
songScore += score;
|
2020-11-01 14:16:22 -05:00
|
|
|
|
2022-02-16 16:31:20 -05:00
|
|
|
comboPopUps.displayRating(daRating);
|
2021-01-25 05:04:31 -05:00
|
|
|
|
2021-04-20 14:38:07 -04:00
|
|
|
if (combo >= 10 || combo == 0)
|
2022-02-16 16:31:20 -05:00
|
|
|
comboPopUps.displayCombo(combo);
|
2020-10-03 15:32:15 -04:00
|
|
|
}
|
|
|
|
|
2022-09-24 15:02:10 -04:00
|
|
|
/*
|
|
|
|
function controlCamera()
|
2022-03-25 22:30:37 -04:00
|
|
|
{
|
2022-09-24 15:02:10 -04:00
|
|
|
if (currentStage == null)
|
|
|
|
return;
|
2021-03-24 22:41:41 -04:00
|
|
|
|
2022-09-24 15:02:10 -04:00
|
|
|
switch (cameraFocusCharacter)
|
2022-05-01 15:20:15 -04:00
|
|
|
{
|
2022-09-24 15:02:10 -04:00
|
|
|
default: // null = No change
|
|
|
|
break;
|
|
|
|
case 0: // Boyfriend
|
|
|
|
var isFocusedOnBF = cameraFollowPoint.x == currentStage.getBoyfriend().cameraFocusPoint.x;
|
|
|
|
if (!isFocusedOnBF)
|
|
|
|
{
|
|
|
|
// Focus the camera on the player.
|
|
|
|
cameraFollowPoint.setPosition(currentStage.getBoyfriend().cameraFocusPoint.x, currentStage.getBoyfriend().cameraFocusPoint.y);
|
|
|
|
}
|
|
|
|
case 1: // Dad
|
|
|
|
var isFocusedOnDad = cameraFollowPoint.x == currentStage.getDad().cameraFocusPoint.x;
|
|
|
|
if (!isFocusedOnDad)
|
|
|
|
{
|
|
|
|
cameraFollowPoint.setPosition(currentStage.getDad().cameraFocusPoint.x, currentStage.getDad().cameraFocusPoint.y);
|
|
|
|
}
|
|
|
|
case 2: // Girlfriend
|
|
|
|
var isFocusedOnGF = cameraFollowPoint.x == currentStage.getGirlfriend().cameraFocusPoint.x;
|
|
|
|
if (!isFocusedOnGF)
|
|
|
|
{
|
|
|
|
cameraFollowPoint.setPosition(currentStage.getGirlfriend().cameraFocusPoint.x, currentStage.getGirlfriend().cameraFocusPoint.y);
|
|
|
|
}
|
2022-05-01 15:20:15 -04:00
|
|
|
}
|
|
|
|
|
2022-09-24 15:02:10 -04:00
|
|
|
/*
|
|
|
|
if (cameraRightSide && !isFocusedOnBF)
|
|
|
|
{
|
|
|
|
// Focus the camera on the player.
|
|
|
|
cameraFollowPoint.setPosition(currentStage.getBoyfriend().cameraFocusPoint.x, currentStage.getBoyfriend().cameraFocusPoint.y);
|
|
|
|
|
|
|
|
// TODO: Un-hardcode this.
|
|
|
|
if (currentSong.song.toLowerCase() == 'tutorial')
|
|
|
|
FlxTween.tween(FlxG.camera, {zoom: 1 * FlxCamera.defaultZoom}, (Conductor.stepCrochet * 4 / 1000), {ease: FlxEase.elasticInOut});
|
|
|
|
}
|
|
|
|
else if (!cameraRightSide && !isFocusedOnDad)
|
|
|
|
{
|
|
|
|
// Focus the camera on the opponent.
|
|
|
|
cameraFollowPoint.setPosition(currentStage.getDad().cameraFocusPoint.x, currentStage.getDad().cameraFocusPoint.y);
|
|
|
|
|
|
|
|
// TODO: Un-hardcode this stuff.
|
|
|
|
if (currentStage.getDad().characterId == 'mom')
|
|
|
|
{
|
|
|
|
vocals.volume = 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (currentSong.song.toLowerCase() == 'tutorial')
|
|
|
|
tweenCamIn();
|
|
|
|
}
|
|
|
|
*/
|
|
|
|
// }
|
2021-03-24 22:41:41 -04:00
|
|
|
|
2022-03-14 20:48:45 -04:00
|
|
|
public function keyShit(test:Bool):Void
|
2020-10-03 13:36:39 -04:00
|
|
|
{
|
2022-03-21 00:19:05 -04:00
|
|
|
if (PlayState.instance == null)
|
|
|
|
return;
|
|
|
|
|
2021-03-28 17:29:44 -04:00
|
|
|
// control arrays, order L D R U
|
|
|
|
var holdArray:Array<Bool> = [controls.NOTE_LEFT, controls.NOTE_DOWN, controls.NOTE_UP, controls.NOTE_RIGHT];
|
2021-03-30 16:58:05 -04:00
|
|
|
var pressArray:Array<Bool> = [
|
|
|
|
controls.NOTE_LEFT_P,
|
|
|
|
controls.NOTE_DOWN_P,
|
|
|
|
controls.NOTE_UP_P,
|
|
|
|
controls.NOTE_RIGHT_P
|
|
|
|
];
|
|
|
|
var releaseArray:Array<Bool> = [
|
|
|
|
controls.NOTE_LEFT_R,
|
|
|
|
controls.NOTE_DOWN_R,
|
|
|
|
controls.NOTE_UP_R,
|
|
|
|
controls.NOTE_RIGHT_R
|
|
|
|
];
|
2021-03-28 17:29:44 -04:00
|
|
|
// HOLDS, check for sustain notes
|
2022-03-14 20:48:45 -04:00
|
|
|
if (holdArray.contains(true) && PlayState.instance.generatedMusic)
|
2020-10-03 13:36:39 -04:00
|
|
|
{
|
2022-03-14 20:48:45 -04:00
|
|
|
PlayState.instance.activeNotes.forEachAlive(function(daNote:Note)
|
2021-03-28 17:29:44 -04:00
|
|
|
{
|
2022-01-22 16:57:49 -05:00
|
|
|
if (daNote.isSustainNote && daNote.canBeHit && daNote.mustPress && holdArray[daNote.data.noteData])
|
2022-03-14 20:48:45 -04:00
|
|
|
PlayState.instance.goodNoteHit(daNote);
|
2021-03-28 17:29:44 -04:00
|
|
|
});
|
|
|
|
}
|
2021-03-21 16:29:47 -04:00
|
|
|
|
2021-03-28 17:29:44 -04:00
|
|
|
// PRESSES, check for note hits
|
2022-03-14 20:48:45 -04:00
|
|
|
if (pressArray.contains(true) && PlayState.instance.generatedMusic)
|
2021-03-28 17:29:44 -04:00
|
|
|
{
|
2021-08-22 16:54:22 -04:00
|
|
|
Haptic.vibrate(100, 100);
|
2021-08-22 10:37:06 -04:00
|
|
|
|
2022-03-14 20:48:45 -04:00
|
|
|
PlayState.instance.currentStage.getBoyfriend().holdTimer = 0;
|
2020-11-11 05:00:13 -05:00
|
|
|
|
2021-03-28 17:29:44 -04:00
|
|
|
var possibleNotes:Array<Note> = []; // notes that can be hit
|
|
|
|
var directionList:Array<Int> = []; // directions that can be hit
|
|
|
|
var dumbNotes:Array<Note> = []; // notes to kill later
|
2021-01-17 21:23:40 -05:00
|
|
|
|
2022-03-14 20:48:45 -04:00
|
|
|
PlayState.instance.activeNotes.forEachAlive(function(daNote:Note)
|
2020-10-03 13:36:39 -04:00
|
|
|
{
|
2021-02-19 19:22:23 -05:00
|
|
|
if (daNote.canBeHit && daNote.mustPress && !daNote.tooLate && !daNote.wasGoodHit)
|
2020-10-04 23:29:35 -04:00
|
|
|
{
|
2022-01-22 16:53:38 -05:00
|
|
|
if (directionList.contains(daNote.data.noteData))
|
2021-01-17 21:23:40 -05:00
|
|
|
{
|
2021-01-17 21:36:23 -05:00
|
|
|
for (coolNote in possibleNotes)
|
2021-01-17 21:23:40 -05:00
|
|
|
{
|
2022-01-22 16:53:38 -05:00
|
|
|
if (coolNote.data.noteData == daNote.data.noteData
|
|
|
|
&& Math.abs(daNote.data.strumTime - coolNote.data.strumTime) < 10)
|
2021-03-30 16:58:05 -04:00
|
|
|
{ // if it's the same note twice at < 10ms distance, just delete it
|
2021-03-28 17:29:44 -04:00
|
|
|
// EXCEPT u cant delete it in this loop cuz it fucks with the collection lol
|
|
|
|
dumbNotes.push(daNote);
|
|
|
|
break;
|
|
|
|
}
|
2022-01-22 16:53:38 -05:00
|
|
|
else if (coolNote.data.noteData == daNote.data.noteData && daNote.data.strumTime < coolNote.data.strumTime)
|
2021-03-30 16:58:05 -04:00
|
|
|
{ // if daNote is earlier than existing note (coolNote), replace
|
2021-03-28 17:29:44 -04:00
|
|
|
possibleNotes.remove(coolNote);
|
|
|
|
possibleNotes.push(daNote);
|
|
|
|
break;
|
2021-01-17 21:36:23 -05:00
|
|
|
}
|
2021-01-17 21:23:40 -05:00
|
|
|
}
|
|
|
|
}
|
2021-01-19 21:09:47 -05:00
|
|
|
else
|
|
|
|
{
|
2021-03-28 17:29:44 -04:00
|
|
|
possibleNotes.push(daNote);
|
2022-01-22 16:53:38 -05:00
|
|
|
directionList.push(daNote.data.noteData);
|
2021-01-19 21:09:47 -05:00
|
|
|
}
|
2021-01-17 21:36:23 -05:00
|
|
|
}
|
2021-03-28 17:29:44 -04:00
|
|
|
});
|
2021-03-04 14:30:35 -05:00
|
|
|
|
2021-03-28 17:29:44 -04:00
|
|
|
for (note in dumbNotes)
|
2020-10-04 23:29:35 -04:00
|
|
|
{
|
2022-01-22 16:53:38 -05:00
|
|
|
FlxG.log.add("killing dumb ass note at " + note.data.strumTime);
|
2021-03-28 17:29:44 -04:00
|
|
|
note.kill();
|
2022-03-14 20:48:45 -04:00
|
|
|
PlayState.instance.activeNotes.remove(note, true);
|
2021-03-28 17:29:44 -04:00
|
|
|
note.destroy();
|
2020-10-04 23:29:35 -04:00
|
|
|
}
|
2020-10-04 17:44:52 -04:00
|
|
|
|
2022-01-22 16:53:38 -05:00
|
|
|
possibleNotes.sort((a, b) -> Std.int(a.data.strumTime - b.data.strumTime));
|
2021-03-28 17:29:44 -04:00
|
|
|
|
2022-03-14 20:48:45 -04:00
|
|
|
if (PlayState.instance.perfectMode)
|
|
|
|
PlayState.instance.goodNoteHit(possibleNotes[0]);
|
2021-03-28 17:29:44 -04:00
|
|
|
else if (possibleNotes.length > 0)
|
2020-10-05 03:49:53 -04:00
|
|
|
{
|
2021-03-28 17:29:44 -04:00
|
|
|
for (shit in 0...pressArray.length)
|
2021-03-30 16:58:05 -04:00
|
|
|
{ // if a direction is hit that shouldn't be
|
2021-03-28 17:29:44 -04:00
|
|
|
if (pressArray[shit] && !directionList.contains(shit))
|
2022-03-21 00:19:05 -04:00
|
|
|
PlayState.instance.ghostNoteMiss(shit);
|
2021-03-28 17:29:44 -04:00
|
|
|
}
|
|
|
|
for (coolNote in possibleNotes)
|
2020-10-05 03:49:53 -04:00
|
|
|
{
|
2022-01-22 16:53:38 -05:00
|
|
|
if (pressArray[coolNote.data.noteData])
|
2022-03-14 20:48:45 -04:00
|
|
|
PlayState.instance.goodNoteHit(coolNote);
|
2020-10-05 03:49:53 -04:00
|
|
|
}
|
2021-03-28 17:29:44 -04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2022-03-21 00:19:05 -04:00
|
|
|
// HNGGG I really want to add an option for ghost tapping
|
2022-09-16 01:44:50 -04:00
|
|
|
// L + ratio
|
2021-04-20 11:55:42 -04:00
|
|
|
for (shit in 0...pressArray.length)
|
|
|
|
if (pressArray[shit])
|
2022-03-21 00:19:05 -04:00
|
|
|
PlayState.instance.ghostNoteMiss(shit, false);
|
2021-03-28 17:29:44 -04:00
|
|
|
}
|
2020-10-05 03:49:53 -04:00
|
|
|
}
|
|
|
|
|
2022-04-18 19:36:09 -04:00
|
|
|
if (PlayState.instance == null || PlayState.instance.currentStage == null)
|
2022-03-13 14:36:03 -04:00
|
|
|
return;
|
2020-10-23 19:12:38 -04:00
|
|
|
|
2022-03-14 20:48:45 -04:00
|
|
|
for (keyId => isPressed in pressArray)
|
2020-10-04 17:44:52 -04:00
|
|
|
{
|
2022-03-25 22:30:37 -04:00
|
|
|
if (playerStrumline == null)
|
|
|
|
continue;
|
2022-03-14 20:48:45 -04:00
|
|
|
var arrow:StrumlineArrow = PlayState.instance.playerStrumline.getArrow(keyId);
|
2020-10-05 06:53:10 -04:00
|
|
|
|
2022-03-14 20:48:45 -04:00
|
|
|
if (isPressed && arrow.animation.curAnim.name != 'confirm')
|
2020-10-04 17:44:52 -04:00
|
|
|
{
|
2022-03-14 20:48:45 -04:00
|
|
|
arrow.playAnimation('pressed');
|
2020-10-04 17:44:52 -04:00
|
|
|
}
|
2022-03-14 20:48:45 -04:00
|
|
|
if (!holdArray[keyId])
|
|
|
|
{
|
|
|
|
arrow.playAnimation('static');
|
|
|
|
}
|
|
|
|
}
|
2020-10-03 13:36:39 -04:00
|
|
|
}
|
|
|
|
|
2022-03-21 00:19:05 -04:00
|
|
|
/**
|
|
|
|
* Called when a player presses a key with no note present.
|
|
|
|
* Scripts can modify the amount of health/score lost, whether player animations or sounds are used,
|
|
|
|
* or even cancel the event entirely.
|
|
|
|
*
|
|
|
|
* @param direction
|
|
|
|
* @param hasPossibleNotes
|
|
|
|
*/
|
2022-09-16 01:44:50 -04:00
|
|
|
function ghostNoteMiss(direction:funkin.noteStuff.NoteBasic.NoteType = 1, hasPossibleNotes:Bool = true):Void
|
2020-10-04 23:29:35 -04:00
|
|
|
{
|
2022-03-21 00:19:05 -04:00
|
|
|
var event:GhostMissNoteScriptEvent = new GhostMissNoteScriptEvent(direction, // Direction missed in.
|
|
|
|
hasPossibleNotes, // Whether there was a note you could have hit.
|
|
|
|
- 0.035 * 2, // How much health to add (negative).
|
|
|
|
- 10 // Amount of score to add (negative).
|
|
|
|
);
|
|
|
|
dispatchEvent(event);
|
|
|
|
|
|
|
|
// Calling event.cancelEvent() skips animations and penalties. Neat!
|
|
|
|
if (event.eventCanceled)
|
|
|
|
return;
|
|
|
|
|
|
|
|
health += event.healthChange;
|
2020-10-05 10:03:38 -04:00
|
|
|
|
2022-03-11 01:30:01 -05:00
|
|
|
if (!isPracticeMode)
|
2022-03-21 00:19:05 -04:00
|
|
|
songScore += event.scoreChange;
|
|
|
|
|
|
|
|
if (event.playSound)
|
|
|
|
{
|
|
|
|
vocals.volume = 0;
|
|
|
|
FlxG.sound.play(Paths.soundRandom('missnote', 1, 3), FlxG.random.float(0.1, 0.2));
|
|
|
|
}
|
|
|
|
}
|
2020-11-01 14:16:22 -05:00
|
|
|
|
2022-03-21 00:19:05 -04:00
|
|
|
function noteMiss(note:Note):Void
|
|
|
|
{
|
2022-06-09 22:28:58 -04:00
|
|
|
var event:NoteScriptEvent = new NoteScriptEvent(ScriptEvent.NOTE_MISS, note, combo, true);
|
2022-03-21 00:19:05 -04:00
|
|
|
dispatchEvent(event);
|
|
|
|
// Calling event.cancelEvent() skips all the other logic! Neat!
|
|
|
|
if (event.eventCanceled)
|
|
|
|
return;
|
|
|
|
|
|
|
|
health -= 0.0775;
|
|
|
|
if (!isPracticeMode)
|
|
|
|
songScore -= 10;
|
2022-03-06 03:33:12 -05:00
|
|
|
vocals.volume = 0;
|
2022-06-09 22:28:58 -04:00
|
|
|
|
|
|
|
if (combo != 0)
|
|
|
|
{
|
|
|
|
combo = comboPopUps.displayCombo(0);
|
|
|
|
}
|
2022-03-21 00:19:05 -04:00
|
|
|
|
|
|
|
note.active = false;
|
|
|
|
note.visible = false;
|
2020-10-05 03:49:53 -04:00
|
|
|
|
2022-03-21 00:19:05 -04:00
|
|
|
note.kill();
|
|
|
|
activeNotes.remove(note, true);
|
|
|
|
note.destroy();
|
2020-10-04 23:29:35 -04:00
|
|
|
}
|
|
|
|
|
2020-10-03 13:36:39 -04:00
|
|
|
function goodNoteHit(note:Note):Void
|
|
|
|
{
|
2020-10-03 15:32:15 -04:00
|
|
|
if (!note.wasGoodHit)
|
|
|
|
{
|
2022-06-09 22:28:58 -04:00
|
|
|
var event:NoteScriptEvent = new NoteScriptEvent(ScriptEvent.NOTE_HIT, note, combo + 1, true);
|
2022-03-21 00:19:05 -04:00
|
|
|
dispatchEvent(event);
|
|
|
|
|
|
|
|
// Calling event.cancelEvent() skips all the other logic! Neat!
|
|
|
|
if (event.eventCanceled)
|
|
|
|
return;
|
|
|
|
|
2020-10-30 19:47:19 -04:00
|
|
|
if (!note.isSustainNote)
|
|
|
|
{
|
|
|
|
combo += 1;
|
2022-01-22 16:53:38 -05:00
|
|
|
popUpScore(note.data.strumTime, note);
|
2020-10-30 19:47:19 -04:00
|
|
|
}
|
2022-02-16 16:31:20 -05:00
|
|
|
|
2022-03-14 20:48:45 -04:00
|
|
|
playerStrumline.getArrow(note.data.noteData).playAnimation('confirm', true);
|
2020-10-04 14:50:12 -04:00
|
|
|
|
2020-10-03 15:32:15 -04:00
|
|
|
note.wasGoodHit = true;
|
2020-10-04 02:42:58 -04:00
|
|
|
vocals.volume = 1;
|
2020-10-05 18:29:59 -04:00
|
|
|
|
2021-02-13 17:39:31 -05:00
|
|
|
if (!note.isSustainNote)
|
|
|
|
{
|
|
|
|
note.kill();
|
2022-03-11 01:30:01 -05:00
|
|
|
activeNotes.remove(note, true);
|
2021-02-13 17:39:31 -05:00
|
|
|
note.destroy();
|
|
|
|
}
|
2020-10-03 15:32:15 -04:00
|
|
|
}
|
2020-10-03 02:50:15 -04:00
|
|
|
}
|
|
|
|
|
2022-03-29 21:56:04 -04:00
|
|
|
override function stepHit():Bool
|
2020-10-09 23:22:07 -04:00
|
|
|
{
|
2022-08-27 02:02:29 -04:00
|
|
|
if (SongLoad.songData == null)
|
|
|
|
return false;
|
|
|
|
|
2022-03-29 21:56:04 -04:00
|
|
|
// super.stepHit() returns false if a module cancelled the event.
|
|
|
|
if (!super.stepHit())
|
|
|
|
return false;
|
|
|
|
|
2021-04-18 16:54:21 -04:00
|
|
|
if (Math.abs(FlxG.sound.music.time - (Conductor.songPosition - Conductor.offset)) > 20
|
2022-03-09 19:07:39 -05:00
|
|
|
|| Math.abs(vocals.checkSyncError(Conductor.songPosition - Conductor.offset)) > 20)
|
2020-10-09 23:22:07 -04:00
|
|
|
{
|
2021-02-08 12:47:15 -05:00
|
|
|
resyncVocals();
|
2020-10-30 19:47:19 -04:00
|
|
|
}
|
2020-10-09 23:22:07 -04:00
|
|
|
|
2022-10-07 00:37:21 -04:00
|
|
|
if (iconP1 != null)
|
|
|
|
iconP1.onStepHit(Std.int(Conductor.currentStep));
|
|
|
|
if (iconP2 != null)
|
|
|
|
iconP2.onStepHit(Std.int(Conductor.currentStep));
|
2022-03-26 22:18:26 -04:00
|
|
|
|
2022-03-29 21:56:04 -04:00
|
|
|
return true;
|
2022-02-25 02:02:06 -05:00
|
|
|
}
|
2020-11-02 01:46:37 -05:00
|
|
|
|
2022-03-29 21:56:04 -04:00
|
|
|
override function beatHit():Bool
|
2020-10-03 02:50:15 -04:00
|
|
|
{
|
2022-03-29 21:56:04 -04:00
|
|
|
// super.beatHit() returns false if a module cancelled the event.
|
|
|
|
if (!super.beatHit())
|
|
|
|
return false;
|
2020-10-05 05:48:30 -04:00
|
|
|
|
2020-10-24 05:19:13 -04:00
|
|
|
if (generatedMusic)
|
|
|
|
{
|
2022-09-24 15:02:10 -04:00
|
|
|
// TODO: Sort more efficiently, or less often, to improve performance.
|
2022-03-11 01:30:01 -05:00
|
|
|
activeNotes.sort(SortUtil.byStrumtime, FlxSort.DESCENDING);
|
2020-10-24 05:19:13 -04:00
|
|
|
}
|
|
|
|
|
2022-03-29 21:56:04 -04:00
|
|
|
// Moving this code into the `beatHit` function allows for scripts and modules to control the camera better.
|
2022-09-24 01:28:39 -04:00
|
|
|
if (currentSong != null)
|
2022-03-29 21:56:04 -04:00
|
|
|
{
|
2022-09-24 01:28:39 -04:00
|
|
|
if (generatedMusic && SongLoad.getSong()[Std.int(Conductor.currentStep / 16)] != null)
|
|
|
|
{
|
2022-09-24 15:02:10 -04:00
|
|
|
// cameraRightSide = SongLoad.getSong()[Std.int(Conductor.currentStep / 16)].mustHitSection;
|
2022-09-24 01:28:39 -04:00
|
|
|
}
|
2022-03-29 21:56:04 -04:00
|
|
|
|
2022-09-24 01:28:39 -04:00
|
|
|
if (SongLoad.getSong()[Math.floor(Conductor.currentStep / 16)] != null)
|
2020-10-31 21:11:14 -04:00
|
|
|
{
|
2022-09-24 01:28:39 -04:00
|
|
|
if (SongLoad.getSong()[Math.floor(Conductor.currentStep / 16)].changeBPM)
|
|
|
|
{
|
|
|
|
Conductor.forceBPM(SongLoad.getSong()[Math.floor(Conductor.currentStep / 16)].bpm);
|
|
|
|
FlxG.log.add('CHANGED BPM!');
|
|
|
|
}
|
2020-10-31 21:11:14 -04:00
|
|
|
}
|
2020-10-30 19:47:19 -04:00
|
|
|
}
|
|
|
|
|
2022-09-24 15:02:10 -04:00
|
|
|
// Manage the camera focus, if necessary.
|
|
|
|
// controlCamera();
|
|
|
|
|
2020-12-22 20:55:03 -05:00
|
|
|
// HARDCODING FOR MILF ZOOMS!
|
|
|
|
|
2021-03-26 21:28:04 -04:00
|
|
|
if (PreferencesMenu.getPref('camera-zoom'))
|
2020-11-02 01:46:37 -05:00
|
|
|
{
|
2022-09-24 01:28:39 -04:00
|
|
|
if (currentSong != null
|
|
|
|
&& currentSong.song.toLowerCase() == 'milf'
|
|
|
|
&& Conductor.currentBeat >= 168
|
|
|
|
&& Conductor.currentBeat < 200
|
|
|
|
&& camZooming
|
|
|
|
&& FlxG.camera.zoom < 1.35)
|
2021-03-26 21:28:04 -04:00
|
|
|
{
|
2021-08-21 20:45:03 -04:00
|
|
|
FlxG.camera.zoom += 0.015 * FlxCamera.defaultZoom;
|
2021-03-26 21:28:04 -04:00
|
|
|
camHUD.zoom += 0.03;
|
|
|
|
}
|
|
|
|
|
2022-09-24 01:28:39 -04:00
|
|
|
if (camZooming && FlxG.camera.zoom < (1.35 * FlxCamera.defaultZoom) && Conductor.currentBeat % 4 == 0)
|
2021-03-26 21:28:04 -04:00
|
|
|
{
|
2021-08-21 20:45:03 -04:00
|
|
|
FlxG.camera.zoom += 0.015 * FlxCamera.defaultZoom;
|
2021-03-26 21:28:04 -04:00
|
|
|
camHUD.zoom += 0.03;
|
|
|
|
}
|
2020-11-02 01:46:37 -05:00
|
|
|
}
|
2020-10-03 13:36:39 -04:00
|
|
|
|
2022-03-29 21:56:04 -04:00
|
|
|
// That combo counter that got spoiled that one time.
|
|
|
|
// Comes with NEAT visual and audio effects.
|
|
|
|
|
2022-04-29 23:46:41 -04:00
|
|
|
// bruh this var is bonkers i thot it was a function lmfaooo
|
|
|
|
|
2022-07-14 19:03:42 -04:00
|
|
|
// Break up into individual lines to aid debugging.
|
2022-07-06 21:49:42 -04:00
|
|
|
|
2022-09-24 01:28:39 -04:00
|
|
|
var shouldShowComboText:Bool = false;
|
|
|
|
if (currentSong != null)
|
|
|
|
{
|
|
|
|
shouldShowComboText = (Conductor.currentBeat % 8 == 7);
|
|
|
|
var daSection = SongLoad.getSong()[Std.int(Conductor.currentBeat / 16)];
|
|
|
|
shouldShowComboText = shouldShowComboText && (daSection != null && daSection.mustHitSection);
|
|
|
|
shouldShowComboText = shouldShowComboText && (combo > 5);
|
|
|
|
|
|
|
|
var daNextSection = SongLoad.getSong()[Std.int(Conductor.currentBeat / 16) + 1];
|
|
|
|
var isEndOfSong = SongLoad.getSong().length < Std.int(Conductor.currentBeat / 16);
|
|
|
|
shouldShowComboText = shouldShowComboText && (isEndOfSong || (daNextSection != null && !daNextSection.mustHitSection));
|
|
|
|
}
|
2022-03-29 21:56:04 -04:00
|
|
|
|
|
|
|
if (shouldShowComboText)
|
|
|
|
{
|
|
|
|
var animShit:ComboCounter = new ComboCounter(-100, 300, combo);
|
|
|
|
animShit.scrollFactor.set(0.6, 0.6);
|
|
|
|
add(animShit);
|
|
|
|
|
|
|
|
var frameShit:Float = (1 / 24) * 2; // equals 2 frames in the animation
|
|
|
|
|
|
|
|
new FlxTimer().start(((Conductor.crochet / 1000) * 1.25) - frameShit, function(tmr)
|
|
|
|
{
|
|
|
|
animShit.forceFinish();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
2022-03-13 14:36:03 -04:00
|
|
|
// Make the characters dance on the beat
|
|
|
|
danceOnBeat();
|
2021-07-15 18:22:15 -04:00
|
|
|
|
2022-03-29 21:56:04 -04:00
|
|
|
return true;
|
2022-03-13 14:36:03 -04:00
|
|
|
}
|
2021-07-15 18:22:15 -04:00
|
|
|
|
2022-03-13 14:36:03 -04:00
|
|
|
/**
|
|
|
|
* Handles characters dancing to the beat of the current song.
|
|
|
|
*
|
|
|
|
* TODO: Move some of this logic into `Bopper.hx`
|
|
|
|
*/
|
|
|
|
public function danceOnBeat()
|
|
|
|
{
|
|
|
|
if (currentStage == null)
|
|
|
|
return;
|
2021-07-14 20:32:09 -04:00
|
|
|
|
2022-07-06 21:49:42 -04:00
|
|
|
// TODO: Move this to a song event.
|
2022-09-24 01:28:39 -04:00
|
|
|
// if (Conductor.currentBeat % 8 == 7 && currentSong.song == 'Bopeebo')
|
|
|
|
// {
|
|
|
|
// currentStage.getBoyfriend().playAnimation('hey', true);
|
|
|
|
// }
|
2020-10-30 19:47:19 -04:00
|
|
|
|
2022-07-06 21:49:42 -04:00
|
|
|
// TODO: Move this to a song event.
|
2022-09-24 01:28:39 -04:00
|
|
|
if (Conductor.currentBeat % 16 == 15 // && currentSong.song == 'Tutorial'
|
2022-03-21 00:19:05 -04:00
|
|
|
&& currentStage.getDad().characterId == 'gf'
|
2022-09-24 01:28:39 -04:00
|
|
|
&& Conductor.currentBeat > 16
|
|
|
|
&& Conductor.currentBeat < 48)
|
2021-02-26 18:43:20 -05:00
|
|
|
{
|
2022-03-17 01:40:08 -04:00
|
|
|
currentStage.getBoyfriend().playAnimation('hey', true);
|
2022-03-21 00:19:05 -04:00
|
|
|
currentStage.getDad().playAnimation('cheer', true);
|
2020-10-30 19:47:19 -04:00
|
|
|
}
|
2020-10-03 02:50:15 -04:00
|
|
|
}
|
2020-12-10 18:23:53 -05:00
|
|
|
|
2022-03-13 14:36:03 -04:00
|
|
|
/**
|
|
|
|
* Constructs the strumlines for each player.
|
|
|
|
*/
|
2022-03-11 01:30:01 -05:00
|
|
|
function buildStrumlines():Void
|
|
|
|
{
|
|
|
|
var strumlineStyle:StrumlineStyle = NORMAL;
|
2021-08-27 18:08:01 -04:00
|
|
|
|
2022-03-11 01:30:01 -05:00
|
|
|
// TODO: Put this in the chart or something?
|
|
|
|
switch (currentStageId)
|
|
|
|
{
|
|
|
|
case 'school':
|
|
|
|
strumlineStyle = PIXEL;
|
|
|
|
case 'schoolEvil':
|
|
|
|
strumlineStyle = PIXEL;
|
|
|
|
}
|
2021-08-27 18:08:01 -04:00
|
|
|
|
2022-03-11 01:30:01 -05:00
|
|
|
var strumlineYPos = Strumline.getYPos();
|
2021-08-28 12:41:15 -04:00
|
|
|
|
2022-03-11 01:30:01 -05:00
|
|
|
playerStrumline = new Strumline(0, strumlineStyle, 4);
|
2022-03-14 20:48:45 -04:00
|
|
|
playerStrumline.x = 50 + FlxG.width / 2;
|
|
|
|
playerStrumline.y = strumlineYPos;
|
2022-03-13 14:36:03 -04:00
|
|
|
// Set the z-index so they don't appear in front of notes.
|
2022-03-11 01:30:01 -05:00
|
|
|
playerStrumline.zIndex = 100;
|
|
|
|
add(playerStrumline);
|
|
|
|
playerStrumline.cameras = [camHUD];
|
|
|
|
|
2022-03-14 20:48:45 -04:00
|
|
|
if (!isStoryMode)
|
|
|
|
{
|
|
|
|
playerStrumline.fadeInArrows();
|
|
|
|
}
|
|
|
|
|
2022-03-11 01:30:01 -05:00
|
|
|
enemyStrumline = new Strumline(1, strumlineStyle, 4);
|
2022-03-14 20:48:45 -04:00
|
|
|
enemyStrumline.x = 50;
|
|
|
|
enemyStrumline.y = strumlineYPos;
|
2022-03-13 14:36:03 -04:00
|
|
|
// Set the z-index so they don't appear in front of notes.
|
2022-03-11 01:30:01 -05:00
|
|
|
enemyStrumline.zIndex = 100;
|
|
|
|
add(enemyStrumline);
|
|
|
|
enemyStrumline.cameras = [camHUD];
|
|
|
|
|
2022-03-14 20:48:45 -04:00
|
|
|
if (!isStoryMode)
|
|
|
|
{
|
|
|
|
enemyStrumline.fadeInArrows();
|
|
|
|
}
|
|
|
|
|
2022-03-11 01:30:01 -05:00
|
|
|
this.refresh();
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function called before opening a new substate.
|
|
|
|
* @param subState The substate to open.
|
|
|
|
*/
|
|
|
|
override function openSubState(subState:FlxSubState)
|
|
|
|
{
|
|
|
|
// If there is a substate which requires the game to continue,
|
|
|
|
// then make this a condition.
|
|
|
|
var shouldPause = true;
|
|
|
|
|
|
|
|
if (shouldPause)
|
|
|
|
{
|
|
|
|
// Pause the music.
|
|
|
|
if (FlxG.sound.music != null)
|
|
|
|
{
|
|
|
|
FlxG.sound.music.pause();
|
|
|
|
if (vocals != null)
|
|
|
|
vocals.pause();
|
|
|
|
}
|
|
|
|
|
2022-03-13 14:36:03 -04:00
|
|
|
// Pause the countdown.
|
|
|
|
Countdown.pauseCountdown();
|
2022-03-11 01:30:01 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
super.openSubState(subState);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Function called before closing the current substate.
|
|
|
|
* @param subState
|
|
|
|
*/
|
|
|
|
override function closeSubState()
|
|
|
|
{
|
|
|
|
if (isGamePaused)
|
|
|
|
{
|
2022-03-29 21:56:04 -04:00
|
|
|
var event:ScriptEvent = new ScriptEvent(ScriptEvent.RESUME, true);
|
|
|
|
|
|
|
|
dispatchEvent(event);
|
|
|
|
|
|
|
|
if (event.eventCanceled)
|
|
|
|
return;
|
|
|
|
|
|
|
|
if (FlxG.sound.music != null && !startingSong && !isInCutscene)
|
2022-03-11 01:30:01 -05:00
|
|
|
resyncVocals();
|
|
|
|
|
2022-03-13 14:36:03 -04:00
|
|
|
// Resume the countdown.
|
|
|
|
Countdown.resumeCountdown();
|
2022-03-11 01:30:01 -05:00
|
|
|
|
|
|
|
#if discord_rpc
|
|
|
|
if (startTimer.finished)
|
|
|
|
DiscordClient.changePresence(detailsText, currentSong.song + " (" + storyDifficultyText + ")", iconRPC, true,
|
|
|
|
songLength - Conductor.songPosition);
|
|
|
|
else
|
|
|
|
DiscordClient.changePresence(detailsText, currentSong.song + " (" + storyDifficultyText + ")", iconRPC);
|
|
|
|
#end
|
|
|
|
}
|
|
|
|
|
|
|
|
super.closeSubState();
|
|
|
|
}
|
|
|
|
|
2022-03-13 14:36:03 -04:00
|
|
|
/**
|
|
|
|
* Prepares to start the countdown.
|
|
|
|
* Ends any running cutscenes, creates the strumlines, and starts the countdown.
|
|
|
|
*/
|
|
|
|
function startCountdown():Void
|
|
|
|
{
|
2022-03-29 21:56:04 -04:00
|
|
|
var result = Countdown.performCountdown(currentStageId.startsWith('school'));
|
|
|
|
if (!result)
|
|
|
|
return;
|
|
|
|
|
2022-03-13 14:36:03 -04:00
|
|
|
isInCutscene = false;
|
|
|
|
camHUD.visible = true;
|
|
|
|
talking = false;
|
|
|
|
|
|
|
|
buildStrumlines();
|
|
|
|
}
|
|
|
|
|
|
|
|
override function dispatchEvent(event:ScriptEvent):Void
|
|
|
|
{
|
2022-03-21 00:19:05 -04:00
|
|
|
// ORDER: Module, Stage, Character, Song, Note
|
|
|
|
// Modules should get the first chance to cancel the event.
|
|
|
|
|
|
|
|
// super.dispatchEvent(event) dispatches event to module scripts.
|
|
|
|
super.dispatchEvent(event);
|
|
|
|
|
|
|
|
// Dispatch event to stage script.
|
2022-03-13 14:36:03 -04:00
|
|
|
ScriptEventDispatcher.callEvent(currentStage, event);
|
|
|
|
|
2022-03-21 00:19:05 -04:00
|
|
|
// Dispatch event to character script(s).
|
|
|
|
if (currentStage != null)
|
|
|
|
currentStage.dispatchToCharacters(event);
|
2022-03-13 14:36:03 -04:00
|
|
|
|
2022-03-21 00:19:05 -04:00
|
|
|
// TODO: Dispatch event to song script
|
2022-03-13 14:36:03 -04:00
|
|
|
}
|
|
|
|
|
2022-03-11 01:30:01 -05:00
|
|
|
/**
|
|
|
|
* Updates the position and contents of the score display.
|
|
|
|
*/
|
|
|
|
function updateScoreText():Void
|
|
|
|
{
|
|
|
|
// TODO: Add functionality for modules to update the score text.
|
|
|
|
scoreText.text = "Score:" + songScore;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Updates the values of the health bar.
|
|
|
|
*/
|
|
|
|
function updateHealthBar():Void
|
|
|
|
{
|
|
|
|
healthLerp = FlxMath.lerp(healthLerp, health, 0.15);
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Resets the camera's zoom level and focus point.
|
|
|
|
*/
|
2022-04-29 23:46:41 -04:00
|
|
|
public function resetCamera():Void
|
2022-03-11 01:30:01 -05:00
|
|
|
{
|
|
|
|
FlxG.camera.follow(cameraFollowPoint, LOCKON, 0.04);
|
2022-04-29 23:46:41 -04:00
|
|
|
FlxG.camera.targetOffset.set();
|
2022-03-13 14:36:03 -04:00
|
|
|
FlxG.camera.zoom = defaultCameraZoom;
|
2022-03-11 01:30:01 -05:00
|
|
|
FlxG.camera.focusOn(cameraFollowPoint.getPosition());
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Perform necessary cleanup before leaving the PlayState.
|
|
|
|
*/
|
|
|
|
function performCleanup()
|
|
|
|
{
|
|
|
|
// Uncache the song.
|
2022-09-22 06:34:03 -04:00
|
|
|
if (currentChart != null)
|
|
|
|
{
|
|
|
|
}
|
2022-09-24 01:28:39 -04:00
|
|
|
else if (currentSong != null)
|
2022-09-22 06:34:03 -04:00
|
|
|
{
|
|
|
|
openfl.utils.Assets.cache.clear(Paths.inst(currentSong.song));
|
|
|
|
openfl.utils.Assets.cache.clear(Paths.voices(currentSong.song));
|
|
|
|
}
|
2022-03-11 01:30:01 -05:00
|
|
|
|
|
|
|
// Remove reference to stage and remove sprites from it to save memory.
|
|
|
|
if (currentStage != null)
|
|
|
|
{
|
|
|
|
remove(currentStage);
|
|
|
|
currentStage.kill();
|
2022-03-14 20:48:45 -04:00
|
|
|
dispatchEvent(new ScriptEvent(ScriptEvent.DESTROY, false));
|
2022-03-11 01:30:01 -05:00
|
|
|
currentStage = null;
|
|
|
|
}
|
|
|
|
|
2022-07-22 22:25:19 -04:00
|
|
|
GameOverSubstate.reset();
|
|
|
|
|
2022-03-11 01:30:01 -05:00
|
|
|
// Clear the static reference to this state.
|
|
|
|
instance = null;
|
|
|
|
}
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This function is called whenever Flixel switches switching to a new FlxState.
|
2022-03-21 00:19:05 -04:00
|
|
|
* @return Whether to actually switch to the new state.
|
2022-03-11 01:30:01 -05:00
|
|
|
*/
|
|
|
|
override function switchTo(nextState:FlxState):Bool
|
|
|
|
{
|
2022-03-21 00:19:05 -04:00
|
|
|
var result = super.switchTo(nextState);
|
|
|
|
|
|
|
|
if (result)
|
|
|
|
{
|
|
|
|
performCleanup();
|
|
|
|
}
|
2022-03-11 01:30:01 -05:00
|
|
|
|
2022-03-21 00:19:05 -04:00
|
|
|
return result;
|
2022-03-11 01:30:01 -05:00
|
|
|
}
|
2021-08-27 18:08:01 -04:00
|
|
|
}
|