• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# WVec类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了C#中WVec的典型用法代码示例。如果您正苦于以下问题:C# WVec类的具体用法?C# WVec怎么用?C# WVec使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



WVec类属于命名空间,在下文中一共展示了WVec类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。

示例1: Missile

        public Missile(MissileInfo info, ProjectileArgs args)
        {
            this.info = info;
            this.args = args;

            pos = args.Source;
            facing = args.Facing;

            targetPosition = args.PassiveTarget;

            var world = args.SourceActor.World;

            if (world.SharedRandom.Next(100) <= info.LockOnProbability)
                lockOn = true;

            if (info.Inaccuracy.Range > 0)
            {
                var inaccuracy = OpenRA.Traits.Util.ApplyPercentageModifiers(info.Inaccuracy.Range, args.InaccuracyModifiers);
                offset = WVec.FromPDF(world.SharedRandom, 2) * inaccuracy / 1024;
            }

            if (info.Image != null)
            {
                anim = new Animation(world, info.Image, () => facing);
                anim.PlayRepeating("idle");
            }

            if (info.ContrailLength > 0)
            {
                var color = info.ContrailUsePlayerColor ? ContrailRenderable.ChooseColor(args.SourceActor) : info.ContrailColor;
                trail = new ContrailRenderable(world, color, info.ContrailLength, info.ContrailDelay, 0);
            }
        }
开发者ID:RobotCaleb,项目名称:OpenRA,代码行数:33,代码来源:Missile.cs


示例2: RenderAfterWorld

        public void RenderAfterWorld(WorldRenderer wr, Actor self)
        {
            if (devMode == null || !devMode.ShowCombatGeometry)
                return;

            var wcr = Game.Renderer.WorldRgbaColorRenderer;
            var iz = 1 / wr.Viewport.Zoom;

            if (healthInfo != null)
                healthInfo.Shape.DrawCombatOverlay(wr, wcr, self);

            var blockers = allBlockers.Where(Exts.IsTraitEnabled).ToList();
            if (blockers.Count > 0)
            {
                var hc = Color.Orange;
                var height = new WVec(0, 0, blockers.Max(b => b.BlockingHeight.Length));
                var ha = wr.ScreenPosition(self.CenterPosition);
                var hb = wr.ScreenPosition(self.CenterPosition + height);
                wcr.DrawLine(ha, hb, iz, hc);
                TargetLineRenderable.DrawTargetMarker(wr, hc, ha);
                TargetLineRenderable.DrawTargetMarker(wr, hc, hb);
            }

            foreach (var attack in self.TraitsImplementing<AttackBase>().Where(x => !x.IsTraitDisabled))
                DrawArmaments(self, attack, wr, wcr, iz);
        }
开发者ID:CH4Code,项目名称:OpenRA,代码行数:26,代码来源:CombatDebugOverlay.cs


示例3: RenderAfterWorld

        public void RenderAfterWorld(WorldRenderer wr, Actor self)
        {
            if (devMode == null || !devMode.ShowMuzzles)
                return;

            if (health.Value != null)
                wr.DrawRangeCircle(Color.Red, wr.ScreenPxPosition(self.CenterPosition), health.Value.Info.Radius / Game.CellSize);

            var wlr = Game.Renderer.WorldLineRenderer;
            var c = Color.White;

            foreach (var a in armaments.Value)
            {
                foreach (var b in a.Barrels)
                {
                    var muzzle = self.CenterPosition + a.MuzzleOffset(self, b);
                    var dirOffset = new WVec(0, -224, 0).Rotate(a.MuzzleOrientation(self, b));

                    var sm = wr.ScreenPosition(muzzle);
                    var sd = wr.ScreenPosition(muzzle + dirOffset);
                    wlr.DrawLine(sm, sd, c, c);
                    wr.DrawTargetMarker(c, sm);
                }
            }
        }
开发者ID:Generalcamo,项目名称:OpenRA,代码行数:25,代码来源:CombatDebugOverlay.cs


