public void Update(List <Inpc> npcs) { if (Tint < 1f) { Tint += Game1.Delta / 100; } if (Tint > 1f) { Tint = 1f; } _timeShoot.Update(); if (Health <= 0) { Kill(); } if (LineSegmentF.Lenght(Boundary.Origin, Game1.PlayerInstance.Boundary.Origin) < 800) { //----------- _angle = Vector2.Dot(new LineSegmentF(Boundary.Origin, Game1.PlayerInstance.Boundary.Origin).NormalizedWithZeroSolution(), CompareF.AngleToVector(_rotation)); _velocityOfRotation = 0f; if (_angle > 0.01f) { _velocityOfRotation = -0.001f; } if (_angle < -0.01f) { _velocityOfRotation = 0.001f; } //--------- _rotation += _velocityOfRotation * Game1.Delta; _destination = CompareF.AngleToVector((float)(_rotation + Math.PI / 2f)); _barrel = Boundary.Origin + Vector2.Normalize(_destination) * (24 + 6); _destination = CompareF.RotateVector2(_destination, (float)(Globals.GlobalRandom.NextDouble() - 0.5f) / 4f); if (_timeShoot.Ready == true) { _ammo--; Game1.mapLive.MapProjectiles.Add(new Projectile(5, _destination, _barrel, this)); Sound.PlaySoundPosition(Boundary.Origin, Game1.sound); _timeShoot.Reset(); } } }
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); }