Esempio n. 1
0
        public static bool StrikeLightning(Vector2 position, Inpc npc, short damage)
        {
            if (npc.Friendly == false)
            {
                if (LineSegmentF.Lenght(npc.Boundary.Origin, position) < 256)
                {
                    LineSegmentF _ray = new LineSegmentF(npc.Boundary.Origin, position);

                    if (CompareF.LineVsMap(Game1.mapLive.MapTree, new LineObject(Game1.mapLive, _ray)).Count == 0)
                    {
                        Game1.mapLive.mapLightings.Add(new Lightning(npc.Boundary.Origin, position, Game1.debug_thin, 6));
                        Game1.mapLive.mapLightings.Add(new Lightning(npc.Boundary.Origin, position, Game1.debug_thin, 2));
                        npc.Stun();
                        npc.Push(new Vector2(0, -0.2f));
                        npc.KineticDamage(damage);
                        Camera2DGame.Shake(5, position);

                        Sound _strikeSound = new Sound(Game1.soundElectro, position);
                        Game1.Sounds3D.Add(_strikeSound);
                        Game1.Sounds3D[Game1.Sounds3D.IndexOf(_strikeSound)].Play();
                    }
                    return(true);
                }
            }

            return(false);
        }
Esempio n. 2
0
        public void Update(List <Inpc> npcs)
        {
            foreach (Inpc npc in npcs)
            {
                if (npc != this)
                {
                    if (CompareF.RectangleFVsCircleF(BoundaryCircle, npc.Boundary) == true)
                    {
                        npc.KineticDamage(25);
                        LineSegmentF temp = new LineSegmentF(BoundaryCircle.Center, npc.Boundary.Origin);
                        npc.Push(temp.NormalizedWithZeroSolution() * 6f);
                        npc.Stun();
                        PlaySaw();
                    }
                }
            }

            if (CompareF.RectangleFVsCircleF(BoundaryCircle, Game1.PlayerInstance.Boundary) == true)
            {
                Game1.PlayerInstance.TakeDamage(25);
                LineSegmentF temp = new LineSegmentF(BoundaryCircle.Center, Game1.PlayerInstance.Boundary.Origin);
                Game1.PlayerInstance.Push(temp.NormalizedWithZeroSolution() * 6f);
                PlaySaw();
            }

            rotation += Game1.Delta;
        }
Esempio n. 3
0
        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);
        }
Esempio n. 4
0
        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)
                    {
                    }
                }
            }
        }
Esempio n. 5
0
        public static void DrawFlameGunNormal(LineSegmentF rayBarrel, int GunOffset)
        {
            if (Math.Abs(rayBarrel.ToAngle() * (180 / Math.PI)) < 25 + 45)
            {
                Effects.RotateNormalsEffect(rayBarrel.ToAngle(), new Vector2(1, 1));
                Game1.SpriteBatchGlobal.Draw(Game1.Textures["flameThrowerNormal"], rayBarrel.Start, rotation: rayBarrel.ToAngle(), origin: new Vector2(0, 8f * 2));
            }
            else if (Math.Abs(rayBarrel.ToAngle() * (180 / Math.PI)) > 155 - 45)
            {
                Effects.RotateNormalsEffect(rayBarrel.ToAngle(), new Vector2(1, -1));
                Game1.SpriteBatchGlobal.Draw(Game1.Textures["flameThrowerNormal"], rayBarrel.Start, rotation: rayBarrel.ToAngle(), origin: new Vector2(0, 16f * 2), effects: SpriteEffects.FlipVertically);
            }
            else if (rayBarrel.ToAngle() * (180 / Math.PI) > 25 + 45 && rayBarrel.ToAngle() * (180 / Math.PI) < 155 - 45)
            {
                Effects.RotateNormalsEffect(rayBarrel.ToAngle(), new Vector2(1, 1));
                Game1.SpriteBatchGlobal.Draw(Game1.Textures["flameThrowerUpNormal"], rayBarrel.Start, rotation: rayBarrel.ToAngle(), origin: new Vector2(0, 5.5f * 2));
            }
            else
            {
                Effects.RotateNormalsEffect(rayBarrel.ToAngle(), new Vector2(1, -1));
                Game1.SpriteBatchGlobal.Draw(Game1.Textures["flameThrowerDownNormal"], rayBarrel.Start, rotation: rayBarrel.ToAngle(), origin: new Vector2(0, 5.5f * 2));
            }

            Effects.ResetEffect3D();
        }
