public void ShootWeapons(Player player, Vector2 realPos) { ShootCalc.LineAim(realPos, player, player.WeaponOrigin, player.CurrentWeaponObject.GunBarrel, player.CurrentWeaponObject.Reach); if (player.WeaponsAvailable == true && player.ControlsActive == true && player.Carry == null && player.InVehicle == false) { if (MouseInput.MouseStateNew.LeftButton == ButtonState.Pressed) { if (CompareF.WeaponRayObstruction(player.Boundary, ShootCalc.RayBarrel, Game1.PlayerInstance).Object == null) { player.CurrentWeaponObject.Fire(ShootCalc.RaySegment, ShootCalc.RayDestination); } else { player.CurrentWeaponObject.SetOff(); } } } }
public void Update(List <Inpc> npcs) { _time.Update(); _bubbleTime.Update(); if (_muzzleAlpha > 0) { _muzzleAlpha -= Game1.Delta / 50; } if (_kick > 0) { _kick--; } if (_resolver.InWater == true) { if (_bubbleTime.Ready == true) { Game1.mapLive.mapParticles.Add(new ParticleBubble(HeadPos)); _bubbleTime.Reset(); } } if (_target != null && _ammo > 0) { _angle = Vector2.Dot(new LineSegmentF(HeadPos, _target.Boundary.Origin).NormalizedWithZeroSolution(), CompareF.AngleToVector(_rotation)); _rotVelocity = 0f; if (_angle > 0.06f) { _rotVelocity = -(float)Math.PI / 720; } if (_angle < -0.06f) { _rotVelocity = (float)Math.PI / 720; } //--------- _rotation += _rotVelocity * Game1.Delta; _destination = CompareF.AngleToVector((float)(_rotation + Math.PI / 2f)); } else { _angle = Vector2.Dot(CompareF.AngleToVector(_rotation), CompareF.AngleToVector((float)Math.PI)); _rotVelocity = 0f; if (_angle > 0.02f) { _rotVelocity = -(float)Math.PI / 720; } if (_angle < -0.02f) { _rotVelocity = (float)Math.PI / 720; } _rotation += _rotVelocity * Game1.Delta; _destination = CompareF.AngleToVector((float)(_rotation + Math.PI / 2f)); } if (_time.Ready == true && _target != null && _ammo > 0 && Math.Abs(ExtensionMethods.AngleDifference(new LineSegmentF(HeadPos, _target.Boundary.Origin).ToAngle(), _rotation)) < 25f) { if (Locked == false) { _ammo--; } Game1.mapLive.MapProjectiles.Add(new Projectile(5, _destination, Barrel, Game1.PlayerInstance)); _kick = 4; _muzzleAlpha = 1f; Sound.PlaySoundPosition(HeadPos, Game1.sound); _time.Reset(); } if (Game1.mapLive.MapNpcs.Contains(_target) == false) { _target = null; } Pressure(this); _target = null; foreach (Inpc npc in Game1.mapLive.MapNpcs) { if (npc.Friendly == false && !(npc is IUnkillable) && LineSegmentF.Lenght(HeadPos, npc.Boundary.Origin) <= 512 && CompareF.WeaponRayObstruction(Boundary, new LineSegmentF(HeadPos, npc.Boundary.Origin), this).Object == null) { _target = npc; break; } } _resolver.move(ref _velocity, new Vector2(2f), Boundary, 0f, new Vector2(0.2f), new Vector2(0.02f), new Vector2(0.3f), Game1.mapLive.MapMovables); }