public void Tick(TickContext context) { var keys = Keyboard.GetState(); var mouse = Mouse.GetState(); if (mouse.LeftButton == ButtonState.Pressed || keys.IsKeyDown(Keys.Space)) { WeaponCapability?.StandardFire(); } if (mouse.RightButton == ButtonState.Pressed || keys.IsKeyDown(Keys.Enter)) { WeaponCapability?.HeavyFire(); } if (KeyControls.HasBeenPressed(Keys.D1)) { WeaponCapability?.ShieldDeploy(); } if (KeyControls.HasBeenPressed(Keys.D2)) { WeaponCapability?.BombardFire(); } if (KeyControls.HasBeenPressed(Keys.D6)) { WeaponCapability?.RocketBlast(); } }
//private (Point point, BuildNode buildNode) GetSelectedGridPoint() //{ //} public void Tick(TickContext context) { var mouse = Mouse.GetState(); var screenPos = new Vector2( mouse.X / (float)GraphicsDevice.Viewport.Width, 1.0f - (mouse.Y / (float)GraphicsDevice.Viewport.Height) ) * 2 - new Vector2(1, 1); //Console.WriteLine($"screen {screenPos}"); //Console.WriteLine(screenPos); //Console.WriteLine(worldDirectionVector); var ray = Camera.CreateRay(screenPos); var res = RayCollider.RayCast(ray, (byte)HitLayers.BuildTile); // Console.WriteLine($"Location: {res.location}"); var buildNode = res.entity?.Get <BuildNode>(); if (buildNode != null) { //Console.WriteLine($"{buildNode.GridLocation}"); } this.Update(() => HoverNode = buildNode); if (PlacingSection != null) { if (KeyControls.HasBeenPressed(Keys.R)) { PlacingSection.Rotate(1); } if (MouseControls.RightClicked) { CancelPlacing(); } else if (buildNode != null && MouseControls.LeftClicked) { var gridLocation = buildNode.GridLocation; if (_shipTopology.SectionAt(gridLocation) == null && _shipTopology.LegalSectionCheck(PlacingSection, gridLocation)) { this.Update(() => { _shipTopology.SetSection(gridLocation, PlacingSection); _productionLine.Remove(PlacingSection); PlacingSection = null; SoundEffects.Get("Hammer")?.Play(); }); } else { SoundEffects.Get("Click")?.Play(); } } } }