示例#1
0
        public IEnumerable <SpacialElement> Explode()
        {
            var ret = new List <SpacialElement>();

            if (Lifetime.IsExpired)
            {
                return(ret);
            }

            this.Lifetime.Dispose();
            var shrapnelSet = new List <Projectile>();

            for (float angle = 0; angle < 360; angle += AngleIncrement)
            {
                var effectiveRange = Range;

                if ((angle > 200 && angle < 340) || (angle > 20 && angle < 160))
                {
                    effectiveRange = Range / 3;
                }

                var shrapnel = SpaceTime.CurrentSpaceTime.Add(new Projectile(this.Weapon, ExplosiveProjectileSpeed, angle, autoLocate: false)
                {
                    Range = effectiveRange
                });
                shrapnel.AddTag(nameof(Explosive));
                shrapnel.MoveTo(this.Left, this.Top, this.ZIndex);
                OnProjectileAdded.Fire(shrapnel);
                if (ProjectilePen != null)
                {
                    shrapnel.Pen = ProjectilePen;
                }

                shrapnelSet.Add(shrapnel);
                shrapnel.AddTag("hot");
                ret.Add(shrapnel);
            }

            foreach (var shrapnel in shrapnelSet)
            {
                shrapnel.Velocity.HitDetectionExclusions.AddRange(shrapnelSet.Where(s => s != shrapnel));
            }

            Exploded.Fire();
            OnExplode.Fire(this);
            return(ret);
        }
示例#2
0
        public void Explode()
        {
            var shrapnelSet = new List <Projectile>();

            for (float angle = 0; angle < 360; angle += AngleIncrement)
            {
                var effectiveRange = Range;

                if ((angle > 200 && angle < 340) || (angle > 20 && angle < 160))
                {
                    effectiveRange = Range / 3;
                }

                var shrapnel = SpaceTime.CurrentSpaceTime.Add(new Projectile(this.Weapon, this.Left, this.Top, angle)
                {
                    Range = effectiveRange
                });
                shrapnel.MoveTo(shrapnel.Left, shrapnel.Top, this.ZIndex);
                OnProjectileAdded.Fire(shrapnel);
                if (ProjectilePen != null)
                {
                    shrapnel.Pen = ProjectilePen;
                }

                shrapnelSet.Add(shrapnel);
                shrapnel.Tags.Add("hot");
            }

            foreach (var shrapnel in shrapnelSet)
            {
                shrapnel.Speed.HitDetectionExclusions.AddRange(shrapnelSet.Where(s => s != shrapnel));
            }

            Exploded.Fire();
            OnExplode.Fire(this);
            this.Lifetime.Dispose();
        }