public DebugComponent(GameState State) : base(State) { this.DrawOrder = int.MaxValue; this.Font = CorvusGame.Instance.GlobalContent.Load<SpriteFont>("Fonts/TestFont"); if(Directory.Exists(DATA_FOLDER_PATH)) { FileSystemWatcher fsw = new FileSystemWatcher(DATA_FOLDER_PATH); fsw.InternalBufferSize = 1024 * 256; fsw.IncludeSubdirectories = true; fsw.Changed += DataFileUpdate; fsw.Created += DataFileUpdate; fsw.EnableRaisingEvents = true; } SceneManager = CorvusGame.Instance.SceneManager; CorvusGame.Instance.Game.IsMouseVisible = true; this.Player = (CorvusPlayer)CorvusGame.Instance.Players.First(); Bind ReloadLevelsBind = new Bind(Player.InputManager, ReloadPressed, false, Keys.F5); Player.InputManager.RegisterBind(ReloadLevelsBind); Bind ClearCameraBind = new Bind(Player.InputManager, ClearCameraPressed, false, Keys.F12); Player.InputManager.RegisterBind(ClearCameraBind); Bind ToggleGeometryBind = new Bind(Player.InputManager, ToggleGeometryPressed, false, Keys.F11); Player.InputManager.RegisterBind(ToggleGeometryBind); Bind ToggleEntityBind = new Bind(Player.InputManager, ToggleEntityPressed, false, Keys.F10); Player.InputManager.RegisterBind(ToggleEntityBind); Bind TogglePerformanceBind = new Bind(Player.InputManager, TogglePerformancePressed, false, Keys.F9); Player.InputManager.RegisterBind(TogglePerformanceBind); CurrentCamera = Player.Character.GetComponent<ChaseCameraComponent>(); GeometryTexture = CorvusGame.Instance.GlobalContent.Load<Texture2D>("Interface/Outline"); }
protected override void OnUpdate(GameTime gameTime) { MouseState State = Mouse.GetState(); if (State.LeftButton == ButtonState.Pressed && OldState.LeftButton != ButtonState.Pressed) { var Entity = SceneManager.ActiveScene.GetEntityAtPosition(new Point(State.X + (int)Player.Camera.Position.X, State.Y + (int)Player.Camera.Position.Y)); if (Entity != null) { if (!CurrentCamera.IsDisposed) { CurrentCamera.Dispose(); } CurrentCamera = new ChaseCameraComponent(Player.Camera); Entity.Components.Add(CurrentCamera); } } if (State.RightButton == ButtonState.Pressed && OldState.RightButton != ButtonState.Pressed) { var Entity = SceneManager.ActiveScene.GetEntityAtPosition(new Point(State.X + (int)Player.Camera.Position.X, State.Y + (int)Player.Camera.Position.Y)); if (Entity != null) { foreach (var OtherEntity in SceneManager.ActiveScene.Entities.ToArray()) { if (OtherEntity != Entity && !CorvusGame.Instance.Players.Any(c => c.Character == OtherEntity)) { OtherEntity.Dispose(); } } } } }
private void ClearCameraPressed(BindState State) { if (State != BindState.Pressed) { return; } if (!CurrentCamera.IsDisposed) { CurrentCamera.Dispose(); } Player.Character.Components.Add((CurrentCamera = new ChaseCameraComponent(Player.Camera))); }
private void ClearCameraPressed(BindState State) { if(State != BindState.Pressed) return; if(!CurrentCamera.IsDisposed) CurrentCamera.Dispose(); Player.Character.Components.Add((CurrentCamera = new ChaseCameraComponent(Player.Camera))); }
protected override void OnUpdate(GameTime gameTime) { MouseState State = Mouse.GetState(); if(State.LeftButton == ButtonState.Pressed && OldState.LeftButton != ButtonState.Pressed) { var Entity = SceneManager.ActiveScene.GetEntityAtPosition(new Point(State.X + (int)Player.Camera.Position.X, State.Y + (int)Player.Camera.Position.Y)); if(Entity != null) { if(!CurrentCamera.IsDisposed) CurrentCamera.Dispose(); CurrentCamera = new ChaseCameraComponent(Player.Camera); Entity.Components.Add(CurrentCamera); } } if(State.RightButton == ButtonState.Pressed && OldState.RightButton != ButtonState.Pressed) { var Entity = SceneManager.ActiveScene.GetEntityAtPosition(new Point(State.X + (int)Player.Camera.Position.X, State.Y + (int)Player.Camera.Position.Y)); if(Entity != null) { foreach(var OtherEntity in SceneManager.ActiveScene.Entities.ToArray()) { if(OtherEntity != Entity && !CorvusGame.Instance.Players.Any(c => c.Character == OtherEntity)) OtherEntity.Dispose(); } } } }
private void SetCamera(Player Player) { var CameraComponent = new ChaseCameraComponent(Player.Camera); Player.Character.Components.Add(CameraComponent); /*float AspectRatio = GraphicsDevice.DisplayMode.AspectRatio; Vector2 Size; if(Math.Abs(AspectRatio - (16f / 9f)) < 0.01f) Size = new Vector2(1600, 900); else if(Math.Abs(AspectRatio - (16f / 10f)) < 0.01f) Size = new Vector2(1680, 1050); else Size = new Vector2(1600, 900); obj.Camera.Size = Size;*/ }