예제 #1
0
 public void Update()
 {
     _alpha -= Game1.Delta / 512;
     _resolver.move(ref _velocity, new Vector2(2f), Boundary, 0f, new Vector2(0f), new Vector2(0.01f), new Vector2(0.5f), Game1.mapLive.MapMovables, 0.00f);
     _trail.Update(Boundary.Origin, _velocity, _alpha);
     if (_alpha <= 0)
     {
         Game1.mapLive.mapParticles.Remove(this);
     }
 }
예제 #2
0
        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);
        }
예제 #3
0
        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);
        }