Example #1
0
        /// <summary>
        /// Updates streams.
        /// </summary>
        private void UpdateStreams(LevelTime levelTime, Vector2 playerCenter)
        {
            // TODO Refactor this old mess

            if (ActiveStreams.Count == 0)
            {
                return;
            }

            for (int i = 0; i < ActiveStreams.Count; i++)
            {
                var stream = ActiveStreams[i];

                stream.TimeSinceLastShot += (float)levelTime.ElapsedMs;
                if (stream.TimeSinceLastShot >= StreamShot.FireFrequency)
                {
                    var currStreamTime = levelTime.SongPosition - stream.Time;
                    var currSpeed      = stream.Speed0 + (currStreamTime * ((stream.Speed1 - stream.Speed0) / stream.Duration));
                    var currAngle      = stream.Angle0 + (currStreamTime * ((stream.Angle1 - stream.Angle0) / stream.Duration));
                    var currOffset     = stream.Offset0 + (currStreamTime * ((stream.Offset1 - stream.Offset0) / stream.Duration));

                    bool lastShot = levelTime.SongPosition + StreamShot.FireFrequency > stream.Time + stream.Duration;

                    foreach (int enemy in stream.Enemies)
                    {
                        var spawner = Util.GetSpawnerFromShotIndex(spawners, enemy);
                        var wave    = new Wave()
                        {
                            BulletType     = stream.BulletType,
                            Amount         = stream.Amount0,
                            Speed          = currSpeed,
                            Angle          = currAngle,
                            Offset         = currOffset,
                            Aim            = stream.Aim,
                            HomingLifespan = stream.HomingLifespan,
                        };
                        Bullets.AddRange(wave.Create(spawner.Center, spawner.Angle,
                                                     playerCenter, level.Info.Colors));

                        if (lastShot && Config.GameSettings.DrawParticles)
                        {
                            particles.CreateShotSpawnParticles(spawner, stream.Color);
                        }
                    }

                    if (lastShot)
                    {
                        ActiveStreams.RemoveAt(i);
                        i--;
                    }
                    else
                    {
                        stream.TimeSinceLastShot -= StreamShot.FireFrequency;
                    }
                }
            }
        }
Example #2
0
        public void Update()
        {
            if (Bullets.Count == 0)
            {
                return;
            }
            for (var i = 0; i < Bullets.Count; i++)
            {
                Bullets[i].UpdateNotImportant();
            }
            var exists = Bullets.Where(e => e.Exists).ToArray();

            Bullets.Clear();
            Bullets.AddRange(exists);
        }
Example #3
0
        private void OnFireShot(TimeIterActionArgs <Shot> args)
        {
            var newBullets = shotCreator.FireShot(args.List[args.Index], spawners, playerCenter);

            Bullets.AddRange(newBullets);
        }