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


C# Actor.TraitsImplementing方法代码示例

本文整理汇总了C#中Actor.TraitsImplementing方法的典型用法代码示例。如果您正苦于以下问题:C# Actor.TraitsImplementing方法的具体用法?C# Actor.TraitsImplementing怎么用?C# Actor.TraitsImplementing使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Actor的用法示例。


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

示例1: Tick

		public override Activity Tick(Actor self)
		{
			if (IsCanceled)
				return NextActivity;

			self.World.AddFrameEndTask(w =>
			{
				if (self.IsDead)
					return;

				foreach (var nt in self.TraitsImplementing<INotifyTransform>())
					nt.OnTransform(self);

				var selected = w.Selection.Contains(self);
				var controlgroup = w.Selection.GetControlGroupForActor(self);

				self.Dispose();
				foreach (var s in Sounds)
					Game.Sound.PlayToPlayer(self.Owner, s, self.CenterPosition);

				Game.Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Speech", Notification, self.Owner.Faction.InternalName);

				var init = new TypeDictionary
				{
					new LocationInit(self.Location + Offset),
					new OwnerInit(self.Owner),
					new FacingInit(Facing),
				};

				if (SkipMakeAnims)
					init.Add(new SkipMakeAnimsInit());

				if (Faction != null)
					init.Add(new FactionInit(Faction));

				var health = self.TraitOrDefault<Health>();
				if (health != null)
				{
					var newHP = ForceHealthPercentage > 0 ? ForceHealthPercentage : (health.HP * 100) / health.MaxHP;
					init.Add(new HealthInit(newHP));
				}

				var cargo = self.TraitOrDefault<Cargo>();
				if (cargo != null)
					init.Add(new RuntimeCargoInit(cargo.Passengers.ToArray()));

				var a = w.CreateActor(ToActor, init);
				foreach (var nt in self.TraitsImplementing<INotifyTransform>())
					nt.AfterTransform(a);

				if (selected)
					w.Selection.Add(w, a);
				if (controlgroup.HasValue)
					w.Selection.AddToControlGroup(a, controlgroup.Value);
			});

			return this;
		}
开发者ID:Roger-luo,项目名称:OpenRA,代码行数:58,代码来源:Transform.cs

示例2: Tick

		public override Activity Tick(Actor self)
		{
			if (IsCanceled)
				return NextActivity;

			self.World.AddFrameEndTask(w =>
			{
				if (self.IsDead())
					return;

				foreach (var nt in self.TraitsImplementing<INotifyTransform>())
					nt.OnTransform(self);

				var selected = w.Selection.Contains(self);

				self.Destroy();
				foreach (var s in Sounds)
					Sound.PlayToPlayer(self.Owner, s, self.CenterPosition);

				var init = new TypeDictionary
				{
					new LocationInit(self.Location + Offset),
					new OwnerInit(self.Owner),
					new FacingInit(Facing),
				};

				if (SkipMakeAnims)
					init.Add(new SkipMakeAnimsInit());

				if (Race != null)
					init.Add(new RaceInit(Race));

				var health = self.TraitOrDefault<Health>();
				if (health != null)
				{
					var newHP = (ForceHealthPercentage > 0)
						? ForceHealthPercentage / 100f
						: (float)health.HP / health.MaxHP;

					init.Add(new HealthInit(newHP));
				}

				var cargo = self.TraitOrDefault<Cargo>();
				if (cargo != null)
					init.Add(new RuntimeCargoInit(cargo.Passengers.ToArray()));

				var a = w.CreateActor(ToActor, init);
				foreach (var nt in self.TraitsImplementing<INotifyTransform>())
					nt.AfterTransform(a);

				if (selected)
					w.Selection.Add(w, a);
			});

			return this;
		}
开发者ID:Berzeger,项目名称:OpenRA,代码行数:56,代码来源:Transform.cs