Esempio n. 6
0
        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));
        }
Esempio n. 7
0
        public void Update(Vector2 listenerPos)
        {
            if (soundEffectInstance.State == SoundState.Playing)
            {
                if (_position != null)
                {
                    float pan    = (_position.Value.X - listenerPos.X) / (2048f * 2);
                    float volume = 1f - LineSegmentF.Lenght(listenerPos, _position.Value) / 2048;

                    if (pan > _maxPan)
                    {
                        pan = _maxPan;
                    }
                    if (pan < -_maxPan)
                    {
                        pan = -_maxPan;
                    }

                    if (volume > 1f)
                    {
                        volume = 1f;
                    }
                    if (volume < 0)
                    {
                        volume = 0f;
                    }

                    Change(volume * MathHelper.Clamp(VolumeOveral, 0f, 1f), pan);
                }
            }

            IsNew = false;
        }
Esempio n. 8
0
 public LineShootCalc()
 {
     RaySegment     = new LineSegmentF();
     RayBarrel      = new LineSegmentF();
     RayEnlonged    = new LineSegmentF();
     RayDestination = null;
 }
Esempio n. 9
0
        new public void Draw(LineSegmentF rayBarrel)
        {
            SimpleGunDrawModule.DrawPlasmaGun(rayBarrel, (int)OffsetKick);

            Effects.ColorEffect(new Vector4(1f, 1f, 1f, _muzzleAlpha));
            Game1.SpriteBatchGlobal.Draw(Game1.muzzlePlasma, rayBarrel.End, scale: new Vector2(1), origin: new Vector2(0, 19f), rotation: rayBarrel.ToAngle());
            Game1.EffectBaseColor.CurrentTechnique.Passes[0].Apply();
        }
Esempio n. 10
0
 public bool Fire(LineSegmentF rayEnlonged, Vector2Object destination)
 {
     if (_module.Fire(rayEnlonged, destination) == true)
     {
         return(true);
     }
     return(false);
 }
Esempio n. 11
0
        public void Draw(LineSegmentF rayBarrel)
        {
            SimpleGunDrawModule.DrawSimpleGun(rayBarrel, (int)Kick);

            Effects.ColorEffect(new Vector4(1f, 1f, 1f, Light));
            Game1.SpriteBatchGlobal.Draw(Game1.muzzleSimple, rayBarrel.End, origin: new Vector2(0, 19f), rotation: rayBarrel.ToAngle());
            Effects.ResetEffect3D();
        }
Esempio n. 12
0
        new public void Draw(LineSegmentF rayBarrel)
        {
            SimpleGunDrawModule.DrawRocketGun(rayBarrel, (int)OffsetKick);

            Effects.ColorEffect(new Vector4(1f, 1f, 1f, _muzzleAlpha));
            Game1.SpriteBatchGlobal.Draw(Game1.rocketLauncherFlame, rayBarrel.Start.ShiftOverDistance(-64 - OffsetKick, rayBarrel.ToAngle()), scale: new Vector2((2 - _muzzleAlpha * 2), 1), origin: new Vector2(0, 22), rotation: (float)(rayBarrel.ToAngle() - Math.PI));
            Game1.EffectBaseColor.CurrentTechnique.Passes[0].Apply();
        }
