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); } }) )); }