/// <summary> /// This function creates a screen object and inserts it in an internal /// list and also inserts it in an interface list for external use /// </summary> public void CreateScreens() { fadeArea = new Rectangle(0, 0, Globals.ScreenWidth, Globals.ScreenHeight); selectedScreen = EScreen.MainScreen; Screen screen = new MainScreen(this); screens.Add(screen); iScreens.Add((IScreen)screen); screen = new GameScreen(this); screens.Add(screen); iScreens.Add((IScreen)screen); screen = new CreditsScreen(this); screens.Add(screen); iScreens.Add((IScreen)screen); screen = new SetupScreen(this); screens.Add(screen); iScreens.Add((IScreen)screen); screen = new MenuScreen(this); screens.Add(screen); iScreens.Add((IScreen)screen); screen = new WinScreen(this); screens.Add(screen); iScreens.Add((IScreen)screen); screen = new DialogScreen(this, ExitGame, LeaveDialog); iDialogScreens.Add((IScreen)screen); }
private bool CreateMouseWheelEvents(EScreen screen) { if (!mMouseWheelListener.ContainsKey(screen)) { return(true); } var giveThrough = true; if (mCurrentMouseState.ScrollWheelValue < mPreviousMouseState.ScrollWheelValue) // mouse wheel has been scrolled downwards -> create event 'ScrollDown' { foreach (var mouseWheelListener in mMouseWheelListener[screen]) { giveThrough = giveThrough && mouseWheelListener.MouseWheelValueChanged(EMouseAction.ScrollDown); } } else if (mCurrentMouseState.ScrollWheelValue > mPreviousMouseState.ScrollWheelValue) // mouse wheel has been scrolled upwards -> create event 'ScrollUp' { foreach (var mouseWheelListener in mMouseWheelListener[screen]) { giveThrough = giveThrough && mouseWheelListener.MouseWheelValueChanged(EMouseAction.ScrollUp); } } return(giveThrough); }
/// <summary> /// STANDARD CONSTRUCTOR - window with standard border / background / padding /// </summary> /// <param name="windowName">window title</param> /// <param name="position">top left corner of the window</param> /// <param name="size">window size</param> /// <param name="minimizable">window minimizable</param> /// <param name="spriteFont">title font</param> /// <param name="director">basic director</param> /// <param name="screen">the screen to place the window on</param> public WindowObject( string windowName, Vector2 position, Vector2 size, bool minimizable, SpriteFont spriteFont, Director director, EScreen screen = EScreen.UserInterfaceScreen) { // use parameter-variables WindowName = windowName; Position = position; Size = size; mColorBorder = new Color(0.68f, 0.933f, 0.933f, .8f); mColorFill = new Color(0.27f, 0.5f, 0.7f, 0.8f); mBorderPadding = 10f; mObjectPadding = 10f; mMinimizable = minimizable; mSpriteFont = spriteFont; // screen size - needed for input management mCurrentScreenWidth = director.GetGraphicsDeviceManager.PreferredBackBufferWidth; mCurrentScreenHeight = director.GetGraphicsDeviceManager.PreferredBackBufferHeight; Initialization(); mBackgroundGiven = true; Screen = screen; director.GetInputManager.FlagForAddition(this, EClickType.InBoundsOnly, EClickType.InBoundsOnly); director.GetInputManager.FlagForAddition(this); director.GetInputManager.AddMousePositionListener(this); }
public void TransitionTo(EScreen originScreen, EScreen targetScreen, GameTime gameTime) { mTargetScreen = targetScreen; mTransitionDuration = 350; mTransitionStartTime = gameTime.TotalGameTime.TotalMilliseconds; TransitionRunning = true; }
public void TransitionTo(EScreen originScreen, EScreen targetScreen, GameTime gameTime) { mTargetScreen = targetScreen; TransitionRunning = true; mTransitionStartTime = gameTime.TotalGameTime.TotalMilliseconds; switch (targetScreen) { case EScreen.SaveGameScreen: break; case EScreen.StatisticsScreen: break; case EScreen.GamePauseScreen: // means transitioning into this screen // simply pull opacity from 0 to 1.0 mTransitionDuration = 350d; mMenuOpacity = 0f; mMenuBoxSize = new Vector2(350, 400); mMenuBoxPosition = new Vector2(mScreenResolution.X / 2 - 175, mScreenResolution.Y / 2 - 200); mSelectorPosition = new Vector2(mMenuBoxPosition.X + 22, mButtonTopPadding + mButtonVerticalCenter); break; default: throw new ArgumentOutOfRangeException(nameof(originScreen), originScreen, null); } }
public void UpdateScreen(EScreen screen) { if (!fading) { iScreens[(int)screen].Update(cursor); } }
/// <summary> /// Unload Child UI Screen prefabs from scene /// </summary> /// <param name="screen">Screen.</param> private void UnloadScreen(EScreen screen) { Transform page = null; switch (screen) { case EScreen.Title: page = transform.FindChild("TitleScreen"); break; case EScreen.NameEntry: page = transform.FindChild("NameEntryScreen"); break; case EScreen.SelectGame: page = transform.FindChild("SelectGameScreen"); break; case EScreen.Game: page = transform.FindChild("Game"); break; } if (page != null) { Destroy(page.gameObject); } }
/// <summary> /// Set current screen /// Load UI Screen prefab from Resources/UIScreens. /// Instantiate screens and set UI as parent /// </summary> /// <param name="screen">Screen.</param> private void loadScreen(EScreen screen) { CurrScreen = screen; Object go = null; GameObject page = null; switch (screen) { case EScreen.Title: // Not required break; case EScreen.NameEntry: go = Resources.Load <GameObject> ("UIScreens/NameEntryScreen"); break; case EScreen.Game: go = Resources.Load <GameObject> ("UIScreens/Game"); break; case EScreen.SelectGame: go = Resources.Load <GameObject> ("UIScreens/SelectGameScreen"); break; } // Set UI(Canvas) as parent if (go != null) { page = Instantiate(go) as GameObject; page.transform.SetParent(transform, false); page.name = page.name.Replace("(Clone)", ""); } }
public static IMenu GetScreen(EScreen screen) { if (screen == EScreen.Unknown || screen == EScreen.CountEntry) { throw new ArgumentException("Invalid screen: " + screen); } return(_Screens[(int)screen]); }
public void ResumeScreen() { if (lastScreen == EScreen.CreditsScreen) { selectedScreen = prevLastScreen; } else { selectedScreen = lastScreen; } }
public void ChangeScreen(EScreen screen) { CurScreen = screen; HideAllScreen(); foreach(MonoBehaviour agent in ScreenAgentMap[screen]) { agent.gameObject.SetActive(true); if(screen== EScreen.Search && UISearchPanel.btnFight) UISearchPanel.btnFight.gameObject.SetActive(false); } }
public void TransitionTo(EScreen originScreen, EScreen targetScreen, GameTime gameTime) { if (originScreen == EScreen.MainMenuScreen) { mMenuOpacity = 0f; } mTargetScreen = targetScreen; mTransitionDuration = 300; mTransitionStartTime = gameTime.TotalGameTime.TotalMilliseconds; mMenuBoxPosition = new Vector2(mScreenResolution.X / 2 - 283, mScreenResolution.Y / 4 - 120); mMenuBoxSize = new Vector2(566, 634); TransitionRunning = true; }
private static string ScreenTypeToString(EScreen screenType) { if (screenType == EScreen.MainMenu) { return("MenuScreen"); } else if (screenType == EScreen.Game) { return("GameScreen"); } throw new Exception("Unknow screen type"); }
public void ChangeScreen(EScreen screen) { HideAllScreen(); foreach (MonoBehaviour agent in ScreenAgentMap[screen]) { agent.gameObject.SetActive(true); if (screen == EScreen.Search && UISearchPanel.btnFight) { UISearchPanel.btnFight.gameObject.SetActive(false); } } }
public virtual void OnHide() { EScreen check = CBase.Graphics.GetNextScreenType(); if (CBase.Graphics.GetNextScreenType() == EScreen.Sing) { _ResetPreview(false); } else if (CBase.Graphics.GetNextScreenType() != EScreen.Names || CBase.Config.GetBackgroundMusicStatus() == EBackgroundMusicOffOn.TR_CONFIG_OFF) { _ResetPreview(); } }
public void TransitionTo(EScreen originScreen, EScreen targetScreen, GameTime gameTime) { if (originScreen == EScreen.GamePauseScreen) { mMenuOpacity = 0f; } mMenuBoxPosition = new Vector2(mScreenResolution.X / 2 - 200, mScreenResolution.Y / 2 - 225); mMenuBoxSize = new Vector2(400, 450); mTargetScreen = targetScreen; mTransitionDuration = 350f; mTransitionStartTime = gameTime.TotalGameTime.TotalMilliseconds; TransitionRunning = true; }
/// <summary> /// Creates an instance of the GamePauseManagerScreen class /// </summary> /// <param name="screenResolution">Screen resolution of the game.</param> /// <param name="screenManager">Stack screen manager of the game.</param> /// <param name="director">Director of the game.</param> public GamePauseManagerScreen(Vector2 screenResolution, IScreenManager screenManager, Director director) { mScreenManager = screenManager; mDirector = director; mScreenResolution = screenResolution; Initialize(screenResolution, director); mScreenState = EScreen.GamePauseScreen; sPressed = "None"; mTransitionState = 0; }
public StructurePlacer(EStructureType platformType, EPlacementType placementType, EScreen screen, Camera camera, ref Director director, ref Map.Map map, float x = 0, float y = 0, ResourceMap resourceMap = null) { mUnregister = false; mCamera = camera; Screen = screen; mDirector = director; mPlatformType = platformType; // need the structure map to make sure platforms arent placed on collidable objects mMap = map; mDirector.GetInputManager.FlagForAddition(this, EClickType.Both, EClickType.Both); mDirector.GetInputManager.AddMousePositionListener(this); mCurrentState = new State3(); director.GetUserInterfaceController.BuildingProcessStarted(platformType); // for further information as to why which states refer to the documentation for mCurrentState switch (placementType) { case EPlacementType.RoadMouseFollowAndRoad: mIsRoadPlacement = true; break; case EPlacementType.PlatformMouseFollowAndRoad: break; } if (mIsRoadPlacement) { return; } mPlatform = PlatformFactory.Get(platformType, ref director, x, y, resourceMap); mPlatform.SetLayer(LayerConstants.PlatformAboveFowLayer); UpdateBounds(); // makes a sound once when platform is placed mPlatformCreateSoundId = mDirector.GetSoundManager.CreateSoundInstance("PlatformCreate", mPlatform.Center.X, mPlatform.Center.Y, .24f, .01f, true, false, SoundClass.Effect); }
/// <summary> /// Creates an instance of the MainMenuManagerScreen class /// </summary> /// <param name="screenResolution">Screen resolution of the game.</param> /// <param name="screenManager">Stack screen manager of the game.</param> /// <param name="director">The director of the game.</param> /// <param name="showSplash">Defines if the splash screen should be shown /// (used when going back to main menu from within the game where showing the /// splash screen would not be necessary).</param> /// <param name="game">Used to pass on to the options screen to change game settings</param> public MainMenuManagerScreen(Vector2 screenResolution, IScreenManager screenManager, ref Director director, bool showSplash, Game1 game) { mScreenManager = screenManager; mGame = game; mDirector = director; Initialize(screenResolution, false, showSplash, game); mScreenState = showSplash ? EScreen.SplashScreen : EScreen.MainMenuScreen; sPressed = "None"; sResolutionChanged = false; mTransitionState = 0; }
public void TransitionTo(EScreen originScreen, EScreen targetScreen, GameTime gameTime) { if (originScreen == EScreen.GamePauseScreen) { mMenuOpacity = 0f; } if (originScreen == EScreen.SaveGameScreen) { mMenuOpacity = 1f; } mTargetScreen = targetScreen; mTransitionDuration = 350f; mTransitionStartTime = gameTime.TotalGameTime.TotalMilliseconds; TransitionRunning = true; }
public void TransitionTo(EScreen originScreen, EScreen targetScreen, GameTime gameTime) { if (originScreen == EScreen.MainMenuScreen) { mMenuOpacity = 0f; } else if (originScreen == EScreen.OptionsScreen) { mDirector.SaveConfig(); } mMenuBoxPosition = new Vector2(mScreenResolution.X / 2 - 306, mScreenResolution.Y / 4); mMenuBoxSize = new Vector2(612, 420); mTargetScreen = targetScreen; mTransitionDuration = 350f; mTransitionStartTime = gameTime.TotalGameTime.TotalMilliseconds; TransitionRunning = true; }
/// <summary> /// Automates the process of removing and adding new screens /// that are part of the PauseMenu to the stack screen manager. /// </summary> /// <param name="targetEScreen"></param> /// <param name="originScreen"></param> /// <param name="targetScreen"></param> /// <param name="gameTime">Used for animations</param> private void SwitchScreen(EScreen targetEScreen, ITransitionableMenu originScreen, ITransitionableMenu targetScreen, GameTime gameTime) { switch (mTransitionState) { case 0: // start the necessary transitions originScreen.TransitionTo(mScreenState, targetEScreen, gameTime); mTransitionState = 1; break; case 1: // Wait for the origin screen to finish transitioning out if (!originScreen.TransitionRunning) { // once it is done transitioning out, remove it and add the target screen mScreenManager.RemoveScreen(); mScreenManager.AddScreen(targetScreen); // then start transitioning the target screen targetScreen.TransitionTo(mScreenState, targetEScreen, gameTime); mTransitionState = 2; } break; case 2: // now wait for the target screen to finish transitioning in if (!targetScreen.TransitionRunning) { // once it is done transitioning in, change the states of everyone to reflect the new state mScreenState = targetEScreen; sPressed = "None"; mTransitionState = 0; } break; default: throw new ArgumentOutOfRangeException(); } }
public void GoToScreen(EScreen screenType, bool showTransition = true) { if (showTransition) { ScreenTransitionManager.ShowTransition(); StartCoroutine(LoadScene(screenType)); } else { SceneManager.LoadScene(ScreenTypeToString(screenType)); } if (CurrentScreen != EScreen.None) { _previousScenes.Push(CurrentScreen); } CurrentScreen = screenType; }
public void TransitionTo(EScreen originScreen, EScreen targetScreen, GameTime gameTime) { if (!TransitionRunning) { switch (targetScreen) { case EScreen.MainMenuScreen: TransitionRunning = true; mMTransitionStep = 1; mMTransitionStartTime = gameTime.TotalGameTime.TotalMilliseconds; mMTransitionDuration = 500d; break; default: throw new ArgumentOutOfRangeException(nameof(originScreen), originScreen, "Tried going from splash screen to somewhere inaccessible."); } } }
public static GameScreen GetScreen(EScreen aScreen) { GameScreenManager gameScreenManager = GameScreenManager.Instance; IServiceProvider serviceProvider = gameScreenManager.Service; GraphicsDeviceManager graphics = gameScreenManager.Graphics; switch (aScreen) { case EScreen.SplashScreen: return(new cIntro(serviceProvider, graphics)); case EScreen.MainTitle: return(new MainTitle(serviceProvider, graphics)); case EScreen.MainMenu: return(new cMainMenu(serviceProvider, graphics)); } return(null); }
public void TransitionTo(EScreen originScreen, EScreen targetScreen, GameTime gameTime) { mOriginScreen = originScreen; mTargetScreen = targetScreen; TransitionRunning = true; mTransitionStartTime = gameTime.TotalGameTime.TotalMilliseconds; if (originScreen != EScreen.SplashScreen) { mWindowOpacity = 1f; } switch (targetScreen) { case EScreen.AchievementsScreen: break; case EScreen.GameModeSelectScreen: break; case EScreen.LoadSelectScreen: break; case EScreen.MainMenuScreen: // means transitioning into this screen // simply pull opacity from 0 to 1.0 mTransitionDuration = 350d; mMenuOpacity = 0f; mMenuBoxSize = new Vector2(408, 420); mMenuBoxPosition = new Vector2(mScreenResolution.X / 2 - 204, mScreenResolution.Y / 4); mSelectorPosition = new Vector2(mMenuBoxPosition.X + 22, mButtonTopPadding + mButtonVerticalCenter); break; case EScreen.OptionsScreen: // grow break; default: throw new ArgumentOutOfRangeException(nameof(originScreen), originScreen, null); } }
/// <summary> /// +BACKGROUND CONSTRUCTOR - window with given border / background / padding /// </summary> /// <param name="windowName">window title</param> /// <param name="position">top left corner of the window</param> /// <param name="size">window size</param> /// <param name="colorBorder">color windowBorder</param> /// <param name="colorFill">color windowBackground</param> /// <param name="borderPadding">gap between item & border</param> /// <param name="objectPadding">gap between items</param> /// <param name="minimizable">window minimizable</param> /// <param name="spriteFont">title font</param> /// <param name="director">basic director</param> /// <param name="screen">the screen to place the window on</param> public WindowObject( string windowName, Vector2 position, Vector2 size, Color colorBorder, Color colorFill, float borderPadding, float objectPadding, bool minimizable, SpriteFont spriteFont, Director director, EScreen screen = EScreen.UserInterfaceScreen) { // set parameter-variables WindowName = windowName; Position = position; Size = size; mColorBorder = colorBorder; mColorFill = colorFill; mBorderPadding = borderPadding; mObjectPadding = objectPadding; mMinimizable = minimizable; mSpriteFont = spriteFont; // screen size - needed for input management mCurrentScreenWidth = director.GetGraphicsDeviceManager.PreferredBackBufferWidth; mCurrentScreenHeight = director.GetGraphicsDeviceManager.PreferredBackBufferHeight; Screen = screen; Initialization(); // set start values mBackgroundGiven = true; director.GetInputManager.FlagForAddition(this, EClickType.InBoundsOnly, EClickType.InBoundsOnly); director.GetInputManager.FlagForAddition(this); director.GetInputManager.AddMousePositionListener(this); }
/// <summary> /// Changes the HoloProjectionTexture width based on the screen being shown and /// starts the animation for the screen. /// </summary> /// <param name="originSscreen">Choose the screen to be overlayed on top /// of the menu background</param> /// <param name="targetScreen"></param> /// <param name="gameTime">gameTime used to calculate animations</param> public void TransitionTo(EScreen originSscreen, EScreen targetScreen, GameTime gameTime) { mTargetScreen = targetScreen; switch (targetScreen) { case EScreen.AchievementsScreen: mTransitionTargetValue = 5f; mTransitionDuration = 300; break; case EScreen.GameModeSelectScreen: mTransitionTargetValue = 2f; mTransitionDuration = 300; break; case EScreen.LoadSelectScreen: mTransitionTargetValue = 2f; mTransitionDuration = 300; break; case EScreen.MainMenuScreen: mTransitionTargetValue = 2f; mTransitionDuration = originSscreen == EScreen.SplashScreen ? 500 : 300; break; case EScreen.OptionsScreen: mTransitionTargetValue = 4f; mTransitionDuration = 300; break; default: throw new ArgumentOutOfRangeException(); } // SetHoloProjectionScaling(mHoloProjectionWidthScaling); TransitionRunning = true; mTransitionStartTime = gameTime.TotalGameTime.TotalMilliseconds; mTransitionInitialValue = mHoloProjectionWidthScaling; }
public IMenu GetScreen(EScreen screen) { return(CGraphics.GetScreen(screen)); }
public void FadeTo(EScreen nextScreen) { CGraphics.FadeTo(nextScreen); }
public static void FadeTo(EScreen screen) { FadeTo(GetScreen(screen)); }
public void ScheduleSwitch(EAnimMode animMode, EScreen nextScreen) { stage = 1; sharedTimer = 0; this.nextScreen = nextScreen; foreach(GameObject c in Clouds) { c.GetComponent<Animator>().Play(c.name + "_in"); } }