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("button_bg", new Vector2(1.2f, 0.2f), offset: new Vector2(0.5f, 0f), origin: new Vector2(0.5f, 0f)); AddEntity(new Entity(this, EntityType.UI, buttonBackground, new HUDTextComponent(MainFont, 0.1f, "Select a game mode:", offset: buttonBackground.LocalPointToWorldPoint(new Vector2(0.5f, 0.5f)), origin: new Vector2(0.5f, 0.5f)) )); HUDListEntity levelList = new HUDListEntity(this, new Vector2(0.5f, 0.5f), menuEntries: levels.Select(l => new HUDListEntity.ListEntry(l.Item2, item => { selectedLevel = l.Item1; Dispatcher.NextFrame(StartLevel); })).ToArray()); AddEntity(levelList); AddEntity(new Entity(this, EntityType.LayerIndependent, new CenterCameraComponent(Game.Camera))); }
/// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// </summary> protected override void Initialize() { // Makes Input Manager as a service and adds as a component m_gameState = new GameState(this); Components.Add(m_gameState); m_inputManager = new InputManager(this); Services.AddService(typeof(InputManager), m_inputManager); Components.Add(m_inputManager); m_movementManager = new MovementManager(this); Services.AddService(typeof(MovementManager), m_movementManager); Components.Add(m_movementManager); // Setting up HUD. Must follow setting up MovementManager! headsUpDisplay = new HUDComponent(this); Components.Add(headsUpDisplay); RasterizerState state = new RasterizerState(); state.CullMode = CullMode.None; m_graphics.GraphicsDevice.RasterizerState = state; m_gameState.GraphicsDevice = m_graphics.GraphicsDevice; m_gameState.AspectRatio = m_graphics.GraphicsDevice.Viewport.AspectRatio; base.Initialize(); }
/// <summary> /// Creates an new Player with Controlls /// </summary> /// <param name="pixlePer"> True if pixelPerfect shall be used </param> /// <param name="GamePade"> True if GamePad the player uses a gamepad </param> /// <param name="PadJump"> Key binding to gamePad </param> /// <param name="Jump"> key binding to keybord </param> /// <param name="position"> Player start Position </param> /// <param name="name"> The name off the player</param> /// <param name="dir"> The players starting direction</param> /// <param name="index"> Playerindex For GamePad </param> /// <returns></returns> public int CreatePlayer(bool pixlePer, bool GamePade, Buttons PadJump, Keys Jump, Vector2 position, string name, Direction dir, PlayerIndex index, Color colour) { SpriteEffects flip; GamePadComponent gam; KeyBoardComponent kcb; int id = ComponentManager.Instance.CreateID(); if (dir == Direction.Left) { flip = SpriteEffects.FlipHorizontally; } else { flip = SpriteEffects.None; } if (GamePade == true) { gam = new GamePadComponent(index); gam.gamepadActions.Add(ActionsEnum.Jump, PadJump); ComponentManager.Instance.AddComponentToEntity(id, gam); } else { kcb = new KeyBoardComponent(); kcb.keyBoardActions.Add(ActionsEnum.Jump, Jump); ComponentManager.Instance.AddComponentToEntity(id, kcb); } DirectionComponent dc = new DirectionComponent(dir); DrawableComponent comp = new DrawableComponent(Game.Instance.GetContent <Texture2D>("Pic/kanin1"), flip); PositionComponent pos = new PositionComponent(position); VelocityComponent vel = new VelocityComponent(new Vector2(200F, 0), 50F); JumpComponent jump = new JumpComponent(300F, 200F); CollisionRectangleComponent CRC = new CollisionRectangleComponent(new Rectangle((int)pos.position.X, (int)pos.position.Y, comp.texture.Width, comp.texture.Height)); CollisionComponent CC = new CollisionComponent(pixlePer); PlayerComponent pc = new PlayerComponent(name); DrawableTextComponent dtc = new DrawableTextComponent(name, Color.Black, Game.Instance.GetContent <SpriteFont>("Fonts/TestFont")); HUDComponent hudc = new HUDComponent(Game.Instance.GetContent <Texture2D>("Pic/PowerUp"), new Vector2(pos.position.X, pos.position.Y)); HUDComponent hudc2 = new HUDComponent(Game.Instance.GetContent <Texture2D>("Pic/PowerUp"), Vector2.One); HealthComponent hc = new HealthComponent(3, false); //AnimationComponent ani = new AnimationComponent(100, 114, comp.texture.Width, comp.texture.Height, 0.2); comp.colour = colour; ComponentManager.Instance.AddComponentToEntity(id, vel); ComponentManager.Instance.AddComponentToEntity(id, comp); ComponentManager.Instance.AddComponentToEntity(id, pos); ComponentManager.Instance.AddComponentToEntity(id, CRC); ComponentManager.Instance.AddComponentToEntity(id, CC); ComponentManager.Instance.AddComponentToEntity(id, pc); ComponentManager.Instance.AddComponentToEntity(id, dtc); ComponentManager.Instance.AddComponentToEntity(id, hudc); ComponentManager.Instance.AddComponentToEntity(id, hc); //ComponentManager.Instance.AddComponentToEntity(id, ani); ComponentManager.Instance.AddComponentToEntity(id, dc); ComponentManager.Instance.AddComponentToEntity(id, jump); return(id); }
public GameManager(Game game) : base(game) { input = new InputHandler(game); hud = new HUDComponent(game); BlockType.textureAsset = "Game/Bricks/Cat-Eye Brick"; loadingScreen = new LoadingScreen("Fonts/LindseyMedium"); }
// 设置hud显示组件 protected void SetHUDComponent(HUDComponent hud) { _hud = hud; if (_hud == null) { RemoveComponent(typeof(HUDComponent).FullName); } else { AddComponent(_hud); } }
/// <summary> /// /// </summary> /// <param name="dir"></param> /// <param name="position"></param> /// <param name="pixlePer"></param> /// <param name="name"></param> /// <returns></returns> public int CreateAIPlayer(Direction dir, Vector2 position, bool pixlePer, string name, Color colour) { SpriteEffects flip; if (dir == Direction.Left) { flip = SpriteEffects.FlipHorizontally; } else { flip = SpriteEffects.None; } DirectionComponent dc = new DirectionComponent(dir); DrawableComponent comp = new DrawableComponent(Game.Instance.GetContent <Texture2D>("Pic/Helmutsh"), flip); PositionComponent pos = new PositionComponent(position); VelocityComponent vel = new VelocityComponent(new Vector2(200F, 0), 50F); JumpComponent jump = new JumpComponent(300F, 50F); CollisionRectangleComponent CRC = new CollisionRectangleComponent(new Rectangle((int)pos.position.X, (int)pos.position.Y, comp.texture.Width, comp.texture.Height)); CollisionComponent CC = new CollisionComponent(pixlePer); DrawableTextComponent dtc = new DrawableTextComponent(name, Color.Yellow, Game.Instance.GetContent <SpriteFont>("Fonts/NewTestFont")); HUDComponent hudc = new HUDComponent(Game.Instance.GetContent <Texture2D>("Pic/PowerUp"), new Vector2(pos.position.X, pos.position.Y)); HUDComponent hudc2 = new HUDComponent(Game.Instance.GetContent <Texture2D>("Pic/PowerUp"), Vector2.One); HealthComponent hc = new HealthComponent(3, false); AnimationComponent ani = new AnimationComponent(75, 75, comp.texture.Width, comp.texture.Height, 0.2); AIComponent ai = new AIComponent(); PlayerComponent play = new PlayerComponent(name); comp.colour = colour; int id = ComponentManager.Instance.CreateID(); ComponentManager.Instance.AddComponentToEntity(id, vel); ComponentManager.Instance.AddComponentToEntity(id, comp); ComponentManager.Instance.AddComponentToEntity(id, pos); ComponentManager.Instance.AddComponentToEntity(id, CRC); ComponentManager.Instance.AddComponentToEntity(id, CC); ComponentManager.Instance.AddComponentToEntity(id, dtc); ComponentManager.Instance.AddComponentToEntity(id, hudc); ComponentManager.Instance.AddComponentToEntity(id, hc); ComponentManager.Instance.AddComponentToEntity(id, ani); ComponentManager.Instance.AddComponentToEntity(id, dc); ComponentManager.Instance.AddComponentToEntity(id, jump); ComponentManager.Instance.AddComponentToEntity(id, play); ComponentManager.Instance.AddComponentToEntity(id, ai); return(id); }
protected override void OnUpdate() { for (int i = 0; i < hudData.Length; i++) { HUDComponent hud = hudData.hud[i]; for (int j = 0; j < playerData.Length; j++) { WeaponState weaponState = playerData.weaponState[j]; WeaponComponent weapon = playerData.weapon[j]; Health health = playerData.health[j]; hud.ammo.text = weaponState.magazine.ToString(); float reloadProgress = 1 - weaponState.reloadTimer / weapon.reloadTime; hud.reloadBar.size = reloadProgress; hud.healthBar.size = health.value / 100f; hud.gameOver.SetActive(health.value == 0); } } }
private void CreateWinningImage(string asset, string name, int totalScore, int boars, int chickens, Vector2 position, float scale, float baseLayerDepth) { HUDComponent winnerComponent = new HUDComponent("WinOverlay", Vector2.One * scale, new Vector2(0.5f, 0.5f), layerDepth: baseLayerDepth + 0.01f); // pixel perfect, taken from graphic Vector2 textPosition = (new Vector2(0.5f, 0.65f) - Vector2.One / 2f) * scale; Vector2 totalPosition = (new Vector2(0.488f, 0.85f) - Vector2.One / 2f) * scale; Vector2 leftPosition = (new Vector2(0.455f, 0.955f) - Vector2.One / 2f) * scale; Vector2 rightPosition = (new Vector2(0.56f, 0.955f) - Vector2.One / 2f) * scale; Entity winnerEntity = new Entity(this, EntityType.UI, position, new HUDComponent(asset, Vector2.One * scale, new Vector2(0.5f, 0.5f), layerDepth: baseLayerDepth), winnerComponent, new HUDTextComponent(MainFont, 0.12f * scale, name, new Vector2(0.5f, 0.5f), layerDepth: baseLayerDepth + 0.02f, offset: textPosition), new HUDTextComponent(MainFont, 0.17f * scale, totalScore.ToString(), new Vector2(0.5f, 0.5f), layerDepth: baseLayerDepth + 0.02f, offset: totalPosition), new HUDTextComponent(MainFont, 0.05f * scale, boars.ToString(), new Vector2(0.5f, 0.5f), layerDepth: baseLayerDepth + 0.02f, offset: leftPosition), new HUDTextComponent(MainFont, 0.05f * scale, chickens.ToString(), new Vector2(0.5f, 0.5f), layerDepth: baseLayerDepth + 0.02f, offset: rightPosition) ); AddEntity(winnerEntity); }
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 void draw(GameTime gameTime, SpriteBatch spriteBatch) { List <int> entitys = ComponentManager.Instance.GetAllEntitiesWithComponentType <HUDComponent>(); if (entitys != null) { foreach (var entity in entitys) { PositionComponent pc = ComponentManager.Instance.GetEntityComponent <PositionComponent>(entity); HUDComponent hudc = ComponentManager.Instance.GetEntityComponent <HUDComponent>(entity); DrawableComponent dc = ComponentManager.Instance.GetEntityComponent <DrawableComponent>(entity); HealthComponent hc = ComponentManager.Instance.GetEntityComponent <HealthComponent>(entity); AnimationComponent ani = ComponentManager.Instance.GetEntityComponent <AnimationComponent>(entity); width = hudc.texture.Width; if (pc != null && hudc != null && hc != null && ani != null) { hudc.position.X = pc.position.X + (ani.sourceRectangle.Width * 0.5f) - (hudc.texture.Width * (hc.health * 0.5f)); hudc.position.Y = pc.position.Y - hudc.texture.Height; for (int i = 0; i < hc.health; i++) { spriteBatch.Draw(hudc.texture, hudc.position, Color.White); hudc.position.X += width; } } else { hudc.position.X = pc.position.X + (dc.texture.Width * 0.5f) - (hudc.texture.Width * (hc.health * 0.5f)); hudc.position.Y = pc.position.Y - hudc.texture.Height; for (int i = 0; i < hc.health; i++) { spriteBatch.Draw(hudc.texture, hudc.position, Color.White); hudc.position.X += width; } } } } }
//This region contains all HUD data #region HUD data void initializeHUD() { hud = new HUDComponent(this, GraphicsDevice); BaseTextType temp; temp = new BaseTextType("Score:", "Fonts/LindseySmall", new Vector2(10, 5), Color.Blue); hud.addText(temp); temp = new BaseTextType("Score Number", "Fonts/LindseySmall", new Vector2(55, 5), Color.Blue); temp = new NumberWrapper(temp, score); hud.addText(temp); temp = new BaseTextType("Lives:", "Fonts/LindseySmall", new Vector2(100, 5), Color.Blue); hud.addText(temp); temp = new BaseTextType("Lives Number", "Fonts/LindseySmall", new Vector2(145, 5), Color.Blue); temp = new NumberWrapper(temp, lives); hud.addText(temp); temp = new BaseTextType("Level:", "Fonts/LindseySmall", new Vector2(170, 5), Color.Blue); hud.addText(temp); temp = new BaseTextType("Level Number", "Fonts/LindseySmall", new Vector2(220, 5), Color.Blue); temp = new NumberWrapper(temp, levelNumber); hud.addText(temp); temp = new BaseTextType("Add Score Number", "Fonts/LindseySmall", new Vector2(60, 15), Color.Yellow); temp = new NumberWrapper(temp, 0); temp = new FloatWrapper(temp, new Vector2(0, 3), 1.0f); temp = new FadeWrapper(temp, 1.0f, -1); temp = new ScaleWrapper(temp, 1.02f, 1.0f, 1.0f); hud.addText(temp); Components.Add(hud); }
private void CreateLoosingImage(string asset, bool isWide, string name, int totalScore, int boars, int chickens, Vector2 position, float scale, float baseLayerDepth) { Vector2 imageSize; Vector2 textPosition; Vector2 totalPosition; Vector2 leftPosition; Vector2 rightPosition; if (isWide) // team looser graphics are wider to accomodate both players { imageSize = new Vector2(1f, 0.3864090606262492f); textPosition = (new Vector2(0.352f, 0.275f) - Vector2.One / 2f) * imageSize * scale; totalPosition = (new Vector2(0.355f, 0.7f) - Vector2.One / 2f) * imageSize * scale; leftPosition = (new Vector2(0.575f, 0.81f) - Vector2.One / 2f) * imageSize * scale; rightPosition = (new Vector2(0.675f, 0.81f) - Vector2.One / 2f) * imageSize * scale; } else { imageSize = new Vector2(1f, 0.4531f); textPosition = (new Vector2(0.362f, 0.275f) - Vector2.One / 2f) * imageSize * scale; totalPosition = (new Vector2(0.362f, 0.7f) - Vector2.One / 2f) * imageSize * scale; leftPosition = (new Vector2(0.575f, 0.81f) - Vector2.One / 2f) * imageSize * scale; rightPosition = (new Vector2(0.72f, 0.81f) - Vector2.One / 2f) * imageSize * scale; } HUDComponent looserGraphic = new HUDComponent(asset, imageSize * scale, new Vector2(0.5f, 0.5f), layerDepth: baseLayerDepth); Entity looserEntity = new Entity(this, EntityType.UI, position, looserGraphic, new HUDTextComponent(MainFont, 0.08f * scale, name, new Vector2(0.5f, 0.5f), layerDepth: baseLayerDepth + 0.02f, offset: textPosition), new HUDTextComponent(MainFont, 0.17f * scale, totalScore.ToString(), new Vector2(0.5f, 0.5f), layerDepth: baseLayerDepth + 0.02f, offset: totalPosition), new HUDTextComponent(MainFont, 0.05f * scale, boars.ToString(), new Vector2(0.5f, 0.5f), layerDepth: baseLayerDepth + 0.02f, offset: leftPosition), new HUDTextComponent(MainFont, 0.05f * scale, chickens.ToString(), new Vector2(0.5f, 0.5f), layerDepth: baseLayerDepth + 0.02f, offset: rightPosition) ); AddEntity(looserEntity); }
//This region contains code for the HUD component, such as initializing and loading, as well as Event Handlers #region HUD Data void initializeHUD() { hud = new HUDComponent(this, GraphicsDevice); BaseTextType temp; temp = new TextType("Score", new Vector2(190, 90), Color.Red); hud.addText(temp); temp = new TextType("Score Number", new Vector2(190, 105), Color.Red); temp = new NumberWrapper(temp, score); hud.addText(temp); temp = new TextType("Level", new Vector2(190, 130), Color.Red); hud.addText(temp); temp = new TextType("Level Number", new Vector2(210, 145), Color.Red); temp = new NumberWrapper(temp, level); hud.addText(temp); temp = new TextType("Bonus", new Vector2(190, 170), Color.Red); hud.addText(temp); temp = new TextType("Multiplier Number", new Vector2(210, 185), Color.Red); temp = new NumberWrapper(temp, multiplier); hud.addText(temp); temp = new TextType("High\nScore", new Vector2(190, 210), Color.Red); hud.addText(temp); temp = new TextType("High Score Number", new Vector2(190, 245), Color.Red); temp = new NumberWrapper(temp, highScores.getHighScore()); hud.addText(temp); temp = new TextType("Next Level", new Vector2(25, 160), Color.White); temp = new FloatWrapper(temp, new Vector2(0, -3), 3.0f); hud.addText(temp); temp = new TextType("Next Level Number", new Vector2(90, 190), Color.White); temp = new NumberWrapper(temp, level); temp = new FloatWrapper(temp, new Vector2(0, -3), 3.0f); hud.addText(temp); temp = new TextType("Add Score Number", new Vector2(80, 240), Color.Yellow); temp = new NumberWrapper(temp, 0); temp = new FloatWrapper(temp, new Vector2(0, -3), 1.0f); hud.addText(temp); temp = new TextType("Multiplier Bonus", new Vector2(100, 100), Color.Orange); temp = new ScaleWrapper(temp, 1, 1.5f, 0.5f, 3); hud.addText(temp); temp = new TextType("Add Multiplier Number", new Vector2(100, 130), Color.Orange); temp = new NumberWrapper(temp, level); temp = new ScaleWrapper(temp, 1, 1.5f, 0.5f, 3); hud.addText(temp); temp = new TextType("Bonus Expired", new Vector2(25, 120), Color.Orange); temp = new FadeWrapper(temp, 4); hud.addText(temp); Components.Add(hud); }
/// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// </summary> protected override void Initialize() { AggregateFactory = new AggregateFactory(this); WeaponFactory = new WeaponFactory(this); DoorFactory = new DoorFactory(this); RoomFactory = new RoomFactory(this); CollectableFactory = new CollectibleFactory(this); WallFactory = new WallFactory(this); EnemyFactory = new EnemyFactory(this); SkillEntityFactory = new SkillEntityFactory(this); NPCFactory = new NPCFactory(this); // Initialize Components PlayerComponent = new PlayerComponent(); LocalComponent = new LocalComponent(); RemoteComponent = new RemoteComponent(); PositionComponent = new PositionComponent(); MovementComponent = new MovementComponent(); MovementSpriteComponent = new MovementSpriteComponent(); SpriteComponent = new SpriteComponent(); DoorComponent = new DoorComponent(); RoomComponent = new RoomComponent(); HUDSpriteComponent = new HUDSpriteComponent(); HUDComponent = new HUDComponent(); InventoryComponent = new InventoryComponent(); InventorySpriteComponent = new InventorySpriteComponent(); ContinueNewGameScreen = new ContinueNewGameScreen(graphics, this); EquipmentComponent = new EquipmentComponent(); WeaponComponent = new WeaponComponent(); BulletComponent = new BulletComponent(); PlayerInfoComponent = new PlayerInfoComponent(); WeaponSpriteComponent = new WeaponSpriteComponent(); StatsComponent = new StatsComponent(); EnemyAIComponent = new EnemyAIComponent(); NpcAIComponent = new NpcAIComponent(); CollectibleComponent = new CollectibleComponent(); CollisionComponent = new CollisionComponent(); TriggerComponent = new TriggerComponent(); EnemyComponent = new EnemyComponent(); NPCComponent = new NPCComponent(); //QuestComponent = new QuestComponent(); LevelManager = new LevelManager(this); SpriteAnimationComponent = new SpriteAnimationComponent(); SkillProjectileComponent = new SkillProjectileComponent(); SkillAoEComponent = new SkillAoEComponent(); SkillDeployableComponent = new SkillDeployableComponent(); SoundComponent = new SoundComponent(); ActorTextComponent = new ActorTextComponent(); TurretComponent = new TurretComponent(); TrapComponent = new TrapComponent(); ExplodingDroidComponent = new ExplodingDroidComponent(); HealingStationComponent = new HealingStationComponent(); PortableShieldComponent = new PortableShieldComponent(); PortableStoreComponent = new PortableStoreComponent(); ActiveSkillComponent = new ActiveSkillComponent(); PlayerSkillInfoComponent = new PlayerSkillInfoComponent(); Quests = new List<Quest>(); #region Initialize Effect Components AgroDropComponent = new AgroDropComponent(); AgroGainComponent = new AgroGainComponent(); BuffComponent = new BuffComponent(); ChanceToSucceedComponent = new ChanceToSucceedComponent(); ChangeVisibilityComponent = new ChangeVisibilityComponent(); CoolDownComponent = new CoolDownComponent(); DamageOverTimeComponent = new DamageOverTimeComponent(); DirectDamageComponent = new DirectDamageComponent(); DirectHealComponent = new DirectHealComponent(); FearComponent = new FearComponent(); HealOverTimeComponent = new HealOverTimeComponent(); InstantEffectComponent = new InstantEffectComponent(); KnockBackComponent = new KnockBackComponent(); TargetedKnockBackComponent = new TargetedKnockBackComponent(); ReduceAgroRangeComponent = new ReduceAgroRangeComponent(); ResurrectComponent = new ResurrectComponent(); StunComponent = new StunComponent(); TimedEffectComponent = new TimedEffectComponent(); EnslaveComponent = new EnslaveComponent(); CloakComponent = new CloakComponent(); #endregion base.Initialize(); }
/// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// </summary> protected override void Initialize() { AggregateFactory = new AggregateFactory(this); WeaponFactory = new WeaponFactory(this); DoorFactory = new DoorFactory(this); RoomFactory = new RoomFactory(this); CollectableFactory = new CollectibleFactory(this); WallFactory = new WallFactory(this); EnemyFactory = new EnemyFactory(this); SkillEntityFactory = new SkillEntityFactory(this); NPCFactory = new NPCFactory(this); // Initialize Components PlayerComponent = new PlayerComponent(); LocalComponent = new LocalComponent(); RemoteComponent = new RemoteComponent(); PositionComponent = new PositionComponent(); MovementComponent = new MovementComponent(); MovementSpriteComponent = new MovementSpriteComponent(); SpriteComponent = new SpriteComponent(); DoorComponent = new DoorComponent(); RoomComponent = new RoomComponent(); HUDSpriteComponent = new HUDSpriteComponent(); HUDComponent = new HUDComponent(); InventoryComponent = new InventoryComponent(); InventorySpriteComponent = new InventorySpriteComponent(); ContinueNewGameScreen = new ContinueNewGameScreen(graphics, this); EquipmentComponent = new EquipmentComponent(); WeaponComponent = new WeaponComponent(); BulletComponent = new BulletComponent(); PlayerInfoComponent = new PlayerInfoComponent(); WeaponSpriteComponent = new WeaponSpriteComponent(); StatsComponent = new StatsComponent(); EnemyAIComponent = new EnemyAIComponent(); NpcAIComponent = new NpcAIComponent(); CollectibleComponent = new CollectibleComponent(); CollisionComponent = new CollisionComponent(); TriggerComponent = new TriggerComponent(); EnemyComponent = new EnemyComponent(); NPCComponent = new NPCComponent(); //QuestComponent = new QuestComponent(); LevelManager = new LevelManager(this); SpriteAnimationComponent = new SpriteAnimationComponent(); SkillProjectileComponent = new SkillProjectileComponent(); SkillAoEComponent = new SkillAoEComponent(); SkillDeployableComponent = new SkillDeployableComponent(); SoundComponent = new SoundComponent(); ActorTextComponent = new ActorTextComponent(); TurretComponent = new TurretComponent(); TrapComponent = new TrapComponent(); ExplodingDroidComponent = new ExplodingDroidComponent(); HealingStationComponent = new HealingStationComponent(); PortableShieldComponent = new PortableShieldComponent(); PortableStoreComponent = new PortableStoreComponent(); ActiveSkillComponent = new ActiveSkillComponent(); PlayerSkillInfoComponent = new PlayerSkillInfoComponent(); MatchingPuzzleComponent = new MatchingPuzzleComponent(); pI = new PlayerInfo(); Quests = new List <Quest>(); #region Initialize Effect Components AgroDropComponent = new AgroDropComponent(); AgroGainComponent = new AgroGainComponent(); BuffComponent = new BuffComponent(); ChanceToSucceedComponent = new ChanceToSucceedComponent(); ChangeVisibilityComponent = new ChangeVisibilityComponent(); CoolDownComponent = new CoolDownComponent(); DamageOverTimeComponent = new DamageOverTimeComponent(); DirectDamageComponent = new DirectDamageComponent(); DirectHealComponent = new DirectHealComponent(); FearComponent = new FearComponent(); HealOverTimeComponent = new HealOverTimeComponent(); PsiOrFatigueRegenComponent = new PsiOrFatigueRegenComponent(); InstantEffectComponent = new InstantEffectComponent(); KnockBackComponent = new KnockBackComponent(); TargetedKnockBackComponent = new TargetedKnockBackComponent(); ReduceAgroRangeComponent = new ReduceAgroRangeComponent(); ResurrectComponent = new ResurrectComponent(); StunComponent = new StunComponent(); TimedEffectComponent = new TimedEffectComponent(); EnslaveComponent = new EnslaveComponent(); CloakComponent = new CloakComponent(); #endregion base.Initialize(); }
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(); }
/// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// </summary> protected override void Initialize() { AggregateFactory = new AggregateFactory(this); // Initialize Components PlayerComponent = new PlayerComponent(); LocalComponent = new LocalComponent(); RemoteComponent = new RemoteComponent(); PositionComponent = new PositionComponent(); MovementComponent = new MovementComponent(); MovementSpriteComponent = new MovementSpriteComponent(); SpriteComponent = new SpriteComponent(); DoorComponent = new DoorComponent(); RoomComponent = new RoomComponent(); HUDSpriteComponent = new HUDSpriteComponent(); HUDComponent = new HUDComponent(); CharacterSelectionScreen = new CharacterSelectionScreen(graphics, this); LevelManager = new LevelManager(this); base.Initialize(); }
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(); 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(); }
/// <summary> /// Allows the game to perform any initialization it needs to before starting to run. /// This is where it can query for any required services and load any non-graphic /// related content. Calling base.Initialize will enumerate through any components /// and initialize them as well. /// </summary> protected override void Initialize() { AggregateFactory = new AggregateFactory(this); WeaponFactory = new WeaponFactory(this); DoorFactory = new DoorFactory(this); RoomFactory = new RoomFactory(this); CollectableFactory = new CollectibleFactory(this); WallFactory = new WallFactory(this); EnemyFactory = new EnemyFactory(this); // Initialize Components PlayerComponent = new PlayerComponent(); LocalComponent = new LocalComponent(); RemoteComponent = new RemoteComponent(); PositionComponent = new PositionComponent(); MovementComponent = new MovementComponent(); MovementSpriteComponent = new MovementSpriteComponent(); SpriteComponent = new SpriteComponent(); DoorComponent = new DoorComponent(); RoomComponent = new RoomComponent(); HUDSpriteComponent = new HUDSpriteComponent(); HUDComponent = new HUDComponent(); InventoryComponent = new InventoryComponent(); InventorySpriteComponent = new InventorySpriteComponent(); ContinueNewGameScreen = new ContinueNewGameScreen(graphics, this); EquipmentComponent = new EquipmentComponent(); WeaponComponent = new WeaponComponent(); BulletComponent = new BulletComponent(); PlayerInfoComponent = new PlayerInfoComponent(); WeaponSpriteComponent = new WeaponSpriteComponent(); StatsComponent = new StatsComponent(); EnemyAIComponent = new EnemyAIComponent(); CollectibleComponent = new CollectibleComponent(); CollisionComponent = new CollisionComponent(); TriggerComponent = new TriggerComponent(); EnemyComponent = new EnemyComponent(); QuestComponent = new QuestComponent(); LevelManager = new LevelManager(this); SpriteAnimationComponent = new SpriteAnimationComponent(); SkillProjectileComponent = new SkillProjectileComponent(); SkillAoEComponent = new SkillAoEComponent(); SkillDeployableComponent = new SkillDeployableComponent(); //TurretComponent = new TurretComponent(); //TrapComponent = new TrapComponent(); //PortableShopComponent = new PortableShopComponent(); //PortableShieldComponent = new PortableShieldComponent(); //MotivateComponent = new MotivateComponent(); //FallbackComponent = new FallbackComponent(); //ChargeComponent = new ChargeComponent(); //HealingStationComponent = new HealingStationComponent(); //ExplodingDroidComponent = new ExplodingDroidComponent(); base.Initialize(); }
public override void LoadContent() { base.LoadContent(); Game.CurrentGameMode.ClearPlayers(); 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("button_bg", new Vector2(1.2f, 0.2f), offset: new Vector2(0.5f, 0f), origin: new Vector2(0.5f, 0f)); //AddEntity(new Entity(this, EntityType.UI, buttonBackground, // new HUDTextComponent(MainFont, 0.1f, "Vacamole", // offset: buttonBackground.LocalPointToWorldPoint(new Vector2(0.5f, 0.5f)), // origin: new Vector2(0.5f, 0.5f)) //)); HUDComponent vignetteComponent = new HUDComponent(Game.Debug.DebugRectangle, Vector2.One, layerDepth: -0.1f) { MaintainAspectRation = false, OnVirtualUIScreen = false, Color = Color.FromNonPremultiplied(22, 59, 59, 163) }; Vector2 logoSize = new Vector2(1, 0.7684f); HUDComponent logoComponent = new HUDComponent("titleScreen", 0.8f * logoSize, offset: new Vector2(0.5f, 0.1f), origin: new Vector2(0.5f, 0f), layerDepth: -0.1f); AddEntity(new Entity(this, EntityType.UI, Vector2.Zero, vignetteComponent, logoComponent)); mainMenuList = new HUDListEntity(this, new Vector2(0.5f, 0.8f), elementSize: 0.1f, allowAllControllers: true, isHorizontal: true, menuEntries: new[] { new HUDListEntity.ListEntry("New Game", OnNewGame), new HUDListEntity.ListEntry("Options", (i) => GoToMenuState(MenuState.Options)), new HUDListEntity.ListEntry("Controls", (i) => GoToMenuState(MenuState.Controls)), new HUDListEntity.ListEntry("Tutorial", OnGoToTutorial), new HUDListEntity.ListEntry("Credits", (i) => GoToMenuState(MenuState.Credits)), new HUDListEntity.ListEntry("Exit", OnExit) }) { Enabled = false, Opacity = 0 }; optionsList = new HUDListEntity(this, new Vector2(0.5f, 0.8f), elementSize: 0.15f, allowAllControllers: true, isHorizontal: true, menuEntries: new[] { new HUDListEntity.ListEntry($"Master: {GetPercentage(Settings<GameSettings>.Value.MasterVolume)}%", OnMasterVolume), new HUDListEntity.ListEntry($"Sound: {GetPercentage(Settings<GameSettings>.Value.SoundVolume)}%", OnSoundVolume), new HUDListEntity.ListEntry($"Music: {GetPercentage(Settings<GameSettings>.Value.MusicVolume)}%", OnMusicVolume), new HUDListEntity.ListEntry("Back", SaveAndBack) }) { Enabled = false, Opacity = 0 }; controlInstructionsBackground = new HUDComponent(Game.Debug.DebugRectangle, Vector2.One, origin: new Vector2(0.5f, 0.5f), layerDepth: -0.1f) { MaintainAspectRation = false, OnVirtualUIScreen = false, Color = Color.FromNonPremultiplied(0, 0, 0, 160), Opacity = 0 }; controlInstructions = new HUDComponent("controls", new Vector2(0.85f, 0.4f), origin: new Vector2(0.5f, 0.5f)) { Opacity = 0, MaintainAspectRation = true }; AddEntity(new Entity(this, EntityType.UI, new Vector2(0.5f, 0.5f), controlInstructionsBackground, controlInstructions)); AddEntity(mainMenuList); AddEntity(optionsList); GoToMenuState(MenuState.MainMenu); var layerIndependent = new Entity(this, EntityType.LayerIndependent, new CenterCameraComponent(Game.Camera)); // Add controls to hide the controls overlay or the credits overlay (later version) for (int i = 0; i < 4; i++) { layerIndependent.AddComponent(new InputComponent(i, new InputMapping(f => InputFunctions.MenuSelect(f) || InputFunctions.MenuBack(f), HideControls))); } layerIndependent.AddComponent(new InputComponent(new InputMapping(f => InputFunctions.KeyboardMenuSelect(f) || InputFunctions.KeyboardMenuBack(f), HideControls))); AddEntity(layerIndependent); creditsScene = new[] { new HUDTextComponent(MainFont, 0.03f, "Credits", offset: new Vector2(0.5f, 0.1f), origin: new Vector2(0.5f, 0.5f)) { Opacity = 0 }, new HUDTextComponent(MainFont, 0.04f, "Programming", offset: new Vector2(0.5f, 0.25f), origin: new Vector2(0.5f, 0.5f)) { Opacity = 0 }, new HUDTextComponent(MainFont, 0.06f, "Alexander Kayed\nMoritz Zilian\nFlorian Zinggeler", offset: new Vector2(0.5f, 0.4f), origin: new Vector2(0.5f, 0.5f)) { Opacity = 0 }, new HUDTextComponent(MainFont, 0.04f, "Art", offset: new Vector2(0.5f, 0.6f), origin: new Vector2(0.5f, 0.5f)) { Opacity = 0 }, new HUDTextComponent(MainFont, 0.06f, "Sonja Böckler", offset: new Vector2(0.5f, 0.675f), origin: new Vector2(0.5f, 0.5f)) { Opacity = 0 }, new HUDTextComponent(MainFont, 0.035f, "This game was created during the\nETH Game Programming Laboratory course\nin collaboration with ZHdK", offset: new Vector2(0.5f, 0.85f), origin: new Vector2(0.5f, 0.5f)) { Opacity = 0 }, }; AddEntity(new Entity(this, EntityType.UI, creditsScene)); this.TransitionIn(); }