当前位置: 首页>>代码示例>>C#>>正文


C# Traits.Target类代码示例

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


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

示例1: DoImpact

        public override void DoImpact(Target target, Actor firedBy, IEnumerable<int> damageModifiers)
        {
            if (!target.IsValidFor(firedBy))
                return;

            var pos = target.CenterPosition;
            var world = firedBy.World;
            var targetTile = world.Map.CellContaining(pos);
            var isValid = IsValidImpact(pos, firedBy);

            if ((!world.Map.Contains(targetTile)) || (!isValid))
                return;

            var palette = ExplosionPalette;
            if (UsePlayerPalette)
                palette += firedBy.Owner.InternalName;

            var explosion = Explosions.RandomOrDefault(Game.CosmeticRandom);
            if (Image != null && explosion != null)
                world.AddFrameEndTask(w => w.Add(new SpriteEffect(pos, w, Image, explosion, palette)));

            var impactSound = ImpactSounds.RandomOrDefault(Game.CosmeticRandom);
            if (impactSound != null)
                Game.Sound.Play(impactSound, pos);
        }
开发者ID:OpenRA,项目名称:OpenRA,代码行数:25,代码来源:CreateEffectWarhead.cs

示例2: IssueOrder

        public Order IssueOrder( Actor self, IOrderTargeter order, Target target, bool queued )
        {
            if( order.OrderID == "Unload" )
                return new Order( order.OrderID, self, queued );

            return null;
        }
开发者ID:jeff-1amstudios,项目名称:OpenRA,代码行数:7,代码来源:Cargo.cs

示例3: IssueOrder

		public Order IssueOrder(Actor self, IOrderTargeter order, Target target, bool queued)
		{
			if (order.OrderID == "DeployTransform")
				return new Order(order.OrderID, self, queued);

			return null;
		}
开发者ID:JackKucan,项目名称:OpenRA,代码行数:7,代码来源:Transforms.cs

示例4: FlyAttack

 public FlyAttack(Actor self, Target target)
 {
     this.target = target;
     attackPlane = self.TraitOrDefault<AttackPlane>();
     ammoPools = self.TraitsImplementing<AmmoPool>().ToArray();
     ticksUntilTurn = attackPlane.AttackPlaneInfo.AttackTurnDelay;
 }
开发者ID:cjshmyr,项目名称:OpenRA,代码行数:7,代码来源:FlyAttack.cs

示例5: IssueOrder

        public Order IssueOrder( Actor self, IOrderTargeter order, Target target, bool queued )
        {
            if( order.OrderID == "EnterTransport" )
                return new Order( order.OrderID, self, target.Actor, queued );

            return null;
        }
开发者ID:geckosoft,项目名称:OpenRA,代码行数:7,代码来源:Passenger.cs

示例6: DoImpact

		// TODO: Allow maximum resource splatter to be defined. (Per tile, and in total).
		public override void DoImpact(Target target, Actor firedBy, IEnumerable<int> damageModifiers)
		{
			if (string.IsNullOrEmpty(AddsResourceType))
				return;

			var world = firedBy.World;
			var targetTile = world.Map.CellContaining(target.CenterPosition);
			var resLayer = world.WorldActor.Trait<ResourceLayer>();

			var minRange = (Size.Length > 1 && Size[1] > 0) ? Size[1] : 0;
			var allCells = world.Map.FindTilesInAnnulus(targetTile, minRange, Size[0]);

			var resourceType = world.WorldActor.TraitsImplementing<ResourceType>()
				.FirstOrDefault(t => t.Info.Name == AddsResourceType);

			if (resourceType == null)
				Log.Write("debug", "Warhead defines an invalid resource type '{0}'".F(AddsResourceType));
			else
			{
				foreach (var cell in allCells)
				{
					if (!resLayer.CanSpawnResourceAt(resourceType, cell))
						continue;

					var splash = world.SharedRandom.Next(1, resourceType.Info.MaxDensity - resLayer.GetResourceDensity(cell));
					resLayer.AddResource(resourceType, cell, splash);
				}
			}
		}
开发者ID:Roger-luo,项目名称:OpenRA,代码行数:30,代码来源:CreateResourceWarhead.cs

示例7: ResolveOrder

        public override void ResolveOrder(Actor self, Order order)
        {
            base.ResolveOrder(self, order);

            if (order.OrderString == "Stop")
                target = Target.None;
        }
开发者ID:katzsmile,项目名称:OpenRA,代码行数:7,代码来源:AttackTurreted.cs

示例8: CanAttack

        protected override bool CanAttack(Actor self, Target target)
        {
            if (!target.IsValidFor(self))
                return false;

            return base.CanAttack(self, target);
        }
开发者ID:RunCraze,项目名称:OpenRA,代码行数:7,代码来源:AttackFollow.cs

示例9: IssueOrder

        public Order IssueOrder( Actor self, IOrderTargeter order, Target target )
        {
            if( order.OrderID == "Disguise" )
                return new Order( order.OrderID, self, target.Actor );

            return null;
        }
开发者ID:pdovy,项目名称:OpenRA,代码行数:7,代码来源:RenderSpy.cs

示例10: IssueOrder

        public Order IssueOrder( Actor self, IOrderTargeter order, Target target, bool queued )
        {
            if( order.OrderID == "SetRallyPoint" )
                return new Order(order.OrderID, self, false) { TargetLocation = target.CenterPosition.ToCPos() };

            return null;
        }
开发者ID:Generalcamo,项目名称:OpenRA,代码行数:7,代码来源:RallyPoint.cs

示例11: Enter

 protected Enter(Actor self, Actor target, int maxTries = 1, bool targetCenter = false)
 {
     this.move = self.Trait<IMove>();
     this.target = Target.FromActor(target);
     this.maxTries = maxTries;
     this.targetCenter = targetCenter;
 }
开发者ID:ushardul,项目名称:OpenRA,代码行数:7,代码来源:Enter.cs

示例12: FlyFollow

		public FlyFollow(Actor self, Target target, WDist minRange, WDist maxRange)
		{
			this.target = target;
			plane = self.Trait<Aircraft>();
			this.minRange = minRange;
			this.maxRange = maxRange;
		}
开发者ID:Roger-luo,项目名称:OpenRA,代码行数:7,代码来源:FlyFollow.cs

示例13: DoImpact

		public override void DoImpact(Target target, Actor firedBy, IEnumerable<int> damageModifiers)
		{
			var actors = target.Type == TargetType.Actor ? new[] { target.Actor } :
				firedBy.World.FindActorsInCircle(target.CenterPosition, Range);

			foreach (var a in actors)
			{
				// Don't do anything on friendly fire
				if (a.Owner == firedBy.Owner)
					continue;

				if (Duration == 0)
					a.ChangeOwner(firedBy.Owner); // Permanent
				else
				{
					var tempOwnerManager = a.TraitOrDefault<TemporaryOwnerManager>();
					if (tempOwnerManager == null)
						continue;

					tempOwnerManager.ChangeOwner(a, firedBy.Owner, Duration);
				}

				// Stop shooting, you have new enemies
				a.CancelActivity();
			}
		}
开发者ID:Roger-luo,项目名称:OpenRA,代码行数:26,代码来源:ChangeOwnerWarhead.cs

示例14: 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

示例15: CanAttack

        protected override bool CanAttack(Actor self, Target target)
        {
            if (!IsReachableTarget(target, true))
                return false;

            return base.CanAttack(self, target);
        }
开发者ID:RobotCaleb,项目名称:OpenRA,代码行数:7,代码来源:AttackCharge.cs


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