void OnGUI() { if (!PhotonNetwork.connected) { NecroGUI.connectWindow = true; return; //Wait for a connection } else NecroGUI.connectWindow = false; //Stop redrawing GUI if state is going to change if(lastMenuState != currentMenuState){ endFrame = false; StartCoroutine(wait()); lastMenuState = currentMenuState; } if(!endFrame || currentMenuState == menuState.none) return; //Draw different GUI depending on state switch (currentMenuState) { case menuState.login: NecroGUI.loginWindow = true; break; case menuState.signup: NecroGUI.signupWindow = true; break; case menuState.profile: NecroGUI.lobbyWindow = true; break; case menuState.roleSelect: NecroGUI.roleSelectWindow = true; break; } }
void Update() { if (Input.GetKeyDown(KeyCode.Escape)) { switch (state) { case menuState.Main: Application.Quit(); break; case menuState.Options: state = menuState.Main; break; case menuState.Audio: case menuState.Graphics: case menuState.Gameplay: state = menuState.Options; break; default: break; } } }
private void OnGUI() { if (myState == menuState.mainMenu) { if (GUI.Button(new Rect(xPos, yPos, width, height), "Play")) { myState = menuState.connectionMenu; } } else if (myState == menuState.connectionMenu) { if (GUI.Button(new Rect(xPos, yPos, width, height), "Host")) { NetworkInfo.Host = true; SceneManager.LoadScene(1); } if (GUI.Button(new Rect(xPos, yPos + height + spacingY, width, height), "Connect")) { NetworkInfo.Host = false; SceneManager.LoadScene(1); } NetworkInfo.IP = GUI.TextField(new Rect(xPos, yPos + ((height + spacingY) * 2), width, (height * 0.75f)), NetworkInfo.IP); if (GUI.Button(new Rect(xPos, yPos + ((height * 2.75f) + (spacingY * 3.0f)), width, height), "Cancel")) { myState = menuState.mainMenu; } } }
void Start() { Screen.orientation = ScreenOrientation.LandscapeLeft; me = GetComponent <RectTransform>(); #if MOBILE_INPUT me.sizeDelta = new Vector2(360, me.sizeDelta.y); foreach (LayoutElement child in buttonsGroup.GetComponentsInChildren <LayoutElement>()) { child.minHeight = 60; } #else me.sizeDelta = new Vector2(320, me.sizeDelta.y); foreach (LayoutElement child in transform.GetComponentsInChildren <LayoutElement>()) { child.minHeight = 70; } #endif state = menuState.isIn; inPos = -(me.rect.width / 2); outPos = (me.rect.width / 2); me.anchoredPosition = new Vector2(inPos, 0); // Get the nu beam for later nuBeam = GameObject.Find("NuBeamParticleSystem"); }
private void drawOptionsMenu() { GUILayout.BeginArea(new Rect(Screen.width / 2 - 200, Screen.height / 2, 400, 200)); using (new GuiCenter()) { GUILayout.BeginVertical(); if (GUILayout.Button("Graphics")) { state = menuState.Graphics; } if (GUILayout.Button("Audio")) { state = menuState.Audio; } if (GUILayout.Button("Gameplay")) { state = menuState.Gameplay; } GUILayout.Space(10); if (GUILayout.Button("Back")) { state = menuState.Main; } GUILayout.EndVertical(); } GUILayout.EndArea(); }
public void changeState(int State) { if (State >= 1) { MenuState = menuState.menu; } if (State >= 2) { MenuState = menuState.customisation; } if (State >= 3) { if (PlayerStats.weightSet == true) { if (PlayerStats.genderSet == true) { MenuState = menuState.game; } } if (State >= 4) { MenuState = menuState.credits; } if (PlayerStats.weightSet == false) { StartCoroutine(message1()); } if (PlayerStats.genderSet == false) { StartCoroutine(message2()); } } }
public void Update() { mouseState = Mouse.GetState(); //mouse position mousePoint = new Vector2(mouseState.X, mouseState.Y); //does the player click play if (playButton.Contains(mousePoint) && (mouseState.LeftButton == ButtonState.Pressed) && state == menuState.mainMenu) { //begin playing UserInterface.setIntitialValues(); GameBase.setState(GameBase.gameStates.Playing); EntityManager.Initialize(); GameBase.setLevel(GameBase.level.one); } //does the player click help if (helpButton.Contains(mousePoint) && (mouseState.LeftButton == ButtonState.Pressed) && state == menuState.mainMenu) { state = menuState.help; //send to help screenn } //does the player click back if (backButton.Contains(mousePoint) && (mouseState.LeftButton == ButtonState.Pressed) && state == menuState.help) { state = menuState.mainMenu; //send back to main menu } }
public void StartGame() { if (PlayerStats.weightSet == true) { if (PlayerStats.genderSet == true) { /* * MenuState = menuState.game; * GameFlowManager GameFlowManager = GameObject.Find("GameFlowManager").GetComponent<GameFlowManager>(); * music.MusicStop(); * GameFlowManager.MoveFromStartMenuToGame(); */ MenuState = menuState.opening; } } if (PlayerStats.weightSet == false) { StartCoroutine(message1()); } if (PlayerStats.genderSet == false) { StartCoroutine(message2()); } }
public void OpenQuitDialog() { if (phase == menuState.MAIN) { phase = menuState.QUIT; quitDialogBox.SetActive(true); } }
public void startMainGame() { MenuState = menuState.game; GameFlowManager GameFlowManager = GameObject.Find("GameFlowManager").GetComponent <GameFlowManager>(); music.MusicStop(); GameFlowManager.MoveFromStartMenuToGame(); }
public void CloseQuitDialog() { if (phase == menuState.QUIT) { phase = menuState.MAIN; quitDialogBox.SetActive(false); } }
// method to keep track of keys pressed public void KeyUpdate() { // keeps track of current keyboard state KeyboardState newState = Keyboard.GetState(); // only do the following if the menustate is on if (myState == menuState.Off) { return; } if (myState == menuState.Clicking) { return; } if (keysOff) { return; } // if up is pressed, moves selector up if (newState.IsKeyDown(Keys.Up)) { if (!oldState.IsKeyDown(Keys.Up)) { selected--; if (selected == -1) { selected = buttons.Length - 1; } } } // if down is pressed, moves selector down if (newState.IsKeyDown(Keys.Down)) { if (!oldState.IsKeyDown(Keys.Down)) { selected++; if (selected == buttons.Length) { selected = 0; } } } // if enter is pressed, ... if (newState.IsKeyDown(Keys.Enter)) { if (!oldState.IsKeyDown(Keys.Enter)) { myState = menuState.Clicking; buttons[selected].WhenButtonClicked(delegate() { myState = menuState.On; }); buttons[selected].Click(); } } // makes the oldstate the previous state oldState = newState; }
void Awake() { //Connect to the main photon server. This is the only IP and port we ever need to set(!) if (!PhotonNetwork.connected) PhotonNetwork.ConnectUsingSettings("v1.0"); // version of the game/demo. used to separate older clients from newer ones (e.g. if incompatible) //Load name from PlayerPrefs PhotonNetwork.playerName = PlayerPrefs.GetString("playerName", "Guest" + Random.Range(1, 9999)); currentMenuState = menuState.login; }
// Use this for initialization void Start() { MenuState = menuState.menu; //set initial state of menu //loginRender = LoginMenu.GetComponent<CanvasRenderer>(); menu.SetActive(true); message_1.SetActive(false); message_2.SetActive(false); PlayerStats.weightSet = false; PlayerStats.genderSet = false; music.MenuMusicPlay(); }
void Awake() { //Connect to the main photon server. This is the only IP and port we ever need to set(!) if (!PhotonNetwork.connected) { PhotonNetwork.ConnectUsingSettings("v1.0"); // version of the game/demo. used to separate older clients from newer ones (e.g. if incompatible) } //Load name from PlayerPrefs PhotonNetwork.playerName = PlayerPrefs.GetString("playerName", "Guest" + Random.Range(1, 9999)); currentMenuState = menuState.login; }
void Start() { if (instatnce == null) { instatnce = this; } homeState.gameObjectsInThisState = gameObjectsInHomeState; selectLevelState.gameObjectsInThisState = gameObjectsSelectLevelState; selectNumberOfPlayersState.gameObjectsInThisState = gameObjectsSelectNumberOfPlayersState; currentState = homeState; currentState.enterState(); }
public void Keyboard_KeyDown(object sender, KeyboardKeyEventArgs e) { if (state != menuState.NEXTMENU) { KeyboardState KeyStates = Keyboard.GetState(); if (KeyStates.IsKeyDown(Key.Down)) { Console.WriteLine("Debug: AIscene({0}) - Down", state); if (state == menuState.HOST) { state = menuState.JOIN; } else if (state == menuState.JOIN) { state = menuState.HOST; } } else if (KeyStates.IsKeyDown(Key.Up)) { Console.WriteLine("Debug: AIscene({0}) - Up", state); if (state == menuState.HOST) { state = menuState.JOIN; } else if (state == menuState.JOIN) { state = menuState.HOST; } } if (KeyStates.IsKeyDown(Key.Enter)) { Console.WriteLine("Debug: AIscene({0}) - Enter", state); if (state == menuState.HOST) { sceneManager.HostNetwork(); state = menuState.NEXTMENU; } if (state == menuState.JOIN) { sceneManager.JoinNetwork(); state = menuState.NEXTMENU; } } if (KeyStates.IsKeyDown(Key.Escape)) { //Go to previous scene state = menuState.NEXTMENU; sceneManager.StartMenu(); } } }
private void drawGameplayOptionsMenu() { GUILayout.BeginArea(new Rect(Screen.width / 2 - 200, Screen.height / 2, 400, 200)); using (new GuiCenter()) { if (clearPersistance) { GUILayout.BeginVertical(); GUILayout.Label("Are you sure you want to clear your notebook?"); GUILayout.BeginHorizontal(); if (GUILayout.Button("Yes")) { clearPersistance = false; persistanceCleared = true; PlayerPrefs.SetString("FoundNotes", ""); } if (GUILayout.Button("NO!")) { clearPersistance = false; } GUILayout.EndHorizontal(); GUILayout.EndVertical(); } else { GUILayout.BeginVertical(); if (persistanceCleared) { GUILayout.Label("Persistance Cleared!"); } else if (GUILayout.Button("Clear Persistance")) { clearPersistance = true; persistanceCleared = false; } GUILayout.EndVertical(); } } using (new GuiCenter()) { if (GUILayout.Button("Back")) { persistanceCleared = false; state = menuState.Options; } } GUILayout.EndArea(); }
public void Keyboard_KeyDown(object sender, KeyboardKeyEventArgs e) { if (state != menuState.NEXTMENU) { KeyboardState KeyStates = Keyboard.GetState(); if (KeyStates.IsKeyDown(Key.Down)) { Console.WriteLine("Debug: AIscene({0}) - Down", state); if (state == menuState.SINGLE) { state = menuState.MULTI; } else if (state == menuState.MULTI) { state = menuState.SINGLE; } } else if (KeyStates.IsKeyDown(Key.Up)) { Console.WriteLine("Debug: AIscene({0}) - Up", state); if (state == menuState.SINGLE) { state = menuState.MULTI; } else if (state == menuState.MULTI) { state = menuState.SINGLE; } } if (KeyStates.IsKeyDown(Key.Enter)) { Console.WriteLine("Debug: AIscene({0}) - Enter", state); if (state == menuState.SINGLE) { sceneManager.OpenSingleLeaderboard(false, -1); state = menuState.NEXTMENU; } if (state == menuState.MULTI) { sceneManager.OpenMultiLeaderboard(false, -1); state = menuState.NEXTMENU; } } if (KeyStates.IsKeyDown(Key.Escape)) { //Go to previous scene state = menuState.NEXTMENU; sceneManager.StartMenu(); } } }
public void SlideMenu() { if (state == menuState.isIn) { state = menuState.slidingOut; slideButton.GetComponent <RectTransform>().eulerAngles = new Vector3(0, 0, 0); //AMCLEAN changed (0,0,180) to (0,0,0) startTime = Time.time; } else if (state == menuState.isOut) { state = menuState.slidingIn; slideButton.GetComponent <RectTransform>().eulerAngles = new Vector3(0, 0, 0); startTime = Time.time; } }
// menu constructor public Menu(Drawable background, int numberOfButtons, Text title, String[] buttonNames, Button.ClickHandler[] buttonActions, SpriteFont buttonFont, Drawable checkMark) : base(background) { // gives buttons height & width, adds title, makes buttons & gives position in middle of screen buttonHeight = 75; buttons = new Button[numberOfButtons]; buttonAmount = numberOfButtons; _checkMark = checkMark; base.Add(title); title.attributes.position = new Vector2(512, title.height / 2 + 40); title.attributes.depth = .01f; maxButtonWidth = 0; // makes new buttons, adds heights, adds actions and events for if clicked for (int i = 0; i < numberOfButtons; i++) { buttons[i] = new Button(buttonNames[i], buttonFont, new Vector2(512, title.height + 140 + ((800 - title.height - 80 - buttonHeight) / numberOfButtons) * i), Color.Black, _checkMark); buttons[i].height = buttonHeight; buttons[i].Clicked += buttonActions[i]; buttons[i].Clicked += delegate() { for (int j = 0; j < numberOfButtons; j++) { if (j != i) { buttons[j].Remove(); } } }; if (buttons[i].width > maxButtonWidth) { maxButtonWidth = buttons[i].width; } base.Add(buttons[i]); buttons[i].attributes.depth = .01f; } // sets selected button to the top button selected = 0; // initializes menu to off, then turns it on after .5 seconds myState = menuState.Off; keysOff = false; Timer state = new Timer(1); base.Add(state); state.SetTimer(0, .5f, delegate() { myState = menuState.On; }); }
void drawMainMenu() { Rect startRect = new Rect((Screen.width / 5) - 60, Screen.height / 2 - 50, 150, 75); GUI.DrawTexture(startRect, start, ScaleMode.ScaleToFit); if (startRect.Contains(Event.current.mousePosition)) { GUI.DrawTexture(startRect, highlight, ScaleMode.ScaleToFit); if (Input.GetMouseButtonDown(0)) { Application.LoadLevel(2); } } Rect optionsRect = new Rect((Screen.width / 5) - 60, Screen.height / 2 + 30, 150, 50); if (GUI.Button(optionsRect, "Options")) { state = menuState.Options; } Rect creditsRect = new Rect((Screen.width / 5) - 50, Screen.height / 2 + 100, 150, 75); GUI.DrawTexture(creditsRect, credits, ScaleMode.StretchToFill); if (creditsRect.Contains(Event.current.mousePosition)) { GUI.DrawTexture(creditsRect, highlight, ScaleMode.ScaleToFit); if (Input.GetMouseButtonDown(0)) { Application.LoadLevel("Credits"); } } if (!Application.isWebPlayer) { Rect exitRect = new Rect(Screen.width / 5 - 60, Screen.height / 2 + 200, 150, 75); GUI.DrawTexture(exitRect, exit, ScaleMode.ScaleToFit); if (exitRect.Contains(Event.current.mousePosition)) { GUI.DrawTexture(exitRect, highlight, ScaleMode.ScaleToFit); if (Input.GetMouseButtonDown(0)) { Application.Quit(); } } } }
public void Room() { //Patient is where you write your room code if (state == menuState.room) { return; } onSave(); menuManager.Instance.input.characterValidation = InputField.CharacterValidation.Integer; menuManager.Instance.input.characterLimit = 8; state = menuState.room; menuManager.Instance.input.text = PlayerPrefs.GetString("roomCode"); menuManager.Instance.animator.Play(Animator.StringToHash("playerRoom"), -1, 0); soundManager.playSound(soundManager.soundList["decline1"], false, 3f); }
void Awake() { //this will keep the code object from being destroyed // added after push //PhotonNetwork.logLevel = NetworkLogLevel.Full; Playtomic.Initialize(428042, "077e33f2d4704abd", "15d6d5a5dd864d97a38851a7541448"); Playtomic.Log.View(); //Connect to the main photon server. This is the only IP and port we ever need to set(!) if (!PhotonNetwork.connected) PhotonNetwork.ConnectUsingSettings("v1.0"); // version of the game/demo. used to separate older clients from newer ones (e.g. if incompatible) //Load name from PlayerPrefs PhotonNetwork.playerName = PlayerPrefs.GetString("playerName", "Guest" + Random.Range(1, 9999)); currentMenuState = menuState.login; }
void OnGUI() { if (!PhotonNetwork.connected) { NecroGUI.connectWindow = true; return; //Wait for a connection } else { NecroGUI.connectWindow = false; } //Stop redrawing GUI if state is going to change if (lastMenuState != currentMenuState) { endFrame = false; StartCoroutine(wait()); lastMenuState = currentMenuState; } if (!endFrame || currentMenuState == menuState.none) { return; } //Draw different GUI depending on state switch (currentMenuState) { case menuState.login: NecroGUI.loginWindow = true; break; case menuState.signup: NecroGUI.signupWindow = true; break; case menuState.profile: NecroGUI.lobbyWindow = true; break; case menuState.roleSelect: NecroGUI.roleSelectWindow = true; break; } }
public void Patient() { //Patient is where you write your player name if (state == menuState.system) { return; } menuManager.Instance.input.characterValidation = InputField.CharacterValidation.Name; menuManager.Instance.input.characterLimit = 16; menuManager.Instance.input.text = state != menuState.off ? PlayerPrefs.GetString("name") : defaultPlayerName; state = menuState.system; menuManager.Instance.animator.Play(Animator.StringToHash("playerPatient"), -1, 0); soundManager.playSound(soundManager.soundList["accept1"], false, 3f); onSave(); }
private void drawGraphicsOptionsMenu() { GUILayout.BeginArea(new Rect(Screen.width / 2 - 300, Screen.height / 2, 600, 300)); Screen.fullScreen = GUILayout.Toggle(Screen.fullScreen, "Full Screen"); if (Screen.fullScreen) { GUILayout.Label("Resolution"); int res = Array.IndexOf(Screen.resolutions, Screen.currentResolution); var resolutions = Screen.resolutions.Select(r => String.Format("{0}X{1}X{2}Hz", r.width, r.height, r.refreshRate)).ToList(); int newResolution = GUILayout.SelectionGrid(res, resolutions.ToArray(), 5); if (res != newResolution) { var newRes = Screen.resolutions[newResolution]; Screen.SetResolution(newRes.width, newRes.height, Screen.fullScreen, newRes.refreshRate); } } else { using (new GuiCenter()) { GUILayout.Label("Resolution"); GUILayout.Label(String.Format("{0}X{1}", Screen.width, Screen.height)); } } GUILayout.Label("Quality Level"); var level = QualitySettings.GetQualityLevel(); var newLevel = GUILayout.SelectionGrid(level, QualitySettings.names, QualitySettings.names.Length); if (newLevel != level) { QualitySettings.SetQualityLevel(newLevel, true); } using (new GuiCenter()) { if (GUILayout.Button("Back")) { state = menuState.Options; } } GUILayout.EndArea(); }
void Update() { if (state == menuState.slidingOut) { me.anchoredPosition = Vector2.Lerp(new Vector2(inPos, 0), new Vector2(outPos, 0), (Time.time - startTime) * slideSpeed); //slideButton.GetComponent<RectTransform>().eulerAngles = Vector3.Lerp(new Vector3(0, 0, 0), new Vector3(0, 180, 0), (Time.time - startTime) * slideSpeed); if (me.anchoredPosition == new Vector2(outPos, 0)) { state = menuState.isOut; } } else if (state == menuState.slidingIn) { me.anchoredPosition = Vector2.Lerp(new Vector2(outPos, 0), new Vector2(inPos, 0), (Time.time - startTime) * slideSpeed); //slideButton.GetComponent<RectTransform>().eulerAngles = Vector3.Lerp(new Vector3(0, 180, 0), new Vector3(0, 0, 0), (Time.time - startTime) * slideSpeed); if (me.anchoredPosition == new Vector2(inPos, 0)) { state = menuState.isIn; } } }
// overloaded constructor to add buttonheight public Menu(Drawable background, int numberOfButtons, Text title, String[] buttonNames, Button.ClickHandler[] buttonActions, SpriteFont buttonFont, int buttonHeight, bool PAMenuButtonHeight) : base(background) { this.buttonHeight = buttonHeight; buttons = new Button[numberOfButtons]; base.Add(title); title.attributes.position = new Vector2(512, title.height / 2 + 40); title.attributes.depth = .01f; maxButtonWidth = 0; for (int i = 0; i < numberOfButtons; i++) { buttons[i] = new Button(buttonNames[i], buttonFont, new Vector2(512, 550 + (125 * i)), Color.Black); buttons[i].height = 100; buttons[i].Clicked += buttonActions[i]; buttons[i].Clicked += delegate() { for (int j = 0; j < numberOfButtons; j++) { if (j != i) { buttons[j].Remove(); } } }; if (buttons[i].width > maxButtonWidth) { maxButtonWidth = buttons[i].width; } base.Add(buttons[i]); buttons[i].attributes.depth = .01f; } selected = 0; myState = menuState.Off; keysOff = false; Timer state = new Timer(1); base.Add(state); state.SetTimer(0, .5f, delegate() { myState = menuState.On; }); }
public void MouseUpdate() { if (myState == menuState.Off) { return; } if (myState == menuState.Clicking) { return; } MouseState newstate = Mouse.GetState(); if (newstate == oldstate) { return; } float x = newstate.X; float y = newstate.Y; Vector2 mousePosition = new Vector2(x, y); for (int i = 0; i < buttonAmount; i++) { float halfWidth = buttons[i].width / 2; float halfHeight = buttons[i].height / 2; float xOrigin = buttons[i].attributes.position.X; float yOrigin = buttons[i].attributes.position.Y; if ((x > (xOrigin - halfWidth)) && (x < (xOrigin + halfWidth)) && (y < (yOrigin + halfHeight)) && (y > (yOrigin - halfHeight))) { selected = i; if ((newstate.LeftButton == ButtonState.Pressed) && (oldstate.LeftButton == ButtonState.Released)) { myState = menuState.Clicking; buttons[selected].WhenButtonClicked(delegate() { myState = menuState.On; }); buttons[selected].Click(); } } } oldstate = newstate; }
// menu constructor public Menu(Drawable background, int numberOfButtons, Text title, String[] buttonNames, Button.ClickHandler[] buttonActions, SpriteFont buttonFont) : base(background) { // gives buttons height & width, adds title, makes buttons & gives position in middle of screen buttonHeight = 75; buttons = new Button[numberOfButtons]; buttonAmount = numberOfButtons; base.Add(title); title.attributes.position = new Vector2(512, title.height / 2 + 40); title.attributes.depth = .01f; maxButtonWidth = 0; // makes new buttons, adds heights, adds actions and events for if clicked for (int i = 0; i < numberOfButtons; i++) { buttons[i] = new Button(buttonNames[i], buttonFont, new Vector2(512, title.height + 140 + ((800 - title.height - 80 - buttonHeight) / numberOfButtons) * i), Color.Black); buttons[i].height = buttonHeight; buttons[i].Clicked += buttonActions[i]; buttons[i].Clicked += delegate() { for (int j = 0; j < numberOfButtons; j++) { if (j != i) buttons[j].Remove(); } }; if (buttons[i].width > maxButtonWidth) maxButtonWidth = buttons[i].width; base.Add(buttons[i]); buttons[i].attributes.depth = .01f; } // sets selected button to the top button selected = 0; // initializes menu to off, then turns it on after .5 seconds myState = menuState.Off; keysOff = false; Timer state = new Timer(1); base.Add(state); state.SetTimer(0, .5f, delegate() { myState = menuState.On; }); }
void Start() { me = GetComponent <RectTransform>(); #if MOBILE_INPUT me.sizeDelta = new Vector2(360, me.sizeDelta.y); foreach (LayoutElement child in buttonsGroup.GetComponentsInChildren <LayoutElement>()) { child.minHeight = 60; } #else me.sizeDelta = new Vector2(320, me.sizeDelta.y); foreach (LayoutElement child in transform.GetComponentsInChildren <LayoutElement>()) { child.minHeight = 70; } #endif state = menuState.isIn; inPos = -(me.rect.width / 2); outPos = (me.rect.width / 2); me.anchoredPosition = new Vector2(inPos, 0); }
// overloaded constructor to add buttonheight public Menu(Drawable background, int numberOfButtons, Text title, String[] buttonNames, Button.ClickHandler[] buttonActions, SpriteFont buttonFont, int buttonHeight, bool PAMenuButtonHeight) : base(background) { this.buttonHeight = buttonHeight; buttons = new Button[numberOfButtons]; base.Add(title); title.attributes.position = new Vector2(512, title.height / 2 + 40); title.attributes.depth = .01f; maxButtonWidth = 0; for (int i = 0; i < numberOfButtons; i++) { buttons[i] = new Button(buttonNames[i], buttonFont, new Vector2(512, 550 + (125 * i)), Color.Black); buttons[i].height = 100; buttons[i].Clicked += buttonActions[i]; buttons[i].Clicked += delegate() { for (int j = 0; j < numberOfButtons; j++) { if (j != i) buttons[j].Remove(); } }; if (buttons[i].width > maxButtonWidth) maxButtonWidth = buttons[i].width; base.Add(buttons[i]); buttons[i].attributes.depth = .01f; } selected = 0; myState = menuState.Off; keysOff = false; Timer state = new Timer(1); base.Add(state); state.SetTimer(0, .5f, delegate() { myState = menuState.On; }); }
public void Keyboard_KeyDown(object sender, KeyboardKeyEventArgs e) { if (state != menuState.NEXTMENU) { KeyboardState KeyStates = Keyboard.GetState(); if (KeyStates.IsKeyDown(Key.Down)) { Console.WriteLine("Debug: MainMenuScene({0}) - Key Down", state); if (state == menuState.HIGHSCORES) { state = menuState.SINGLEPLAYER; } else if (state == menuState.SINGLEPLAYER) { state = menuState.MULTIPLAYER; } else if (state == menuState.MULTIPLAYER) { state = menuState.NETWORK; } else if (state == menuState.NETWORK) { state = menuState.EXIT; } else if (state == menuState.EXIT) { state = menuState.HIGHSCORES; } } if (KeyStates.IsKeyDown(Key.Up)) { Console.WriteLine("Debug: MainMenuScene({0}) - Key Up", state); if (state == menuState.HIGHSCORES) { state = menuState.EXIT; } else if (state == menuState.SINGLEPLAYER) { state = menuState.HIGHSCORES; } else if (state == menuState.MULTIPLAYER) { state = menuState.SINGLEPLAYER; } else if (state == menuState.NETWORK) { state = menuState.MULTIPLAYER; } else if (state == menuState.EXIT) { state = menuState.NETWORK; } } if (KeyStates.IsKeyDown(Key.Enter)) { Console.WriteLine("Debug: MainMenuScene({0}) - Enter", state); if (state == menuState.HIGHSCORES) { sceneManager.OpenLeaderboardMenu(); state = menuState.NEXTMENU; } else if (state == menuState.SINGLEPLAYER) { sceneManager.AIScene(); state = menuState.NEXTMENU; } else if (state == menuState.MULTIPLAYER) { sceneManager.StartNewLocalGame(); state = menuState.NEXTMENU; } else if (state == menuState.NETWORK) { sceneManager.ChooseNetwork(); state = menuState.NEXTMENU; } else if (state == menuState.EXIT) { Environment.Exit(0); } } } }
public override void ProcessInput() { switch (currentMenuState) { case menuState.main: if (InputManager.isCombinedDownCombinedStickPressed(player.PlayerNumber)) { switch (currentMainState) { case mainState.resume: currentMainState = mainState.options; // currentMainState = mainState.options; break; case mainState.options: currentMainState = mainState.destruct; break; /*case mainState.vote: currentMainState = mainState.destruct; break;*/ case mainState.destruct: currentMainState = mainState.leave; break; case mainState.leave: currentMainState = mainState.resume; break; } } else if (InputManager.isCombinedUpCombinedStickPressed(player.PlayerNumber)) { switch (currentMainState) { case mainState.resume: currentMainState = mainState.leave; break; case mainState.options: currentMainState = mainState.resume; break; /*case mainState.vote: currentMainState = mainState.vote; break;*/ case mainState.destruct: currentMainState = mainState.options; // currentMainState = mainState.vote; break; case mainState.leave: currentMainState = mainState.destruct; break; } } if (InputManager.isCombinedConfirmPressed(player.PlayerNumber)) { switch (currentMainState) { case mainState.resume: currentMenuState = menuState.main; currentMainState = mainState.resume; player.unpause(); break; case mainState.options: currentMenuState = menuState.options; currentOptionsState = optionsState.controls; break; /*case mainState.vote: currentMainState = mainState.vote; break;*/ case mainState.destruct: currentMenuState = menuState.destruct; currentYesNoState = yesNoState.no; break; case mainState.leave: currentMenuState = menuState.leave; currentYesNoState = yesNoState.no; break; } } else if (InputManager.isCombinedUnconfirmPressed(player.PlayerNumber)) { currentMenuState = menuState.main; currentMainState = mainState.resume; player.unpause(); } else { } break; case menuState.options: if (InputManager.isCombinedDownCombinedStickPressed(player.PlayerNumber)) { switch (currentOptionsState) { case optionsState.controls: currentOptionsState = optionsState.controls; break; } } else if (InputManager.isCombinedUpCombinedStickPressed(player.PlayerNumber)) { switch (currentOptionsState) { case optionsState.controls: currentOptionsState = optionsState.controls; break; } } if (InputManager.isCombinedConfirmPressed(player.PlayerNumber)) { switch (currentOptionsState) { case optionsState.controls: if (!drawingControls) { drawingControls = true; } else { drawingOtherControls = !drawingOtherControls; // Toggle } break; } } else if (InputManager.isCombinedUnconfirmPressed(player.PlayerNumber)) { if (drawingControls) { drawingControls = false; drawingOtherControls = false; } else { currentMenuState = menuState.main; } } else { } break; case menuState.leave: if (InputManager.isCombinedUpCombinedStickPressed(player.PlayerNumber) || InputManager.isCombinedDownCombinedStickPressed(player.PlayerNumber)) { switch (currentYesNoState) { case yesNoState.yes: currentYesNoState = yesNoState.no; break; case yesNoState.no: currentYesNoState = yesNoState.yes; break; } } else { } if (InputManager.isCombinedConfirmPressed(player.PlayerNumber)) { switch (currentYesNoState) { case yesNoState.yes: currentMenuState = menuState.main; currentMainState = mainState.resume; player.unpause(); //Space394Game.GameInstance.decreasePlayers((int)player.PlayerNumber); Space394Game.GameInstance.CurrentScene.ForceReadyToExit(); // Temporary break; case yesNoState.no: currentMenuState = menuState.main; break; } } else if (InputManager.isCombinedUnconfirmPressed(player.PlayerNumber)) { currentMenuState = menuState.main; } else { } break; case menuState.destruct: if (InputManager.isCombinedUpCombinedStickPressed(player.PlayerNumber) || InputManager.isCombinedDownCombinedStickPressed(player.PlayerNumber)) { switch (currentYesNoState) { case yesNoState.yes: currentYesNoState = yesNoState.no; break; case yesNoState.no: currentYesNoState = yesNoState.yes; break; } } else { } if (InputManager.isCombinedConfirmPressed(player.PlayerNumber)) { switch (currentYesNoState) { case yesNoState.yes: currentMenuState = menuState.main; currentMainState = mainState.resume; player.unpause(); if (player.PlayerShip != null) { player.PlayerShip.Health = 0; } else { } break; case yesNoState.no: currentMenuState = menuState.main; break; } } else if (InputManager.isCombinedUnconfirmPressed(player.PlayerNumber)) { currentMenuState = menuState.main; } else { } break; } if (InputManager.isCombinedPausePressed(player.PlayerNumber)) { currentMenuState = menuState.main; currentMainState = mainState.resume; player.unpause(); } else { } }
public void Draw(GameTime gameTime, SpriteBatch spriteBatch) { foo += gameTime.ElapsedGameTime.Milliseconds; gamepadState = GamePad.GetState(PlayerIndex.One); keyBoardState = Keyboard.GetState(); #region MENUENUM spriteBatch.Draw(background, new Rectangle(0, 0, Game1.INSTANCE.GraphicsDevice.Viewport.Width, Game1.INSTANCE.GraphicsDevice.Viewport.Height), Color.White); switch (_buttonPressed) { case buttonsPressed.DEFAULTMENUSTATE: _menuState = menuState.DEFAULT; break; case buttonsPressed.OPTIONSPRESSED: _menuState = menuState.OPTIONS; break; case buttonsPressed.STARTGAMEPRESSED: _menuState = menuState.START; break; case buttonsPressed.CHANGEPLATFORMPRESSED: _menuState = menuState.CHANGEPLATFORM; break; case buttonsPressed.CREDITSPRESSED: _menuState = menuState.CREDITS; break; case buttonsPressed.EXITPRESSED: _menuState = menuState.EXIT; break; } switch (_menuState) { case menuState.START: if (_buttonPressed == buttonsPressed.BACKPRESSED) { _menuState = menuState.DEFAULT; } break; case menuState.OPTIONS: if (_buttonPressed == buttonsPressed.BACKPRESSED) { _menuState = menuState.DEFAULT; } break; case menuState.CREDITS: if (_buttonPressed == buttonsPressed.BACKPRESSED) { _menuState = menuState.DEFAULT; } break; case menuState.CHANGEPLATFORM: if (_buttonPressed == buttonsPressed.BACKPRESSED) { _buttonPressed = buttonsPressed.NONE; _menuState = menuState.START; } break; case menuState.EXIT: if (_buttonPressed == buttonsPressed.BACKPRESSED) { _menuState = menuState.DEFAULT; } break; } switch (_dPadState) { case dPadState.BUTTON1: _buttonSelect = buttonSelect.BUTTON1; break; case dPadState.BUTTON2: _buttonSelect = buttonSelect.BUTTON2; break; case dPadState.BUTTON3: _buttonSelect = buttonSelect.BUTTON3; break; case dPadState.BUTTON4: _buttonSelect = buttonSelect.BUTTON4; break; case dPadState.BUTTON5: _buttonSelect = buttonSelect.BUTTON5; break; case dPadState.BUTTON6: _buttonSelect = buttonSelect.BUTTON6; break; case dPadState.BUTTON7: _buttonSelect = buttonSelect.BUTTON7; break; } #endregion #region DEFAULT if (_menuState == menuState.DEFAULT) { spriteBatch.Draw(_knop, _knop1Position, knopColor); spriteBatch.Draw(_knop, _knop2Position, knopColor); spriteBatch.Draw(_knop, _knop3Position, knopColor); spriteBatch.Draw(_knop, _knop4Position, knopColor); if (_buttonSelect == buttonSelect.BUTTON1) { spriteBatch.Draw(_knop, _knop1Position, knopSelectColor); if (foo >= fooLimit) { if (gamepadState.DPad.Down == ButtonState.Pressed || gamepadState.ThumbSticks.Left.Y <= -0.1) { _dPadState = dPadState.BUTTON2; foo = 0; } else if (gamepadState.DPad.Up == ButtonState.Pressed || gamepadState.ThumbSticks.Left.Y >= 0.1) { _dPadState = dPadState.BUTTON4; foo = 0; } else if (gamepadState.Buttons.A == ButtonState.Pressed) { _buttonPressed = buttonsPressed.STARTGAMEPRESSED; foo = 0; } } if (previousKeyBoardState != keyBoardState) { if (keyBoardState.IsKeyDown(Keys.Down)) { _dPadState = dPadState.BUTTON2; } else if (keyBoardState.IsKeyDown(Keys.Up)) { _dPadState = dPadState.BUTTON4; } else if (keyBoardState.IsKeyDown(Keys.Enter)) { _buttonPressed = buttonsPressed.STARTGAMEPRESSED; } } } else if (_buttonSelect == buttonSelect.BUTTON2) { spriteBatch.Draw(_knop, _knop2Position, knopSelectColor); if (foo >= fooLimit) { if (gamepadState.DPad.Down == ButtonState.Pressed || gamepadState.ThumbSticks.Left.Y <= -0.1) { _dPadState = dPadState.BUTTON3; foo = 0; } else if (gamepadState.DPad.Up == ButtonState.Pressed || gamepadState.ThumbSticks.Left.Y >= 0.1) { _dPadState = dPadState.BUTTON1; foo = 0; } else if (gamepadState.Buttons.A == ButtonState.Pressed) { _buttonPressed = buttonsPressed.OPTIONSPRESSED; _dPadState = dPadState.BUTTON1; foo = 0; } } if (previousKeyBoardState != keyBoardState) { if (keyBoardState.IsKeyDown(Keys.Down)) { _dPadState = dPadState.BUTTON3; } else if (keyBoardState.IsKeyDown(Keys.Up)) { _dPadState = dPadState.BUTTON1; } else if (keyBoardState.IsKeyDown(Keys.Enter)) { _buttonPressed = buttonsPressed.OPTIONSPRESSED; _dPadState = dPadState.BUTTON1; } } } else if (_buttonSelect == buttonSelect.BUTTON3) { spriteBatch.Draw(_knop, _knop3Position, knopSelectColor); if (foo >= fooLimit) { if (gamepadState.DPad.Down == ButtonState.Pressed || gamepadState.ThumbSticks.Left.Y <= -0.1) { _dPadState = dPadState.BUTTON4; foo = 0; } else if (gamepadState.DPad.Up == ButtonState.Pressed || gamepadState.ThumbSticks.Left.Y >= 0.1) { _dPadState = dPadState.BUTTON2; foo = 0; } else if (gamepadState.Buttons.A == ButtonState.Pressed) { _buttonPressed = buttonsPressed.CREDITSPRESSED; _dPadState = dPadState.BUTTON6; foo = 0; } } if (previousKeyBoardState != keyBoardState) { if (keyBoardState.IsKeyDown(Keys.Down)) { _dPadState = dPadState.BUTTON4; } else if (keyBoardState.IsKeyDown(Keys.Up)) { _dPadState = dPadState.BUTTON2; } else if (keyBoardState.IsKeyDown(Keys.Enter)) { _buttonPressed = buttonsPressed.CREDITSPRESSED; _dPadState = dPadState.BUTTON6; } } } else if (_buttonSelect == buttonSelect.BUTTON4) { spriteBatch.Draw(_knop, _knop4Position, knopSelectColor); if (foo >= fooLimit) { if (gamepadState.DPad.Down == ButtonState.Pressed || gamepadState.ThumbSticks.Left.Y <= -0.1) { _dPadState = dPadState.BUTTON1; foo = 0; } else if (gamepadState.DPad.Up == ButtonState.Pressed || gamepadState.ThumbSticks.Left.Y >= 0.1) { _dPadState = dPadState.BUTTON3; foo = 0; } else if (gamepadState.Buttons.A == ButtonState.Pressed) { _buttonPressed = buttonsPressed.EXITPRESSED; _dPadState = dPadState.BUTTON2; foo = 0; } } if (previousKeyBoardState != keyBoardState) { if (keyBoardState.IsKeyDown(Keys.Down)) { _dPadState = dPadState.BUTTON1; } else if (keyBoardState.IsKeyDown(Keys.Up)) { _dPadState = dPadState.BUTTON3; } else if (keyBoardState.IsKeyDown(Keys.Enter)) { _buttonPressed = buttonsPressed.EXITPRESSED; _dPadState = dPadState.BUTTON2; } } } if (foo >= fooLimit) { if (gamepadState.Buttons.B == ButtonState.Pressed) { _buttonPressed = buttonsPressed.EXITPRESSED; _dPadState = dPadState.BUTTON2; foo = 0; } } spriteBatch.DrawString(menuSpriteFont, "Start New Game", _text1Position, textColor); spriteBatch.DrawString(menuSpriteFont, "Options", _text2Position, textColor); spriteBatch.DrawString(menuSpriteFont, "About us", _text3Position, textColor); spriteBatch.DrawString(menuSpriteFont, "Exit", _text4Position, textColor); } #endregion #region STARTGAME else if (_menuState == menuState.START) { spriteBatch.Draw(_knop, _knop1Position, knopColor); spriteBatch.Draw(_knopArrows, _knop2Position, knopColor); spriteBatch.Draw(_knopArrows, _knop3Position, knopColor); spriteBatch.Draw(_knopArrows, _knop4Position, knopColor); spriteBatch.Draw(_knop, _knop5Position, knopColor); fragString = fragLimit.ToString(); timeString = timeLimit.ToString(); if (fragLimit >= 0 && fragLimit < 10) { _frags = 1; } else if (fragLimit >= 10 && fragLimit < 30) { _frags = 5; } else if (fragLimit >= 30) { _frags = 10; } if (fragLimit > 100) { fragLimit = 0; } else if (fragLimit < 0) { fragLimit = 100; } if (timeLimit >= 0 && timeLimit < 10) { _time = 1; } if (timeLimit >= 10 && timeLimit < 30) { _time = 5; } else if (timeLimit >= 30) { _time = 10; } if (timeLimit > 100) { timeLimit = 0; } else if (timeLimit < 0) { timeLimit = 100; } if (fragLimit == 0) { fragString = "Infinite"; } if (timeLimit == 0) { timeString = "Infinite"; } if (_buttonSelect == buttonSelect.BUTTON1) { spriteBatch.Draw(_knop, _knop1Position, knopSelectColor); if (foo >= fooLimit) { if (gamepadState.DPad.Down == ButtonState.Pressed || gamepadState.ThumbSticks.Left.Y <= -0.1) { _dPadState = dPadState.BUTTON2; foo = 0; } else if (gamepadState.DPad.Up == ButtonState.Pressed || gamepadState.ThumbSticks.Left.Y >= 0.1) { _dPadState = dPadState.BUTTON5; foo = 0; } else if (gamepadState.Buttons.A == ButtonState.Pressed) { _buttonPressed = buttonsPressed.CHANGEPLATFORMPRESSED; _dPadState = dPadState.BUTTON5; foo = 0; } } if (previousKeyBoardState != keyBoardState) { if (keyBoardState.IsKeyDown(Keys.Down)) { _dPadState = dPadState.BUTTON2; } else if (keyBoardState.IsKeyDown(Keys.Up)) { _dPadState = dPadState.BUTTON5; } else if (keyBoardState.IsKeyDown(Keys.Enter)) { _buttonPressed = buttonsPressed.CHANGEPLATFORMPRESSED; _dPadState = dPadState.BUTTON5; } } } else if (_buttonSelect == buttonSelect.BUTTON2) { spriteBatch.Draw(_knopArrows, _knop2Position, knopSelectColor); if (foo >= fooLimit) { if (gamepadState.DPad.Down == ButtonState.Pressed || gamepadState.ThumbSticks.Left.Y <= -0.1) { _dPadState = dPadState.BUTTON3; foo = 0; } else if (gamepadState.DPad.Up == ButtonState.Pressed || gamepadState.ThumbSticks.Left.Y >= 0.1) { _dPadState = dPadState.BUTTON1; foo = 0; } else if (gamepadState.DPad.Left == ButtonState.Pressed || gamepadState.ThumbSticks.Left.X <= -0.1) { if (numPlayers > 2) { numPlayers--; } foo = 0; } else if (gamepadState.DPad.Right == ButtonState.Pressed || gamepadState.ThumbSticks.Left.X >= 0.1) { if (numPlayers < 4) { numPlayers++; } foo = 0; } } if (previousKeyBoardState != keyBoardState) { if (keyBoardState.IsKeyDown(Keys.Down)) { _dPadState = dPadState.BUTTON3; } else if (keyBoardState.IsKeyDown(Keys.Up)) { _dPadState = dPadState.BUTTON1; } if (keyBoardState.IsKeyDown(Keys.Left)) { if (numPlayers > 2) numPlayers--; } else if (keyBoardState.IsKeyDown(Keys.Right)) { if (numPlayers < 4) numPlayers++; } } } else if (_buttonSelect == buttonSelect.BUTTON3) { spriteBatch.Draw(_knopArrows, _knop3Position, knopSelectColor); if (foo >= fooLimit) { if (gamepadState.DPad.Down == ButtonState.Pressed || gamepadState.ThumbSticks.Left.Y <= -0.1) { _dPadState = dPadState.BUTTON4; foo = 0; } else if (gamepadState.DPad.Up == ButtonState.Pressed || gamepadState.ThumbSticks.Left.Y >= 0.1) { _dPadState = dPadState.BUTTON2; foo = 0; } else if (gamepadState.DPad.Left == ButtonState.Pressed || gamepadState.ThumbSticks.Left.X <= -0.1) { if (fragLimit == 30) { _frags = 5; } else if (fragLimit == 10) { _frags = 1; } fragLimit -= _frags; foo = 0; } else if (gamepadState.DPad.Right == ButtonState.Pressed || gamepadState.ThumbSticks.Left.X >= 0.1) { fragLimit += _frags; foo = 0; } } if (previousKeyBoardState != keyBoardState) { if (keyBoardState.IsKeyDown(Keys.Down)) { _dPadState = dPadState.BUTTON4; } else if (keyBoardState.IsKeyDown(Keys.Up)) { _dPadState = dPadState.BUTTON2; } if (keyBoardState.IsKeyDown(Keys.Left)) { fragLimit -= _frags; } else if (keyBoardState.IsKeyDown(Keys.Right)) { fragLimit += _frags; } } } else if (_buttonSelect == buttonSelect.BUTTON4) { spriteBatch.Draw(_knopArrows, _knop4Position, knopSelectColor); if (foo >= fooLimit) { if (gamepadState.DPad.Down == ButtonState.Pressed || gamepadState.ThumbSticks.Left.Y <= -0.1) { _dPadState = dPadState.BUTTON5; foo = 0; } else if (gamepadState.DPad.Up == ButtonState.Pressed || gamepadState.ThumbSticks.Left.Y >= 0.1) { _dPadState = dPadState.BUTTON3; foo = 0; } else if (gamepadState.DPad.Left == ButtonState.Pressed || gamepadState.ThumbSticks.Left.X <= -0.1) { if (timeLimit == 30) { _time = 5; } else if (timeLimit == 10) { _time = 1; } timeLimit -= _time; foo = 0; } else if (gamepadState.DPad.Right == ButtonState.Pressed || gamepadState.ThumbSticks.Left.X >= 0.1) { timeLimit += _time; foo = 0; } } if (previousKeyBoardState != keyBoardState) { if (keyBoardState.IsKeyDown(Keys.Down)) { _dPadState = dPadState.BUTTON5; } else if (keyBoardState.IsKeyDown(Keys.Up)) { _dPadState = dPadState.BUTTON3; } if (keyBoardState.IsKeyDown(Keys.Left)) { timeLimit -= _time; } else if (keyBoardState.IsKeyDown(Keys.Right)) { timeLimit += _time; } } } else if (_buttonSelect == buttonSelect.BUTTON5) { spriteBatch.Draw(_knop, _knop5Position, knopSelectColor); if (foo >= fooLimit) { if (gamepadState.DPad.Down == ButtonState.Pressed || gamepadState.ThumbSticks.Left.Y <= -0.1) { _dPadState = dPadState.BUTTON1; foo = 0; } else if (gamepadState.DPad.Up == ButtonState.Pressed || gamepadState.ThumbSticks.Left.Y >= 0.1) { _dPadState = dPadState.BUTTON4; foo = 0; } else if (gamepadState.Buttons.A == ButtonState.Pressed) { _buttonPressed = buttonsPressed.BACKPRESSED; _dPadState = dPadState.BUTTON1; foo = 0; } } if (previousKeyBoardState != keyBoardState) { if (keyBoardState.IsKeyDown(Keys.Down)) { _dPadState = dPadState.BUTTON1; } else if (keyBoardState.IsKeyDown(Keys.Up)) { _dPadState = dPadState.BUTTON4; } else if (keyBoardState.IsKeyDown(Keys.Enter)) { _buttonPressed = buttonsPressed.BACKPRESSED; _dPadState = dPadState.BUTTON1; } } } if (foo >= fooLimit) { if (gamepadState.Buttons.B == ButtonState.Pressed) { _buttonPressed = buttonsPressed.BACKPRESSED; _dPadState = dPadState.BUTTON1; foo = 0; } } spriteBatch.DrawString(menuSpriteFont, "Start new Game", _menuWindowPosition, textColor); spriteBatch.DrawString(menuSpriteFont, "Start Game", _text1Position, textColor); spriteBatch.DrawString(menuSpriteFont, "Players : " + numPlayers, _text2Position, textColor); spriteBatch.DrawString(menuSpriteFont, "Frag Limit: " + fragString, _text3Position, textColor); if (timeLimit != 0) { spriteBatch.DrawString(menuSpriteFont, "Time Limit: " + timeString + " mins.", _text4Position, textColor); } else { spriteBatch.DrawString(menuSpriteFont, "Time Limit: " + timeString, _text4Position, textColor); } spriteBatch.DrawString(menuSpriteFont, "Back", _text5Position, textColor); } #endregion #region CHANGEMAP else if (_menuState == menuState.CHANGEPLATFORM) { spriteBatch.DrawString(menuSpriteFont, "Change Map", _menuWindowPosition, textColor); levels = Directory.GetFiles("Maps"); if (maps > levels.Length - 1) { maps = 0; } else if (maps < 0) { maps = levels.Length - 1; } string mapName = levels[maps]; levelName = mapName; int first = mapName.IndexOf("\\"); mapName = mapName.Remove(0, first + 1); int last = mapName.IndexOf("."); mapName = mapName.Remove(last, 4); //Create an filestream. FileStream fstream = new FileStream(levelName, FileMode.Open, FileAccess.Read); byte[] filecontent = new byte[fstream.Length]; //Create an array to put our data in. string[][] leveldata = new string[filecontent.Length][]; //Read the file and put data in the filecontent. for (int i = 0; i < fstream.Length; i++) { fstream.Read(filecontent, i, 1); } //Split up the file in "words". int currentAt = 0; int currentAt2 = 0; for (int i = 0; i < filecontent.Length; i++) { if (leveldata[currentAt] == null) { leveldata[currentAt] = new string[255]; } if ((char)filecontent[i] == ' ') { currentAt2++; } else if ((char)filecontent[i] == (char)10) { currentAt2 = 0; currentAt++; } else { leveldata[currentAt][currentAt2] += (char)filecontent[i]; } } //Go through every data in leveldata. for (int i = 0; i < leveldata.Length; ++i) { if (leveldata[i] != null) { if (leveldata[i][0].Contains("background:")) { mapTex = Game1.INSTANCE.Content.Load<Texture2D>("Images/Maps/" + leveldata[i][1]); } } } spriteBatch.Draw(mapTex, _mapsPosition, Color.White); spriteBatch.Draw(_knopArrows, _knop5Position, knopColor); spriteBatch.Draw(_knop, _knop6Position, knopColor); spriteBatch.Draw(_knop, _knop7Position, knopColor); if (_buttonSelect == buttonSelect.BUTTON5) { spriteBatch.Draw(_knopArrows, _knop5Position, knopSelectColor); if (foo >= fooLimit) { if (gamepadState.DPad.Down == ButtonState.Pressed || gamepadState.ThumbSticks.Left.Y <= -0.1) { _dPadState = dPadState.BUTTON6; foo = 0; } else if (gamepadState.DPad.Up == ButtonState.Pressed || gamepadState.ThumbSticks.Left.Y >= 0.1) { _dPadState = dPadState.BUTTON7; foo = 0; } else if (gamepadState.DPad.Left == ButtonState.Pressed || gamepadState.ThumbSticks.Left.X <= -0.1) { maps--; foo = 0; } else if (gamepadState.DPad.Right == ButtonState.Pressed || gamepadState.ThumbSticks.Left.X >= 0.1) { maps++; foo = 0; } } if (previousKeyBoardState != keyBoardState) { if (keyBoardState.IsKeyDown(Keys.Down)) { _dPadState = dPadState.BUTTON6; } else if (keyBoardState.IsKeyDown(Keys.Up)) { _dPadState = dPadState.BUTTON7; } else if (keyBoardState.IsKeyDown(Keys.Left)) { maps--; } else if (keyBoardState.IsKeyDown(Keys.Right)) { maps++; } } } else if (_buttonSelect == buttonSelect.BUTTON6) { spriteBatch.Draw(_knop, _knop6Position, knopSelectColor); if (foo >= fooLimit) { if (gamepadState.DPad.Down == ButtonState.Pressed || gamepadState.ThumbSticks.Left.Y <= -0.1) { _dPadState = dPadState.BUTTON7; foo = 0; } else if (gamepadState.DPad.Up == ButtonState.Pressed || gamepadState.ThumbSticks.Left.Y >= 0.1) { _dPadState = dPadState.BUTTON5; foo = 0; } else if (gamepadState.Buttons.A == ButtonState.Pressed) { audio.StopMusic(); startGame = true; foo = 0; } } if (previousKeyBoardState != keyBoardState) { if (keyBoardState.IsKeyDown(Keys.Down)) { _dPadState = dPadState.BUTTON7; } else if (keyBoardState.IsKeyDown(Keys.Up)) { _dPadState = dPadState.BUTTON5; } else if (keyBoardState.IsKeyDown(Keys.Enter)) { audio.StopMusic(); startGame = true; } } } else if (_buttonSelect == buttonSelect.BUTTON7) { spriteBatch.Draw(_knop, _knop7Position, knopSelectColor); if (foo >= fooLimit) { if (gamepadState.DPad.Down == ButtonState.Pressed || gamepadState.ThumbSticks.Left.Y <= -0.1) { _dPadState = dPadState.BUTTON5; foo = 0; } else if (gamepadState.DPad.Up == ButtonState.Pressed || gamepadState.ThumbSticks.Left.Y >= 0.1) { _dPadState = dPadState.BUTTON6; foo = 0; } else if (gamepadState.Buttons.A == ButtonState.Pressed) { _buttonPressed = buttonsPressed.BACKPRESSED; _dPadState = dPadState.BUTTON1; foo = 0; } } if (previousKeyBoardState != keyBoardState) { if (keyBoardState.IsKeyDown(Keys.Down)) { _dPadState = dPadState.BUTTON5; } else if (keyBoardState.IsKeyDown(Keys.Up)) { _dPadState = dPadState.BUTTON6; } else if (keyBoardState.IsKeyDown(Keys.Enter)) { _buttonPressed = buttonsPressed.BACKPRESSED; _dPadState = dPadState.BUTTON1; foo = 0; } } } if (foo >= fooLimit) { if (gamepadState.Buttons.B == ButtonState.Pressed) { _buttonPressed = buttonsPressed.BACKPRESSED; _dPadState = dPadState.BUTTON1; foo = 0; } } spriteBatch.DrawString(menuSpriteFont, mapName, _text5Position, textColor); spriteBatch.DrawString(menuSpriteFont, "Start Game", _text6Position, textColor); spriteBatch.DrawString(menuSpriteFont, "Back", _text7Position, textColor); } #endregion #region OPTIONS else if (_menuState == menuState.OPTIONS) { spriteBatch.DrawString(menuSpriteFont, "Options", _menuWindowPosition, textColor); spriteBatch.Draw(_knop, _knop1Position, Color.White); spriteBatch.Draw(_knop, _knop2Position, Color.White); spriteBatch.Draw(_knopArrows, _knop3Position, Color.White); spriteBatch.Draw(_knopArrows, _knop4Position, Color.White); spriteBatch.Draw(_knop, _knop5Position, Color.White); if (musicVol <= 0) { _music = "OFF"; } else { _music = "ON"; } if (soundVol <= 0) { _sound = "OFF"; } else { _sound = "ON"; } if (_dPadState == dPadState.BUTTON1) { spriteBatch.Draw(_knop, _knop1Position, knopSelectColor); if (foo >= fooLimit) { if (gamepadState.DPad.Down == ButtonState.Pressed || gamepadState.ThumbSticks.Left.Y <= -0.1) { _dPadState = dPadState.BUTTON2; foo = 0; } else if (gamepadState.DPad.Up == ButtonState.Pressed || gamepadState.ThumbSticks.Left.Y >= 0.1) { _dPadState = dPadState.BUTTON5; foo = 0; } else if (gamepadState.Buttons.A == ButtonState.Pressed) { if (_music == "ON") { _music = "OFF"; musicVol = 0; } else { _music = "ON"; musicVol = 1; } foo = 0; } } if (previousKeyBoardState != keyBoardState) { if (keyBoardState.IsKeyDown(Keys.Down)) { _dPadState = dPadState.BUTTON2; } else if (keyBoardState.IsKeyDown(Keys.Up)) { _dPadState = dPadState.BUTTON5; } else if (keyBoardState.IsKeyDown(Keys.Enter)) { if (_music == "ON") { _music = "OFF"; musicVol = 0; } else { _music = "ON"; musicVol = 1; } } } } else if (_dPadState == dPadState.BUTTON2) { spriteBatch.Draw(_knop, _knop2Position, knopSelectColor); if (foo >= fooLimit) { if (gamepadState.DPad.Down == ButtonState.Pressed || gamepadState.ThumbSticks.Left.Y <= -0.1) { _dPadState = dPadState.BUTTON3; foo = 0; } else if (gamepadState.DPad.Up == ButtonState.Pressed || gamepadState.ThumbSticks.Left.Y >= 0.1) { _dPadState = dPadState.BUTTON1; foo = 0; } else if (gamepadState.Buttons.A == ButtonState.Pressed) { if (_sound == "ON") { _sound = "OFF"; soundVol = 0; } else { _sound = "ON"; soundVol = 1; } foo = 0; } } if (previousKeyBoardState != keyBoardState) { if (keyBoardState.IsKeyDown(Keys.Down)) { _dPadState = dPadState.BUTTON3; } else if (keyBoardState.IsKeyDown(Keys.Up)) { _dPadState = dPadState.BUTTON1; } else if (keyBoardState.IsKeyDown(Keys.Enter)) { if (_sound == "ON") { _sound = "OFF"; soundVol = 0; } else { _sound = "ON"; soundVol = 1; } } } } else if (_dPadState == dPadState.BUTTON3) { spriteBatch.Draw(_knopArrows, _knop3Position, knopSelectColor); if (foo >= fooLimit) { if (gamepadState.DPad.Down == ButtonState.Pressed || gamepadState.ThumbSticks.Left.Y <= -0.1) { _dPadState = dPadState.BUTTON4; foo = 0; } else if (gamepadState.DPad.Up == ButtonState.Pressed || gamepadState.ThumbSticks.Left.Y >= 0.1) { _dPadState = dPadState.BUTTON2; foo = 0; } else if (gamepadState.DPad.Left == ButtonState.Pressed || gamepadState.ThumbSticks.Left.X <= -0.1) { if (musicVol > 0) { musicVol -= 0.1f; } foo = 0; } else if (gamepadState.DPad.Right == ButtonState.Pressed || gamepadState.ThumbSticks.Left.X >= 0.1) { if (musicVol < 1) { musicVol += 0.1f; } foo = 0; } } if (previousKeyBoardState != keyBoardState) { if (keyBoardState.IsKeyDown(Keys.Down)) { _dPadState = dPadState.BUTTON4; } else if (keyBoardState.IsKeyDown(Keys.Up)) { _dPadState = dPadState.BUTTON2; } else if (keyBoardState.IsKeyDown(Keys.Left)) { if (musicVol > 0) { musicVol -= 0.1f; } } else if (keyBoardState.IsKeyDown(Keys.Right)) { if (musicVol < 1) { musicVol += 0.1f; } } } } else if (_dPadState == dPadState.BUTTON4) { spriteBatch.Draw(_knopArrows, _knop4Position, knopSelectColor); if (foo >= fooLimit) { if (gamepadState.DPad.Down == ButtonState.Pressed || gamepadState.ThumbSticks.Left.Y <= -0.1) { _dPadState = dPadState.BUTTON5; foo = 0; } else if (gamepadState.DPad.Up == ButtonState.Pressed || gamepadState.ThumbSticks.Left.Y >= 0.1) { _dPadState = dPadState.BUTTON3; foo = 0; } else if (gamepadState.DPad.Left == ButtonState.Pressed || gamepadState.ThumbSticks.Left.X <= -0.1) { if (soundVol > 0) { soundVol -= 0.1f; } foo = 0; } else if (gamepadState.DPad.Right == ButtonState.Pressed || gamepadState.ThumbSticks.Left.X >= 0.1) { if (soundVol < 1) { soundVol += 0.1f; } foo = 0; } } if (previousKeyBoardState != keyBoardState) { if (keyBoardState.IsKeyDown(Keys.Down)) { _dPadState = dPadState.BUTTON5; } else if (keyBoardState.IsKeyDown(Keys.Up)) { _dPadState = dPadState.BUTTON3; } else if (keyBoardState.IsKeyDown(Keys.Left)) { if (soundVol > 0) { soundVol -= 0.1f; } } else if (keyBoardState.IsKeyDown(Keys.Right)) { if (soundVol < 1) { soundVol += 0.1f; } } } } else if (_dPadState == dPadState.BUTTON5) { spriteBatch.Draw(_knop, _knop5Position, knopSelectColor); if (foo >= fooLimit) { if (gamepadState.DPad.Down == ButtonState.Pressed || gamepadState.ThumbSticks.Left.Y <= -0.1) { _dPadState = dPadState.BUTTON1; foo = 0; } else if (gamepadState.DPad.Up == ButtonState.Pressed || gamepadState.ThumbSticks.Left.Y >= 0.1) { _dPadState = dPadState.BUTTON4; foo = 0; } else if (gamepadState.Buttons.A == ButtonState.Pressed) { _buttonPressed = buttonsPressed.BACKPRESSED; _dPadState = dPadState.BUTTON2; foo = 0; } } if (previousKeyBoardState != keyBoardState) { if (keyBoardState.IsKeyDown(Keys.Down)) { _dPadState = dPadState.BUTTON1; } else if (keyBoardState.IsKeyDown(Keys.Up)) { _dPadState = dPadState.BUTTON4; } else if (keyBoardState.IsKeyDown(Keys.Enter)) { _buttonPressed = buttonsPressed.BACKPRESSED; _dPadState = dPadState.BUTTON2; } } } if (foo >= fooLimit) { if (gamepadState.Buttons.B == ButtonState.Pressed) { _buttonPressed = buttonsPressed.BACKPRESSED; _dPadState = dPadState.BUTTON2; foo = 0; } } spriteBatch.DrawString(menuSpriteFont, "Music: " + _music, _text1Position, textColor); spriteBatch.DrawString(menuSpriteFont, "Sound: " + _sound, _text2Position, textColor); spriteBatch.DrawString(menuSpriteFont, "Musicvolume: " + (int)(musicVol * 100) + "%", _text3Position, textColor); spriteBatch.DrawString(menuSpriteFont, "Soundvolume: " + (int)(soundVol * 100) + "%", _text4Position, textColor); spriteBatch.DrawString(menuSpriteFont, "Back", _text5Position, textColor); audio.setMusicVolume(musicVol); } #endregion #region CREDITS else if (_menuState == menuState.CREDITS) { spriteBatch.DrawString(menuSpriteFont, "Credits", _menuWindowPosition, textColor); _names = Directory.GetFiles("Content\\Images\\Photos"); if (nameInt > _names.Length - 1) { nameInt = 0; } else if (nameInt < 0) { nameInt = _names.Length - 1; } string creditName = _names[nameInt]; names = creditName; int first = creditName.IndexOf("Images\\Photos\\"); creditName = creditName.Remove(0, first + 14); int last = creditName.IndexOf("."); creditName = creditName.Remove(last, 4); for (int i = 0; i < names.Length; i++) { photos = Game1.INSTANCE.Content.Load<Texture2D>("Images\\Photos\\" + creditName); } spriteBatch.Draw(photos, _mapsPosition, Color.White); spriteBatch.Draw(_knopArrows, _knop6Position, knopColor); spriteBatch.Draw(_knop, _knop7Position, knopColor); if (_buttonSelect == buttonSelect.BUTTON6) { spriteBatch.Draw(_knopArrows, _knop6Position, knopSelectColor); if (foo >= fooLimit) { if (gamepadState.DPad.Down == ButtonState.Pressed || gamepadState.ThumbSticks.Left.Y <= -0.1) { _dPadState = dPadState.BUTTON7; foo = 0; } else if (gamepadState.DPad.Up == ButtonState.Pressed || gamepadState.ThumbSticks.Left.Y >= 0.1) { _dPadState = dPadState.BUTTON7; foo = 0; } else if (gamepadState.DPad.Left == ButtonState.Pressed || gamepadState.ThumbSticks.Left.X <= -0.1) { nameInt--; foo = 0; } else if (gamepadState.DPad.Right == ButtonState.Pressed || gamepadState.ThumbSticks.Left.X >= 0.1) { nameInt++; foo = 0; } } if (previousKeyBoardState != keyBoardState) { if (keyBoardState.IsKeyDown(Keys.Down)) { _dPadState = dPadState.BUTTON7; } else if (keyBoardState.IsKeyDown(Keys.Up)) { _dPadState = dPadState.BUTTON7; } else if (keyBoardState.IsKeyDown(Keys.Left)) { nameInt--; } else if (keyBoardState.IsKeyDown(Keys.Right)) { nameInt++; } } } else if (_buttonSelect == buttonSelect.BUTTON7) { spriteBatch.Draw(_knop, _knop7Position, knopSelectColor); if (foo >= fooLimit) { if (gamepadState.DPad.Down == ButtonState.Pressed || gamepadState.ThumbSticks.Left.Y <= -0.1) { _dPadState = dPadState.BUTTON6; foo = 0; } else if (gamepadState.DPad.Up == ButtonState.Pressed || gamepadState.ThumbSticks.Left.Y >= 0.1) { _dPadState = dPadState.BUTTON6; foo = 0; } else if (gamepadState.Buttons.A == ButtonState.Pressed) { _buttonPressed = buttonsPressed.BACKPRESSED; _dPadState = dPadState.BUTTON1; foo = 0; } } if (previousKeyBoardState != keyBoardState) { if (keyBoardState.IsKeyDown(Keys.Down)) { _dPadState = dPadState.BUTTON6; } else if (keyBoardState.IsKeyDown(Keys.Up)) { _dPadState = dPadState.BUTTON6; } else if (keyBoardState.IsKeyDown(Keys.Enter)) { _buttonPressed = buttonsPressed.BACKPRESSED; _dPadState = dPadState.BUTTON1; foo = 0; } } } string taak = "Blaat"; Vector2 textOffset = new Vector2(); switch (creditName) { case "Daan": taak = "Designer"; break; case "Erwin": taak = "Project Leader"; break; case "Gerjo": taak = "Programmer&Graphic Design"; textOffset = new Vector2(90, 0); break; case "Jur": taak = "Programmer"; break; case "Robby": taak = "Programmer"; break; case "Sander": taak = "Lead Programmer"; break; case "Stephan": taak = "Designer & Audio Design"; textOffset = new Vector2(40, 0); break; } if (foo >= fooLimit) { if (gamepadState.Buttons.B == ButtonState.Pressed) { _buttonPressed = buttonsPressed.BACKPRESSED; _dPadState = dPadState.BUTTON1; foo = 0; } } spriteBatch.DrawString(menuSpriteFont, taak, _text1Position - textOffset, textColor); spriteBatch.DrawString(menuSpriteFont, creditName, _text6Position, textColor); spriteBatch.DrawString(menuSpriteFont, "Back", _text7Position, textColor); } #endregion #region EXITGAME else if (_menuState == menuState.EXIT) { spriteBatch.Draw(_knop, _knop1Position, knopColor); spriteBatch.Draw(_knop, _knop2Position, knopColor); if (_buttonSelect == buttonSelect.BUTTON1) { spriteBatch.Draw(_knop, _knop1Position, knopSelectColor); if (foo >= fooLimit) { if (gamepadState.DPad.Down == ButtonState.Pressed || gamepadState.ThumbSticks.Left.Y <= -0.1) { _dPadState = dPadState.BUTTON2; foo = 0; } else if (gamepadState.DPad.Up == ButtonState.Pressed || gamepadState.ThumbSticks.Left.Y >= 0.1) { _dPadState = dPadState.BUTTON2; foo = 0; } else if (gamepadState.Buttons.A == ButtonState.Pressed) { Game1.INSTANCE.Exit(); } } if (previousKeyBoardState != keyBoardState) { if (keyBoardState.IsKeyDown(Keys.Up)) { _dPadState = dPadState.BUTTON2; } else if (keyBoardState.IsKeyDown(Keys.Down)) { _dPadState = dPadState.BUTTON2; } else if (keyBoardState.IsKeyDown(Keys.Enter)) { Game1.INSTANCE.Exit(); } } } else if (_buttonSelect == buttonSelect.BUTTON2) { spriteBatch.Draw(_knop, _knop2Position, knopSelectColor); if (foo >= fooLimit) { if (gamepadState.DPad.Down == ButtonState.Pressed || gamepadState.ThumbSticks.Left.Y <= -0.1) { _dPadState = dPadState.BUTTON1; foo = 0; } else if (gamepadState.DPad.Up == ButtonState.Pressed || gamepadState.ThumbSticks.Left.Y >= 0.1) { _dPadState = dPadState.BUTTON1; foo = 0; } else if (gamepadState.Buttons.A == ButtonState.Pressed) { _buttonPressed = buttonsPressed.BACKPRESSED; _dPadState = dPadState.BUTTON2; foo = 0; } } if (previousKeyBoardState != keyBoardState) { if (keyBoardState.IsKeyDown(Keys.Up)) { _dPadState = dPadState.BUTTON1; } else if (keyBoardState.IsKeyDown(Keys.Down)) { _dPadState = dPadState.BUTTON1; } else if (keyBoardState.IsKeyDown(Keys.Enter)) { _buttonPressed = buttonsPressed.BACKPRESSED; _dPadState = dPadState.BUTTON2; } } } if (foo >= fooLimit) { if (gamepadState.Buttons.B == ButtonState.Pressed) { _buttonPressed = buttonsPressed.BACKPRESSED; _dPadState = dPadState.BUTTON4; foo = 0; } } spriteBatch.DrawString(menuSpriteFont, "Exit. Are you sure?", _menuWindowPosition, textColor); spriteBatch.DrawString(menuSpriteFont, "Yes", _text1Position, textColor); spriteBatch.DrawString(menuSpriteFont, "NO", _text2Position, textColor); } #endregion previousKeyBoardState = keyBoardState; }
//IEnumerator because needs yield return to check for errors in creating account IEnumerator ShowSignupGUI() { GUILayout.BeginArea(new Rect((Screen.width - 400) / 2, (Screen.height - 300) / 2, 400, 300)); GUILayout.Label("Sign Up"); GUILayout.BeginHorizontal(); GUILayout.Label("Email:", GUILayout.Width(150)); emailInput = GUILayout.TextField(emailInput); GUILayout.Label("@", GUILayout.Width(20)); email2Input = GUILayout.TextField(email2Input); GUILayout.Label(".com"); GUILayout.EndHorizontal(); GUILayout.Space(15); GUILayout.BeginHorizontal(); GUILayout.Label("Nickname:", GUILayout.Width(150)); nickInput = GUILayout.TextField(nickInput); GUILayout.EndHorizontal(); GUILayout.Space(15); GUILayout.BeginHorizontal(); GUILayout.Label("Password:"******"*"[0], 15); GUILayout.EndHorizontal(); GUILayout.Space(15); GUILayout.BeginHorizontal(); GUILayout.Label("Confirm Password:"******"*"[0], 15); GUILayout.EndHorizontal(); GUILayout.Space(20); GUILayout.BeginHorizontal(); //GUILayout.Width(120); if (GUILayout.Button("Create!", GUILayout.Width(200))) { if(pass1Input != pass2Input){ print("Passwords do not match!"); } else{ email3Input = emailInput + "@"+ email2Input + ".com"; yield return StartCoroutine(UserDatabase.signUp(email3Input, nickInput, pass1Input)); if(userTally){ PhotonNetwork.playerName = nickInput; levelSelected = maxLevelData; currentMenuState = menuState.profile; } } } if (GUILayout.Button("Cancel", GUILayout.Width(200))){ pass1Input = ""; pass2Input = ""; currentMenuState = menuState.login; } GUILayout.EndHorizontal(); GUILayout.EndArea(); }
// Update is called once per frame void Update() { bool isLight = digTest.turnedOn; if(isLight){ timer-=Time.deltaTime; } else if(!isLight){ float tempTimer = timer; timer= tempTimer; } if(timer<=0) Application.LoadLevel("EndMenu"); if(Input.GetKey(KeyCode.M)&&canToggle) { if(state==menuState.off) { state=menuState.isMenu; show=true; } else { show=false; state=menuState.off; } canToggle=false; } if(Input.GetKey(KeyCode.P)&&canToggle) { if(state==menuState.off) { state=menuState.isPause; show=true; } else { show=false; state=menuState.off; } canToggle=false; } if(Input.GetKey(KeyCode.J)&&canToggle) { if(state==menuState.off) { state=menuState.isJournal; show=true; } else { state=menuState.off; show=false; } canToggle=false; } if((!Input.GetKey(KeyCode.M)) && (!Input.GetKey(KeyCode.P)) && (!Input.GetKey(KeyCode.J))) { canToggle=true; } }
public void Room() { //Patient is where you write your room code if (state == menuState.room) return; onSave(); menuManager.Instance.input.characterValidation = InputField.CharacterValidation.Integer; menuManager.Instance.input.characterLimit = 8; state = menuState.room; menuManager.Instance.input.text = PlayerPrefs.GetString("roomCode"); menuManager.Instance.animator.Play(Animator.StringToHash("playerRoom"), -1, 0); soundManager.playSound(soundManager.soundList["decline1"], false, 3f); }
//IEnumerator because needs yield return to check for errors in login IEnumerator ShowLoginGUI() { GUILayout.BeginArea(new Rect((Screen.width - 400) / 2, (Screen.height - 300) / 2, 400, 300)); GUILayout.Label("Log In"); //Player name input GUILayout.BeginHorizontal(); GUILayout.Label("Username", GUILayout.Width(150)); PhotonNetwork.playerName = GUILayout.TextField(PhotonNetwork.playerName); if (GUI.changed) PlayerPrefs.SetString("playerName", PhotonNetwork.playerName); GUILayout.EndHorizontal(); GUILayout.Space(15); //Player password input GUILayout.BeginHorizontal(); GUILayout.Label("Password:"******"*"[0], 15); GUILayout.EndHorizontal(); GUILayout.Space(20); //Log in or create new account GUILayout.BeginHorizontal(); if (GUILayout.Button("Create New Account", GUILayout.Width(200))) { //StartCoroutine(UserDatabase.getData("qq", "qq", "email")); tested getData() works, delete this testing line soon pass1Input = ""; currentMenuState = menuState.signup; } if (GUILayout.Button("GO", GUILayout.Width(200))) { yield return StartCoroutine(UserDatabase.login(PhotonNetwork.playerName, pass1Input)); if(userTally) currentMenuState = menuState.profile; } GUILayout.EndHorizontal(); GUILayout.EndArea(); }
//handle change to download list public void listValueChanged() { Debug.Log ("VAlue " + soundDropdown.value + currentMenuState); if (currentMenuState == menuState.main) { //got to sound menu if (soundDropdown.value == 0) { soundDropdown.options = includedSounds; currentMenuState = menuState.included; soundDropdown.value = 1; } //go to download menu else if(soundDropdown.value == 1) { soundDropdown.options = downloadMenu; currentMenuState = menuState.downloads; soundDropdown.value = 1; } } else if (currentMenuState == menuState.downloads) { //go back if (soundDropdown.value == 0) { soundDropdown.options = mainMenu; currentMenuState = menuState.main; soundDropdown.value = 2; } } else if (currentMenuState == menuState.included) { if(soundDropdown.value == 0) { soundDropdown.options = mainMenu; currentMenuState = menuState.main; soundDropdown.value = 2; } } }
void joinServer( string inIPAddress ) { // Validate IP try { NetworkConnectionError error = Network.Connect( inIPAddress,DEFAULT_PORT); if( error != NetworkConnectionError.NoError) { } else { // Connected } } catch(System.Exception e)// NetworkConnectionError { errorString = "Failed to Connect to Server"; curMenuState = menuState.error; } }
void OnFailedToConnect(NetworkConnectionError error) { //Debug.Log("Could not connect to server: " + error); errorString = "Failed to Connect to Server"; curMenuState = menuState.error; }
void OnGUI(){ switch(curMenuState) { case menuState.main: // Draw Box GUI.Label(new Rect(buttonLeft, buttonTop, buttonWidth, buttonHeight), titleString); // Start if (GUI.Button (new Rect (buttonLeft, buttonTop + buttonHeight, buttonWidth, buttonHeight), playString)) { // Launch curMenuState = menuState.play; } // Exit if (GUI.Button (new Rect (buttonLeft, buttonTop + buttonHeight * 2.0f, buttonWidth, buttonHeight), quitString)) { // This code is executed when the Button is clicked } break; case menuState.play: // Draw Box GUI.Label(new Rect(buttonLeft, buttonTop, buttonWidth, buttonHeight), titleString); // Start if (GUI.Button (new Rect (buttonLeft, buttonTop + buttonHeight, buttonWidth, buttonHeight), joinServerString)) { // Launch curMenuState = menuState.join; } if (GUI.Button (new Rect (buttonLeft, buttonTop + buttonHeight * 2.0f, buttonWidth, buttonHeight), makeServerString)) { // This code is executed when the Button is clicked buildServer(); } // Exit if (GUI.Button (new Rect (buttonLeft, buttonTop + buttonHeight * 3.0f, buttonWidth, buttonHeight), backString)) { // This code is executed when the Button is clicked curMenuState = menuState.main; } break; case menuState.join: // Draw Box GUI.Label(new Rect(buttonLeft, buttonTop, buttonWidth, buttonHeight), titleString); // Input box inputIPString = GUI.TextField(new Rect(buttonLeft, buttonTop + buttonHeight, buttonWidth, buttonHeight), inputIPString, 25); // Start if(GUI.Button (new Rect (buttonLeft, buttonTop + buttonHeight * 2.0f, buttonWidth, buttonHeight), joinServerString)) { // This code is executed when the Button is clicked curMenuState = menuState.loading; joinServer( inputIPString ); } // Exit if (GUI.Button (new Rect (buttonLeft, buttonTop + buttonHeight * 3.0f, buttonWidth, buttonHeight), backString)) { // This code is executed when the Button is clicked curMenuState = menuState.main; } break; case menuState.hidden: break; case menuState.loading: GUI.Label(new Rect(buttonLeft, buttonTop, buttonWidth, buttonHeight), loadingString); break; case menuState.error: // Draw Box GUI.Label(new Rect(buttonLeft, buttonTop, buttonWidth, buttonHeight), errorString); if(GUI.Button (new Rect (buttonLeft, buttonTop + buttonHeight * 1.0f, buttonWidth, buttonHeight), acceptString)) { // This code is executed when the Button is clicked curMenuState = menuState.main; } break; } }
public void GamePadUpdate() { // keeps track of current keyboard state GamePadState youngState = GamePad.GetState(PlayerIndex.One); // only do the following if the menustate is on if (myState == menuState.Off) return; if (myState == menuState.Clicking) return; if (keysOff) return; // if up is pressed, moves selector up if (youngState.IsButtonDown(Buttons.LeftThumbstickUp)) { if (!elderState.IsButtonDown(Buttons.LeftThumbstickUp)) { selected--; if (selected == -1) selected = buttons.Length - 1; } } if (youngState.IsButtonDown(Buttons.DPadUp)) { if (!elderState.IsButtonDown(Buttons.DPadUp)) { selected--; if (selected == -1) selected = buttons.Length - 1; } } // if down is pressed, moves selector down if (youngState.IsButtonDown(Buttons.LeftThumbstickDown)) { if (!elderState.IsButtonDown(Buttons.LeftThumbstickDown)) { selected++; if (selected == buttons.Length) selected = 0; } } if (youngState.IsButtonDown(Buttons.DPadDown)) { if (!elderState.IsButtonDown(Buttons.DPadDown)) { selected++; if (selected == buttons.Length) selected = 0; } } // if enter is pressed, ... if (youngState.IsButtonDown(Buttons.A)) { if (!elderState.IsButtonDown(Buttons.A)) { myState = menuState.Clicking; buttons[selected].WhenButtonClicked(delegate() { myState = menuState.On; }); buttons[selected].Click(); } } // makes the oldstate the previous state elderState = youngState; }
public void setState(menuState State) { state = State; }
// method to keep track of keys pressed public void KeyUpdate() { // keeps track of current keyboard state KeyboardState newState = Keyboard.GetState(); // only do the following if the menustate is on if (myState == menuState.Off) return; if (myState == menuState.Clicking) return; if (keysOff) return; // if up is pressed, moves selector up if (newState.IsKeyDown(Keys.Up)) { if (!oldState.IsKeyDown(Keys.Up)) { selected--; if (selected == -1) selected = buttons.Length - 1; } } // if down is pressed, moves selector down if (newState.IsKeyDown(Keys.Down)) { if (!oldState.IsKeyDown(Keys.Down)) { selected++; if (selected == buttons.Length) selected = 0; } } // if enter is pressed, ... if (newState.IsKeyDown(Keys.Enter)) { if (!oldState.IsKeyDown(Keys.Enter)) { myState = menuState.Clicking; buttons[selected].WhenButtonClicked(delegate() { myState = menuState.On; }); buttons[selected].Click(); } } // makes the oldstate the previous state oldState = newState; }
public void Patient() { //Patient is where you write your player name if (state == menuState.system) return; menuManager.Instance.input.characterValidation = InputField.CharacterValidation.Name; menuManager.Instance.input.characterLimit = 16; menuManager.Instance.input.text = state != menuState.off ? PlayerPrefs.GetString("name") : defaultPlayerName; state = menuState.system; menuManager.Instance.animator.Play(Animator.StringToHash("playerPatient"), -1, 0); soundManager.playSound(soundManager.soundList["accept1"], false, 3f); onSave(); }
public void MouseUpdate() { if (myState == menuState.Off) return; if (myState == menuState.Clicking) return; MouseState newstate = Mouse.GetState(); if (newstate == oldstate) return; float x = newstate.X; float y = newstate.Y; Vector2 mousePosition = new Vector2(x, y); for (int i = 0; i < buttonAmount; i++) { float halfWidth = buttons[i].width / 2; float halfHeight = buttons[i].height / 2; float xOrigin = buttons[i].attributes.position.X; float yOrigin = buttons[i].attributes.position.Y; if ((x > (xOrigin - halfWidth)) && (x < (xOrigin + halfWidth)) && (y < (yOrigin + halfHeight)) && (y > (yOrigin - halfHeight))) { selected = i; if ((newstate.LeftButton == ButtonState.Pressed) && (oldstate.LeftButton == ButtonState.Released)) { myState = menuState.Clicking; buttons[selected].WhenButtonClicked(delegate() { myState = menuState.On; }); buttons[selected].Click(); } } } oldstate = newstate; }
void setupDropdown() { currentMenuState = menuState.main; mainMenu = new List<Dropdown.OptionData> (); mainMenu.Add(new Dropdown.OptionData("Sounds")); mainMenu.Add (new Dropdown.OptionData ("Downloads")); mainMenu.Add (new Dropdown.OptionData ("")); soundDropdown.options = mainMenu; soundDropdown.value = 2; downloadMenu = new List<Dropdown.OptionData> (); downloadMenu.Add (new Dropdown.OptionData ("Back")); includedSounds = new List<Dropdown.OptionData> (); includedSounds.Add (new Dropdown.OptionData ("Back")); Debug.Log (allList.Count); for (int i =0; i < allList.Count; i++) { includedSounds.Add(new Dropdown.OptionData(allList[i].name)); } }
void Start() { phase = menuState.MAIN; FindObjectOfType <AudioManager>().Play("Turkish March"); // Play the main menu BGM. }
void changeStateTo(menuState nextState) { //initState = false; currentMenuState = nextState; }
public PausedPlayerState(Player _player) { player = _player; pauseBackgroundEsx = new AutoTexture2D(ContentLoadManager.loadTexture("Textures/Screens/menu_esx"), new Vector2(0, 0)); pauseBackgroundHalk = new AutoTexture2D(ContentLoadManager.loadTexture("Textures/Screens/menu_halk"), new Vector2(0, 0)); optionsBackgroundEsx = new AutoTexture2D(ContentLoadManager.loadTexture("Textures/Screens/options_esx"), new Vector2(0, 0)); optionsBackgroundHalk = new AutoTexture2D(ContentLoadManager.loadTexture("Textures/Screens/options_halk"), new Vector2(0, 0)); destructBackgroundEsx = new AutoTexture2D(ContentLoadManager.loadTexture("Textures/Screens/destruct_esx"), new Vector2(0, 0)); destructBackgroundHalk = new AutoTexture2D(ContentLoadManager.loadTexture("Textures/Screens/destruct_halk"), new Vector2(0, 0)); leaveBackgroundEsx = new AutoTexture2D(ContentLoadManager.loadTexture("Textures/Screens/leave_esx"), new Vector2(0, 0)); leaveBackgroundHalk = new AutoTexture2D(ContentLoadManager.loadTexture("Textures/Screens/leave_halk"), new Vector2(0, 0)); resumeEsx = new AutoTexture2D(ContentLoadManager.loadTexture("Textures/Screens/menu_esx_resume"), new Vector2(347, 165)); resumeHalk = new AutoTexture2D(ContentLoadManager.loadTexture("Textures/Screens/menu_halk_resume"), new Vector2(345, 168)); optionsEsx = new AutoTexture2D(ContentLoadManager.loadTexture("Textures/Screens/menu_esx_options"), new Vector2(347, 202)); optionsHalk = new AutoTexture2D(ContentLoadManager.loadTexture("Textures/Screens/menu_halk_options"), new Vector2(347, 204)); voteEsx = new AutoTexture2D(ContentLoadManager.loadTexture("Textures/Screens/menu_esx_vote"), new Vector2(338, 238)); voteHalk = new AutoTexture2D(ContentLoadManager.loadTexture("Textures/Screens/menu_halk_vote"), new Vector2(336, 240)); destructEsx = new AutoTexture2D(ContentLoadManager.loadTexture("Textures/Screens/menu_esx_destruct"), new Vector2(330, 274)); destructHalk = new AutoTexture2D(ContentLoadManager.loadTexture("Textures/Screens/menu_halk_destruct"), new Vector2(327, 277)); leaveEsx = new AutoTexture2D(ContentLoadManager.loadTexture("Textures/Screens/menu_esx_leave"), new Vector2(332, 310)); leaveHalk = new AutoTexture2D(ContentLoadManager.loadTexture("Textures/Screens/menu_halk_leave"), new Vector2(330, 312)); yesEsx = new AutoTexture2D(ContentLoadManager.loadTexture("Textures/Screens/destruct_esx_yes"), new Vector2(361, 246)); yesHalk = new AutoTexture2D(ContentLoadManager.loadTexture("Textures/Screens/destruct_halk_yes"), new Vector2(358, 247)); noEsx = new AutoTexture2D(ContentLoadManager.loadTexture("Textures/Screens/destruct_esx_no"), new Vector2(364, 282)); noHalk = new AutoTexture2D(ContentLoadManager.loadTexture("Textures/Screens/destruct_halk_no"), new Vector2(363, 284)); settingsEsx = new AutoTexture2D(ContentLoadManager.loadTexture("Textures/Screens/options_esx_settings"), new Vector2(345, 198)); settingsHalk = new AutoTexture2D(ContentLoadManager.loadTexture("Textures/Screens/options_halk_settings"), new Vector2(341, 201)); controlsEsx = new AutoTexture2D(ContentLoadManager.loadTexture("Textures/Screens/options_esx_controls"), new Vector2(343, 235)); controlsHalk = new AutoTexture2D(ContentLoadManager.loadTexture("Textures/Screens/options_halk_controls"), new Vector2(340, 237)); profileEsx = new AutoTexture2D(ContentLoadManager.loadTexture("Textures/Screens/options_esx_profile"), new Vector2(349, 271)); profileHalk = new AutoTexture2D(ContentLoadManager.loadTexture("Textures/Screens/options_halk_profile"), new Vector2(347, 273)); resumeEsxLit = new AutoTexture2D(ContentLoadManager.loadTexture("Textures/Screens/menu_esx_resume_lit"), new Vector2(347, 165)); resumeHalkLit = new AutoTexture2D(ContentLoadManager.loadTexture("Textures/Screens/menu_halk_resume_lit"), new Vector2(345, 168)); optionsEsxLit = new AutoTexture2D(ContentLoadManager.loadTexture("Textures/Screens/menu_esx_options_lit"), new Vector2(347, 202)); optionsHalkLit = new AutoTexture2D(ContentLoadManager.loadTexture("Textures/Screens/menu_halk_options_lit"), new Vector2(347, 204)); voteEsxLit = new AutoTexture2D(ContentLoadManager.loadTexture("Textures/Screens/menu_esx_vote_lit"), new Vector2(338, 238)); voteHalkLit = new AutoTexture2D(ContentLoadManager.loadTexture("Textures/Screens/menu_halk_vote_lit"), new Vector2(336, 240)); destructEsxLit = new AutoTexture2D(ContentLoadManager.loadTexture("Textures/Screens/menu_esx_destruct_lit"), new Vector2(330, 274)); destructHalkLit = new AutoTexture2D(ContentLoadManager.loadTexture("Textures/Screens/menu_halk_destruct_lit"), new Vector2(327, 277)); leaveEsxLit = new AutoTexture2D(ContentLoadManager.loadTexture("Textures/Screens/menu_esx_leave_lit"), new Vector2(332, 310)); leaveHalkLit = new AutoTexture2D(ContentLoadManager.loadTexture("Textures/Screens/menu_halk_leave_lit"), new Vector2(330, 312)); yesEsxLit = new AutoTexture2D(ContentLoadManager.loadTexture("Textures/Screens/destruct_esx_yes_lit"), new Vector2(361, 246)); yesHalkLit = new AutoTexture2D(ContentLoadManager.loadTexture("Textures/Screens/destruct_halk_yes_lit"), new Vector2(358, 247)); noEsxLit = new AutoTexture2D(ContentLoadManager.loadTexture("Textures/Screens/destruct_esx_no_lit"), new Vector2(364, 282)); noHalkLit = new AutoTexture2D(ContentLoadManager.loadTexture("Textures/Screens/destruct_halk_no_lit"), new Vector2(363, 284)); settingsEsxLit = new AutoTexture2D(ContentLoadManager.loadTexture("Textures/Screens/options_esx_settings_lit"), new Vector2(345, 198)); settingsHalkLit = new AutoTexture2D(ContentLoadManager.loadTexture("Textures/Screens/options_halk_settings_lit"), new Vector2(341, 201)); controlsEsxLit = new AutoTexture2D(ContentLoadManager.loadTexture("Textures/Screens/options_esx_controls_lit"), new Vector2(343, 235)); controlsHalkLit = new AutoTexture2D(ContentLoadManager.loadTexture("Textures/Screens/options_halk_controls_lit"), new Vector2(340, 237)); profileEsxLit = new AutoTexture2D(ContentLoadManager.loadTexture("Textures/Screens/options_esx_profile_lit"), new Vector2(349, 271)); profileHalkLit = new AutoTexture2D(ContentLoadManager.loadTexture("Textures/Screens/options_halk_profile_lit"), new Vector2(347, 273)); controlsPC = new AutoTexture2D(ContentLoadManager.loadTexture("Textures/Screens/controls_PC"), new Vector2(0, 0)); controlsXBox = new AutoTexture2D(ContentLoadManager.loadTexture("Textures/Screens/controls_xbox"), new Vector2(0, 0)); currentMenuState = menuState.main; currentMainState = mainState.resume; currentYesNoState = yesNoState.no; currentOptionsState = optionsState.controls; drawingControls = false; drawingOtherControls = false; }
//bool isLightOn; // Use this for initialization void Start() { rectangle = new Rect (0, 0, 200, 200); batteryRectangle = new Rect (500, 0, 200, 50); show = false; state = menuState.off; numFoundRocks = 0; numNeededRocks = 5; timer = 100.0f; RenderSettings.ambientLight = Color.black; hintContent = ""; currentColl = ""; digTest = GameObject.Find("Fox").GetComponent<DigTest>(); }