當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。