Esempio n. 13
0
        public static void Explode(Vector2 pos, short damage)
        {
            CircleF circle = new CircleF(pos, 128);

            foreach (IParticle prtcl in Game1.mapLive.mapParticles)
            {
                if (prtcl.Boundary != null)
                {
                    LineSegmentF Temp = new LineSegmentF(pos, prtcl.Boundary.Origin);

                    Vector2?_thru = CompareF.IntersectionLineWithOthers(Temp, Game1.mapLive.TileMapLines, null);
                    if (_thru == null)
                    {
                        prtcl.Push(Vector2.Normalize(Temp.NormalizedWithZeroSolution() * (float)(Globals.GlobalRandom.NextDouble()) * 2));
                    }
                }
            }

            int j = 0;

            foreach (Inpc npc in Game1.mapLive.MapNpcs)
            {
                if (j < 8)
                {
                    LineSegmentF Temp = new LineSegmentF(pos, npc.Boundary.Origin);

                    Vector2?_thru = CompareF.IntersectionLineWithOthers(Temp, Game1.mapLive.TileMapLines, null);

                    if (_thru == null && LineSegmentF.Lenght(pos, npc.Boundary.Origin) < 256)
                    {
                        if (npc.Friendly == false)
                        {
                            npc.KineticDamage(damage);
                        }
                        npc.Push(Vector2.Normalize(Temp.NormalizedWithZeroSolution() * (float)(Globals.GlobalRandom.NextDouble()) * 2));
                        j++;
                    }
                }
            }

            int x = 4;

            for (int i = 0; i < x; i++)
            {
                Game1.mapLive.mapParticles.Add(new ParticleSmokeBig(circle.GenerateRandomPoint()));
            }
            for (int i = 0; i < x; i++)
            {
                Game1.mapLive.mapParticles.Add(new ParticleFireBig(circle.GenerateRandomPoint()));
            }
            for (int i = 0; i < x; i++)
            {
                Game1.mapLive.mapParticles.Add(new ParticleFireSmall(circle.GenerateRandomPoint()));
            }
            Camera2DGame.Shake(10, pos);

            Sound.PlaySoundPosition(pos, Game1.soundExplosion, CustomMath.RandomAroundZero(Globals.GlobalRandom) / 2f);
        }
Esempio n. 14
0
 public EnergyBall(Vector2 velocity, Vector2 position, object from, short damage) : base(velocity, position, from, damage)
 {
     _lightTime    = new Timer(400, true);
     _ballTime     = new Timer(200, true);
     _particleTime = new Timer(100, true);
     _strikeMap    = new LineSegmentF();
     _effects      = new List <IEffect>();
     _size         = 1f;
 }
Esempio n. 15
0
        public void LineAim(Vector2 realPos, object whoShoots, Vector2 origin, float barrelLenght, float reach)
        {
            RaySegment.Start = origin;
            RaySegment.End   = realPos;

            RayEnlonged = new LineSegmentF(RaySegment.Start, RaySegment.Start + RaySegment.NormalizedWithZeroSolution() * reach);

            RayBarrel.Start = origin;
            RayBarrel.End   = RaySegment.Start + RaySegment.NormalizedWithZeroSolution() * barrelLenght;

            RayDestination = CompareF.RaySegmentCalc(origin, RayEnlonged, whoShoots);
        }
Esempio n. 16
0
 public static void Shake(int amount, Vector2 origin)
 {
     ShakeAmountTime     = amount;
     ShakeAmountVelocity = (512 - (int)LineSegmentF.Lenght(Position + Globals.WinRenderSize / 2, origin)) / 32;
     if (ShakeAmountVelocity > 16)
     {
         ShakeAmountVelocity = 16;
     }
     if (ShakeAmountVelocity < 0)
     {
         ShakeAmountVelocity = 0;
     }
 }
Esempio n. 17
0
        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);
        }
Esempio n. 18
0
        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);
        }
Esempio n. 19
0
        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();
                }
            }
        }
Esempio n. 20
0
        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));
            }
        }
Esempio n. 21
0
        public Vector2 NormalizedWithZeroSolution()
        {
            LineSegmentF segment        = new LineSegmentF(Start, End);
            Vector2      line_to_vector = segment.ToVector2();

            if (Math.Abs(line_to_vector.X) > 0 || Math.Abs(line_to_vector.Y) > 0)
            {
                return(Vector2.Normalize(line_to_vector));
            }
            else
            {
                return(Vector2.UnitY);
            }
        }
