public bool Fire(LineSegmentF rayEnlonged, Vector2Object destination) { if ((Ammo > 0 && GunTimer.Ready == true) || MaxAmmo == 0) { Vector2 barrel = rayEnlonged.Start + rayEnlonged.NormalizedWithZeroSolution() * GunBarrel; Game1.soundElectro.Play(1f, (float)(Globals.GlobalRandom.NextDouble()) / 2f, 0f); Ammo--; fireRay(barrel, destination); if (Owner is Player) { for (int i = 0; i < 3; i++) { Game1.mapLive.mapLightings.Add(new Lightning(barrel, destination.Vector2, Game1.Textures["Lightning"], 16, -1)); } for (int i = 0; i < 1; i++) { Game1.mapLive.mapLightings.Add(new Lightning(barrel, destination.Vector2, Game1.Textures["LightningBig"], 16, -1)); } for (int i = 0; i < 1; i++) { Game1.mapLive.mapLightings.Add(new Lightning(barrel, destination.Vector2, Game1.Textures["lightningChain"], 16, -3, 3f)); } } GunTimer.Reset(); return(true); } return(false); }
private void fireRay(Vector2 rayStart, Vector2Object RayDestination) { if (RayDestination != null && RayDestination.Vector2 != null) { if (Owner is Player) { _line = new LineSegmentF(rayStart, RayDestination.Vector2); } if (Owner is Inpc) { _line = new LineSegmentF((Owner as Inpc).Boundary.Origin, RayDestination.Vector2); } if (RayDestination.Object != null && RayDestination.Object is Inpc && (RayDestination.Object as Inpc).Friendly == false) { (RayDestination.Object as Inpc).Push(_line.NormalizedWithZeroSolution() * _velocityAdd * 0.5f); (RayDestination.Object as Inpc).Stun(); (RayDestination.Object as Inpc).KineticDamage(Damage); } if (RayDestination.Object != null) { if (RayDestination.Object is Map || RayDestination.Object is Player) { Game1.mapLive.mapParticles.Add(new ParticleLaserDest(RayDestination.Vector2)); } if (RayDestination.Object is IRectanglePhysics) { } } } }
public static Vector2Object WeaponRayObstruction(RectangleF boundary, LineSegmentF ray, object whoShoots) { Vector2Object withBoundary = NearestVector(boundary.Origin, LineIntersectionRectangle(Game1.mapLive.MapBoundary, new LineObject(whoShoots, ray))); Vector2Object withMap = NearestVector(boundary.Origin, LineVsMap(Game1.mapLive.MapTree, new LineObject(Game1.mapLive, ray))); Vector2Object withMovables = NearestFromRectangles(boundary.Origin, new LineObject(whoShoots, ray), Game1.mapLive.MapMovables); List <Vector2Object> vectorsToCompare = new List <Vector2Object>(); if (withBoundary != null) { vectorsToCompare.Add(withBoundary); } if (withMap != null) { vectorsToCompare.Add(withMap); } if (withMovables != null) { vectorsToCompare.Add(withMovables); } if (NearestVector(boundary.Origin, vectorsToCompare) != null) { return(NearestVector(boundary.Origin, vectorsToCompare)); } return(new Vector2Object(null, ray.End)); }
public void Update(Map map) { Update(map, this); PlayerTakeDamage(5, this); DamageToNPC(map, this); Vector2Object hitPos = null; if (OutOfmap(this, out hitPos) == true) { } if (RemoveOnMapCollision(map.MapTree, this, out hitPos) == true) { } if (CollisionWithMovables(map, this, out hitPos) == true) { } if (_wet == true) { Game1.mapLive.MapProjectiles.Remove(this); } else { if (CompareF.LineVsMap(map.WaterTree, _track).Count > 0) { _velocity /= 4; } } }
protected override void AfterCollision(Map map, Vector2Object hit) { for (int i = 0; i < 3; i++) { Game1.mapLive.mapParticles.Add(new ParticleSpark(hit.Vector2)); } }
private void Damage(Vector2Object position, Inpc npc) { npc.Stun(); npc.KineticDamage(_damage); npc.Push(_velocity * 0.5f); Game1.mapLive.MapProjectiles.Remove(this); }
public bool Fire(LineSegmentF rayEnlonged, Vector2Object destination) { if (_module.Fire(rayEnlonged, destination) == true) { return(true); } return(false); }
protected override void AfterCollision(Map map, Vector2Object hit) { Explosion.Explode(hit.Vector2, _damage); if (_wet == false) { _trail.LeftParticle(); } }
protected virtual void Update(Map map, IProjectile projectile) { Vector2Object hitPos = null; UpdateLine(); OutOfmap(projectile, out hitPos); RemoveOnMapCollision(map.MapTree, projectile, out hitPos); GetWet(map); }
protected override void AfterCollision(Map map, Vector2Object hit) { foreach (Inpc npc in map.MapNpcs) { LightningAttack.StrikeLightning(_position, npc, _damage); } for (int i = 0; i < 8; i++) { Game1.mapLive.mapParticles.Add(new ParticleBlackDrop(hit.Vector2, _velocity, Game1.Textures["BlackParticle"])); } }
protected bool OutOfmap(IProjectile projectile, out Vector2Object hitPos) { hitPos = null; if (CompareF.LineIntersectionRectangle(Game1.mapLive.MapBoundary, _track).Count > 0) { hitPos = CompareF.NearestVector(_track.Line.Start, CompareF.LineIntersectionRectangle(Game1.mapLive.MapBoundary, _track)); Game1.mapLive.MapProjectiles.Remove(projectile); return(true); } return(false); }
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 Projectile(Damage, rayEnlonged.NormalizedWithZeroSolution() * VelocityOfProjectile, barrel, Owner)); return(true); } return(false); }
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); }
protected override void Update(Map map, IProjectile projectile) { Vector2Object hitPos = null; UpdateLine(); if (OutOfmap(projectile, out hitPos) == true || RemoveOnMapCollision(map.MapTree, projectile, out hitPos) == true || CollisionWithMovables(map, this, out hitPos) == true) { AfterCollision(map, hitPos); } _wetPreviousFrame = _wet; GetWet(map); }
public static Vector2Object RaySegmentCalc(Vector2 origin, LineSegmentF ray, object whoShoots) { Vector2Object withBoundary = NearestVector(origin, LineIntersectionRectangle(Game1.mapLive.MapBoundary, new LineObject(whoShoots, ray))); Vector2Object withNpcs = NearestFromRectangles(origin, new LineObject(whoShoots, ray), Game1.mapLive.MapNpcs); Vector2Object withMap = NearestVector(origin, LineVsMap(Game1.mapLive.MapTree, new LineObject(Game1.mapLive, ray))); Vector2Object withMovables = NearestFromRectangles(origin, new LineObject(whoShoots, ray), Game1.mapLive.MapMovables); Vector2Object withPlayer = NearestVector(origin, LineIntersectionRectangle(Game1.PlayerInstance.Boundary, new LineObject(Game1.PlayerInstance, ray))); List <Vector2Object> vectorsToCompare = new List <Vector2Object>(); if (withBoundary != null) { vectorsToCompare.Add(withBoundary); } if (withMap != null) { vectorsToCompare.Add(withMap); } if (withMovables != null) { vectorsToCompare.Add(withMovables); } if (whoShoots is Player) { if (withNpcs != null) { vectorsToCompare.Add(withNpcs); } } if (whoShoots is Inpc) { if (withPlayer != null) { vectorsToCompare.Add(withPlayer); } } if (NearestVector(origin, vectorsToCompare) != null) { return(NearestVector(origin, vectorsToCompare)); } else { return(new Vector2Object(null, ray.End)); } }
public bool Fire(LineSegmentF rayEnlonged, Vector2Object destination) { Vector2 barrel = rayEnlonged.Start + rayEnlonged.NormalizedWithZeroSolution() * GunBarrel; if (Ammo > 0 && GunTimer.Ready == true) { Game1.soundFlamb.Play((float)((1f / 2f) + Globals.GlobalRandom.NextDouble() / 2f), (float)(Globals.GlobalRandom.NextDouble() - 0.5f) / 2f, 0f); GunTimer.Reset(); Game1.mapLive.MapProjectiles.Add(new FlameProjectile(rayEnlonged.NormalizedWithZeroSolution() * VelocityOfProjectile, barrel, Owner, 16)); _muzzleAlpha = 1f; Ammo--; return(true); } return(false); }
public bool Fire(LineSegmentF rayEnlonged, Vector2Object destination) { Vector2 barrel = rayEnlonged.Start + rayEnlonged.NormalizedWithZeroSolution() * GunBarrel; if (Ammo > 0 && GunTimer.Ready == true) { Sound.PlaySoundSimple(Game1.soundVortex, (float)((1f / 2f) + Globals.GlobalRandom.NextDouble() / 2f), (float)(Globals.GlobalRandom.NextDouble() - 0.5f) / 2f, 0f); Ammo--; GunTimer.Reset(); Game1.mapLive.MapProjectiles.Add(new EnergyBall(rayEnlonged.NormalizedWithZeroSolution() * VelocityOfProjectile, barrel, Owner, Damage)); Kick(4); return(true); } return(false); }
public bool Fire(LineSegmentF rayEnlonged, Vector2Object destination) { Vector2 barrel = rayEnlonged.Start + rayEnlonged.NormalizedWithZeroSolution() * GunBarrel; if (Ammo > 0 && GunTimer.Ready == true) { Ammo--; GunTimer.Reset(); Game1.mapLive.MapProjectiles.Add(new Rocket(rayEnlonged.NormalizedWithZeroSolution() * VelocityOfProjectile, barrel, Owner, 64)); _muzzleAlpha = 1; Kick(8); return(true); } return(false); }
private bool fireRay(Vector2 rayStart, Vector2Object RayDestination) { if (RayDestination != null && RayDestination.Vector2 != null) { if (RayDestination.Object != null && RayDestination.Object is Inpc && (RayDestination.Object as Inpc).Friendly == false) { (RayDestination.Object as Inpc).Push(_line.NormalizedWithZeroSolution() * _velocityAdd * 0.1f); (RayDestination.Object as Inpc).Stun(); (RayDestination.Object as Inpc).KineticDamage(Damage); } if (RayDestination.Object != null && (RayDestination.Object is Map || RayDestination.Object is Player)) { Game1.mapLive.mapParticles.Add(new ParticleLaserDest(RayDestination.Vector2)); } return(true); } return(false); }
public bool Fire(LineSegmentF rayEnlonged, Vector2Object destination) { Vector2 barrel = rayEnlonged.Start + rayEnlonged.NormalizedWithZeroSolution() * GunBarrel; if (destination != null && destination != null) { if (Owner is Player) { _line = new LineSegmentF(rayEnlonged.Start, destination.Vector2); } if (Owner is Inpc) { _line = new LineSegmentF((Owner as Inpc).Boundary.Origin, destination.Vector2); } } _rotation = rayEnlonged.ToAngle(); if ((Ammo > 0 && GunTimer.Ready == true) || MaxAmmo == 0) { Ammo--; SetOn(); fireRay(barrel, destination); GunTimer.Reset(); if (destination != null && destination != null) { if (Owner is Player) { } if (Owner is Inpc) { //Game1.PlayerIns.Push(LineSegmentF.SegmentToNormalizedVector((Owner as Enemy).Ray) * 0.02f); } } return(true); } return(false); }
public void Update(Map map) { base.Update(map, this); 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(npc); AfterCollision(map, new Vector2Object(npc, _position)); map.MapProjectiles.Remove(this); break; } } } Vector2Object hitPos = null; if (OutOfmap(this, out hitPos) == true) { } if (RemoveOnMapCollision(map.MapTree, this, out hitPos) == true) { AfterCollision(map, hitPos); } if (CollisionWithMovables(map, this, out hitPos) == true) { AfterCollision(map, hitPos); } if (_wet == true) { _velocity /= 4; } }
public static Vector2Object NearestVector(Vector2 origin, List <Vector2Object> vectors) { if (vectors != null) { Vector2Object nearest = null; float shortestDistance = float.PositiveInfinity; foreach (Vector2Object vector in vectors) { if (LineSegmentF.Lenght(origin, vector.Vector2) < shortestDistance) { shortestDistance = LineSegmentF.Lenght(origin, vector.Vector2); nearest = vector; } } return(nearest); } else { return(null); } }
protected virtual bool CollisionWithMovables(Map map, IProjectile projectile, out Vector2Object hit) { foreach (IRectanglePhysics rec in map.MapMovables) { List <Vector2Object> intersections = CompareF.LineIntersectionRectangle(rec, new LineObject(rec, _track.Line)); if (intersections?.Count > 0) { Game1.mapLive.MapProjectiles.Remove(projectile); hit = CompareF.NearestVector(_track.Line.Start, intersections); return(true); } if (CompareF.RectangleVsVector2(rec, _track.Line.End) == true) { Game1.mapLive.MapProjectiles.Remove(projectile); hit = new Vector2Object(rec, _track.Line.End); return(true); } } hit = null; return(false); }
protected override void AfterCollision(Map map, Vector2Object hit) { }
public void Update(Map map) { UpdateLine(); _hurtTimer.Update(); List <Vector2Object> intersectionsPlayer = CompareF.LineIntersectionRectangle(Game1.PlayerInstance.Boundary, new LineObject(Game1.PlayerInstance, _track.Line)); if (intersectionsPlayer?.Count > 0 && (_from is Inpc)) { Game1.PlayerInstance.TakeDamage(5); } foreach (Inpc npc in map.MapNpcs) { if (npc.Friendly == false) { List <Vector2Object> intersections = CompareF.LineIntersectionRectangle(npc, new LineObject(npc, _track.Line)); if ((intersections != null && intersections.Count > 0 && (_from is Player)) || CompareF.RectangleVsVector2(npc.Boundary, _track.Line.End) == true) { if (_hurtTimer.Ready == true) { npc.Stun(); npc.KineticDamage(_damage); npc.Push(_velocity * 0.1f); _hurtTimer.Reset(); i++; } break; } if (i > 4) { Game1.mapLive.MapProjectiles.Remove(this); } } } Vector2Object hitPos = null; if (OutOfmap(this, out hitPos) == true) { BurstParticles(hitPos.Vector2); } if (RemoveOnMapCollision(map.MapTree, this, out hitPos) == true) { BurstParticles(hitPos.Vector2); } if (CollisionWithMovables(map, this, out hitPos) == true) { BurstParticles(hitPos.Vector2); } GetWet(map); if (_wet) { Game1.mapLive.MapProjectiles.Remove(this); } _velocity.Y += 0.03f; _trailTimer.Update(); if (_trailTimer.Ready == true) { List <Vector2> vectors = LineSegmentF.PointsOnLine(_position, _oldInterpol, 64); Vector2 random = new Vector2(Globals.GlobalRandom.Next(-_maximums, _maximums + 1), Globals.GlobalRandom.Next(-_maximums, _maximums + 1)); foreach (Vector2 vector in vectors) { for (int i = 0; i < 3; i++) { Game1.mapLive.mapParticles.Add(new ParticleCircleFlame(vector + new Vector2(Globals.GlobalRandom.Next(-16, 17), Globals.GlobalRandom.Next(-16, 17)), Game1.Textures["FlameCircle"])); } } _trailTimer.Reset(); _oldInterpol = _position + random; } _trail.Update(_position, _velocity, 1); }
public void Update(Map map) { _size = (float)Math.Sin(Game1.Time * 32) / 8 + 0.5f; _particleTime.Update(); if (_ballTime.Ready) { _effects.Add(new EnerergyCircle(new CircleF(_position, 16), 16, _velocity)); _ballTime.Reset(); } List <Vector2> trackVectors = LineSegmentF.PointsOnLine(_position, _oldPosition, 64); if (_particleTime.Ready == true) { foreach (Vector2 vector in trackVectors) { Game1.mapLive.mapParticles.Add(new ParticleBlackDrop(vector, _velocity, Game1.Textures["BlackParticle"])); } _particleTime.Reset(); } UpdateLine(); _lightTime.Update(); _ballTime.Update(); GetWet(map); int j = 0; foreach (Inpc npc in map.MapNpcs.Reverse <Inpc>()) { if (j < 8) { if (npc.Friendly == false) { List <Vector2Object> intersections = CompareF.LineIntersectionRectangle(npc, new LineObject(npc, _track.Line)); if (intersections != null && intersections.Count > 0) { Damage(npc, this); break; } else if (CompareF.RectangleVsVector2(npc.Boundary, _track.Line.End) == true) { Damage(npc, this); break; } if (_lightTime.Ready) { if (LightningAttack.StrikeLightning(_position, npc, _damage) == true) { j++; } _lightTime.Reset(); } } } } Vector2Object hitPos = null; if (OutOfmap(this, out hitPos) == true) { AfterCollision(map, hitPos); } if (RemoveOnMapCollision(map.MapTree, this, out hitPos) == true) { AfterCollision(map, hitPos); } if (CollisionWithMovables(map, this, out hitPos) == true) { AfterCollision(map, hitPos); } if (_wet == true) { Game1.mapLive.MapProjectiles.Remove(this); } foreach (IEffect effect in _effects.Reverse <IEffect>()) { effect.Update(_effects); } }
protected override void AfterCollision(Map map, Vector2Object hit) { Explosion.ExplodeSmall(_position, _damage); }
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); }
protected abstract void AfterCollision(Map map, Vector2Object hit);
protected bool RemoveOnMapCollision(MapTreeHolder map, IProjectile projectile, out Vector2Object hit) { hit = null; if (CompareF.LineVsMap(map, _track).Count > 0) { hit = CompareF.NearestVector(_track.Line.Start, CompareF.LineVsMap(map, _track)); Game1.mapLive.MapProjectiles.Remove(projectile); return(true); } return(false); }