private void PlayerIsReady(JoinState player) { if (player.CurrentState == JoinState.State.Joined) { NonPositionalAudio.PlaySound("Audio/MenuActionSound"); player.Next(); // Animate text var textChooser = player.HUD.GetComponentByName <HUDTextComponent>("nameTextchooser"); Dispatcher.AddAnimation(Animation.Get(textChooser.Opacity, 0f, 1f, false, (o) => textChooser.Opacity = o, EasingFunctions.ToEaseOut(EasingFunctions.QuadIn))); var boardChooser = player.HUD.GetComponentByName <HUDComponent>("namechooser"); Dispatcher.AddAnimation(Animation.Get(boardChooser.Opacity, 0f, 1f, false, (o) => boardChooser.Opacity = o, EasingFunctions.ToEaseOut(EasingFunctions.QuadIn))); var text = player.HUD.GetComponentByName <HUDTextComponent>("nameText"); Dispatcher.AddAnimation(Animation.Get(text.Opacity, 1f, 1f, false, (o) => text.Opacity = o, EasingFunctions.QuadIn)); var board = player.HUD.GetComponentByName <HUDComponent>("name"); Dispatcher.AddAnimation(Animation.Get(board.Opacity, 1f, 1f, false, (o) => board.Opacity = o, EasingFunctions.QuadIn)); Dispatcher.NextFrame(() => player.Player.UnFreeze()); if (players.Count(j => j.CurrentState == JoinState.State.Ready) >= (Game.CurrentGameMode.PlayerMode == PlayerMode.TwoVsTwo ? 4 : 1)) { pressStartToStartAnimation.IsRunning = true; } } }
private void OnNextPressed(InputFrame obj) { if (!areControlsEnabled) { return; } NonPositionalAudio.PlaySound("Audio/MenuActionSound"); switch (state) { case MenuState.ChoosePlayerMode: GoToMenuState(MenuState.ChooseGameMode); break; case MenuState.ChooseGameMode: GoToMenuState(MenuState.ChooseRuntime); break; case MenuState.ChooseRuntime: GoToMenuState(MenuState.PressStart); break; case MenuState.PressStart: Game.CurrentGameMode.GameMode = gameMode; Game.CurrentGameMode.PlayerMode = playerMode; Game.CurrentGameMode.RuntimeInfo = selectedRuntimeMode; this.TransitionOutAndSwitchScene(new JoinScene(Game)); break; } }
private void OnBackPressed(InputFrame obj) { if (!areControlsEnabled) { return; } NonPositionalAudio.PlaySound("Audio/MenuActionSound"); switch (state) { case MenuState.PressStart: GoToMenuState(MenuState.ChooseRuntime); break; case MenuState.ChooseRuntime: GoToMenuState(MenuState.ChooseGameMode); break; case MenuState.ChooseGameMode: GoToMenuState(MenuState.ChoosePlayerMode); break; case MenuState.ChoosePlayerMode: this.TransitionOutAndSwitchScene(new MainMenuScene(Game)); break; } }
private void OnRightPressed(InputFrame obj) { if (!areControlsEnabled) { return; } NonPositionalAudio.PlaySound("Audio/MenuActionSound"); switch (state) { case MenuState.ChoosePlayerMode: if (playerMode == PlayerMode.TwoVsTwo) { SwitchPlayerMode(); } break; case MenuState.ChooseGameMode: if (gameMode == GameMode.Waves) { SwitchGameMode(); } break; case MenuState.ChooseRuntime: SelectedRuntimeMode(selectedRuntimeMode + 1); break; } }
private void OnStartPressed(InputFrame obj) { if (!areControlsEnabled) { return; } NonPositionalAudio.PlaySound("Audio/MenuActionSound"); }
public override void Initialize() { base.Initialize(); Pause(); this.TransitionIn(); Func <int, Action> makeCountDown = (i) => { return(() => { NonPositionalAudio.PlaySound("Audio/countDownShort"); initialCountdownComponent.Text = i.ToString(); }); }; if (spawnAnyUI) { Dispatcher.Delay(2f, () => { Dispatcher.AddAnimation(Animation.Get(1f, 0f, 1f, false, (v) => playerName1Component.Opacity = v, EasingFunctions.ToEaseOut(EasingFunctions.QuadIn), 0.5f)); Dispatcher.AddAnimation(Animation.Get(1f, 0f, 1f, false, (v) => playerName2Component.Opacity = v, EasingFunctions.ToEaseOut(EasingFunctions.QuadIn), 0.5f)); Dispatcher.AddAnimation(Animation.Get(1f, 0f, 1f, false, (v) => playerName3Component.Opacity = v, EasingFunctions.ToEaseOut(EasingFunctions.QuadIn), 0.5f)); Dispatcher.AddAnimation(Animation.Get(1f, 0f, 1f, false, (v) => playerName4Component.Opacity = v, EasingFunctions.ToEaseOut(EasingFunctions.QuadIn), 0.5f)); Dispatcher.AddAnimation(Animation.Get(1f, 0f, 1f, false, (v) => separatorTeam1Component.Opacity = v, EasingFunctions.ToEaseOut(EasingFunctions.QuadIn), 0.5f)); Dispatcher.AddAnimation(Animation.Get(1f, 0f, 1f, false, (v) => separatorTeam2Component.Opacity = v, EasingFunctions.ToEaseOut(EasingFunctions.QuadIn), 0.5f)); }).ThenDelay(0.9f, makeCountDown(3)) .ThenDelay(0.9f, makeCountDown(2)) .ThenDelay(0.9f, makeCountDown(1)) .ThenDelay(0.9f, () => { NonPositionalAudio.PlaySound("Audio/countDownLong"); initialCountdownComponent.Text = "GO!"; Unpause(); Dispatcher.AddAnimation(Animation.Get(1f, 0f, 1f, false, (v) => initialCountdownComponent.Opacity = v, EasingFunctions.ToEaseOut(EasingFunctions.QuadIn), 0.5f)); if (IsCountdownRunning) { StartCountown(); } }); } }
private void UpdateCountdown(float deltaTime) { gameDuration -= deltaTime; if (gameDuration <= 3f) { if (initialCountdownComponent.Opacity == 0) { // fade out Dispatcher.AddAnimation(Animation.Get(1f, 0f, 1f, false, (v) => timeComponent100.Opacity = v, EasingFunctions.ToEaseOut(EasingFunctions.QuadIn), 0.5f)); Dispatcher.AddAnimation(Animation.Get(1f, 0f, 1f, false, (v) => timeComponent10.Opacity = v, EasingFunctions.ToEaseOut(EasingFunctions.QuadIn), 0.5f)); Dispatcher.AddAnimation(Animation.Get(1f, 0f, 1f, false, (v) => timeComponent1.Opacity = v, EasingFunctions.ToEaseOut(EasingFunctions.QuadIn), 0.5f)); Dispatcher.AddAnimation(Animation.Get(1f, 0f, 1f, false, (v) => timeComponentBackground.Opacity = v, EasingFunctions.ToEaseOut(EasingFunctions.QuadIn), 0.5f)); //fade in Dispatcher.AddAnimation(Animation.Get(0f, 1f, 1f, false, (v) => initialCountdownComponent.Opacity = v, EasingFunctions.QuadIn)); initialCountdownComponent.Color = Color.OrangeRed; } if (gameDuration > 0) { initialCountdownComponent.Text = gameDuration.ToString("N0"); NonPositionalAudio.PlaySound("Audio/countDownShort"); } else { initialCountdownComponent.Text = "Game over!"; NonPositionalAudio.PlaySound("Audio/PigHappy"); } } else { UpdateCountdownText(); } }
private InputComponent MakeInput(bool isKeyboard, int gamepadIndex) { return(new InputComponent(gamepadIndex, new InputMapping(f => (isKeyboard) ? InputFunctions.KeyboardMenuStart(f) : InputFunctions.MenuStart(f), f => StartIfReady()), new InputMapping(f => (isKeyboard) ? InputFunctions.KeyboardMenuSelect(f) : InputFunctions.MenuSelect(f), f => { var player = players.FindPlayer(gamepadIndex, isKeyboard); if (player != null) { PlayerIsReady(player); } else { JoinPlayer(isKeyboard, gamepadIndex); } }), new InputMapping(f => (isKeyboard) ? InputFunctions.KeyboardMenuBack(f) : InputFunctions.MenuBack(f), f => { var player = players.FindPlayer(gamepadIndex, isKeyboard); if (player != null) { if (player.CurrentState == JoinState.State.Joined) { NonPositionalAudio.PlaySound("Audio/MenuActionSound"); Game.CurrentGameMode.RemovePlayer(gamepadIndex, isKeyboard); RemoveEntity(player.HUD); RemoveEntity(player.Player); players.Remove(player); numJoinedPlayer--; if (numJoinedPlayer < 4) { Dispatcher.AddAnimation(Animation.Get(joinComponent.Opacity, 1, 0.2f, false, (val) => { joinComponent.Opacity = val; joinTextComponent.Opacity = val; }, EasingFunctions.QuadIn)); } } else if (player.CurrentState == JoinState.State.Ready) { NonPositionalAudio.PlaySound("Audio/MenuActionSound"); player.Back(); // Animate text var textChooser = player.HUD.GetComponentByName <HUDTextComponent>("nameTextchooser"); Dispatcher.AddAnimation(Animation.Get(textChooser.Opacity, 1f, 1f, false, (o) => textChooser.Opacity = o, EasingFunctions.QuadIn)); var boardChooser = player.HUD.GetComponentByName <HUDComponent>("namechooser"); Dispatcher.AddAnimation(Animation.Get(boardChooser.Opacity, 1f, 1f, false, (o) => boardChooser.Opacity = o, EasingFunctions.QuadIn)); var text = player.HUD.GetComponentByName <HUDTextComponent>("nameText"); Dispatcher.AddAnimation(Animation.Get(text.Opacity, 0f, 1f, false, (o) => text.Opacity = o, EasingFunctions.ToEaseOut(EasingFunctions.QuadIn))); var board = player.HUD.GetComponentByName <HUDComponent>("name"); Dispatcher.AddAnimation(Animation.Get(board.Opacity, 0f, 1f, false, (o) => board.Opacity = o, EasingFunctions.ToEaseOut(EasingFunctions.QuadIn))); player.Player.Freeze(); if (players.Count(j => j.CurrentState == JoinState.State.Ready) >= (Game.CurrentGameMode.PlayerMode == PlayerMode.TwoVsTwo ? 4 : 1)) { pressStartToStartAnimation.IsRunning = false; Dispatcher.AddAnimation(Animation.Get(pressStartToStart.Opacity, 0f, 0.3f, false, (o) => pressStartToStart.Opacity = o, EasingFunctions.ToEaseOut(EasingFunctions.QuadIn))); } } } else if (!players.Any()) { this.TransitionOutAndSwitchScene(new GameModeScene(Game)); } }), new InputMapping( f => (isKeyboard) ? InputFunctions.KeyboardMenuRandom(f) : InputFunctions.MenuRandom(f), f => { var player = players.FindPlayer(gamepadIndex, isKeyboard); if (player != null && player.CurrentState == JoinState.State.Joined) { NonPositionalAudio.PlaySound("Audio/MenuActionSound"); SetRandomName(player); } }), new InputMapping( f => (isKeyboard) ? InputFunctions.KeyboardMenuLeft(f) || InputFunctions.KeyboardMenuUp(f) : InputFunctions.MenuLeft(f) || InputFunctions.MenuUp(f), f => { var player = players.FindPlayer(gamepadIndex, isKeyboard); if (player != null && player.CurrentState == JoinState.State.Joined) { NonPositionalAudio.PlaySound("Audio/MenuActionSound"); SetNextOrPreviousName(player, 1); } }), new InputMapping( f => (isKeyboard) ? InputFunctions.KeyboardMenuRight(f) || InputFunctions.KeyboardMenuDown(f) : InputFunctions.MenuRight(f) || InputFunctions.MenuDown(f), f => { var player = players.FindPlayer(gamepadIndex, isKeyboard); if (player != null && player.CurrentState == JoinState.State.Joined) { NonPositionalAudio.PlaySound("Audio/MenuActionSound"); SetNextOrPreviousName(player, -1); } }) )); }