Esempio n. 22
0
        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);
        }
Esempio n. 23
0
        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);
        }
Esempio n. 24
0
        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);
        }
Esempio n. 25
0
        public static bool LinesIntersection(LineSegmentF line_l, LineSegmentF line_r, out Vector2 intersection)
        {
            intersection = Vector2.Zero;

            //https://www.codeproject.com/Tips/862988/Find-the-Intersection-Point-of-Two-Line-Segments odkaz na originální kód, který jsem si dovolil použít

            /// <param name="p">Vector to the start point of p.</param>
            /// <param name="p2">Vector to the end point of p.</param>
            /// <param name="q">Vector to the start point of q.</param>
            /// <param name="q2">Vector to the end point of q.</param>
            /// <param name="intersection">The point of intersection, if any.</param>
            /// <param name="considerOverlapAsIntersect">Do we consider overlapping lines as intersecting?</param>
            /// <returns>True if an intersection point was found.</returns>

            var r    = line_l.End - line_l.Start;
            var s    = line_r.End - line_r.Start;
            var rxs  = r.Cross(s);
            var qpxr = (line_r.Start - line_l.Start).Cross(r);

            // 3. If r x s = 0 and (q - p) x r != 0, then the two lines are parallel and non-intersecting.
            if (rxs.IsZero() && !qpxr.IsZero())
            {
                return(false);
            }

            // t = (q - p) x s / (r x s)
            var t = (float)(line_r.Start - line_l.Start).Cross(s) / rxs;

            // u = (q - p) x r / (r x s)

            var u = (float)(line_r.Start - line_l.Start).Cross(r) / rxs;

            // 4. If r x s != 0 and 0 <= t <= 1 and 0 <= u <= 1
            // the two line segments meet at the point p + t r = q + u s.
            if (!rxs.IsZero() && (0 <= t && t <= 1) && (0 <= u && u <= 1))
            {
                // We can calculate the intersection point using either t or u.
                intersection = line_l.Start + new Vector2((float)t * r.X, (float)t * r.Y);
                // An intersection was found.
                return(true);
            }

            // 5. Otherwise, the two line segments are not parallel but do not intersect.
            return(false);
        }
Esempio n. 26
0
        new public void DrawLight(LineSegmentF rayBarrel)
        {
            if (Ammo > 0)
            {
                if (_IsOn)
                {
                    if (_line != null)
                    {
                        Game1.SpriteBatchGlobal.Draw(Game1.LaserLight, rayBarrel.End, null,
                                                     new Rectangle(0, 0, (int)(_line.Lenght().Value - GunBarrel), 48),
                                                     new Vector2(0, 24),
                                                     _rotation, new Vector2(1, (float)(Math.Sin(Game1.Time * _timeMultiplier) * 0.5f) + 1), Color.White, SpriteEffects.None);

                        Game1.SpriteBatchGlobal.Draw(Game1.laserDestHalo, _line.End, origin: new Vector2(32), scale: new Vector2((float)(Math.Sin(Game1.Time * _timeMultiplier) * 1.2f) + 2f), color: Color.White);
                    }
                }
            }
        }
Esempio n. 27
0
        public static List <Vector2> PointsOnLine(Vector2 start, Vector2 end, float offsetAdd)
        {
            List <Vector2> vectors = new List <Vector2>();

            Vector2 offsetUnit = new LineSegmentF(start, end).NormalizedWithZeroSolution() * offsetAdd;

            vectors.Add(start);

            float i = 1;

            while (Lenght(start, start + offsetUnit * i) < Lenght(start, end))
            {
                vectors.Add(start + offsetUnit * i);
                i++;
            }

            return(vectors);
        }