示例4: Missile

        public Missile(MissileInfo info, ProjectileArgs args)
        {
            this.info = info;
            this.args = args;

            pos = args.Source;
            facing = args.Facing;

            targetPosition = args.PassiveTarget;

            // Convert ProjectileArg definitions to world coordinates
            // TODO: Change the yaml definitions so we don't need this
            var inaccuracy = (int)(info.Inaccuracy * 1024 / Game.CellSize);
            speed = info.Speed * 1024 / (5 * Game.CellSize);

            if (info.Inaccuracy > 0)
                offset = WVec.FromPDF(args.SourceActor.World.SharedRandom, 2) * inaccuracy / 1024;

            if (info.Image != null)
            {
                anim = new Animation(info.Image, () => facing);
                anim.PlayRepeating("idle");
            }

            if (info.ContrailLength > 0)
            {
                var color = info.ContrailUsePlayerColor ? ContrailRenderable.ChooseColor(args.SourceActor) : info.ContrailColor;
                trail = new ContrailRenderable(args.SourceActor.World, color, info.ContrailLength, info.ContrailDelay, 0);
            }
        }
开发者ID:TiriliPiitPiit,项目名称:OpenRA,代码行数:30,代码来源:Missile.cs


示例5: Tick

        public override Activity Tick(Actor self)
        {
            if (self.CenterPosition.Z <= 0)
            {
                if (info.Explosion != null)
                {
                    var weapon = self.World.Map.Rules.Weapons[info.Explosion.ToLowerInvariant()];

                    // Use .FromPos since this actor is killed. Cannot use Target.FromActor
                    weapon.Impact(Target.FromPos(self.CenterPosition), self, Enumerable.Empty<int>());
                }

                self.Destroy();
                return null;
            }

            if (info.Spins)
            {
                spin += acceleration;
                aircraft.Facing = (aircraft.Facing + spin) % 256;
            }

            var move = info.Moves ? aircraft.FlyStep(aircraft.Facing) : WVec.Zero;
            move -= new WVec(WRange.Zero, WRange.Zero, info.Velocity);
            aircraft.SetPosition(self, aircraft.CenterPosition + move);

            return this;
        }
开发者ID:ushardul,项目名称:OpenRA,代码行数:28,代码来源:FallToEarth.cs


示例6: TryGetAlternateTargetInCircle

		protected bool TryGetAlternateTargetInCircle(
			Actor self, WDist radius, Action<Target> update, Func<Actor, bool> primaryFilter, Func<Actor, bool>[] preferenceFilters = null)
		{
			var diff = new WVec(radius, radius, WDist.Zero);
			var candidates = self.World.ActorMap.ActorsInBox(self.CenterPosition - diff, self.CenterPosition + diff)
				.Where(primaryFilter).Select(a => new { Actor = a, Ls = (self.CenterPosition - a.CenterPosition).HorizontalLengthSquared })
				.Where(p => p.Ls <= radius.LengthSquared).OrderBy(p => p.Ls).Select(p => p.Actor);
			if (preferenceFilters != null)
				foreach (var filter in preferenceFilters)
				{
					var preferredCandidate = candidates.FirstOrDefault(filter);
					if (preferredCandidate == null)
						continue;
					target = Target.FromActor(preferredCandidate);
					update(target);
					return true;
				}

			var candidate = candidates.FirstOrDefault();
			if (candidate == null)
				return false;
			target = Target.FromActor(candidate);
			update(target);
			return true;
		}
开发者ID:Roger-luo,项目名称:OpenRA,代码行数:25,代码来源:Enter.cs


示例7: FallDown

		public FallDown(Actor self, WPos dropPosition, int fallRate, Actor ignoreActor = null)
		{
			pos = self.TraitOrDefault<IPositionable>();
			IsInterruptible = false;
			fallVector = new WVec(0, 0, fallRate);
			this.dropPosition = dropPosition;
		}
