public Menu(List <Button> buttons) { this.buttons = buttons; foreach (Button button in buttons) { button.Pressed = false; } state = StateMenu.None; }
public Menu() { positionHand = new Vector2(290, 300); this.menuActive = true; this.option = StateMenu.newGame; this.texture = new AnimatedTexture(3f, new Point(3, 5), new Point(0, 1), new Point(20, 20), 180); this.difficulty = false; this.optionDif = 0; }
public void Update(GameTime gameTime) { timer += (float)gameTime.ElapsedGameTime.TotalSeconds; if (timer > 0.1f) { for (int i = 0; i < buttons.Count; i++) { buttons[i].Update(gameTime); if (buttons[i].Pressed) { state = (StateMenu)i; } } } }
private void Cleanup() { lastHighlightedState = null; if (stateSelector != null) { StopCoroutine(stateSelector); } stateSelector = null; if (timerUpdateRoutine != null) { StopCoroutine(timerUpdateRoutine); } timerUpdateRoutine = null; }
void HighlightState(StateMenu state) { try { if (lastHighlightedState != null) { lastHighlightedState.highlight?.SetActive(false); } state.highlight.SetActive(true); lastHighlightedState = state; } catch (System.Exception) { Debug.Log("Exeption"); return; } }
/// <summary> /// конструктор екрана игры /// </summary> /// <param name="control">принимает родительский Control</param> public Menu(Control control) { stateMenu = StateMenu.Game; menuControl = new Label(); menuControl.Parent = control; menuControl.Location = new Point(0, 0); menuControl.Image = Properties.Resources.Menu; menuControl.Size = menuControl.Image.Size; player = new Label(); player.Parent = menuControl; player.Location = new Point(265, 770); player.BackColor = Color.Transparent; player.Font = new Font("COURER", 20, FontStyle.Bold); player.ForeColor = Color.White; player.TextAlign = ContentAlignment.MiddleLeft; player.Size = new Size(200, 30); player.Text = "1 PLAYER"; saveGame = new Label(); saveGame.Parent = menuControl; saveGame.Location = new Point(265, 800); saveGame.BackColor = Color.Transparent; saveGame.Font = new Font("COURER", 20, FontStyle.Bold); saveGame.ForeColor = Color.White; saveGame.TextAlign = ContentAlignment.MiddleLeft; saveGame.Size = new Size(200, 30); saveGame.Text = "SAVE GAME"; loadGame = new Label(); loadGame.Parent = menuControl; loadGame.Location = new Point(265, 830); loadGame.BackColor = Color.Transparent; loadGame.Font = new Font("COURER", 20, FontStyle.Bold); loadGame.ForeColor = Color.White; loadGame.TextAlign = ContentAlignment.MiddleLeft; loadGame.Size = new Size(200, 30); loadGame.Text = "LOAD GAME"; marker = new Label(); marker.Parent = menuControl; marker.Image = Properties.Resources.Marker; marker.Size = marker.Image.Size; }
void ExecuteAction(int type = -1) { if (type == 0) { if (state != StateMenu.Start) { OnLeave(std_object[selectedMenu]); clock = timer; state = StateMenu.Start; Init(btn_object); } } else { switch (state) { case (StateMenu.Start): switch (selectedMenu) { case 0: Debug.Log("Goto Level Selector"); clock = timer; state = StateMenu.LevelSelector; Init(lvl_object); break; case 2: Debug.Log("Exiting..."); Application.Quit(); break; } break; case (StateMenu.LevelSelector): GameManagerSc.Instance.level = selectedMenu + 1; GameManagerSc.Instance.LoadSceneUnity(GameManagerSc.SceneUnity.LevelScene); break; } } }
public void setCar(CarInfo carInfo, StateMenu menuState, Vector3 carStartingPosition) { playerCar.setCar(carInfo, carStartingPosition); this.menuState = menuState; }
void MakeState() { nameStateFile = "StateMenu.json"; if (File.Exists(nameStateFile)) { var str = File.ReadAllText(nameStateFile); stateMenu = str != "null" ? JsonConvert.DeserializeObject<StateMenu>(str) : new StateMenu(Dispatcher.Loader.Levels); stateMenu.CheckContaints(Dispatcher.Loader.Levels); } else stateMenu = new StateMenu(Dispatcher.Loader.Levels); }
// Use this for initialization void Start() { state = StateMenu.Start; Init(btn_object); }
public int updateMenu(GameTime gameTime) { texture.UpdateFrame(gameTime); if (menuActive) { if (!this.difficulty) { currentKeyBoardState = Keyboard.GetState(); if (currentKeyBoardState != lastKeyBoardState) { if (Keyboard.GetState().IsKeyDown(Keys.Enter)) { switch (option) { case (StateMenu.newGame): difficulty = true; break; //return 1; //break; case (StateMenu.instructions): return 3; //break; case (StateMenu.exit): return 4; //break; } } else if (Keyboard.GetState().IsKeyDown(Keys.Down)) { if (option.Equals(StateMenu.exit)) { option = StateMenu.newGame; } else { option++; } } else if (Keyboard.GetState().IsKeyDown(Keys.Up)) { if (option.Equals(StateMenu.newGame)) { option = StateMenu.exit; } else { option--; } } } } else { currentKeyBoardState = Keyboard.GetState(); if (currentKeyBoardState != lastKeyBoardState) { if (Keyboard.GetState().IsKeyDown(Keys.Enter)) { switch (optionDif) { case (0): difficulty = false; return 1; //break; case (1): difficulty = false; return 2; //break; } } else if (Keyboard.GetState().IsKeyDown(Keys.Down)) { if (optionDif == 0) { this.optionDif = 1; } else { this.optionDif = 0; } } else if (Keyboard.GetState().IsKeyDown(Keys.Up)) { if (optionDif == 0) { this.optionDif = 1; } else { this.optionDif = 0; } } else if (Keyboard.GetState().IsKeyDown(Keys.A)) { this.optionDif = 0; this.difficulty = false; } } } lastKeyBoardState = currentKeyBoardState; } if (!this.difficulty) { switch (option) { case (StateMenu.newGame): positionHand = new Vector2(310, 285); break; case (StateMenu.instructions): positionHand = new Vector2(305, 320); break; case (StateMenu.exit): positionHand = new Vector2(298, 361); break; } } else { switch (optionDif) { case (0): positionHand = new Vector2(335, 315); break; case (1): positionHand = new Vector2(335, 348); break; } } return -1; }