private void HandleBack() { _stateChangeInformation = StateChangeInformation.StateChange(typeof(MainMenuState), typeof(BlendTransition)); var port = _optionsMenu.GetMenuItem <InputMenuItem>(0); var soundOnOff = _optionsMenu.GetMenuItem <BoolMenuItem>(1); var isFullScreen = _optionsMenu.GetMenuItem <BoolMenuItem>(2); var gameMode = _optionsMenu.GetMenuItem <EnumMenuItem>(3); var resolution = _optionsMenu.GetMenuItem <EnumMenuItem>(4); int width, height; GetResolutionFromString(resolution.SelectedItem, out width, out height); Game.SetProperty(SoundPropertyName, soundOnOff.IsTrue); Game.SetProperty(GameModePropertyName, gameMode.SelectedItem); Game.SetProperty(GameProperty.GameIsFullScreenProperty, isFullScreen.IsTrue); Game.SetProperty(GameProperty.GameResolutionXProperty, width); Game.SetProperty(GameProperty.GameResolutionYProperty, height); if (!string.IsNullOrEmpty(port.InputText)) { Game.SetProperty(MultiPlayerPortPropertyName, int.Parse(port.InputText)); } Game.SavePropertyChanges(); //todo: implement resource reloading //Game.ChangeScreenSettings(width, height, isFullScreen.IsTrue); Resources.ChangeResolution(width, height); }
protected override void OnInitialize(object enterInformation) { base.OnInitialize(enterInformation); _currentLevelIndex = 0; _levelNames = GetLocalLevelNames().ToArray(); _panel = new GuiPanel(Game); var frame = Game.GuiSystem.CreateGuiHierarchyFromXml <GuiElement>("Content/GuiLayouts/LocalGameConfig_Layout.xml"); _panel.AddElement(frame); _playerCountTextBlock = frame.FindGuiElementById <TextBlock>("PlayerCountText"); _comCountTextBlock = frame.FindGuiElementById <TextBlock>("ComCountText"); _levelNameTextBlock = frame.FindGuiElementById <TextBlock>("CurrentLevelText"); _currentTimeTextBlock = frame.FindGuiElementById <TextBlock>("CurrentTimeText"); _playerCountTextBlock.Text = _playerCount.ToString(CultureInfo.InvariantCulture); _comCountTextBlock.Text = _comPlayerCount.ToString(CultureInfo.InvariantCulture); _levelNameTextBlock.Text = _levelNames[_currentLevelIndex]; _currentTimeTextBlock.Text = string.Format("{0:00}:{1:00}", _matchTimeSeconds / 60, _matchTimeSeconds % 60); frame.FindGuiElementById <Button>("DecreasePlayerCountButton").Click += () => OnChangePlayerCount(false); frame.FindGuiElementById <Button>("IncreasePlayerCountButton").Click += () => OnChangePlayerCount(true); frame.FindGuiElementById <Button>("DecreaseComCountButton").Click += () => OnChangeComCount(false); frame.FindGuiElementById <Button>("IncreaseComCountButton").Click += () => OnChangeComCount(true); frame.FindGuiElementById <Button>("PreviousLevelButton").Click += () => OnChangeLevel(false); frame.FindGuiElementById <Button>("NextLevelButton").Click += () => OnChangeLevel(true); frame.FindGuiElementById <Button>("DecreaseTimeButton").Click += () => OnChangeTime(false); frame.FindGuiElementById <Button>("IncreaseTimeButton").Click += () => OnChangeTime(true); frame.FindGuiElementById <Button>("StartGameButton").Click += StartLocalGame; frame.FindGuiElementById <Button>("BackButton").Click += () => { _stateChangeInformation = StateChangeInformation.StateChange(typeof(MainMenuState), typeof(BlendTransition)); }; }
public override StateChangeInformation OnUpdate(float elapsedTime) { _globalTime += elapsedTime; _explosionManager.Update(elapsedTime); _gameBackground.Update(elapsedTime); _carManager.Update(elapsedTime); _player.Update(elapsedTime); _weather.Update(elapsedTime); if (_playerIsDead) { _waitTimer += elapsedTime; if (_waitTimer >= 3.0f) { return(StateChangeInformation.StateChange(typeof(GameOverState), typeof(FlipTransition), _player.Points)); } } else if (!_playerIsDead && _player.PlayerState == PlayerState.Dead) { SoundService.StopCurrentSong(); _playerIsDead = true; _waitTimer = 0; } _carManager.spawnTime = (100 - _player.Points / 50); if (_carManager.spawnTime <= 10) { _carManager.spawnTime = 10; } _carManager.points = _player.Points + 150; return(StateChangeInformation.Empty); }
public override StateChangeInformation OnUpdate(float elapsedTime) { _stateChangeInformation = StateChangeInformation.Empty; _finishSlideAnimator.Update(new GameTime(TimeSpan.Zero, TimeSpan.FromSeconds(elapsedTime))); _gameRenderer.Update(elapsedTime); if (Game.Keyboard.IsKeyDownOnce(Keys.Escape)) { _gameSession.OnQuit(); return(StateChangeInformation.StateChange(typeof(MainMenuState), typeof(FlipTransition), false)); } var result = _gameSession.Update(elapsedTime); switch (result) { case GameUpdateResult.MatchFinished: if (_finishSlideAnimator.CurrentAnimation == null) { _finishSlideAnimator.SetAnimation("RotateText"); var y = _gameSession.CurrentMatchResultType == MatchResultType.Draw ? 50 : 100; _finishedSprite.SetSourceRectangle(new Rectangle(0, y, 300, 50)); } break; case GameUpdateResult.ServerShutdown: return(StateChangeInformation.StateChange(typeof(MainMenuState), typeof(BlendTransition), true)); } return(_stateChangeInformation); }
public override StateChangeInformation OnUpdate(float elapsedTime) { _stateChangeInformation = StateChangeInformation.Empty; _root.Update(elapsedTime); return(_stateChangeInformation); }
private void StartLocalGame() { var levelAssetLocalName = _levelNames[_currentLevelIndex]; var parameters = new GameSessionStartParameters { MatchesToWin = 5, MatchTime = _matchTimeSeconds, SessionName = "Local Session", LevelAssetPath = GetFilePathFromLevelName(levelAssetLocalName), ProvidePlayerFigureController = ProvideFigureController }; var gameSession = new GameSessionImp(parameters); for (var i = 0; i < _playerCount; i++) { gameSession.AddMember(MemberType.ActivePlayer); } for (var i = 0; i < _comPlayerCount; i++) { gameSession.AddMember(MemberType.Computer); } gameSession.StartMatch(); _stateChangeInformation = StateChangeInformation.StateChange(typeof(WaitState), typeof(SlideTransition), gameSession); }
public override StateChangeInformation OnUpdate(float elapsedTime) { base.OnUpdate(elapsedTime); const float timePerDot = 0.33f; _elapsed += elapsedTime; if (_elapsed > timePerDot) { _elapsed -= timePerDot; if (++_dotCount == 4) { _dotCount = 0; } } _updateResult = _gameExecution.Update(elapsedTime); switch (_updateResult) { case GameUpdateResult.SwitchToGame: return(StateChangeInformation.StateChange(typeof(MatchState), typeof(GrowTransition), _gameExecution)); case GameUpdateResult.ServerShutdown: return(StateChangeInformation.StateChange(typeof(MainMenuState), typeof(BlendTransition), true)); } return(StateChangeInformation.Empty); }
public override StateChangeInformation OnUpdate(float elapsedTime) { if (Game.Keyboard.IsKeyDownOnce(Keys.Enter) || Game.Keyboard.IsKeyDownOnce(Keys.Escape)) { return(StateChangeInformation.QuitGameInformation(typeof(ThrowAwayTransition))); } return(StateChangeInformation.Empty); }
private void SetButtonTransitionTo(GuiElement root, string buttonId, Type targetState) { var button = root.FindGuiElementById <Button>(buttonId); button.Click += () => { _stateChangeInformation = StateChangeInformation.StateChange(targetState, typeof(SlideTransition)); }; }
public override StateChangeInformation OnUpdate(float elapsedTime) { if (Game.Keyboard.IsKeyDownOnce(Keys.Enter)) { return(StateChangeInformation.StateChange(typeof(MainGame), typeof(FlipTransition))); } return(StateChangeInformation.Empty); }
private void OnFinishSlideFinished(string name, bool playReversed) { if (_gameSession.CurrentMatchResultType == MatchResultType.SomeOneWins) { _stateChangeInformation = StateChangeInformation.StateChange(typeof(MatchResultState), typeof(FlipTransition), _gameSession); } //todo: Reactivate Winner State //_stateChangeInformation = StateChangeInformation.StateChange(typeof(WinnerState), typeof(FlipTransition), _gameSession); }
protected override void OnEntered(object enterInformation) { _stateChangeInformation = StateChangeInformation.Empty; _mainOverlay.Show(); if (enterInformation is bool && (bool)enterInformation) { _splash.Start("Server Connection Lost", 1.5f); } }
public override StateChangeInformation OnUpdate(float elapsedTime) { base.OnUpdate(elapsedTime); _stateChangeInformation = StateChangeInformation.Empty; _splash.Update(elapsedTime); if (!_splash.Running) { _mainOverlay.Update(new GameTime(TimeSpan.FromSeconds(0), TimeSpan.FromSeconds(elapsedTime))); } return(_stateChangeInformation); }
protected override void OnInitialize(object enterInformation) { base.OnInitialize(enterInformation); _panel = new GuiPanel(Game); var frame = Game.GuiSystem.CreateGuiHierarchyFromXml <Frame>("Content/GuiLayouts/Credits_Layout.xml"); frame.FindGuiElementById <Button>("BackButton").Click += () => { _stateChangeInformation = StateChangeInformation.StateChange(typeof(MainMenuState), typeof(BlendTransition)); }; _panel.AddElement(frame); }
public override StateChangeInformation OnUpdate(float elapsedTime) { base.OnUpdate(elapsedTime); _stateChangeInformation = StateChangeInformation.Empty; _panel.Update(elapsedTime); if (_gameCreationSession.State == GameCreationSessionState.ConnectionToServerFailed) { _waitDialog.IsActive = false; _errorDialog.FindGuiElementById <TextBlock>("MessageText").Text = _gameCreationSession.GetConnectionFailedMessageAndReset(); _errorDialog.Arrange(Game.GetScreenRectangle()); _errorDialog.IsActive = true; } else if (_gameCreationSession.State == GameCreationSessionState.Connected) { //do different. } return(_stateChangeInformation); }
protected override void OnEntered(object enterInformation) { Game.Cursor.IsActive = false; _gameSession = (GameSession)enterInformation; _stateChangeInformation = StateChangeInformation.Empty; //todo: reactivate 3d //var rendererType = Settings.Default.GameMode == "3D" ? GameRendererType.ThreeDe : GameRendererType.TwoDe; _gameRenderer = GameRendererFactory.CreateGameRenderer(GameRendererType.TwoDe, Game, _gameSession.CurrentLevel); _finishSlideAnimator = new Animator(); _finishSlideAnimator.AddAnimation("RotateText", new DeltaAnimation(1.0f, RotateAndSetAlphaText, false)); _finishSlideAnimator.AddAnimation("Wait", new WaitAnimation(1.5f)); _finishSlideAnimator.AddTransition("RotateText", "Wait"); _finishSlideAnimator.AnimationFinished += OnFinishSlideFinished; _finishedSprite = new Sprite(Game.Content.Load <Texture2D>("textures/headings")) { Position = new Vector2(Game.ScreenWidth * 0.5f, Game.ScreenHeight * 0.5f), Alpha = 0.0f }; }
public override StateChangeInformation OnUpdate(float elapsedTime) { base.OnUpdate(elapsedTime); if (_gameExecution.Update(elapsedTime) == GameUpdateResult.ServerShutdown) { return(StateChangeInformation.StateChange(typeof(MainMenuState), typeof(BlendTransition), true)); } if (Game.Keyboard.IsKeyDownOnce(Keys.Escape)) { _gameExecution.OnQuit(); return(StateChangeInformation.StateChange(typeof(MainMenuState), typeof(BlendTransition), false)); } if (Game.Keyboard.IsKeyDownOnce(Keys.Enter)) { _gameExecution.OnQuit(); return(StateChangeInformation.StateChange(typeof(MainMenuState), typeof(BlendTransition), false)); } return(StateChangeInformation.Empty); }
public override StateChangeInformation OnUpdate(float elapsedTime) { base.OnUpdate(elapsedTime); _stateChangeInformation = StateChangeInformation.Empty; //var result = _gameClient.Update(elapsedTime); //_stackedMenu.Update(elapsedTime); //_startGameMenuItem.IsEnabled = IsStartableGame; //if (_startGameMenuItem.IsEnabled && !_startGameWasEnabled && _gameClient.IsAdministrator) //{ // _stackedMenu.SelectItem(0); //} //_startGameWasEnabled = _startGameMenuItem.IsEnabled; //switch (result) //{ // case GameUpdateResult.ServerShutdown: // return StateChangeInformation.StateChange(typeof(MainMenuState), typeof(BlendTransition), true); // case GameUpdateResult.SwitchToPrepareMatch: // return StateChangeInformation.StateChange(typeof(WaitState), typeof(SlideTransition), _gameClient); //} //_playerTable.Clear(); //foreach (var client in _gameClient.Members) //{ // var c = client.Me ? Color.Orange : (Color?) null; // _playerTable.AddRow(new[] // { // new Cell(client.Name, client.Id), // new Cell(client.Ready ? "Yes" : "No"), // }, c); //} return(_stateChangeInformation); }
private void OnQuitClicked() { _stateChangeInformation = StateChangeInformation.QuitGameInformation(ZappoutTransition.Id); }
private void DoTransition(Type targetState) { _stateChangeInformation = StateChangeInformation.StateChange(targetState, SlideTransition.Id); }
private void OnStartTransition() { _stateChangeInformation = StateChangeInformation.StateChange(typeof(StartState), typeof(BlendTransition)); }
private void HandleConfigureInput() { _stateChangeInformation = StateChangeInformation.StateChange(typeof(ConfigureInputState), typeof(SlideTransition)); }
protected override void OnEntered(object enterInformation) { _inputMenu.RecalculatePositions(); _stateChangeInformation = StateChangeInformation.Empty; }
private void OnBack() { _stateChangeInformation = StateChangeInformation.StateChange(typeof(MainMenuState), typeof(BlendTransition)); }
protected override void OnEntered(object enterInformation) { _iconAnimator.SetAnimation("BlendIn"); _stateChangeInformation = StateChangeInformation.Empty; }
protected override void OnEntered(object enterInformation) { _stateChangeInformation = StateChangeInformation.Empty; }
private void HandleBack() { _stateChangeInformation = StateChangeInformation.StateChange(typeof(MainMenuState), BlendTransition.Id); }
protected override void OnEntered(object enterInformation) { Game.Cursor.IsActive = false; _iconAnimator.SetAnimation("BlendIn"); _stateChangeInformation = StateChangeInformation.Empty; }