开发者ID:GraionDilach,项目名称:OpenRA.Mods.AS,代码行数:7,代码来源:FallDown.cs


示例8: OffsetBy

		public IRenderable OffsetBy(WVec vec)
		{
			return new VoxelRenderable(
				voxels, pos + vec, zOffset, camera, scale,
				lightSource, lightAmbientColor, lightDiffuseColor,
				palette, normalsPalette, shadowPalette);
		}
开发者ID:Roger-luo,项目名称:OpenRA,代码行数:7,代码来源:VoxelRenderable.cs


示例9: NukeLaunch

        public NukeLaunch(Player firedBy, string weapon, WPos launchPos, WPos targetPos, WDist velocity, int delay, bool skipAscent, string flashType)
        {
            this.firedBy = firedBy;
            this.weapon = weapon;
            this.delay = delay;
            this.turn = delay / 2;
            this.flashType = flashType;

            var offset = new WVec(WDist.Zero, WDist.Zero, velocity * turn);
            ascendSource = launchPos;
            ascendTarget = launchPos + offset;
            descendSource = targetPos + offset;
            descendTarget = targetPos;

            anim = new Animation(firedBy.World, weapon);
            anim.PlayRepeating("up");

            pos = launchPos;
            var weaponRules = firedBy.World.Map.Rules.Weapons[weapon.ToLowerInvariant()];
            if (weaponRules.Report != null && weaponRules.Report.Any())
                Sound.Play(weaponRules.Report.Random(firedBy.World.SharedRandom), pos);

            if (skipAscent)
                ticks = turn;
        }
开发者ID:rhamilton1415,项目名称:OpenRA,代码行数:25,代码来源:NukeLaunch.cs


示例10: ConvertInt2ToWVec

		static void ConvertInt2ToWVec(ref string input)
		{
			var offset = FieldLoader.GetValue<int2>("(value)", input);
			var ts = Game.modData.Manifest.TileSize;
			var world = new WVec(offset.X * 1024 / ts.Width, offset.Y * 1024 / ts.Height, 0);
			input = world.ToString();
		}
开发者ID:JackKucan,项目名称:OpenRA,代码行数:7,代码来源:UpgradeRules.cs


示例11: Missile

        public Missile(MissileInfo info, ProjectileArgs args)
        {
            this.info = info;
            this.args = args;

            pos = args.Source;
            facing = args.Facing;

            targetPosition = args.PassiveTarget;

            if (info.Inaccuracy.Range > 0)
                offset = WVec.FromPDF(args.SourceActor.World.SharedRandom, 2) * info.Inaccuracy.Range / 1024;

            if (info.Image != null)
            {
                anim = new Animation(args.SourceActor.World, info.Image, () => facing);
                anim.PlayRepeating("idle");
            }

            if (info.ContrailLength > 0)
            {
                var color = info.ContrailUsePlayerColor ? ContrailRenderable.ChooseColor(args.SourceActor) : info.ContrailColor;
                trail = new ContrailRenderable(args.SourceActor.World, color, info.ContrailLength, info.ContrailDelay, 0);
            }
        }
开发者ID:RunCraze,项目名称:OpenRA,代码行数:25,代码来源:Missile.cs


示例12: NukeLaunch

        public NukeLaunch(Player firedBy, string name, WeaponInfo weapon, string weaponPalette, string upSequence, string downSequence,
			WPos launchPos, WPos targetPos, WDist velocity, int delay, bool skipAscent, string flashType)
        {
            this.firedBy = firedBy;
            this.weapon = weapon;
            this.weaponPalette = weaponPalette;
            this.downSequence = downSequence;
            this.delay = delay;
            turn = delay / 2;
            this.flashType = flashType;

            var offset = new WVec(WDist.Zero, WDist.Zero, velocity * turn);
            ascendSource = launchPos;
            ascendTarget = launchPos + offset;
            descendSource = targetPos + offset;
            descendTarget = targetPos;

            anim = new Animation(firedBy.World, name);
            anim.PlayRepeating(upSequence);

            pos = launchPos;
            if (weapon.Report != null && weapon.Report.Any())
                Game.Sound.Play(weapon.Report.Random(firedBy.World.SharedRandom), pos);

            if (skipAscent)
                ticks = turn;
        }