示例3: Killed

        public void Killed(Actor self, AttackInfo e)
        {
            if (!self.IsInWorld)
                return;

            self.World.AddFrameEndTask(w =>
            {
                var td = new TypeDictionary
                {
                    new ParentActorInit(self),
                    new LocationInit(self.Location),
                    new CenterPositionInit(self.CenterPosition),
                    new OwnerInit(self.Owner),
                    new SkipMakeAnimsInit()
                };

                // Allows the husk to drag to its final position
                var mobile = self.TraitOrDefault<Mobile>();
                if (mobile != null)
                {
                    if (!mobile.CanEnterCell(self.Location, self, false)) return;
                    td.Add(new HuskSpeedInit(mobile.MovementSpeedForCell(self, self.Location)));
                }

                var aircraft = self.TraitOrDefault<Aircraft>();
                if (aircraft != null)
                    td.Add(new AltitudeInit(aircraft.CenterPosition.Z * Game.CellSize / 1024));

                var facing = self.TraitOrDefault<IFacing>();
                if (facing != null)
                    td.Add(new FacingInit(facing.Facing));

                // TODO: This will only take the first turret if there are multiple
                // This isn't a problem with the current units, but may be a problem for mods
                var turreted = self.TraitsImplementing<Turreted>().FirstOrDefault();
                if (turreted != null)
                    td.Add(new TurretFacingInit(turreted.turretFacing));

                var chronoshiftable = self.TraitOrDefault<Chronoshiftable>();
                if (chronoshiftable != null && chronoshiftable.ReturnTicks > 0)
                {
                    td.Add(new ChronoshiftOriginInit(chronoshiftable.Origin));
                    td.Add(new ChronoshiftReturnInit(chronoshiftable.ReturnTicks));
                }

                var huskActor = self.TraitsImplementing<IHuskModifier>()
                    .Select(ihm => ihm.HuskActor(self))
                    .FirstOrDefault(a => a != null);

                w.CreateActor(huskActor ?? info.HuskActor, td);
            });
        }
开发者ID:Generalcamo,项目名称:OpenRA,代码行数:52,代码来源:LeavesHusk.cs

示例4: Produce

		public override bool Produce(Actor self, ActorInfo producee, string factionVariant)
		{
			var owner = self.Owner;

			// Start a fixed distance away: the width of the map.
			// This makes the production timing independent of spawnpoint
			var startPos = self.Location + new CVec(owner.World.Map.Bounds.Width, 0);
			var endPos = new CPos(owner.World.Map.Bounds.Left - 5, self.Location.Y);

			// Assume a single exit point for simplicity
			var exit = self.Info.TraitInfos<ExitInfo>().First();

			foreach (var tower in self.TraitsImplementing<INotifyDelivery>())
				tower.IncomingDelivery(self);

			var info = (ProductionAirdropInfo)Info;
			var actorType = info.ActorType;

			owner.World.AddFrameEndTask(w =>
			{
				if (!self.IsInWorld || self.IsDead)
					return;

				var altitude = self.World.Map.Rules.Actors[actorType].TraitInfo<AircraftInfo>().CruiseAltitude;
				var actor = w.CreateActor(actorType, new TypeDictionary
				{
					new CenterPositionInit(w.Map.CenterOfCell(startPos) + new WVec(WDist.Zero, WDist.Zero, altitude)),
					new OwnerInit(owner),
					new FacingInit(64)
				});

				actor.QueueActivity(new Fly(actor, Target.FromCell(w, self.Location + new CVec(12, 0))));
				actor.QueueActivity(new Land(actor, Target.FromActor(self)));
				actor.QueueActivity(new CallFunc(() =>
				{
					if (!self.IsInWorld || self.IsDead)
						return;

					foreach (var cargo in self.TraitsImplementing<INotifyDelivery>())
						cargo.Delivered(self);

					self.World.AddFrameEndTask(ww => DoProduction(self, producee, exit, factionVariant));
					Game.Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Speech", info.ReadyAudio, self.Owner.Faction.InternalName);
				}));

				actor.QueueActivity(new Fly(actor, Target.FromCell(w, endPos)));
				actor.QueueActivity(new RemoveSelf());
			});

			return true;
		}
