/// <summary> /// Update the resolution scale for all inworld entities/lvl/layers /// </summary> public void UpdateResolution(int width, int height, ResolutionState res) { switch (CResolution = res) { case ResolutionState.R1280x720: ResScale = 1; break; case ResolutionState.R1600x900: ResScale = 1.25f; break; case ResolutionState.R1920x1080: ResScale = 1.5f; break; } foreach (var entity in Entities) { entity.ResScale = ResScale * entity.Scale; } FWidth = width; FHeight = height; var frameW = width * 0.5f; var frameH = height * 0.5f; Services.Camera.Origin = new Vector2(frameW, frameH); Services.Camera.viewport = CoreGame.GraphicsDevice.Viewport; LVLManager.UpdateScale(ResScale, new Vector2(frameW, frameH), CoreGame.GraphicsDevice.Viewport); }
public void Unload() { PLManager.Unload(); //SManager.UnloadContent(); LVLManager.Unload(); AUManager.Unload(); }
/// <summary> /// Draw all entities (except player) in the world /// </summary> public void DrawLVLEntities(GameTime gameTime, SpriteBatch batcher) { foreach (var entity in Entities) { if (entity.GetType() != typeof(Character)) { entity.Draw(gameTime, batcher); } } LVLManager.EndDrawLastLayer(batcher); }
// Got all services! public void Initialize(ContentManager content, GraphicsDevice graphdev, int frameWidth, int frameHeight) { this.GraphDev = graphdev; SManager = ScreenManager.Instance; LManager = LoadManager.Instance; LManager.Initialize(content, GraphDev.Viewport); AUManager = AudioManager.Instance; IOHandler = InputHandler.Instance; PLManager = PipelineManager.Instance; PLManager.Initialize(content); LVLManager = LevelManager.Instance; LVLManager.Initialize(); Camera = new Camera(GraphDev.Viewport); Camera.Position = new Vector2(0f, frameWidth / 2); Camera.Zoom = 1.0f; IsInitialized = true; }
/// <summary> /// Draw front layers of the level /// </summary> public virtual void DrawLVLFront(GameTime gameTime, SpriteBatch batcher) { LVLManager.DrawSpecific(batcher, new Vector2(Services.Camera.Position.X + FWidth, Services.Camera.Position.X - FWidth / 2), LevelState.FRONT_NOT_EFFECTED, LevelState.FRONT_NOT_EFFECTED); }
/// <summary> /// Draw back and middle layers of the level /// </summary> public virtual void DrawLVLBack(GameTime gameTime, SpriteBatch batcher) { LVLManager.DrawSpecific(batcher, new Vector2(Services.Camera.Position.X + FWidth, Services.Camera.Position.X), LevelState.BACKGROUND | LevelState.BACK | LevelState.MIDDLE, LevelState.NONE); }
public virtual void Update(GameTime gameTime) { // Check for the need in spawner if (EntitiesToAdd.Count != 0) { Spawner(); } // Updates all entities in world foreach (var entity in Entities) { var oldEntityPosition = entity.WPosition; entity.Update(gameTime); if (entity.IsGrounded) { continue; } entity.IsOnPlatform = false; foreach (var platform in Platforms) { if (entity.BoundingBox.Intersects(platform.BoundingBox)) { if (entity.BoundingBox.Bottom > platform.BoundingBox.Top) { entity.IsOnPlatform = true; } } } } CamInput(); // Move camera position Services.Camera.LookAt(Player.WPosition); /// Update lvl/Layers Cameras prespective LVLManager.Update(Player.WPosition, (int)Player.WPosition.X, FWidth / 2 + FWidth / (int)CResolution); // Collide all entities foreach (var a in Entities) { foreach (var b in Entities) { if (!ReferenceEquals(a, b)) { if (a.BoundingBox.Intersects(b.BoundingBox)) { a.Touch(b); if (a is Projectile && b is Entity) { b.Kill(b); } if (b is Projectile && a is Entity) { a.Kill(a); } } } } } Entities.RemoveAll(e => EntitiesToKill.Contains(e)); EntitiesToKill.Clear(); }