开发者ID:OpenRA,项目名称:OpenRA,代码行数:27,代码来源:NukeLaunch.cs


示例13: Parachute

        public Parachute(Actor cargo, WPos dropPosition)
        {
            this.cargo = cargo;

            parachutableInfo = cargo.Info.Traits.GetOrDefault<ParachutableInfo>();

            if (parachutableInfo != null)
                fallVector = new WVec(0, 0, parachutableInfo.FallRate);

            var parachuteSprite = parachutableInfo != null ? parachutableInfo.ParachuteSequence : null;
            if (parachuteSprite != null)
            {
                parachute = new Animation(cargo.World, parachuteSprite);
                parachute.PlayThen("open", () => parachute.PlayRepeating("idle"));
            }

            var shadowSprite = parachutableInfo != null ? parachutableInfo.ShadowSequence : null;
            if (shadowSprite != null)
            {
                shadow = new Animation(cargo.World, shadowSprite);
                shadow.PlayRepeating("idle");
            }

            if (parachutableInfo != null)
                parachuteOffset = parachutableInfo.ParachuteOffset;

            // Adjust x,y to match the target subcell
            cargo.Trait<IPositionable>().SetPosition(cargo, cargo.World.Map.CellContaining(dropPosition));
            var cp = cargo.CenterPosition;
            pos = new WPos(cp.X, cp.Y, dropPosition.Z);
        }
开发者ID:RobotCaleb,项目名称:OpenRA,代码行数:31,代码来源:Parachute.cs


示例14: CreateActors

        void CreateActors(string actorName, string deliveringActorName, out Actor cargo, out Actor carrier)
        {
            // Get a carryall spawn location
            var location = Info.SpawnLocation;
            if (location == CPos.Zero)
                location = self.World.Map.ChooseClosestEdgeCell(self.Location);

            var spawn = self.World.Map.CenterOfCell(location);

            var initialFacing = self.World.Map.FacingBetween(location, self.Location, 0);

            // If aircraft, spawn at cruise altitude
            var aircraftInfo = self.World.Map.Rules.Actors[deliveringActorName.ToLower()].TraitInfoOrDefault<AircraftInfo>();
            if (aircraftInfo != null)
                spawn += new WVec(0, 0, aircraftInfo.CruiseAltitude.Length);

            // Create delivery actor
            carrier = self.World.CreateActor(false, deliveringActorName, new TypeDictionary
            {
                new LocationInit(location),
                new CenterPositionInit(spawn),
                new OwnerInit(self.Owner),
                new FacingInit(initialFacing)
            });

            // Create delivered actor
            cargo = self.World.CreateActor(false, actorName, new TypeDictionary
            {
                new OwnerInit(self.Owner),
            });
        }
开发者ID:pchote,项目名称:OpenRA,代码行数:31,代码来源:FreeActorWithDelivery.cs


示例15: AreaBeam

        public AreaBeam(AreaBeamInfo info, ProjectileArgs args, Color color)
        {
            this.info = info;
            this.args = args;
            this.color = color;
            actorAttackBase = args.SourceActor.Trait<AttackBase>();

            var world = args.SourceActor.World;
            if (info.Speed.Length > 1)
                speed = new WDist(world.SharedRandom.Next(info.Speed[0].Length, info.Speed[1].Length));
            else
                speed = info.Speed[0];

            // Both the head and tail start at the source actor, but initially only the head is travelling.
            headPos = args.Source;
            tailPos = headPos;

            target = args.PassiveTarget;
            if (info.Inaccuracy.Length > 0)
            {
                var inaccuracy = Util.ApplyPercentageModifiers(info.Inaccuracy.Length, args.InaccuracyModifiers);
                var maxOffset = inaccuracy * (target - headPos).Length / args.Weapon.Range.Length;
                target += WVec.FromPDF(world.SharedRandom, 2) * maxOffset / 1024;
            }

            towardsTargetFacing = (target - headPos).Yaw.Facing;

            // Update the target position with the range we shoot beyond the target by
            // I.e. we can deliberately overshoot, so aim for that position
            var dir = new WVec(0, -1024, 0).Rotate(WRot.FromFacing(towardsTargetFacing));
            target += dir * info.BeyondTargetRange.Length / 1024;

            length = Math.Max((target - headPos).Length / speed.Length, 1);
        }