开发者ID:Roger-luo,项目名称:OpenRA,代码行数:51,代码来源:ProductionAirdrop.cs

示例5: HeliAttack

 public HeliAttack(Actor self, Target target)
 {
     this.target = target;
     helicopter = self.Trait<Helicopter>();
     attackHeli = self.Trait<AttackHeli>();
     ammoPools = self.TraitsImplementing<AmmoPool>().ToArray();
 }
开发者ID:ushardul,项目名称:OpenRA,代码行数:7,代码来源:HeliAttack.cs

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

示例7: DebugFiringOffsets

        public DebugFiringOffsets(Actor self)
        {
            armaments = Lazy.New(() => self.TraitsImplementing<Armament>());

            var localPlayer = self.World.LocalPlayer;
            devMode = localPlayer != null ? localPlayer.PlayerActor.Trait<DeveloperMode>() : null;
        }
开发者ID:TiriliPiitPiit,项目名称:OpenRA,代码行数:7,代码来源:DebugMuzzlePositions.cs

示例8: Tick

        public void Tick(Actor self)
        {
            // todo: don't tick all the time.
            if(self.Owner == null) return;

            if (previousLocation != self.Location && v != null) {
                previousLocation = self.Location;

                var shrouds = self.World.ActorsWithTrait<Shroud>().Select(s => s.Actor.Owner.Shroud);
                foreach (var shroud in shrouds) {
                    shroud.UnhideActor(self, v, Info.Range);
                }
            }

            if (!self.TraitsImplementing<IDisable>().Any(d => d.Disabled)) {
                var shrouds = self.World.ActorsWithTrait<Shroud>().Select(s => s.Actor.Owner.Shroud);
                foreach (var shroud in shrouds) {
                    shroud.HideActor(self, Info.Range);
                }
            }
            else {
                var shrouds = self.World.ActorsWithTrait<Shroud>().Select(s => s.Actor.Owner.Shroud);
                foreach (var shroud in shrouds) {
                    shroud.UnhideActor(self, v, Info.Range);
                }
            }

            v = new Shroud.ActorVisibility {
                vis = Shroud.GetVisOrigins(self).ToArray()
            };
        }
开发者ID:nevelis,项目名称:OpenRA,代码行数:31,代码来源:CreatesShroud.cs

示例9: Tick

        public void Tick(Actor self)
        {
            if (queue == null)
            {
                var type = info.ProductionType ?? self.Trait<Production>().Info.Produces.First();

                // Per-actor queue
                // Note: this includes disabled queues, as each bar must bind to exactly one queue.
                queue = self.TraitsImplementing<ProductionQueue>()
                    .FirstOrDefault(q => type == null || type == q.Info.Type);

                if (queue == null)
                {
                    // No queues available - check for classic production queues
                    queue = self.Owner.PlayerActor.TraitsImplementing<ProductionQueue>()
                        .FirstOrDefault(q => type == null || type == q.Info.Type);
                }

                if (queue == null)
                    throw new InvalidOperationException("No queues available for production type '{0}'".F(type));
            }

            var current = queue.CurrentItem();
            value = current != null ? 1 - (float)current.RemainingCost / current.TotalCost : 0;
        }
开发者ID:ushardul,项目名称:OpenRA,代码行数:25,代码来源:ProductionBar.cs

示例10: Tick

        public override Activity Tick(Actor self)
        {
            var capturing = self.TraitOrDefault<Capturable>();
            if (capturing != null && capturing.CaptureInProgress) return NextActivity;

            var h = self.TraitOrDefault<Health>();
            var si = self.Info.Traits.Get<SellableInfo>();
            var pr = self.Owner.PlayerActor.Trait<PlayerResources>();

            var cost = self.GetSellValue();

            var refund = (cost * si.RefundPercent * (h == null ? 1 : h.HP)) / (100 * (h == null ? 1 : h.MaxHP));
            pr.GiveCash(refund);

            foreach (var ns in self.TraitsImplementing<INotifySold>())
                ns.Sold(self);

            if (refund > 0 && self.World.LocalPlayer != null && self.Owner.Stances[self.World.LocalPlayer] == Stance.Ally)
                self.World.AddFrameEndTask(
                    w => w.Add(new CashTick(refund, 30, 2,
                        self.CenterLocation,
                        self.Owner.ColorRamp.GetColor(0))));

            self.Destroy();
            return this;
        }
