void OnExitState(NotesGameStates stateExit) { if (stateMachineDebug) { Debug.Log("On Exit state " + stateExit); } switch (stateExit) { case NotesGameStates.Idle: { } break; case NotesGameStates.Start: { } break; case NotesGameStates.Intro: { } break; case NotesGameStates.MoveSelect: { } break; case NotesGameStates.Playing: { gameManager.StopMoveEffect(MoveEffects.CrazyStand); //gameManager.StopMoveEffect(MoveEffects.Rocky); //gameManager.StopMoveEffect(MoveEffects.Solo); } break; case NotesGameStates.Hyped: { } break; case NotesGameStates.EnemyIntro: { gameManager.StopMoveEffect(MoveEffects.Stomp); } break; case NotesGameStates.Enemy: { gameManager.StopMoveEffect(MoveEffects.Rhythm); } break; case NotesGameStates.EndSet: { } break; } }
void OnProcessState(NotesGameStates stateProcess) { switch (stateProcess) { case NotesGameStates.Idle: { } break; case NotesGameStates.Start: { } break; case NotesGameStates.Intro: { } break; case NotesGameStates.MoveSelect: { } break; case NotesGameStates.Playing: { // Crazy Stand Code if (gameManager.movesActive[MoveEffects.CrazyStand]) { if (musicPlaying && canCallCrazyStand) { gameManager.AnimateEffectAction(MoveEffects.CrazyStand); StartCoroutine(ResetCallCrazyStand()); CallNoteGenerator(UnityEngine.Random.Range(0, 3)); canCallCrazyStand = false; } } // Switch state to enemy intro after song is finished and all notes are collected if (songFinishRecieved && unusedNotePool.childCount == encounterConstants.notePoolSize) { // Should only be called once songFinishRecieved = false; SwitchState(NotesGameStates.EnemyIntro); } } break; case NotesGameStates.Hyped: if (songFinishRecieved && unusedNotePool.childCount == encounterConstants.notePoolSize) { // Should only be called once songFinishRecieved = false; OnHypeComplete(); } break; case NotesGameStates.EnemyIntro: { } break; case NotesGameStates.Enemy: { // Switch state to enemy intro after song is finished and all notes are collected if (songFinishRecieved && unusedNotePool.childCount == encounterConstants.notePoolSize) { EnemySongComplete(); } } break; case NotesGameStates.EndSet: { } break; } }
// Check entry to stateEnter void OnEnterState(NotesGameStates stateEnter) { if (stateMachineDebug) { Debug.Log("On Enter state " + stateEnter); } switch (stateEnter) { case NotesGameStates.Idle: { } break; case NotesGameStates.Start: { gameManager.ShowGamePanelCount(gameManager.currSet, currSong, false, false); currSong = 0; OnStartGame(() => { SwitchState(NotesGameStates.Intro); }); // Start Game Function Fade In UI Here, call from EncounterGameManager? } break; case NotesGameStates.Intro: { mainUI.IntroUI(hypeMeterUI.canHype, () => { // Call function to fade UI and call next state gameManager.MoveCameraToPlayer(); OnIntro(() => { isTurnVisible = true; // OnIntroComplete }); }); } break; case NotesGameStates.MoveSelect: { // Call function to fade UI and call next state mainUI.MoveSelectUI(() => { gameManager.MoveCameraToFocus(playerEntities.stageEntities[currentPlayer]); OnMoveSelect(() => { gameManager.OnNotesStartComplete(); // On Move Select Complete }); }); } break; case NotesGameStates.Playing: { songFinishRecieved = false; musicPlaying = false; mainUI.FadeTextDescription(() => { OnPlay(() => { // Reset song finished SelectSongAndPlay(() => { OnPlayEnd(() => { songFinishRecieved = true; }); }); }); }); } break; case NotesGameStates.Hyped: { songFinishRecieved = false; musicPlaying = false; mainUI.FadeTextDescription(() => { // Start Hyped Function OnHyped(() => { // Play Song 1 SelectHypedSongAndPlay(() => { // On Complete Play Song 2 SelectHypedSongAndPlay(() => { // Set Song Finished OnPlayEnd(() => { songFinishRecieved = true; }); }); }); }); }); } break; case NotesGameStates.EnemyIntro: { gameManager.MoveCameraToEnemy(); mainUI.EnemyIntroUI(() => { OnEnemyIntro(() => { if (gameManager.movesActive[MoveEffects.Stomp]) { gameManager.AnimateEffectAction(MoveEffects.Stomp); MakeEnemyMissTurn(); } else { SwitchState(NotesGameStates.Enemy); } }); }); } break; case NotesGameStates.Enemy: { mainUI.FadeTextDescription(() => { songFinishRecieved = false; //isTurnVisible = true; ////TransitionStageElements(); SelectEnemySongAndPlay(() => { OnPlayEnd(() => { songFinishRecieved = true; }); }); }); // current player calls here } break; case NotesGameStates.EndSet: { ReducePlayerMoves(); ClearUI(() => { SwitchState(NotesGameStates.Idle); gameManager.OnSetComplete(); //gameManager switch state }); } break; } }
void SwitchState(NotesGameStates newState) { bool switchAllowed = false; // Do check for if switch is possible switch (currentState) { case NotesGameStates.Idle: { switchAllowed = newState == NotesGameStates.Start; } break; case NotesGameStates.Start: { switchAllowed = newState == NotesGameStates.Intro; } break; case NotesGameStates.Intro: { switchAllowed = newState == NotesGameStates.MoveSelect || newState == NotesGameStates.Hyped; } break; case NotesGameStates.MoveSelect: { switchAllowed = newState == NotesGameStates.Playing || newState == NotesGameStates.Intro; } break; case NotesGameStates.Hyped: { switchAllowed = newState == NotesGameStates.Intro; } break; case NotesGameStates.Playing: { switchAllowed = newState == NotesGameStates.EnemyIntro; } break; case NotesGameStates.EnemyIntro: { switchAllowed = newState == NotesGameStates.Enemy || newState == NotesGameStates.Intro || newState == NotesGameStates.EndSet; } break; case NotesGameStates.Enemy: { switchAllowed = newState == NotesGameStates.Intro || newState == NotesGameStates.EndSet; } break; case NotesGameStates.EndSet: { switchAllowed = newState == NotesGameStates.Idle; } break; } if (stateMachineDebug) { Debug.Log("Trying to switch to:" + newState + " Allowed:" + switchAllowed); } if (switchAllowed) { OnExitState(currentState); currentState = newState; OnEnterState(newState); } }