public bool Fire(LineSegmentF rayEnlonged, Vector2Object destination) { Vector2 barrel = rayEnlonged.Start + rayEnlonged.NormalizedWithZeroSolution() * GunBarrel; if (GunTimer.Ready == true) { Game1.sound.Play(1f, (float)(Globals.GlobalRandom.NextDouble() - 0.5f) / 2f, 0f); GunTimer.Reset(); Game1.mapLive.MapProjectiles.Add(new ProjectileExplosive(Damage, CompareF.RotateVector2(rayEnlonged.NormalizedWithZeroSolution(), (float)(Globals.GlobalRandom.NextDouble() - 0.5f) / 8f) * VelocityOfProjectile, barrel, Owner)); return(true); } return(false); }
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 Generate(byte count) { _count = count; _nodes.Clear(); float angleBetween; angleBetween = (float)(Math.PI * 2) / count; for (int i = 0; i < count; i++) { Vector2 _velocity = new Vector2(((float)Globals.GlobalRandom.NextDouble() * 2f), 0); _velocities.Add(CompareF.RotateVector2(_velocity, angleBetween * i)); } _nodes = _circle.DidvideCircle(count); _nodes.AddRange(_circle.DidvideCircle(count)); CircleF _n = new CircleF(_circle.Center, _circle.Radius - 6); _nodes.AddRange(_n.DidvideCircle(count)); _nodes.AddRange(_n.DidvideCircle(count)); }
public void Update(Map map) { if (_wet == false) { _trail.Update(_position, _velocity, 1); } UpdateLine(); _bubbleTime.Update(); _InWater = false; if (CompareF.LineBoundaryVsMap(map.WaterTree, _track).Count > 0) { _InWater = true; if (_bubbleTime.Ready == true) { Game1.mapLive.mapParticles.Add(new ParticleBubble(_position)); _bubbleTime.Reset(); } } if (_wet == true && _wet != _wetPreviousFrame) { _velocity /= 4; _trail.LeftParticle(); } foreach (Inpc npc in map.MapNpcs) { if (npc.Friendly == false) { List <Vector2Object> intersections = CompareF.LineIntersectionRectangle(npc, new LineObject(npc, _track.Line)); if ((intersections?.Count > 0 || CompareF.RectangleVsVector2(npc.Boundary, _track.Line.End) == true) && (_from is Player)) { Damage(new Vector2Object(npc, _position), npc); AfterCollision(map, new Vector2Object(npc, _position)); break; } } } Vector2Object hitPos = null; if (OutOfmap(this, out hitPos) == true) { AfterCollision(map, new Vector2Object(Game1.mapLive, _position)); } if (CollisionWithMovables(map, this, out hitPos) == true) { AfterCollision(map, hitPos); } if (RemoveOnMapCollision(map.MapTree, this, out hitPos) == true) { AfterCollision(map, hitPos); } _velocity = CompareF.RotateVector2(_velocity, (float)(Math.Sin(Game1.Time * 16) / 64f)); _timeTrail.Update(); if (_timeTrail.Ready == true || _wet == true) { if (_wet == false) { List <Vector2> vectors = LineSegmentF.PointsOnLine(_position.ShiftOverDistance(32, (float)(CompareF.VectorToAngle(_velocity) + Math.PI)), _oldInterpol, 64); foreach (Vector2 vector in vectors) { for (int i = 0; i < 3; i++) { Game1.mapLive.mapParticles.Add(new ParticleCircleSmoke(vector + new Vector2(Globals.GlobalRandom.Next(-8, 9), Globals.GlobalRandom.Next(-8, 9)), Game1.Textures["SmokeCircle"])); } } } _timeTrail.Reset(); _oldInterpol = _position; } _wetPreviousFrame = _wet; GetWet(map); }
public bool Fire(LineSegmentF rayEnlonged, Vector2Object destination) { Vector2 barrel = rayEnlonged.Start + rayEnlonged.NormalizedWithZeroSolution() * GunBarrel; if (GunTimer.Ready == true) { Sound.PlaySoundSimple(Game1.sound, 1f, (float)(Globals.GlobalRandom.NextDouble() - 0.5f) / 2f, 0f); GunTimer.Reset(); Game1.mapLive.MapProjectiles.Add(new Projectile((short)(Damage + OwnerGun.DamagePlus), CompareF.RotateVector2(rayEnlonged.NormalizedWithZeroSolution(), (float)((Globals.GlobalRandom.NextDouble() - 0.5f) * (Dispersion + OwnerGun.DispersionPlus))) * (VelocityOfProjectile + OwnerGun.VelocityOfProjectile), barrel, Owner)); return(true); } return(false); }