Esempio n. 28
0
        public void Update()
        {
            if (On == false)
            {
                Speed = 0;
            }
            else
            {
                Speed = SpeedMax;

                if (from == 0)
                {
                    _platform.Update(new LineSegmentF(Start, Nodes[0]).NormalizedWithZeroSolution() * Speed);

                    if (LineSegmentF.Lenght(Start, Nodes[0]) < LineSegmentF.Lenght(Start, _platform.Boundary.Origin))
                    {
                        _platform.Origin = Nodes[0];
                        from++;
                    }
                }

                if (from > 0 && from < Nodes.Count)
                {
                    _platform.Update(new LineSegmentF(Nodes[from - 1], Nodes[from]).NormalizedWithZeroSolution() * Speed);

                    if (LineSegmentF.Lenght(Nodes[from - 1], Nodes[from]) < LineSegmentF.Lenght(Nodes[from - 1], _platform.Boundary.Origin))
                    {
                        _platform.Origin = Nodes[from];
                        from++;
                    }
                }

                if (from == Nodes.Count)
                {
                    _platform.Update(new LineSegmentF(Nodes[from - 1], Start).NormalizedWithZeroSolution() * Speed);

                    if (LineSegmentF.Lenght(Nodes[from - 1], Start) < LineSegmentF.Lenght(Nodes[from - 1], _platform.Boundary.Origin))
                    {
                        _platform.Origin = Start;
                        from             = 0;
                    }
                }
            }
        }
Esempio n. 29
0
 public static void DrawLaserGun(LineSegmentF rayBarrel, int GunOffset)
 {
     if (Math.Abs(rayBarrel.ToAngle() * (180 / Math.PI)) < 25 + 45)
     {
         Game1.SpriteBatchGlobal.Draw(Game1.laserGun, rayBarrel.Start, rotation: rayBarrel.ToAngle(), origin: new Vector2(0, 8.5f * 2));
     }
     else if (Math.Abs(rayBarrel.ToAngle() * (180 / Math.PI)) > 155 - 45)
     {
         Game1.SpriteBatchGlobal.Draw(Game1.laserGun, rayBarrel.Start, rotation: rayBarrel.ToAngle(), origin: new Vector2(0, 7.5f * 2), effects: SpriteEffects.FlipVertically);
     }
     else if (rayBarrel.ToAngle() * (180 / Math.PI) > 25 + 45 && rayBarrel.ToAngle() * (180 / Math.PI) < 155 - 45)
     {
         Game1.SpriteBatchGlobal.Draw(Game1.laserGunDown, rayBarrel.Start, rotation: rayBarrel.ToAngle(), origin: new Vector2(0, 5.5f * 2));
     }
     else
     {
         Game1.SpriteBatchGlobal.Draw(Game1.laserGunUp, rayBarrel.Start, rotation: rayBarrel.ToAngle(), origin: new Vector2(0, 5.5f * 2));
     }
 }
Esempio n. 30
0
 public static void DrawEnergyGun(LineSegmentF rayBarrel, int GunOffset)
 {
     if (Math.Abs(rayBarrel.ToAngle() * (180 / Math.PI)) < 25 + 45)
     {
         Game1.SpriteBatchGlobal.Draw(Game1.energyLauncher, rayBarrel.Start, rotation: rayBarrel.ToAngle(), origin: new Vector2(64 + GunOffset, 12));
     }
     else if (Math.Abs(rayBarrel.ToAngle() * (180 / Math.PI)) > 155 - 45)
     {
         Game1.SpriteBatchGlobal.Draw(Game1.energyLauncher, rayBarrel.Start, rotation: rayBarrel.ToAngle(), origin: new Vector2(64 + GunOffset, 26), effects: SpriteEffects.FlipVertically);
     }
     else if (rayBarrel.ToAngle() * (180 / Math.PI) > 25 + 45 && rayBarrel.ToAngle() * (180 / Math.PI) < 155 - 45)
     {
         Game1.SpriteBatchGlobal.Draw(Game1.energyLauncherDown, rayBarrel.Start, rotation: rayBarrel.ToAngle(), origin: new Vector2(64 + GunOffset, 7.5f * 2));
     }
     else
     {
         Game1.SpriteBatchGlobal.Draw(Game1.energyLauncherUp, rayBarrel.Start, rotation: rayBarrel.ToAngle(), origin: new Vector2(64 + GunOffset, 7.5f * 2));
     }
 }