开发者ID:pchote,项目名称:OpenRA,代码行数:34,代码来源:AreaBeam.cs


示例16: Tick

        public override Activity Tick(Actor self)
        {
            if (self.World.Map.DistanceAboveTerrain(self.CenterPosition).Length <= 0)
            {
                if (info.ExplosionWeapon != null)
                {
                    // Use .FromPos since this actor is killed. Cannot use Target.FromActor
                    info.ExplosionWeapon.Impact(Target.FromPos(self.CenterPosition), self, Enumerable.Empty<int>());
                }

                self.Dispose();
                return null;
            }

            if (info.Spins)
            {
                spin += acceleration;
                aircraft.Facing = (aircraft.Facing + spin) % 256;
            }

            var move = info.Moves ? aircraft.FlyStep(aircraft.Facing) : WVec.Zero;
            move -= new WVec(WDist.Zero, WDist.Zero, info.Velocity);
            aircraft.SetPosition(self, aircraft.CenterPosition + move);

            return this;
        }
开发者ID:CH4Code,项目名称:OpenRA,代码行数:26,代码来源:FallToEarth.cs


示例17: FindActorsOnLine

        /// <summary>
        /// Finds all the actors of which their health radius is intersected by a line (with a definable width) between two points.
        /// </summary>
        /// <param name="world">The engine world the line intersection is to be done in.</param>
        /// <param name="lineStart">The position the line should start at</param>
        /// <param name="lineEnd">The position the line should end at</param>
        /// <param name="lineWidth">How close an actor's health radius needs to be to the line to be considered 'intersected' by the line</param>
        /// <returns>A list of all the actors intersected by the line</returns>
        public static IEnumerable<Actor> FindActorsOnLine(this World world, WPos lineStart, WPos lineEnd, WDist lineWidth, WDist targetExtraSearchRadius)
        {
            // This line intersection check is done by first just finding all actors within a square that starts at the source, and ends at the target.
            // Then we iterate over this list, and find all actors for which their health radius is at least within lineWidth of the line.
            // For actors without a health radius, we simply check their center point.
            // The square in which we select all actors must be large enough to encompass the entire line's width.
            var xDir = Math.Sign(lineEnd.X - lineStart.X);
            var yDir = Math.Sign(lineEnd.Y - lineStart.Y);

            var dir = new WVec(xDir, yDir, 0);
            var overselect = dir * (1024 + lineWidth.Length + targetExtraSearchRadius.Length);
            var finalTarget = lineEnd + overselect;
            var finalSource = lineStart - overselect;

            var actorsInSquare = world.ActorMap.ActorsInBox(finalTarget, finalSource);
            var intersectedActors = new List<Actor>();

            foreach (var currActor in actorsInSquare)
            {
                var actorWidth = 0;
                var healthInfo = currActor.Info.TraitInfoOrDefault<HealthInfo>();
                if (healthInfo != null)
                    actorWidth = healthInfo.Shape.OuterRadius.Length;

                var projection = MinimumPointLineProjection(lineStart, lineEnd, currActor.CenterPosition);
                var distance = (currActor.CenterPosition - projection).HorizontalLength;
                var maxReach = actorWidth + lineWidth.Length;

                if (distance <= maxReach)
                    intersectedActors.Add(currActor);
            }

            return intersectedActors;
        }
