private void OnNewStateEnteredEvent(ApplicationState applicationState) { for (int i = 0; i < uiScreens.Length; i++) { UIScreen uiScreen = uiScreens[i]; if (uiScreen.ApplicationStateType != applicationState.GetType()) { continue; } // Don't do anything if current ui screen is the same as new ui screen if (currentScreen == uiScreen) { return; } // Hide the current screen, if any, and show the new screen currentScreen?.Hide(); uiScreen.Show(); currentScreen = uiScreen; return; } // It's ok if there's no ui screen for a specific state, but at least warn us about this Debug.LogWarning($"No UIScreen found for ApplicationState {applicationState.GetType().Name}"); }
private SinglePlayerInputs GetInputsDispatchState(ApplicationState applicationState) { if (applicationState is GameplayState) { return(GetInputs(applicationState as GameplayState)); } if (applicationState is MainMenu) { return(GetInputs(applicationState as MainMenu)); } if (applicationState is CharacterSelectScreen) { return(GetInputs(applicationState as CharacterSelectScreen)); } throw new NotSupportedException("application state " + applicationState.GetType().ToString() + " not supported by this AI yet"); }