开发者ID:sonygod,项目名称:OpenRA-Dedicated-20120504,代码行数:26,代码来源:Sell.cs

示例11: Killed

        public void Killed(Actor self, AttackInfo e)
        {
            self.World.AddFrameEndTask(w =>
            {
                var td = new TypeDictionary()
                {
                    new LocationInit( self.Location ),
                    new CenterLocationInit(self.CenterLocation),
                    new OwnerInit( self.Owner ),
                    new SkipMakeAnimsInit()
                };

                // Allows the husk to drag to its final position
                var mobile = self.TraitOrDefault<Mobile>();
                if (mobile != null)
                {
                    if (!mobile.CanEnterCell(self.Location, self, false)) return;
                    td.Add(new HuskSpeedInit(mobile.MovementSpeedForCell(self, self.Location)));
                }

                var facing = self.TraitOrDefault<IFacing>();
                if (facing != null)
                    td.Add(new FacingInit( facing.Facing ));

                var turreted = self.TraitOrDefault<Turreted>();
                if (turreted != null)
                    td.Add( new TurretFacingInit(turreted.turretFacing) );

                var huskActor = self.TraitsImplementing<IHuskModifier>()
                    .Select(ihm => ihm.HuskActor(self))
                    .FirstOrDefault(a => a != null);

                w.CreateActor(huskActor ?? Info.HuskActor, td);
            });
        }
开发者ID:Iran,项目名称:ClassicRA,代码行数:35,代码来源:LeavesHusk.cs

示例12: CombatDebugOverlay

        public CombatDebugOverlay(Actor self)
        {
            armaments = Lazy.New(() => self.TraitsImplementing<Armament>());
            health = Lazy.New(() => self.TraitOrDefault<Health>());

            var localPlayer = self.World.LocalPlayer;
            devMode = localPlayer != null ? localPlayer.PlayerActor.Trait<DeveloperMode>() : null;
        }
开发者ID:Generalcamo,项目名称:OpenRA,代码行数:8,代码来源:CombatDebugOverlay.cs

示例13: HeliAttack

		public HeliAttack(Actor self, Target target, bool attackOnlyVisibleTargets = true)
		{
			Target = target;
			helicopter = self.Trait<Aircraft>();
			attackHeli = self.Trait<AttackHeli>();
			ammoPools = self.TraitsImplementing<AmmoPool>().ToArray();
			this.attackOnlyVisibleTargets = attackOnlyVisibleTargets;
		}
开发者ID:Roger-luo,项目名称:OpenRA,代码行数:8,代码来源:HeliAttack.cs

示例14: LayMines

 public LayMines(Actor self)
 {
     minelayer = self.TraitOrDefault<Minelayer>();
     info = self.Info.TraitInfo<MinelayerInfo>();
     ammoPools = self.TraitsImplementing<AmmoPool>().ToArray();
     movement = self.Trait<IMove>();
     rearmBuildings = info.RearmBuildings;
 }
开发者ID:pchote,项目名称:OpenRA,代码行数:8,代码来源:LayMines.cs

示例15: DamageVersus

        public int DamageVersus(Actor victim)
        {
            var armor = victim.TraitsImplementing<Armor>()
                .Where(a => !a.IsTraitDisabled && a.Info.Type != null && Versus.ContainsKey(a.Info.Type))
                .Select(a => Versus[a.Info.Type]);

            return Util.ApplyPercentageModifiers(100, armor);
        }
开发者ID:CH4Code,项目名称:OpenRA,代码行数:8,代码来源:DamageWarhead.cs


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