public static void scavengerAddToSupply(Scavenger scavenger) { scavenger.addLootToSupply(sniperRifle, machineGun, player); }
public void Update(MouseState currentMouseState, Weapon weapon, GameTime gameTime, Wave wave, Scavenger scavenger, GraphicsDevice graphicsDevice) { if (waveManager.State != 0) { if (State == 0) //Moving this check after this block creates cool redirect mechanic { aimingAngle = -100; float aimX = weapon.waveManager.getWave().layout.weaponGunpoint.X + weapon.waveManager.getWave().layout.crosshairAdjustX; float aimY = weapon.waveManager.getWave().layout.weaponGunpoint.Y + weapon.waveManager.getWave().layout.crosshairAdjustY; if (MainGame.currentGamepadState.IsConnected) { aimingVector.X = MainGame.currentGamepadState.ThumbSticks.Left.X; aimingVector.Y = -1 * MainGame.currentGamepadState.ThumbSticks.Left.Y; aimingVector.Normalize(); aimingAngle = (float)Math.Atan2(aimingVector.Y, aimingVector.X); if (!waveManager.getWave().layout.checkAimingVector(aimingVector)) { aimingAngle = -100; } } else { if (aimingAngle == -100) { aimingVector.X = currentMouseState.X - aimX; aimingVector.Y = currentMouseState.Y - aimY; aimingVector.Normalize(); aimingAngle = (float)Math.Atan2(aimingVector.Y, aimingVector.X); if (!waveManager.getWave().layout.checkAimingVector(aimingVector)) { aimingAngle = -100; } } } //If not firing, listen for aiming click //If clicked, place crosshair in front of gun //and switch to aiming state, //recording aiming vector //Also confirm that vector is going in logical direction if (currentMouseState.RightButton == ButtonState.Pressed || (MainGame.currentGamepadState.Buttons.LeftShoulder == ButtonState.Pressed)) // || (MainGame.currentGamepadState.Triggers.Left >= MainGame.triggerThreshold)) //is what we want { if (waveManager.getWave().layout.checkAimingVector(aimingVector) && weapon.reloadOver(gameTime) && !(weapon.clipSupply == 0 && weapon.ammoSupply == 0)) { aimingTimestamp = gameTime.TotalGameTime; Position.X = aimX; Position.Y = aimY; State = 1; } } } else { //If aiming, listen for firing click //If the aiming button is released, place it back offscreen //switch to not firing state //Otherwise, move crosshair along aiming vector //and if there is a firing clip, determine hit //and ammo changes or reload need if (currentMouseState.RightButton == ButtonState.Released && !(MainGame.currentGamepadState.Buttons.LeftShoulder == ButtonState.Pressed)) //&& !(MainGame.currentGamepadState.Triggers.Left >= MainGame.triggerThreshold)) //is what we want { resetPosition(); State = 0; } else { //Need to take firing cooldown/reload into consideration if (currentMouseState.LeftButton == ButtonState.Pressed || MainGame.currentGamepadState.Triggers.Right >= MainGame.triggerThreshold) //implied state==1 { weapon.playShot(gameTime); if (weapon.isFireable(gameTime)) { //Update game world here and inform weapon to draw //shot, but can't draw yet //Make scavengers in trench safe, but not others if (wave.isHit(Position) || (scavenger.action != 0 && scavenger.isHit(Position))) { weapon.ShotPoint.X = Position.X + Width / 2; weapon.ShotPoint.Y = Position.Y + Height / 2; } else { weapon.ShotPoint.X = weapon.waveManager.getWave().layout.weaponGunpoint.X + aimingVector.X * graphicsDevice.Viewport.Width; weapon.ShotPoint.Y = weapon.waveManager.getWave().layout.weaponGunpoint.Y + aimingVector.Y * graphicsDevice.Viewport.Width; } weapon.startShotCooldown(gameTime); } } float velocity = weapon.GetCrosshairVelocity((gameTime.TotalGameTime.Subtract(aimingTimestamp)).TotalMilliseconds); Position.X = aimingVector.X * velocity + Position.X; Position.Y = aimingVector.Y * velocity + Position.Y; } } } }