开发者ID:pchote,项目名称:OpenRA,代码行数:42,代码来源:WorldExtensions.cs


示例18: Activate

        public override void Activate(Actor self, Order order)
        {
            var info = Info as AirstrikePowerInfo;

            var attackFacing = Util.QuantizeFacing(self.World.SharedRandom.Next(256), info.QuantizedFacings) * (256 / info.QuantizedFacings);
            var attackRotation = WRot.FromFacing(attackFacing);
            var delta = new WVec(0, -1024, 0).Rotate(attackRotation);

            var altitude = Rules.Info[info.UnitType].Traits.Get<PlaneInfo>().CruiseAltitude * 1024 / Game.CellSize;
            var target = order.TargetLocation.CenterPosition + new WVec(0, 0, altitude);
            var startEdge = target - (self.World.DistanceToMapEdge(target, -delta) + info.Cordon).Range * delta / 1024;
            var finishEdge = target + (self.World.DistanceToMapEdge(target, delta) + info.Cordon).Range * delta / 1024;

            self.World.AddFrameEndTask(w =>
            {
                var notification = self.Owner.IsAlliedWith(self.World.RenderPlayer) ? Info.LaunchSound : Info.IncomingSound;
                Sound.Play(notification);

                Actor flare = null;
                if (info.FlareType != null)
                {
                    flare = w.CreateActor(info.FlareType, new TypeDictionary
                    {
                        new LocationInit(order.TargetLocation),
                        new OwnerInit(self.Owner),
                    });

                    flare.QueueActivity(new Wait(info.FlareTime));
                    flare.QueueActivity(new RemoveSelf());
                }

                for (var i = -info.SquadSize / 2; i <= info.SquadSize / 2; i++)
                {
                    // Even-sized squads skip the lead plane
                    if (i == 0 && (info.SquadSize & 1) == 0)
                        continue;

                    // Includes the 90 degree rotation between body and world coordinates
                    var so = info.SquadOffset;
                    var spawnOffset = new WVec(i*so.Y, -Math.Abs(i)*so.X, 0).Rotate(attackRotation);
                    var targetOffset = new WVec(i*so.Y, 0, 0).Rotate(attackRotation);

                    var a = w.CreateActor(info.UnitType, new TypeDictionary
                    {
                        new CenterPositionInit(startEdge + spawnOffset),
                        new OwnerInit(self.Owner),
                        new FacingInit(attackFacing),
                    });

                    a.Trait<AttackBomber>().SetTarget(target + targetOffset);

                    if (flare != null)
                        a.QueueActivity(new CallFunc(() => flare.Destroy()));

                    a.QueueActivity(Fly.ToPos(finishEdge + spawnOffset));
                    a.QueueActivity(new RemoveSelf());
                }
            });
        }
开发者ID:Generalcamo,项目名称:OpenRA,代码行数:59,代码来源:AirstrikePower.cs


示例19: DistanceFromEdge

        public WDist DistanceFromEdge(WVec v)
        {
            var r = new int2(
                Math.Max(Math.Abs(v.X - center.X) - quadrantSize.X, 0),
                Math.Max(Math.Abs(v.Y - center.Y) - quadrantSize.Y, 0));

            return new WDist(r.Length);
        }
开发者ID:CH4Code,项目名称:OpenRA,代码行数:8,代码来源:Rectangle.cs


示例20: SpriteActorPreview

		public SpriteActorPreview(Animation animation, WVec offset, int zOffset, PaletteReference pr, float scale)
		{
			this.animation = animation;
			this.offset = offset;
			this.zOffset = zOffset;
			this.pr = pr;
			this.scale = scale;
		}
开发者ID:Roger-luo,项目名称:OpenRA,代码行数:8,代码来源:SpriteActorPreview.cs



注:本文中的WVec类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# WWW类代码示例发布时间:2022-05-24
下一篇:
C# WSGestion.WSGestion类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap