public override void LoadContent() { base.LoadContent(); //Game.CurrentGameMode.ClearPlayers(); Game.EngineComponents.Get <AudioManager>().PreloadSongs("Audio\\joinScreen", "Audio\\gamePlay"); var backgroundSize = new Vector2(6f / 3.508f * 1.1f * GameConstants.ScreenHeight, 1.1f * GameConstants.ScreenHeight); AddEntity(new Entity(this, EntityType.Game, new SpriteComponent("background", backgroundSize, new Vector2(0.5f, 0.5f), layerDepth: -1.0f))); AddEntity(new Entity(this, EntityType.Game, new SpriteComponent("trees_border", backgroundSize, new Vector2(0.5f, 0.5f), layerDepth: -0.9f))); // UI HUDTextComponent pressStartText = new HUDTextComponent(MainFont, 0.04f, "PRESS START", offset: new Vector2(0.5f, 0.9f), origin: new Vector2(0.5f, 0.5f), layerDepth: 1f); HUDComponent vignetteComponent = new HUDComponent(Game.Debug.DebugRectangle, Vector2.One, layerDepth: 0) { MaintainAspectRation = false, OnVirtualUIScreen = false, Color = Color.FromNonPremultiplied(22, 59, 59, 163) }; Vector2 logoSize = new Vector2(1, 0.7684f); HUDComponent logoComponent = new HUDComponent("titleScreen", 0.9f * logoSize, offset: new Vector2(0.5f, 0.5f), origin: new Vector2(0.5f, 0.5f), layerDepth: 0.9f); AddEntity(new Entity(this, EntityType.UI, Vector2.Zero, pressStartText, vignetteComponent, logoComponent)); Dispatcher.AddAnimation(Animation.Get(0, 1, 1.5f, true, val => pressStartText.Opacity = val, EasingFunctions.ToLoop(EasingFunctions.QuadIn))); var inputEntity = new Entity(this, EntityType.LayerIndependent, new InputComponent(0, new InputMapping(f => InputFunctions.KeyboardMenuStart(f), StartPressed)) ); for (int i = 0; i < 4; i++) { inputEntity.AddComponent(new InputComponent(i, new InputMapping(f => InputFunctions.MenuStart(f), StartPressed))); } AddEntity(inputEntity); AddEntity(new Entity(this, EntityType.LayerIndependent, new CenterCameraComponent(Game.Camera))); this.TransitionIn(); }
public override void LoadContent() { base.LoadContent(); // we create them to preload everything new BoarEntity(this, Vector2.Zero); new ChickenEntity(this, Vector2.Zero, 0); // normal chicken new ChickenEntity(this, Vector2.Zero, 1); // yellow chicken player = playerEntities[0]; startPosition = player.Body.Position; // Trees AddEntity(new Entity(this, EntityType.Game, new Vector2(2.4f, 2f), 0.4f, new SpriteComponent("tree1", new Vector2(5.25f, 6.02f), new Vector2(0.5f, 0.5f), layerDepth: 0.9f), new PhysicsComponent(new PolygonShape(new Vertices(GameConstants.BoundingTree1), 1)) )); AddEntity(new Entity(this, EntityType.Game, new Vector2(-2.8f, -3.5f), 1.4f, new SpriteComponent("tree1", new Vector2(5.25f * 1.1f, 6.02f * 1.1f), new Vector2(0.5f, 0.5f), layerDepth: 0.9f), new PhysicsComponent(new PolygonShape(new Vertices(GameConstants.BoundingTree1.Select(v => v * 1.1f)), 1)) )); // UI AddEntity(new Entity(this, EntityType.UI, new Vector2(0.5f, 0.95f), welcome = new HUDTextComponent(MainFont, 0.08f, "Welcome to VACAMOLE.", origin: new Vector2(0.5f, 0.5f)) { Opacity = 0 }, playerAndBarn = new HUDTextComponent(MainFont, 0.08f, "This is your player and your barn.", origin: new Vector2(0.5f, 0.5f)) { Opacity = 0 }, moveWithStick = new HUDTextComponent(MainFont, 0.08f, "Try to move with the left stick of your controller.", origin: new Vector2(0.5f, 0.5f)) { Opacity = 0 }, dash1 = new HUDTextComponent(MainFont, 0.08f, "Good. Now press the right bumper to dash.", origin: new Vector2(0.5f, 0.5f)) { Opacity = 0 }, dash2 = new HUDTextComponent(MainFont, 0.08f, "Try to dash multiple times.", origin: new Vector2(0.5f, 0.5f)) { Opacity = 0 }, lure = new HUDTextComponent(MainFont, 0.08f, "Press A to lure animals towards you!", origin: new Vector2(0.5f, 0.5f)) { Opacity = 0 }, shout = new HUDTextComponent(MainFont, 0.08f, "Press B to shout. The animals will run!", origin: new Vector2(0.5f, 0.5f)) { Opacity = 0 } )); AddEntity(new Entity(this, EntityType.UI, new Vector2(0.5f, 0.9f), dizzy = new HUDTextComponent(MainFont, 0.08f, "If you dash too often or into a something, you get dizzy.\nHowever, if you hit another player you can make them dizzy.", origin: new Vector2(0.5f, 0.5f)) { Opacity = 0 }, fetchAnimal = new HUDTextComponent(MainFont, 0.08f, "Now use luring (B) and shouting (A) to bring animals into your barn.\nBoars give 3 points, chicken 1 point.", origin: new Vector2(0.5f, 0.5f)) { Opacity = 0 }, pressStartToLeave = new HUDTextComponent(MainFont, 0.08f, "Well done! Press START to continue!\nGrab your friends - VACAMOLE is enjoyed best with 4 players!", origin: new Vector2(0.5f, 0.5f)) { Opacity = 0 })); bool isKeyboard = Game.CurrentGameMode.PlayerInfos.First().IsKeyboardPlayer; int gamepadIndex = Game.CurrentGameMode.PlayerInfos.First().GamepadIndex; AddEntity(new Entity(this, EntityType.LayerIndependent, new InputComponent(gamepadIndex, new InputMapping(f => (isKeyboard) ? InputFunctions.KeyboardMenuStart(f) : InputFunctions.MenuStart(f), f => { if (currentState == TutorialState.PressStartToLeaveTutorial && !IsTransitioning) { Settings <GameSettings> .Value.ShowTutorial = false; Settings <GameSettings> .Save(); Pause(); this.TransitionOutAndSwitchScene(navigateBackToMainMenu ? (Scene) new MainMenuScene(Game) : new GameModeScene(Game)); } })))); }
public override void LoadContent() { base.LoadContent(); if (Game.CurrentGameMode.PlayerMode == PlayerMode.Free4All) { LoadContentFree4All(); } else { LoadContent2vs2(); } HUDComponent vignetteComponent = new HUDComponent(Game.Debug.DebugRectangle, Vector2.One, layerDepth: -0.8f) { MaintainAspectRation = false, OnVirtualUIScreen = false, Color = Color.FromNonPremultiplied(22, 59, 59, 163) }; AddEntity(new Entity(this, EntityType.UI, vignetteComponent)); var backgroundSize = new Vector2(6f / 3.508f * 1.1f * GameConstants.ScreenHeight, 1.1f * GameConstants.ScreenHeight); AddEntity(new Entity(this, EntityType.Game, new SpriteComponent("background", backgroundSize, new Vector2(0.5f, 0.5f), layerDepth: -1.0f))); AddEntity(new Entity(this, EntityType.Game, new SpriteComponent("trees_border", backgroundSize, new Vector2(0.5f, 0.5f), layerDepth: 0.9f))); var inputEntity = new Entity(this, EntityType.LayerIndependent); // [FOREACH PERFORMANCE] Should not allocate garbage foreach (var player in Game.CurrentGameMode.PlayerInfos) { if (player.IsKeyboardPlayer) { inputEntity.AddComponent(new InputComponent(player.GamepadIndex, new InputMapping(InputFunctions.KeyboardMenuStart, FadeInMenu) )); } else { inputEntity.AddComponent(new InputComponent(player.GamepadIndex, new InputMapping(InputFunctions.MenuStart, FadeInMenu) )); } } AddEntity(inputEntity); HUDTextComponent pressStartText = new HUDTextComponent(MainFont, 0.04f, "press start to continue", offset: new Vector2(0.5f, 0.9f), origin: new Vector2(0.5f, 0.5f), layerDepth: 0f) { Opacity = 0 }; Dispatcher.AddAnimation(Animation.Get(0, 1, 1.5f, true, val => pressStartText.Opacity = val, EasingFunctions.ToLoop(EasingFunctions.QuadIn), delay: 5f)); AddEntity(new Entity(this, EntityType.UI, pressStartText)); // Add continue overlay AddEntity(new Entity(this, EntityType.UI, continueBackground = new HUDComponent(Game.Debug.DebugRectangle, Vector2.One, layerDepth: 0.99f) { Color = Color.Black, Opacity = 0, MaintainAspectRation = false, OnVirtualUIScreen = false })); AddEntity(continueMenuList = new HUDListEntity(this, new Vector2(0.5f, 0.5f), layerDepth: 1f, menuEntries: new[] { new HUDListEntity.ListEntry("Rematch", Rematch), new HUDListEntity.ListEntry("Rejoin", Rejoin) , new HUDListEntity.ListEntry("Back to main menu", BackToMainMenu) }) { Enabled = false, Opacity = 0 }); AddEntity(new Entity(this, EntityType.LayerIndependent, new CenterCameraComponent(Game.Camera))); this.TransitionIn(); }
private void ShowMidText(string value) { HUDTextComponent midText = new HUDTextComponent(MainFont, 0.06f, value, offset: new Vector2(0.5f, 0.1f), origin: new Vector2(0.5f, 0.5f), layerDepth: 0f); AddEntity(new Entity(this, EntityType.UI, midText)); }
public override void LoadContent() { base.LoadContent(); Game.EngineComponents.Get <AudioManager>().PreloadSongs("Audio\\joinScreen", "Audio\\gamePlay"); joinAnimationDefinition = Game.Content.LoadFromJson <AnimationDefintion>("Animations/join_anim"); availablePlayerNames = Game.Content.LoadFromJson <PlayerNamesDefinition>("Text/player_names_text").Names; // [FOREACH PERFORMANCE] Should not allocate garbage foreach (var p in Game.CurrentGameMode.PlayerInfos) { JoinPlayer(p.IsKeyboardPlayer, p.GamepadIndex, p); } // Player mode AddEntity(new Entity(this, EntityType.UI, new Vector2(0.5f, 0.05f), new HUDComponent(Game.CurrentGameMode.PlayerMode == PlayerMode.Free4All ? "gameMode_freeForAll_" : "gameMode_2VS2_", new Vector2(0.5f, 0.32f), origin: new Vector2(0.5f, 0.5f)), new HUDTextComponent(MainFont, 0.04f, Game.CurrentGameMode.PlayerMode == PlayerMode.TwoVsTwo ? "Team 1" : "", origin: new Vector2(0.5f, 0.5f), offset: new Vector2(-0.25f, 0f)), new HUDTextComponent(MainFont, 0.04f, Game.CurrentGameMode.PlayerMode == PlayerMode.TwoVsTwo ? "Team 2" : "", origin: new Vector2(0.5f, 0.5f), offset: new Vector2(0.25f, 0f)) )); AddEntity(new Entity(this, EntityType.UI, new Vector2(0.5f, 0.95f), pressStartToStart = new HUDTextComponent(MainFont, 0.08f, "PRESS START", origin: new Vector2(0.5f, 0.5f)) { Opacity = 0 } )); pressStartToStartAnimation = Dispatcher.AddAnimation(Animation.Get(0, 1, 1.5f, true, val => pressStartToStart.Opacity = val, EasingFunctions.ToLoop(EasingFunctions.QuadIn)).Set(a => a.IsRunning = false)); // Keyboard Entity AddEntity(new Entity(this, EntityType.LayerIndependent, MakeInput(true, 0))); // Gamepads AddEntity(new Entity(this, EntityType.LayerIndependent, MakeInput(false, 0))); AddEntity(new Entity(this, EntityType.LayerIndependent, MakeInput(false, 1))); AddEntity(new Entity(this, EntityType.LayerIndependent, MakeInput(false, 2))); AddEntity(new Entity(this, EntityType.LayerIndependent, MakeInput(false, 3))); AddEntity(new Entity(this, EntityType.UI, joinComponent = new HUDAnimatedComponent(joinAnimationDefinition, new Vector2(0.4f, 0.4f), origin: new Vector2(0.5f, 0.5f), offset: new Vector2(0.5f, 0.5f)), joinTextComponent = new HUDTextComponent(MainFont, 0.05f, "Press A to join", offset: new Vector2(0.5f, 0.575f), origin: new Vector2(0.5f, 0.5f), layerDepth: 0.1f) )); var backgroundSize = new Vector2(6f / 3.508f * 1.1f * GameConstants.ScreenHeight, 1.1f * GameConstants.ScreenHeight); AddEntity(new Entity(this, EntityType.Game, new SpriteComponent("background", backgroundSize, new Vector2(0.5f, 0.5f), layerDepth: -1.0f))); AddEntity(new Entity(this, EntityType.Game, new SpriteComponent("joinscreen_outerBorder", backgroundSize, new Vector2(0.5f, 0.5f), layerDepth: 0.9f), new PhysicsComponent(new PolygonShape(PolygonTools.CreateRectangle(GameConstants.ScreenWidth, 1, new Vector2(0, GameConstants.ScreenHeight / 2.0f), 0), 1)), new PhysicsComponent(new PolygonShape(PolygonTools.CreateRectangle(GameConstants.ScreenWidth, 1, new Vector2(0, -GameConstants.ScreenHeight / 2.0f), 0), 1)), new PhysicsComponent(new PolygonShape(PolygonTools.CreateRectangle(1, GameConstants.ScreenHeight, new Vector2(GameConstants.ScreenWidth / 2.0f, 0), 0), 1)), new PhysicsComponent(new PolygonShape(PolygonTools.CreateRectangle(1, GameConstants.ScreenHeight, new Vector2(-GameConstants.ScreenWidth / 2.0f, 0), 0), 1)) )); AddEntity(new Entity(this, EntityType.Game, new SpriteComponent("joinscreen_trees_center", backgroundSize, new Vector2(0.5f, 0.5f), layerDepth: 0.9f), new PhysicsComponent(new CircleShape(GameConstants.ScreenHeight / 6.0f, 1f)) )); AddEntity(new Entity(this, EntityType.Game, new SpriteComponent("joinscreen_trees_top", backgroundSize, new Vector2(0.5f, 0.5f), layerDepth: 0.9f), new PhysicsComponent(new PolygonShape(PolygonTools.CreateRectangle(1, GameConstants.ScreenHeight, new Vector2(0, -GameConstants.ScreenHeight / 4.0f), 0), 1)) )); AddEntity(new Entity(this, EntityType.Game, new SpriteComponent("joinscreen_trees_bottom", backgroundSize, new Vector2(0.5f, 0.5f), layerDepth: 0.9f), new PhysicsComponent(new PolygonShape(PolygonTools.CreateRectangle(1, GameConstants.ScreenHeight, new Vector2(0, GameConstants.ScreenHeight / 4.0f), 0), 1)) )); if (Game.CurrentGameMode.PlayerMode == PlayerMode.Free4All) { AddEntity(new Entity(this, EntityType.Game, new SpriteComponent("joinscreen_trees_left", backgroundSize, new Vector2(0.5f, 0.5f), layerDepth: 0.9f), new PhysicsComponent(new PolygonShape(PolygonTools.CreateRectangle(GameConstants.ScreenWidth, 1, new Vector2(-GameConstants.ScreenWidth / 4.0f, 0), 0), 1)) )); AddEntity(new Entity(this, EntityType.Game, new SpriteComponent("joinscreen_trees_right", backgroundSize, new Vector2(0.5f, 0.5f), layerDepth: 0.9f), new PhysicsComponent(new PolygonShape(PolygonTools.CreateRectangle(GameConstants.ScreenWidth, 1, new Vector2(GameConstants.ScreenWidth / 4.0f, 0), 0), 1)) )); } AddEntity(new Entity(this, EntityType.LayerIndependent, new CenterCameraComponent(Game.Camera))); this.TransitionIn(); }
public override void LoadContent() { base.LoadContent(); Game.EngineComponents.Get <AudioManager>().PreloadSoundEffects("Audio/countDownLong", "Audio/countDownShort"); Game.CurrentGameMode.ClearScore(); AddPlayersWithBarns(locs, rotations); // Border trees Entity border; AddEntity(border = new Entity(this, EntityType.Game, new Vector2(0, 0), new SpriteComponent("joinscreen_outerBorder", new Vector2(screenWidth, screenWidth / 3.84f * 2.245f), new Vector2(0.5f, 0.5f), layerDepth: 0.9f) )); var triangulated = Triangulate.ConvexPartition(GameConstants.BoundingGameFieldTop, TriangulationAlgorithm.Earclip); triangulated.AddRange(Triangulate.ConvexPartition(GameConstants.BoundingGameFieldRight, TriangulationAlgorithm.Earclip)); triangulated.AddRange(Triangulate.ConvexPartition(GameConstants.BoundingGameFieldBottom, TriangulationAlgorithm.Earclip)); triangulated.AddRange(Triangulate.ConvexPartition(GameConstants.BoundingGameFieldLeft, TriangulationAlgorithm.Earclip)); var fixtureList = FixtureFactory.AttachCompoundPolygon(triangulated, 1, border.Body); border.AddComponent(new PhysicsComponent(fixtureList[0].Shape)); // Background AddEntity(new Entity(this, EntityType.Game, new Vector2(0, 0), // src image 6000x3508 new SpriteComponent("background", new Vector2(screenWidth, screenWidth / 3.84f * 2.245f), new Vector2(0.5f, 0.5f), layerDepth: -1.0f) )); // HUD // src image 1365x460 if (spawnAnyUI) { timeComponentBackground = new HUDComponent("timer_bg", new Vector2(1.365f / 0.46f * 0.1f, 1f * 0.1f), new Vector2(0.5f, 0f)); this.timeComponent100 = new HUDTextComponent(MainFont, 0.07f, "", color: countdownColor, offset: timeComponentBackground.LocalPointToWorldPoint(new Vector2(0.35f, 0.5f)), origin: new Vector2(0.5f, 0.5f) ); this.timeComponent10 = new HUDTextComponent(MainFont, 0.07f, "", color: countdownColor, offset: timeComponentBackground.LocalPointToWorldPoint(new Vector2(0.425f, 0.5f)), origin: new Vector2(0.5f, 0.5f) ); this.timeComponent1 = new HUDTextComponent(MainFont, 0.07f, "", color: countdownColor, offset: timeComponentBackground.LocalPointToWorldPoint(new Vector2(0.5f, 0.5f)), origin: new Vector2(0.5f, 0.5f) ); AddEntity(new Entity(this, EntityType.UI, new Vector2(0.5f, 0f), timeComponentBackground, timeComponent100, timeComponent10, timeComponent1 )); if (!IsCountdownRunning) { timeComponentBackground.Opacity = timeComponent100.Opacity = timeComponent10.Opacity = timeComponent1.Opacity = 0f; } UpdateCountdown(0); // Add pause overlay AddEntity(new Entity(this, EntityType.UI, pauseOverlayComponents.AddAndReturn(new HUDComponent(Game.Debug.DebugRectangle, Vector2.One, layerDepth: 0.99f) { Color = Color.Black, MaintainAspectRation = false, OnVirtualUIScreen = false, }))); AddEntity(new Entity(this, EntityType.UI, new Vector2(0.5f, 0.25f), pauseTextOverlayComponents.AddAndReturn(new HUDTextComponent(MainFont, 0.2f, "Game Paused", origin: new Vector2(0.5f, 0.5f), layerDepth: 1f)))); pauseTextOverlayComponents.AddRange( AddEntity(pauseMenuList = new HUDListEntity(this, new Vector2(0.5f, 0.5f), layerDepth: 1f, menuEntries: new[] { new HUDListEntity.ListEntry("Resume", TogglePause), new HUDListEntity.ListEntry("Rejoin", BackToJoinScreen) , new HUDListEntity.ListEntry("Back to main menu", BackToMainMenu) }) { Enabled = false }) .GetAllComponents <HUDTextComponent>().ToList()); // make overlay invisible // [FOREACH PERFORMANCE] Should not allocate garbage pauseOverlayComponents.ForEach(c => c.Opacity = 0f); // [FOREACH PERFORMANCE] Should not allocate garbage pauseTextOverlayComponents.ForEach(c => c.Opacity = 0f); // Add pause controls // [FOREACH PERFORMANCE] Should not allocate garbage foreach (var playerInfo in Game.CurrentGameMode.PlayerInfos) { if (playerInfo.IsKeyboardPlayer) { AddEntity(new Entity(this, EntityType.LayerIndependent, new InputComponent(new InputMapping(i => InputFunctions.KeyboardPause(i), (f) => TogglePause(null))))); } else { AddEntity(new Entity(this, EntityType.LayerIndependent, new InputComponent(playerInfo.GamepadIndex, new InputMapping(i => InputFunctions.Pause(i), (f) => TogglePause(null)), new InputMapping(i => InputFunctions.StartCountdown(i), (f) => StartCountown()) ))); } } var playerInfos = Game.CurrentGameMode.PlayerInfos; var colors = ((PlayerColors[])Enum.GetValues(typeof(PlayerColors))); initialCountdownComponent = new HUDTextComponent(MainFont, 0.25f, Game.CurrentGameMode.PlayerMode == PlayerMode.TwoVsTwo ? "vs" : "free4all", origin: new Vector2(0.5f, 0.5f)); playerName1Component = new HUDTextComponent(MainFont, 0.15f, playerInfos[0].Name, color: colors[0].GetColor(), origin: new Vector2(0f, 0.5f), offset: new Vector2(-0.25f, -0.25f)); playerName2Component = new HUDTextComponent(MainFont, 0.15f, playerInfos.Count > 1 ? playerInfos[1].Name : "name2", color: colors[1].GetColor(), origin: new Vector2(0f, 0.5f), offset: new Vector2(-0.25f, 0.25f)); playerName3Component = new HUDTextComponent(MainFont, 0.15f, playerInfos.Count > 2 ? playerInfos[2].Name : "name3", color: colors[2].GetColor(), origin: new Vector2(1f, 0.5f), offset: new Vector2(0.25f, -0.25f)); playerName4Component = new HUDTextComponent(MainFont, 0.15f, playerInfos.Count > 3 ? playerInfos[3].Name : "name4", color: colors[3].GetColor(), origin: new Vector2(1f, 0.5f), offset: new Vector2(0.25f, 0.25f)); separatorTeam1Component = new HUDTextComponent(MainFont, 0.15f, "&", origin: new Vector2(0.5f, 0.5f), offset: new Vector2(0f, -0.25f)); separatorTeam2Component = new HUDTextComponent(MainFont, 0.15f, "&", origin: new Vector2(0.5f, 0.5f), offset: new Vector2(0f, 0.25f)); Entity countdownEntity; AddEntity(countdownEntity = new Entity(this, EntityType.UI, new Vector2(0.5f, 0.5f), initialCountdownComponent)); if (Game.CurrentGameMode.PlayerMode == PlayerMode.TwoVsTwo) { countdownEntity.AddComponent(playerName1Component); countdownEntity.AddComponent(playerName2Component); countdownEntity.AddComponent(playerName3Component); countdownEntity.AddComponent(playerName4Component); countdownEntity.AddComponent(separatorTeam1Component); countdownEntity.AddComponent(separatorTeam2Component); } } // Camera director AddEntity(new Entity(this, EntityType.LayerIndependent, new CameraDirectorComponent(playerEntities, Game.Camera))); }
public override void LoadContent() { base.LoadContent(); var backgroundSize = new Vector2(6f / 3.508f * 1.1f * GameConstants.ScreenHeight, 1.1f * GameConstants.ScreenHeight); AddEntity(new Entity(this, EntityType.Game, new SpriteComponent("background", backgroundSize, new Vector2(0.5f, 0.5f), layerDepth: -1.0f))); AddEntity(new Entity(this, EntityType.Game, new SpriteComponent("trees_border", backgroundSize, new Vector2(0.5f, 0.5f), layerDepth: 0.9f))); // UI var buttonBackground = new HUDComponent("overlayInstructionBox", new Vector2(1.2f, 0.2f), offset: new Vector2(0.5f, 0.05f), origin: new Vector2(0.5f, 0.05f)); AddEntity(new Entity(this, EntityType.UI, buttonBackground, new HUDTextComponent(MainFont, 0.1f, "Game mode", offset: buttonBackground.LocalPointToWorldPoint(new Vector2(0.5f, 0.5f)), origin: new Vector2(0.5f, 0.5f), layerDepth: 0.1f) )); // Player mode selection playerMode2vs2 = new HUDComponent("gameMode_2VS2_notselected", new Vector2(0.5f, 0.32f), origin: new Vector2(0.5f, 0.5f), offset: new Vector2(-0.16f, 0)) { Opacity = 0f }; playerMode2vs2Selected = new HUDComponent("gameMode_2VS2_selected", new Vector2(0.5f, 0.32f), origin: new Vector2(0.5f, 0.5f), offset: new Vector2(-0.16f, 0)); playerModeFree4All = new HUDComponent("gameMode_freeForAll_notselected", new Vector2(0.5f, 0.32f), origin: new Vector2(0.5f, 0.5f), offset: new Vector2(0.16f, 0)); playerModeFree4AllSelected = new HUDComponent("gameMode_freeForAll_selected", new Vector2(0.5f, 0.32f), origin: new Vector2(0.5f, 0.5f), offset: new Vector2(0.16f, 0)) { Opacity = 0f }; AddEntity(new Entity(this, EntityType.UI, new Vector2(0.5f, 0.3f), playerMode2vs2, playerModeFree4All, playerMode2vs2Selected, playerModeFree4AllSelected)); // Game mode selection gameModeWaves = new HUDTextComponent(MainFont, 0.05f, "WAVES", origin: new Vector2(0.5f, 0.5f), offset: new Vector2(-0.11f, 0), color: Color.Yellow) { Opacity = InActiveOpacity }; gameModeBigHerd = new HUDTextComponent(MainFont, 0.05f, "BIG HERD", origin: new Vector2(0.5f, 0.5f), offset: new Vector2(0.11f, 0)) { Opacity = InActiveOpacity }; AddEntity(new Entity(this, EntityType.UI, new Vector2(0.5f, 0.55f), gameModeWaves, gameModeBigHerd)); // Runtime mode selection runtimeModeOptions = Enumerable.Range(0, 4).Select(i => new HUDTextComponent(MainFont, 0.05f, "", origin: new Vector2(0.5f, 0.5f), offset: new Vector2(-0.225f, 0) + new Vector2(0.15f, 0) * i) { Opacity = InActiveOpacity, Color = i == 0 ? Color.Yellow : Color.Wheat }).ToArray(); UpdateRuntimeTexts(); AddEntity(new Entity(this, EntityType.UI, new Vector2(0.5f, 0.65f), runtimeModeOptions)); // CONTINUE TEXT continueText = new HUDTextComponent(MainFont, 0.05f, "press A to continue", origin: new Vector2(0.5f, 0.5f)) { Opacity = 0 }; AddEntity(new Entity(this, EntityType.UI, new Vector2(0.5f, 0.8f), continueText)); continueTextAnimation = Dispatcher.AddAnimation(Animation.Get(0, 1, 1.5f, true, val => continueText.Opacity = val, EasingFunctions.ToLoop(EasingFunctions.QuadIn)) .Set(a => a.IsRunning = false)); // add controls var layerIndependent = new Entity(this, EntityType.LayerIndependent, new CenterCameraComponent(Game.Camera)); for (int i = 0; i < 4; i++) { layerIndependent.AddComponent(new InputComponent(i, new InputMapping(f => InputFunctions.MenuSelect(f) || InputFunctions.MenuDown(f), OnNextPressed), new InputMapping(f => InputFunctions.MenuBack(f) || InputFunctions.MenuUp(f), OnBackPressed), new InputMapping(f => InputFunctions.MenuStart(f), OnStartPressed), new InputMapping(f => InputFunctions.MenuLeft(f), OnLeftPressed), new InputMapping(f => InputFunctions.MenuRight(f), OnRightPressed))); } layerIndependent.AddComponent(new InputComponent( new InputMapping(f => InputFunctions.KeyboardMenuSelect(f) || InputFunctions.KeyboardMenuDown(f), OnNextPressed), new InputMapping(f => InputFunctions.KeyboardMenuBack(f) || InputFunctions.KeyboardMenuUp(f), OnBackPressed), new InputMapping(f => InputFunctions.KeyboardMenuStart(f), OnStartPressed), new InputMapping(f => InputFunctions.KeyboardMenuLeft(f), OnLeftPressed), new InputMapping(f => InputFunctions.KeyboardMenuRight(f), OnRightPressed))); AddEntity(layerIndependent); GoToMenuState(MenuState.ChoosePlayerMode); this.TransitionIn(); }