示例#1
0
        public Laser(ProjectileArgs args, LaserInfo info)
        {
            this.info   = info;
            this.random = args.SourceActor.World.SharedRandom;

            this.colors = new Color[info.Radius];

            for (var i = 0; i < info.Radius; i++)
            {
                var color = info.Color == Color.Transparent ? args.SourceActor.Owner.Color : info.Color;
                var bw    = (float)((info.InnerLightness - info.OuterLightness) * i / (info.Radius - 1) + info.OuterLightness) / 0xff;
                var dstR  = bw > .5 ? 1 - (1 - 2 * (bw - .5)) * (1 - (float)color.R / 0xff) : 2 * bw * ((float)color.R / 0xff);
                var dstG  = bw > .5 ? 1 - (1 - 2 * (bw - .5)) * (1 - (float)color.G / 0xff) : 2 * bw * ((float)color.G / 0xff);
                var dstB  = bw > .5 ? 1 - (1 - 2 * (bw - .5)) * (1 - (float)color.B / 0xff) : 2 * bw * ((float)color.B / 0xff);
                this.colors[i] = Color.FromArgb((int)(dstR * 0xff), (int)(dstG * 0xff), (int)(dstB * 0xff));
            }

            var direction = args.PassiveTarget - args.Source;

            if (this.info.SegmentLength == WDist.Zero)
            {
                this.offsets = new[] { args.Source, args.PassiveTarget }
            }
            ;
            else
            {
                var numSegments = (direction.Length - 1) / info.SegmentLength.Length + 1;

                this.offsets      = new WPos[numSegments + 1];
                this.offsets[0]   = args.Source;
                this.offsets[^ 1] = args.PassiveTarget;
示例#2
0
        public Laser(ProjectileArgs args, LaserInfo info)
        {
            this.info = info;

            colors = new Color[info.Radius];
            for (var i = 0; i < info.Radius; i++)
            {
                var color = info.Color == Color.Transparent ? args.SourceActor.Owner.Color : info.Color;
                var bw    = (float)((info.InnerLightness - info.OuterLightness) * i / (info.Radius - 1) + info.OuterLightness) / 0xff;
                var dstR  = bw > .5 ? 1 - (1 - 2 * (bw - .5)) * (1 - (float)color.R / 0xff) : 2 * bw * ((float)color.R / 0xff);
                var dstG  = bw > .5 ? 1 - (1 - 2 * (bw - .5)) * (1 - (float)color.G / 0xff) : 2 * bw * ((float)color.G / 0xff);
                var dstB  = bw > .5 ? 1 - (1 - 2 * (bw - .5)) * (1 - (float)color.B / 0xff) : 2 * bw * ((float)color.B / 0xff);
                colors[i] = Color.FromArgb((int)(dstR * 0xff), (int)(dstG * 0xff), (int)(dstB * 0xff));
            }

            var direction = args.PassiveTarget - args.Source;

            if (info.Distortion != 0 || info.DistortionAnimation != 0)
            {
                leftVector = new WVec(direction.Y, -direction.X, 0);
                if (leftVector.Length != 0)
                {
                    leftVector = 1024 * leftVector / leftVector.Length;
                }

                upVector = new WVec(
                    -direction.X * direction.Z,
                    -direction.Z * direction.Y,
                    direction.X * direction.X + direction.Y * direction.Y);
                if (upVector.Length != 0)
                {
                    upVector = 1024 * upVector / upVector.Length;
                }

                random = args.SourceActor.World.SharedRandom;
            }

            if (this.info.SegmentLength == WDist.Zero)
            {
                offsets = new[] { args.Source, args.PassiveTarget }
            }
            ;
            else
            {
                var numSegments = (direction.Length - 1) / info.SegmentLength.Length + 1;

                offsets    = new WPos[numSegments + 1];
                offsets[0] = args.Source;
                offsets[offsets.Length - 1] = args.PassiveTarget;

                distances = new float[offsets.Length];

                if (info.Distortion != 0)
                {
                    for (var i = 1; i < numSegments; i++)
                    {
                        distances[i] = random.Next(info.Distortion * 2) - info.Distortion;
                    }
                }

                CalculateOffsets();
            }

            args.Weapon.Impact(Target.FromPos(args.PassiveTarget), args.SourceActor);
        }