public Menu(TornadoGame game) { Game = game; SelectedItem = MenuItems.NewGame; SelectedLevel = 0; State = MenuStates.Menu; Paused = false; Background = Game.Content.Load<Texture2D>(@"Graphics\Menu\cat5fade"); MenuItemTextures = new Texture2D[4]; MenuItemTextures[(int)MenuItems.Resume] = Game.Content.Load<Texture2D>(@"Graphics\Menu\resume"); MenuItemTextures[(int)MenuItems.NewGame] = Game.Content.Load<Texture2D>(@"Graphics\Menu\new"); MenuItemTextures[(int)MenuItems.LoadLevel] = Game.Content.Load<Texture2D>(@"Graphics\Menu\load"); MenuItemTextures[(int)MenuItems.Info] = Game.Content.Load<Texture2D>(@"Graphics\Menu\info"); EscTexture = Game.Content.Load<Texture2D>(@"Graphics\Menu\esc"); TitleTexture = game.Content.Load<Texture2D>(@"Graphics\Menu\title"); CursorFrame = 0; CursorTimeSinceLastFrame = 0.0f; CursorTexture = new Texture2D[4]; for (int i = 0; i < CursorTexture.Length; i++) CursorTexture[i] = Game.Content.Load<Texture2D>(@"Graphics\Menu\tornado" + (i + 1)); InfoFont = Game.Content.Load<SpriteFont>(@"Graphics\Font\CourierNew"); LevelFont = Game.Content.Load<SpriteFont>(@"Graphics\Font\CourierNew"); Music = new MusicTrack(Game.Content, 0.5f); Music.Load(0, "Music\\category5"); Music.Play(0, true); }
/// <summary> /// Used when the player exits the buy menu. /// </summary> public void OnMainMenu() { currentstate = MenuStates.Main; if (teleportPoint != null) { Destroy(teleportPoint); teleportPoint = null; Money.amount += 5; } else if (boughtTower != null) { Destroy(boughtTower); boughtTower = null; Money.amount += 30; } else if (Wall != null) { Destroy(Wall); Wall = null; Money.amount += 5; } else if (slowField != null) { Destroy(slowField); slowField = null; Money.amount += 20; } }
void Start() { player = FindObjectOfType <PlayerController>(); currentState = MenuStates.Playing; audioManager = AudioManager.instance; }
public void OnClickCredits() { currentState = MenuStates.Credits; //ES.SetSelectedGameObject(firstSelectedInCredits); storeSelected = firstSelectedInCredits; ES.SetSelectedGameObject(firstSelectedInCredits); }
// Use this for initialization void Start() { currentState = MenuStates.Main; storeSelected = ES.firstSelectedGameObject; //continueGameBtn.enabled = false; if (PlayerPrefs.GetInt(Constants.LEVELCLEARED, 0) == 0) { Debug.Log("Disable continue btn " + PlayerPrefs.GetInt(Constants.LEVELCLEARED)); continueGameBtn.GetComponent <Button>().interactable = false; } else { Debug.Log("Enable continue btn"); continueGameBtn.GetComponent <Button>().interactable = true; } player1Control = PlayerPrefs.GetInt("Player1", 1); //1 is keyboard1, 2 is keyboard2, 3 is controller1, 4 is controller2 player2Control = PlayerPrefs.GetInt("Player2", 2); SetPlayer1Radio(player1Control); SetPlayer2Radio(player2Control); //SpriteState spriteState = new SpriteState(); //spriteState = continueGameBtn.GetComponent<Button>().spriteState; //spriteState.disabledSprite = testImage; //continueGameBtn.GetComponent<Button>().spriteState = spriteState; masterVolumePercent = PlayerPrefs.GetFloat("master vol", masterVolumePercent); sfxVolumePercent = PlayerPrefs.GetFloat("sfx vol", sfxVolumePercent); musicVolumePercent = PlayerPrefs.GetFloat("music vol", musicVolumePercent); masterSlider.GetComponent <Slider>().value = masterVolumePercent; musicSlider.GetComponent <Slider>().value = musicVolumePercent; fxSlider.GetComponent <Slider>().value = sfxVolumePercent; }
void Start() { currentMenuState = MenuStates.Main; currentARState = ARStates.Vehicle1; placeRemove = GameObject.Find("ARCanvas/PlaceRemove/PlaceRemoveText").GetComponent <TextMeshProUGUI>(); arPlaceScript = GameObject.Find("AR Session Origin").GetComponent <ARPlacement>(); }
public void OnClickOptions() { currentState = MenuStates.Options; //ES.SetSelectedGameObject(firstSelectedInOptions); storeSelected = firstSelectedInOptions; ES.SetSelectedGameObject(firstSelectedInOptions); }
/// <summary> /// Updates the menu manager. /// </summary> public static void Update() { switch (menu_state) { case (MenuStates.Hidden): if (M_InputManager.KeyPressed(M_InputManager.GameKeys.Start)) { menu_state = MenuStates.Open; menu_position += new Vector2(0.0f, 10.0f); } break; case (MenuStates.Open): menu_position = Helpers.H_Math.LerpThreshold(menu_position, Vector2.Zero, 0.3f); if (M_InputManager.KeyPressed(M_InputManager.GameKeys.Start)) { menu_state = MenuStates.Hidden; menu_tab_state = MenuTabStates.Stats; } if (M_InputManager.KeyPressed(M_InputManager.GameKeys.Right)) { menu_tab_state = (MenuTabStates)MathHelper.Clamp((int)++menu_tab_state, 0, 2); menu_position += new Vector2(0.0f, 1.0f); } else if (M_InputManager.KeyPressed(M_InputManager.GameKeys.Left)) { menu_tab_state = (MenuTabStates)MathHelper.Clamp((int)--menu_tab_state, 0, 2); menu_position += new Vector2(0.0f, 1.0f); } break; } }
private void ChangeToPaths(SubMenuStates state_) { if (currentMenuState != MenuStates.paths) { currentMenuState = MenuStates.paths; currentEC = sceneElements[2]; menu.EnableMenu("PathsButton"); menu.DisableMenu("TopoButton"); menu.DisableMenu("GraphButton"); menu.DisableMenu("PeopleButton"); menu.DisableSimulatorButtons(); cam.DisableMovement(); } menu.CloseEditMenus(); currentSubMenuState = state_; currentEC.ChangeState(currentSubMenuState); GameObject pgo = new GameObject("alg"); if (state_ == SubMenuStates.edit) { EnableEditMenu(pgo); } }
// Update is called once per frame void Update() { if (Input.GetKeyDown(KeyCode.Space) && !m_loadedUI) { m_loadedUI = true; } if (m_loadedUI) { if (UI_Title.color.a < 1.0f) { UI_Title.color = new Color(UI_Title.color.r, UI_Title.color.g, UI_Title.color.b, UI_Title.color.a + 0.01f); UI_Title2.color = new Color(UI_Title.color.r, UI_Title.color.g, UI_Title.color.b, UI_Title.color.a + 0.01f); UI_ItemPlay.color = new Color(UI_Title.color.r, UI_Title.color.g, UI_Title.color.b, UI_Title.color.a + 0.01f); UI_ItemAbout.color = new Color(UI_Title.color.r, UI_Title.color.g, UI_Title.color.b, UI_Title.color.a + 0.01f); UI_ItemOptions.color = new Color(UI_Title.color.r, UI_Title.color.g, UI_Title.color.b, UI_Title.color.a + 0.01f); } Menu(); } if (Input.GetKeyDown(KeyCode.Space) && m_loadedUI == true && UI_Title.color.a >= 1f) { ResetColour(0f); m_menuState = MenuStates.StartGame; m_currentSelection = 0; m_loadedUI = false; } }
public MenuStates ValidateTransition(MenuStates currentStates, string userInput = null) { switch (userInput) { case "1": return(MenuStates.AddingPerson); case "2": return(MenuStates.RemovingPerson); case "3": return(MenuStates.ShowAllPersons); case "4": return(MenuStates.FindPersonByCNP); case "5": return(MenuStates.ShowAllPersonsFromCity); case "6": return(MenuStates.ShowAllPersonsFromCountry); case "7": return(MenuStates.Exit); default: return(MenuStates.Initialized); } }
void SetMenuTo(MenuStates menu, bool isActive) { if ((int)menu < transform.childCount) { transform.GetChild((int)menu).gameObject.SetActive(isActive); } }
// ******************************************************************************************* // HISTORY // ******************************************************************************************* public void ChangeToHistory() { // Remember State for Bookmark Actions m_MenuState = MenuStates.History; // Sound Menu Click Singleton.AudioManager.PlaySFX(SFXName.menuButtonClick); // Load Textures in Relation to Unlocked Rewards ManipulateHistoryPages(); // Disable Main Page m_MainPage.SetActive(false); // Display turning Pages m_AnimatedPageBack.SetActive(true); m_AnimatedPageFront.SetActive(true); // do Animation m_BookAnimator.SetTrigger("turnRight"); // set background Textures m_AnimatedPageFront.GetComponent <Renderer>().material.mainTexture = m_HistoryClick; m_BookbackgroundLeft.GetComponent <Renderer>().material.mainTexture = m_HistoryClick; // Set turning Pages Textures m_AnimatedPageBack.GetComponent <Renderer>().material.mainTexture = m_PagesHistory[0].m_LeftSide; m_BookbackgroundRight.GetComponent <Renderer>().material.mainTexture = m_PagesHistory[0].m_RightSide; // Wait 1 Second before resetting Invoke("ChangeToHistory_After", 1.0f); }
//---------------------------------------------------------------------------------------------------- /// <summary> /// ボタン3(操作) /// </summary> void Button3Click() { m_choosingNum = 3; MoveChooseImage(m_choosingNum); menuStates = MenuStates.description; OperationTable.SetActive(true); }
private IEnumerator LeaveLevelAnim() { ScrollRect LevelScrollRect = LevelScroller.GetComponent <ScrollRect>(); const float AnimDuration = 0.5f; float AnimTimer = 0f; float StartPos = LevelScrollRect.horizontalNormalizedPosition; float EndPos = 0f; if (LevelScrollRect.horizontalNormalizedPosition == 0f) { AnimTimer = AnimDuration; } while (AnimTimer < AnimDuration) { AnimTimer += Time.deltaTime; float MovementRatio = 1f - Mathf.Cos(Mathf.PI / 2f * (AnimTimer / AnimDuration)); float Pos = StartPos - (StartPos - EndPos) * MovementRatio; LevelScrollRect.horizontalNormalizedPosition = Pos; yield return(null); } bMenuAtFullSpeed = true; MenuState = MenuStates.MainMenu; StartCoroutine("MoveMenu"); }
private void SwitchMenu(MenuStates menu) { switch (menu) { case MenuStates.Main: MainMenu.SetActive(true); CustomizeMenu.SetActive(false); SettingsMenu.SetActive(false); StoreMenu.SetActive(false); break; case MenuStates.Customize: CustomizeMenu.SetActive(true); MainMenu.SetActive(false); break; case MenuStates.Settings: SettingsMenu.SetActive(true); MainMenu.SetActive(false); break; case MenuStates.Store: StoreMenu.SetActive(true); MainMenu.SetActive(false); break; } }
void TurnOn() { sceneUICG.interactable = false; menuStates = MenuStates.TurningOn; if (puzzEngScript) { puzzEngScript.canPlay = false; } if (sceneTapScript) { sceneTapScript.TapLevelStuffFalse(); } col.enabled = true; if (inputDetScript.detectDrag) { putDragOff = false; } else { inputDetScript.detectDrag = true; putDragOff = true; } if (lvlTapManScript) { lvlTapManScript.ZoomOutCameraReset(); } }
public void DrawPrettyStrings(List <Tekst2> TextToDisplay, FontRenderer FontRenderer, MouseState MouseState, SpriteBatch SpriteBatch) { PreviousStateOfMouse = CurrentStateOfMouse; CurrentStateOfMouse = MouseState.LeftButton; foreach (var item in TextToDisplay) { if (MouseState.LeftButton == ButtonState.Pressed && State != MenuStates.Moving && item.Rect.Intersects(new Rectangle(MouseState.X, MouseState.Y, 1, 1)) && item.ShouldBeColoured) { FontRenderer.DrawText(SpriteBatch, item.Rect.X, item.Rect.Y, item.Text, Color.Red); if (PreviousStateOfMouse == ButtonState.Released && CurrentStateOfMouse == ButtonState.Pressed) { State = item.Stat; NextState = item.NextStat; } } else if (item.Rect.Intersects(new Rectangle(MouseState.X, MouseState.Y, 1, 1)) && item.ShouldBeColoured && State != MenuStates.Moving) { FontRenderer.DrawText(SpriteBatch, item.Rect.X, item.Rect.Y, item.Text, Color.Red); } else { FontRenderer.DrawText(SpriteBatch, item.Rect.X, item.Rect.Y, item.Text, Color.Silver); } } }
public void Update(GameTime gameTime) { if (Keyboard.GetState().IsKeyDown(Keys.A)) { menuState = MenuStates.MENU_CREDITS; } }
// We set up all of the variables needed for the item menu private void InitializeItemMenu() { itemMenuObject.SetActive(true); currentMenuParent = itemMenuObject.transform.GetChild(0).GetChild(0).GetChild(0); currentState = MenuStates.ITEM; UpdateItemMenu(); }
private void ConfirmSelection(bool confirm) { if (confirm) { switch (firstSelection) { case FirstSelection.Button1: { if (SceneManager.GetActiveScene().name.Equals("TutorialScene")) { SceneManager.LoadScene("PaperboyScene"); } break; } case FirstSelection.ExitGame: { SceneManager.LoadScene("MainMenuScene"); break; } } } else { menuState = MenuStates.MainPanel; } }
private void ShowMenu(MenuStates state) { if (mainMenu != null) { mainMenu.SetActive(state == MenuStates.Main); } if (connectMenu != null) { connectMenu.SetActive(state == MenuStates.Connect); } if (settingsMenu != null) { settingsMenu.SetActive(state == MenuStates.Settings); } if (creditsMenu != null) { creditsMenu.SetActive(state == MenuStates.Credits); } if (ingameUI != null) { ingameUI.SetActive(state == MenuStates.InGame); } if (btnBack != null) { btnBack.gameObject.SetActive(state != MenuStates.Main && state != MenuStates.Quitting && state != MenuStates.InGame && state != MenuStates.Connecting); } menuState = state; }
public void LoadOption() { MenuStates m = (MenuStates)CurrentMenu; switch (m) { case MenuStates.PLAY: GameModeUI.SetActive(true); break; case MenuStates.OPTIONS: ActiveMenu((int)MenuStates.OPTIONS); break; case MenuStates.CREDITS: ActiveMenu((int)MenuStates.CREDITS); break; case MenuStates.INFO: ActiveMenu((int)MenuStates.INFO); break; case MenuStates.QUIT: ActiveMenu((int)MenuStates.QUIT); break; } }
void ChangeMenuState(MenuStates newMenuState) { switch (newMenuState) { case MenuStates.Main: case MenuStates.LevelSelect: case MenuStates.Game: SetAllMenusTo(false); SetMenuTo(newMenuState, true); currentMenuState = newMenuState; break; case MenuStates.Pause: if (currentMenuState == MenuStates.Game) { SetMenuTo(newMenuState, true); currentMenuState = newMenuState; } else if (currentMenuState == MenuStates.Pause) { SetMenuTo(newMenuState, false); currentMenuState = MenuStates.Game; } break; } }
public MenuManager(List<Texture2D> menus, int fadeIncrement, SpriteFont bigFont, SpriteFont smallFont) { mMainMenuName = "mainMenu"; mOptionsName = "Options"; mStoryName = "Story"; mControlsName = "Controls"; mCreditsName = "Credits"; mPausedName = "Paused"; mCurrentMenuStates = MenuStates.mainMenu; mMouseAtThisIndex = -1; mMenus = menus; mCurrentMenu = 0; mFading = false; mFadeIncrement = fadeIncrement; mCurrentMenuColor = new Color(255, 255, 255, 1f); mNextMenuColor = new Color(255, 255, 255, 0f); mFont = smallFont; mBigFont = bigFont; mSmallFont = smallFont; mStringPositions = new List<Vector2>(); mSpriteFonts = new List<SpriteFont>(); mStrings = new List<string>(); mGoToString = new List<string>(); mIsClickable = new List<bool>(); }
private void switchMenu(MenuStates menu) { GameObject newState; switch (menu) { case MenuStates.Main: newState = mainMenu; break; case MenuStates.Settings: newState = settingsMenu; break; case MenuStates.Connect: newState = connectMenu; break; default: newState = mainMenu; break; } currentState.SetActive(false); currentState = newState; currentState.SetActive(true); }
public IEnumerator ChangeStateCoroutine(MenuStates gameState) { m_changingState = true; //get old state MenuState currentState = GetState(m_menuState); //get new state MenuState newState = GetState(gameState); Debug.Log("States Fetched"); //transittion from old state yield return(StartCoroutine(currentState.OnExit())); Debug.Log("Exited state"); //transittion into new state yield return(StartCoroutine(newState.OnEnter())); Debug.Log("entered state"); m_menuState = gameState; m_changingState = false; yield return(null); }
public void SkipIntroduction() { currentMenu = MenuStates.GetReadyMenu; mic.mute = false; Assets.Scripts.CharacterController.tutorialTiming = 0; PlayerPrefs.SetInt("Introduction", 1); }
//=====================MAIN MENU SECTION===================== //When play is pressed public void OnStartGame() { Debug.Log("Pressed Play"); //Load game afterwards //If on Menu Scene load the game, if in the game scene, set the timescale back to normal currentState = MenuStates.Player; }
public static void ChangeMenuState(MenuStates state) { if (OnMenuStateChanged != null) { OnMenuStateChanged(state); } }
void TurningOff() { lerpValue += Time.deltaTime / fadeDuration; menuCG.alpha = Mathf.Lerp(1, 0, lerpValue); if (lerpValue >= 1) { menuCG.alpha = 0; lerpValue = 0; menuStates = MenuStates.IsOff; sceneUICG.interactable = true; menuActive = false; if (puzzEngScript) { puzzEngScript.canPlay = true; } if (sceneTapScript) { if (!slideHelpBirdScript.moveUp && !slideHelpBirdScript.isUp) { sceneTapScript.TapLevelStuffTrue(); } } } }
//When exit is pressed public void OnExit() { Debug.Log("Pressed Exit"); SceneManager.LoadScene("Menu"); Time.timeScale = 1.0f; currentState = MenuStates.Main; }
void mainScreen() { if (GUI.Button(new Rect(Screen.width / 2 - 50, Screen.height - 150, 100, 50), "Start")) { Application.LoadLevel(1); } if (GUI.Button(new Rect(Screen.width / 2 - 50, Screen.height - 100, 100, 50), "Credits")) { state = MenuStates.credits; } }
IEnumerator TransitionState(MenuStates state, Sprite sprite) { yield return StartCoroutine(TransitionOut()); spriteRenderer.sprite = sprite; yield return StartCoroutine(TransitionIn()); currentState = state; blocked = false; }
/// <summary> /// Moves the state machine into the next state given a specific command/transition and triggers the transition /// </summary> /// <param name="command">The command/transition to run the machine through</param> public void MoveNextAndTransition(string command) { PreviousState = CurrentState; MenuCommands newCommand; if (!enumParse.TryGetValue(command, out newCommand)) { throw new UnityException("Invalid Command" + command); } CurrentState = GetNext(newCommand); Transition(); }
/// <summary> /// Moves the state machine into the next state given a specific command/transition and triggers the transition /// </summary> /// <param name="command">The command/transition to run the machine through</param> public void MoveNextAndTransition(string command) { //Record the previous state for transition purposes PreviousState = CurrentState; //Location for the new command MenuCommands newCommand; //Try to get the value if(!enumParse.TryGetValue(command, out newCommand)) throw new UnityException("Invalid Command " + command); //Setup the next state CurrentState = GetNext(newCommand); //Transition to the next state Transition (); }
public IEnumerator SetEndSprite(bool success) { blocked = true; if (success){ endSprite = winSprite; } else{ endSprite = failSprite; } currentState = MenuStates.End; spriteRenderer.sprite = endSprite; yield return StartCoroutine(TransitionIn()); blocked = false; }
void creditsScreen() { GUILayout.BeginArea(new Rect(Screen.width / 2 - 200, Screen.height - 300, 400, 300)); GUILayout.BeginVertical(); GUILayout.Label("Phil 'Mothphil' Allcock"); GUILayout.Label("Andrew 'smells' Munro"); GUILayout.Label("Edward 'ZX5' Everett"); GUILayout.Label("Jonny 'your mum' Blackburn"); if (GUILayout.Button("Back")) { state = MenuStates.main; } GUILayout.EndVertical(); GUILayout.EndArea(); }
public ConsoleMenuController() { data = Application.GetData(); state = Application.GetState(); current = new MenuStates(); current = MenuStates.NEW; states = new List<MenuStates>(); foreach (MenuStates value in Enum.GetValues(typeof(MenuStates))) { states.Add(value); } index = 0; }
public void Execute() { data = Application.GetData(); state = Application.GetState(); ConsoleKey input = Console.ReadKey().Key; switch (input) { case ConsoleKey.W: if (index <= 0) { index = states.Count - 1; } else { index--; } current = states[index]; break; case ConsoleKey.S: if (index >= states.Count - 1) { index = 0; } else { index++; } current = states[index]; break; case ConsoleKey.Enter: if (current == MenuStates.NEW) { Application.ChangeGameState(GameStates.MAPS); } if (current == MenuStates.CLOSE) { Environment.Exit(0); } break; } }
public void changeState(MenuStates _st) { CurrentState = _st; switch (CurrentState) { case MenuStates.Credits : { currentActiveMenu = Credits; currFocusedbtn = currentActiveMenu.GetComponent<SubMenu>().menuButtons[0]; currFocusedbtn.resetAllFocus(); currFocusedbtn.giveFocus(true); break; } case MenuStates.LevelChooser : { currentActiveMenu = LevelChooser; currFocusedbtn = null; break; } case MenuStates.Options : { currentActiveMenu = Options; currFocusedbtn = currentActiveMenu.GetComponent<SubMenu>().menuButtons[0]; currFocusedbtn.resetAllFocus(); currFocusedbtn.giveFocus(true); break; } case MenuStates.Start : { currentActiveMenu = Landing; currFocusedbtn = currentActiveMenu.GetComponent<SubMenu>().menuButtons[0]; currFocusedbtn.resetAllFocus(); currFocusedbtn.giveFocus(true); break; } } }
void Update() { Escape = Input.GetKeyDown(KeyCode.Escape); // The FPS Controller will handle movement for now, // I am leaving this here because we may want to implement // "combos" or the like and would want to know if these are being // pressed. // //ForwardBack = 0; //LeftRight = 0; //if (Input.GetKey(KeyCode.W)) ForwardBack = 1; //if (Input.GetKey(KeyCode.S)) ForwardBack = -1; //if (Input.GetKey(KeyCode.A)) LeftRight = -1; //if (Input.GetKey(KeyCode.D)) LeftRight = 1; //Horizontal = Input.GetAxis("Mouse X") * mouseSensitivity; //Vertical = -Input.GetAxis("Mouse Y") * mouseSensitivity; if (menuState == MenuStates.Game) { fpsController.enabled = true; Cursor.visible = false; Cursor.lockState = CursorLockMode.Confined; use = Input.GetKeyDown(KeyCode.E); Weapon = Input.GetKey(KeyCode.Mouse0); Inventory = Input.GetKeyDown(KeyCode.I); Item1 = Input.GetKeyDown(KeyCode.Alpha1); Item2 = Input.GetKeyDown(KeyCode.Alpha2); Item3 = Input.GetKeyDown(KeyCode.Alpha3); Item4 = Input.GetKeyDown(KeyCode.Alpha4); Item5 = Input.GetKeyDown(KeyCode.Alpha5); Item6 = Input.GetKeyDown(KeyCode.Alpha6); } else if (menuState == MenuStates.Inventory) { fpsController.enabled = false; Cursor.visible = true; Cursor.lockState = CursorLockMode.None; } // From GameController, needs to be refactored here (probably) if (Escape) { if (menuState == MenuStates.Game) { menuState = MenuStates.Inventory; } else if (menuState == MenuStates.Inventory) { menuState = MenuStates.Game; } } //if (InputController.Inventory) //{ // if (GameState == GameStates.Game) // { // GameState = GameStates.Inventory; // } // else if (GameState == GameStates.Inventory) // { // GameState = GameStates.Game; // } //} }
// Use this for initialization void Start() { //Setup the current state to be main CurrentState = MenuStates.MENU_MAIN; //Setup the previous state to be connect PreviousState = MenuStates.MENU_CONNECT; //Create the dictionary allTransitions = new Dictionary<MenuTransitions, MenuStates> { //Defines the state transitions where //{ new MenuTransition(actual state of the machine, transition state/command), final state of the machine) } {new MenuTransitions(MenuStates.MENU_MAIN, MenuCommands.GOTO_CONNECT), MenuStates.MENU_CONNECT}, {new MenuTransitions(MenuStates.MENU_MAIN, MenuCommands.GOTO_SETUP), MenuStates.MENU_SETUP}, {new MenuTransitions(MenuStates.MENU_MAIN, MenuCommands.QUIT_APPLICATION), MenuStates.MENU_QUITTING}, {new MenuTransitions(MenuStates.MENU_CONNECT, MenuCommands.GOTO_MAIN), MenuStates.MENU_MAIN}, {new MenuTransitions(MenuStates.MENU_CONNECT, MenuCommands.CONNECT_CLIENT),MenuStates.CONNECT_CONNECTING_TO_SERVER}, {new MenuTransitions(MenuStates.MENU_SETUP,MenuCommands.GOTO_MAIN),MenuStates.MENU_MAIN}, {new MenuTransitions(MenuStates.MENU_SETUP,MenuCommands.SETUP_HOST),MenuStates.SETUP_STARTING_HOST}, {new MenuTransitions(MenuStates.MENU_SETUP,MenuCommands.SETUP_SERVER),MenuStates.SETUP_STARTING_SERVER}, }; //Create the dictionary where //{string that is passed by the button, command the string represets} enumParse = new Dictionary<string, MenuCommands> { {"goto connect menu", MenuCommands.GOTO_CONNECT}, {"goto setup menu", MenuCommands.GOTO_SETUP}, {"goto main menu", MenuCommands.GOTO_MAIN}, {"quit application", MenuCommands.QUIT_APPLICATION}, {"setup host", MenuCommands.SETUP_HOST}, {"setup server", MenuCommands.SETUP_SERVER}, {"connect to server", MenuCommands.CONNECT_CLIENT} }; Debug.Log("Curr state = " + CurrentState); }
/* Теперь второй момент: почему не switch? Смотри, как удобно. * * Даже если без switch, _window может иметь только одно значение, то есть он не может быть и 0, и 2. * Зачем тогда проверять if (_window == 0) и ниже if (_window == 2) - используй else if тогда. */ void OnGUI() { GUI.DrawTexture(new Rect(0,0,Screen.width,Screen.height), bkg); GUI.skin = customSkin; if (buttonStyle == null) { InitGUIStyles(); return; } //if(backgroundTexture != null) // Я сделаю 2 штуки, остальное доделай сам, переменную _window убери вообще тогда: switch (currentMenuState) { case MenuStates.Default: //GUI.Box(new Rect(Screen.width / 3 - 90, Screen.height / 3 - 100, 180, 260), ""); GUI.Box(new Rect(Screen.width / 2 - 90, Screen.height / 2 - 100, 180, 260), ""); if (GUI.Button(new Rect(Screen.width / 2 - 70, Screen.height / 2 - 80, 140, 30), "New Game")) { Application.LoadLevel(1); } /* if (GUI.Button(new Rect(Screen.width / 2 - 90, Screen.height / 2 - 40, 180, 30), "Load Game")) { currentMenuState = MenuStates.LoadGame; } if (GUI.Button(new Rect(Screen.width / 2 - 90, Screen.height / 2 - 0, 180, 30), "Save Game")) { currentMenuState = MenuStates.SaveGame; } */ if (GUI.Button(new Rect(Screen.width / 2 - 70, Screen.height / 2 + 80, 140, 30), "Settings")) { currentMenuState = MenuStates.Options; } if (GUI.Button(new Rect(Screen.width / 2 - 70, Screen.height / 2 + 120, 140, 30), "Quit")) { Application.Quit(); } break; case MenuStates.Options: GUI.Box(new Rect(Screen.width / 2 - 100, Screen.height / 2 - 100, 200, 180), "Options"); if (GUI.Button(new Rect(Screen.width / 2 - 90, Screen.height / 2 - 0, 180, 30), "Back")) { currentMenuState = MenuStates.Default; } if (GUI.Button(new Rect(Screen.width / 2 - 90, Screen.height / 2 - 80, 180, 30), "Music")) { currentMenuState = MenuStates.Audio; } if (GUI.Button(new Rect(Screen.width / 2 - 90, Screen.height / 2 - 40, 180, 30), "Video")) { currentMenuState = MenuStates.Video; } break; case MenuStates.Video: // Quality Settings: http://docs.unity3d.com/Documentation/ScriptReference/QualitySettings.html GUI.Box(new Rect(Screen.width / 2 - 100, Screen.height / 2 - 100, 200, 220), "Video options"); GUI.Label(new Rect(Screen.width / 2 - 90, Screen.height / 2 - 80, 180, 140), "Quality"); if (GUI.Button(new Rect(Screen.width / 2 - 90, Screen.height / 2 + 80, 180, 30), "Back")) { currentMenuState = MenuStates.Options; } if (GUI.Button(new Rect(Screen.width / 2 - 90, Screen.height / 2 - 60, 180, 30), "Low", QualitySettings.GetQualityLevel() == 0 ? buttonPickedStyle : buttonStyle)) { QualitySettings.SetQualityLevel(0); } if (GUI.Button(new Rect(Screen.width / 2 - 90, Screen.height / 2 - 20, 180, 30), "Normal", QualitySettings.GetQualityLevel() == 1 ? buttonPickedStyle : buttonStyle)) { QualitySettings.SetQualityLevel(1); } if (GUI.Button(new Rect(Screen.width / 2 - 90, Screen.height / 2 + 20, 180, 30), "High", QualitySettings.GetQualityLevel() == 2 ? buttonPickedStyle : buttonStyle)) { QualitySettings.SetQualityLevel(2); } break; case MenuStates.Audio: GUI.Box(new Rect(Screen.width / 2 - 100, Screen.height / 2 - 100, 200, 260), "Volume"); GUI.Label(new Rect(Screen.width / 2 - 60, Screen.height / 2 - 80, 180, 140), "Sound"); hSliderValue1 = GUI.HorizontalSlider(slider1Rect, hSliderValue1, 0.0F, 10.0F); GUI.Label(new Rect(Screen.width / 2 - 60, Screen.height / 2 + 0, 180, 140), "Music"); hSliderValue2 = GUI.HorizontalSlider(slider2Rect, hSliderValue2, 0.0F, 10.0F); if (GUI.Button(new Rect(Screen.width / 2 - 90, Screen.height / 2 + 120, 180, 30), "Back")) { currentMenuState = MenuStates.Options; } Music_On = GUI.Toggle(new Rect(450, 210, 100, 100), Music_On, "Music?"); if (Music_On) { // Music } else { // Stop Music } break; case MenuStates.LoadGame: break; case MenuStates.SaveGame: GUI.Box(new Rect(Screen.width / 2 - 100, Screen.height / 2 - 100, 200, 260), "Saves"); GUI.Label(new Rect(Screen.width / 2 - 60, Screen.height / 2 - 80, 180, 140), "Game Saved!"); if (GUI.Button(new Rect(Screen.width / 2 - 90, Screen.height / 2 - 40, 180, 30), "Back")) { currentMenuState = MenuStates.Default; } break; // case MenuStates.SaveGame: } }
void Awake() { fpsController = (FirstPersonController)gameObject.GetComponent(typeof(FirstPersonController)); menuState = MenuStates.Game; }
// Update is called once per frame void Update() { if (currentState == MenuStates.Main){ if (!blocked){ spriteRenderer.sprite = mainMenuSprite; } if (Input.GetKeyDown(KeyCode.Return)){ if (!blocked){ blocked = true; StartCoroutine(TransitionState(MenuStates.Instructions, instructionSprite)); } } } else if (currentState == MenuStates.Instructions){ if(Input.GetKeyDown(KeyCode.Return)) { currentState = MenuStates.Off; GameObject.Find("Map Loader").GetComponent<MapLoader>().StartGame(); StartCoroutine(TransitionOut()); } } else if(currentState == MenuStates.Off) { } else if(currentState == MenuStates.End) { if (Input.GetKeyDown(KeyCode.Return) && !blocked){ blocked = true; Application.LoadLevel("Game"); } } }
// Use this for initialization void Start() { //Setup the current state to be main CurrentState = MenuStates.MENU_MAIN; //Setup the previous state to be connect PreviousState = MenuStates.MENU_CONNECT; //Create the dictionary allTransitions = new Dictionary<MenuTransitions, MenuStates> { //Defines the state transitions where //{ new MenuTransition(actual state of the machine, transition state/command), final state of the machine) } }; //Create the dictionary where //{string that is passed by the button, command the string represets} enumParse = new Dictionary<string, MenuCommands> { }; Debug.Log("Curr state = " + CurrentState); }
private void _SwitchMenu(MenuStates menu) { GameObject new_menu; bool remove = false; switch (menu) { case MenuStates.Previous: new_menu = null; // to make compiler happy remove = true; break; case MenuStates.Settings: new_menu = settings_menu; break; case MenuStates.Connect: new_menu = connect_menu; break; case MenuStates.Lobby: new_menu = lobby_menu; team_select_panel.SetActive(true); break; default: new_menu = main_menu; break; } _menu_order[_menu_order.Count - 1].SetActive(false); if (remove) { _menu_order.RemoveAt(_menu_order.Count - 1); } else { _menu_order.Add(new_menu); } _menu_order[_menu_order.Count - 1].SetActive(true); }
public void OnHighScore() { Debug.Log("You pressed Highscore"); currentstate = MenuStates.Highscore; }
private void InGameMenu() { // wymiary calego menu int w = 500; int h = 470; // skin GUI.skin.box.fontSize = 40; GUI.skin.label.fontSize = 35; GUI.skin.button.fontSize = 35; GUI.skin.label.alignment = TextAnchor.UpperLeft; GUI.skin.horizontalSlider.stretchHeight = true; // wlasciwe rysowanie menu w zaleznosci od stanu if(menuState != MenuStates.NETWORK) { GUI.BeginGroup(new Rect((Screen.width - w)/2,(Screen.height - h)/2, w, h)); } switch(menuState) { case MenuStates.NETWORK: GUI.Box(new Rect(0,0,w,h), "NEW GAME"); break; default: case MenuStates.MAIN: GUI.Box(new Rect(0,0,w,h), "MENU"); if(!isMainMenu) { if (GUI.Button (new Rect (15, 50, w * 0.95f, 60), "BACK TO GAME")) { showInGameMenu = false; } } else { if (GUI.Button (new Rect (15, 50, w * 0.95f, 60), "NEW GAME")) { // 0 = menu, 1 = nasz level Application.LoadLevel(1); } } if (GUI.Button (new Rect (15, 50 + 60 + 60, w * 0.95f, 60), "OPTIONS")) { menuState = MenuStates.OPTIONS; } if(isMainMenu) { if (GUI.Button (new Rect (15, h - 70, w * 0.95f, 60), "QUIT TO DESKTOP")) { Application.Quit(); // to nie dziala jak sie odpala w edytorze unity (trzeba wyeksportowac i dopiero) } } else { if (GUI.Button (new Rect (15, h - 70, w * 0.95f, 60), "QUIT TO MAIN MENU")) { Application.LoadLevel(0); } } break; case MenuStates.OPTIONS: GUI.Box(new Rect(0,0,w,h), "OPTIONS"); if (GUI.Button (new Rect (15, 50, w * 0.95f, 60), "SOUND OPTIONS")) { menuState = MenuStates.SOUND; } if (GUI.Button (new Rect (15, 50 + 60 + 60, w * 0.95f, 60), "KEY BINDINGS")) { menuState = MenuStates.REDEFINE; } if (GUI.Button (new Rect (15, h - 70, w * 0.95f, 60), "BACK")) { menuState = MenuStates.MAIN; } break; case MenuStates.SOUND: GUI.Box(new Rect(0,0,w,h), "SOUND"); GUI.Label (new Rect (15, 50 + 90, w * 0.95f, 60), "VOLUME"); sliderValue = GUI.HorizontalSlider (new Rect (15, 50 + 90 + 50, w * 0.95f, 60), sliderValue, 0, 1); AudioListener.volume = sliderValue; if (GUI.Button (new Rect (15, h - 70, w * 0.95f, 60), "BACK")) { menuState = MenuStates.OPTIONS; } break; case MenuStates.REDEFINE: GUI.skin.label.fontSize = 20; GUI.skin.button.fontSize = 20; GUI.Box(new Rect(0,0,w,h), "KEY BINDINGS"); int offset = 0; // offset przy rysowaniu ArrayList sortedKeys = new ArrayList(); foreach(string name in us.sortedKeys) { // kiedys bylo us.keys.Keys ale hashtable nie są po kolei, a pasowaloby zeby klawisze do sterowania byly na poczatku //Debug.Log(name + " " + us.keys[name]); GUI.Label(new Rect(15, 50 + offset, w * 0.95f, 30), name); GUI.Label(new Rect(100, 50 + offset, w * 0.95f, 30), us.keys[name].ToString()); if(name == keyChanging) { // zmieniamy klawisz ktory aktualnie wyswietlamy if(GUI.Button(new Rect (200, 50 + offset, 280, 30), "PRESS KEY")) { keyChanging = ""; } } else { // nie zmieniamy if(GUI.Button(new Rect (200, 50 + offset, 280, 30), "CHANGE")) { keyChanging = name; } } offset += 32; } GUI.skin.button.fontSize = 35; if (GUI.Button (new Rect (15, h - 70, w * 0.95f, 60), "BACK")) { menuState = MenuStates.OPTIONS; } // tutaj czekamy na jakis klawisz if(keyChanging != "") { // cos zmieniamy Event e = Event.current; KeyCode kc = KeyCode.None; // to ponizej nie wykryje shifta bo // prawdziwy bug w kochanym Unity // http://forum.unity3d.com/threads/30343-current-event-not-detecting-shift-key if(e.isKey && e.keyCode != KeyCode.None) { Debug.Log("nacisneto klawisz: " + e.keyCode); kc = e.keyCode; } // wiec workaround z tego threada ponizej if(e.shift) { if (Input.GetKey(KeyCode.LeftShift)) { Debug.Log("lewy szift"); kc = KeyCode.LeftShift; } else if (Input.GetKey(KeyCode.RightShift)){ Debug.Log("prawy szift"); kc = KeyCode.RightShift; } } // jak mamy klawisz to dokonujemy zamiany if(kc != KeyCode.None) { us.ChangeKey(keyChanging, kc); keyChanging = ""; us.Save(); } } break; } GUI.EndGroup(); }
private void InitMenuState() { MenuState = MenuStates.Main; MenuIndex = 0; }
// Update is called once per frame void Update() { if(showInGameMenu || isMainMenu) Screen.lockCursor = false; else Screen.lockCursor = true; if (Input.GetKeyDown(KeyCode.Escape)) { // pokazujemy kursorek do menu, albo nie pokazujemy w edytorze unity to chyba // i tak zawsze jest showInGameMenu = !showInGameMenu; Cursor.visible = showInGameMenu; menuState = MenuStates.MAIN; } if(!isMainMenu) { // pc - drobna poprawka, bo pokazywanie statsow w main menu nie ma sensu ;) //mantkowicz - dodanie wyswietlania statystyk tab/alt if( Input.GetKey( KeyCode.Tab ) ) { if( !teamStatisticsBoxInitialized ) { teamStatisticsBoxWidth = Screen.width * 0.4f; teamStatisticsBoxHeight = Screen.height * 0.5f; teamStatisticsOffset = -teamStatisticsBoxWidth; teamStatisticsBoxStep = teamStatisticsBoxWidth / 10.0f; teamStatisticsBoxInitialized = true; } showTeamStatistics = true; } else { showTeamStatistics = false; teamStatisticsBoxInitialized = false; } if( Input.GetKey( KeyCode.LeftAlt ) ) { if( !personalStatisticsBoxInitialized ) { personalStatisticsBoxWidth = Screen.width * 0.3f; personalStatisticsBoxHeight = Screen.height * 0.2f; personalStatisticsOffset = -personalStatisticsBoxHeight; personalStatisticsBoxStep = personalStatisticsBoxHeight / 10.0f; personalStatisticsBoxInitialized = true; } showPersonalStatistics = true; } else { showPersonalStatistics = false; personalStatisticsBoxInitialized = false; } //endof mantkowicz } }
void MenuStateSwitch(MenuStates index) { Destroy(curMenu); curMenu = Instantiate(menus[(int)index]) as GameObject; if (index == MenuStates.EmptyMenu) ToggleCursors(false); else ToggleCursors(true); }
//When script first starts void Awake() { //always sets first menu to main menu currentstate = MenuStates.Main; }
public void OnOptions() { Debug.Log("You pressed Options"); currentstate = MenuStates.Options; }
// Use this for initialization void Start() { CurrentState = MenuStates.MENU_MAIN; PreviousState = MenuStates.MENU_CONNECT; allTransitions = new Dictionary<MenuTransitions, MenuStates> { {new MenuTransitions(MenuStates.MENU_MAIN, MenuCommands.GOTO_CONNECT), MenuStates.MENU_CONNECT}, {new MenuTransitions(MenuStates.MENU_MAIN, MenuCommands.GOTO_SETUP), MenuStates.MENU_SETUP }, {new MenuTransitions(MenuStates.MENU_MAIN, MenuCommands.QUIT_APPLICATION), MenuStates.MENU_QUITTING}, {new MenuTransitions(MenuStates.MENU_CONNECT, MenuCommands.GOTO_MAIN), MenuStates.MENU_MAIN}, {new MenuTransitions(MenuStates.MENU_CONNECT, MenuCommands.CONNECT_CLIENT), MenuStates.CONNECT_CONNECTING_TO_SERVER}, {new MenuTransitions(MenuStates.MENU_SETUP, MenuCommands.GOTO_MAIN), MenuStates.MENU_MAIN}, {new MenuTransitions(MenuStates.MENU_SETUP, MenuCommands.SETUP_HOST), MenuStates.SETUP_STARTING_HOST}, {new MenuTransitions(MenuStates.MENU_SETUP, MenuCommands.SETUP_SERVER), MenuStates.SETUP_STARTING_SERVER} }; enumParse = new Dictionary<string, MenuCommands> { {"goto connect menu", MenuCommands.GOTO_CONNECT }, {"goto setup menu", MenuCommands.GOTO_SETUP }, {"goto main menu", MenuCommands.GOTO_MAIN }, {"quit application", MenuCommands.QUIT_APPLICATION }, {"setup host", MenuCommands.SETUP_HOST }, {"setup server", MenuCommands.SETUP_SERVER }, {"connect to server", MenuCommands.CONNECT_CLIENT} }; Debug.Log("Curr state = " + CurrentState);
private void ParseMenuAction() { if (this.MenuState == MenuStates.Main) { if (MenuIndex == 0) { //Start game GameState = gameStates.Play; } else if (MenuIndex == 1) { //About page this.MenuState = MenuStates.About; } else if (MenuIndex == 2) { //Exit this.Exit(); } } else if (this.MenuState == MenuStates.About) { MenuIndex = 1; this.MenuState = MenuStates.Main; } }
// Use this for initialization void Start() { currentState = MenuStates.Main; spriteRenderer = GetComponent<SpriteRenderer>(); spriteRenderer.renderer.sortingLayerID = 5; }
public TornadoGame.GameState Update(float elapsedMilliseconds) { if (State == MenuStates.Menu) { // change selected item if up or down pressed if (Input.KeysHit.Contains(Keys.Up)) SelectedItem--; if (Input.KeysHit.Contains(Keys.Down)) SelectedItem++; if (Paused) { if (SelectedItem > MenuItems.Info) SelectedItem = MenuItems.Resume; if (SelectedItem < MenuItems.Resume) SelectedItem = MenuItems.Info; } else { if (SelectedItem > MenuItems.Info) SelectedItem = MenuItems.NewGame; if (SelectedItem < MenuItems.NewGame) SelectedItem = MenuItems.Info; } // test for selection choice if (Input.KeysHit.Contains(Keys.Enter)) { if (SelectedItem == MenuItems.Resume) { Paused = false; return TornadoGame.GameState.InGame; } else if (SelectedItem == MenuItems.NewGame) { Game.LevelIndex = 0; return TornadoGame.GameState.NewGame; } else if (SelectedItem == MenuItems.LoadLevel) { State = MenuStates.LoadLevel; LevelConfigs = XmlSettingsFile.LevelConfigs; } else if (SelectedItem == MenuItems.Info) State = MenuStates.Info; } if (Input.KeysHit.Contains(Keys.F1)) { Game.CreditsY = Game.WindowHeight; return TornadoGame.GameState.Complete; } if (Input.KeysHit.Contains(Keys.Escape)) return TornadoGame.GameState.Quit; } else if (State == MenuStates.LoadLevel) { if (Input.KeysHit.Contains(Keys.Escape)) State = MenuStates.Menu; // change selected item if up or down pressed if (Input.KeysHit.Contains(Keys.Up)) SelectedLevel--; if (Input.KeysHit.Contains(Keys.Down)) SelectedLevel++; if (SelectedLevel > LevelConfigs.Count - 1) SelectedLevel = 0; if (SelectedLevel < 0) SelectedLevel = LevelConfigs.Count - 1; // test for selection choice if (Input.KeysHit.Contains(Keys.Enter)) { Game.LevelIndex = SelectedLevel; State = MenuStates.Menu; return TornadoGame.GameState.NewGame; } } else if (State == MenuStates.Info) { if (Input.KeysHit.Contains(Keys.Escape)) State = MenuStates.Menu; } CursorTimeSinceLastFrame += elapsedMilliseconds; return Game.State; }
public void OnBack() { Debug.Log("You pressed back to Main Menu"); currentstate = MenuStates.Main; }