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


C# Actor.HasTrait方法代码示例

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


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

示例1: Damaged

        public void Damaged(Actor self, AttackInfo e)
        {
            // only track last hit against our base
            if (!self.HasTrait<Building>())
                return;

            if (e.Attacker == null)
                return;

            if (e.Attacker.Owner == self.Owner)
                return;

            if (e.Attacker == self.World.WorldActor)
                return;

            if (e.Attacker.Owner.IsAlliedWith(self.Owner) && e.Damage <= 0)
                return;

            if (self.World.WorldTick - lastAttackTime > info.NotifyInterval * 25)
            {
                Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Speech", info.Notification, self.Owner.Country.Race);

                if (radarPings != null)
                    radarPings.Add(() => self.Owner == self.World.LocalPlayer, self.CenterPosition, info.RadarPingColor, info.RadarPingDuration);
            }

            lastAttackTime = self.World.WorldTick;
        }
开发者ID:ushardul,项目名称:OpenRA,代码行数:28,代码来源:BaseAttackNotifier.cs

示例2: TargetableBy

        public virtual bool TargetableBy(Actor self, Actor viewer)
        {
            if (cloak == null || (!viewer.IsDead && viewer.HasTrait<IgnoresCloak>()))
                return true;

            return cloak.IsVisible(self, viewer.Owner);
        }
开发者ID:ushardul,项目名称:OpenRA,代码行数:7,代码来源:TargetableUnit.cs

示例3: Damaged

        public void Damaged(Actor self, AttackInfo e)
        {
            if (!Active) return;
            if (!self.HasTrait<AttackBase>()) return;

            ReturnFire(self, e, false, false, true); // only triggers when standing still
        }
开发者ID:patthoyts,项目名称:OpenRA,代码行数:7,代码来源:UnitStanceHoldGround.cs

示例4: Tick

        public override Activity Tick(Actor self)
        {
            if (IsCanceled || limitedAmmo == null) return NextActivity;

            if (--remainingTicks == 0)
            {
                var hostBuilding = self.World.ActorMap.GetUnitsAt(self.Location)
                    .FirstOrDefault(a => a.HasTrait<RenderBuilding>());

                if (!limitedAmmo.GiveAmmo())
                {
                    var helicopter = self.TraitOrDefault<Helicopter>();
                    if (helicopter != null)
                    {
                        if (helicopter.Info.RepairBuildings.Contains(hostBuilding.Info.Name) && self.HasTrait<Health>())
                        {
                            if (self.Trait<Health>().DamageState != DamageState.Undamaged)
                                return NextActivity;
                        }

                        return helicopter.TakeOff(hostBuilding);
                    }

                    return NextActivity;
                }

                if (hostBuilding != null)
                    hostBuilding.Trait<RenderBuilding>().PlayCustomAnim(hostBuilding, "active");

                remainingTicks = limitedAmmo.ReloadTimePerAmmo();
            }

            return this;
        }
开发者ID:RunCraze,项目名称:OpenRA,代码行数:34,代码来源:Rearm.cs

示例5: Tick

        public override Activity Tick(Actor self)
        {
            Sound.Play("chrono2.aud", self.Location.ToPPos());
            Sound.Play("chrono2.aud", destination.ToPPos());

            self.Trait<ITeleportable>().SetPosition(self, destination);

            if (killCargo && self.HasTrait<Cargo>())
            {
                var cargo = self.Trait<Cargo>();
                while (!cargo.IsEmpty(self))
                {
                    if (chronosphere != null)
                        chronosphere.Owner.Kills++;
                    var a = cargo.Unload(self);
                    a.Owner.Deaths++;
                }
            }

            // Trigger screen desaturate effect
            foreach (var a in self.World.ActorsWithTrait<ChronoshiftPaletteEffect>())
                a.Trait.Enable();

            if (chronosphere != null && !chronosphere.Destroyed && chronosphere.HasTrait<RenderBuilding>())
                chronosphere.Trait<RenderBuilding>().PlayCustomAnim(chronosphere, "active");

            return NextActivity;
        }
开发者ID:nevelis,项目名称:OpenRA,代码行数:28,代码来源:Teleport.cs

示例6: AmbientSound

 public AmbientSound(Actor self, AmbientSoundInfo info)
 {
     if (self.HasTrait<IOccupySpace>())
         Sound.PlayLooped(info.SoundFile, self.CenterPosition);
     else
         Sound.PlayLooped(info.SoundFile);
 }
开发者ID:rhamilton1415,项目名称:OpenRA,代码行数:7,代码来源:AmbientSound.cs

示例7: Tick

        public override Activity Tick(Actor self)
        {
            if (IsCanceled) return NextActivity;
            if (target == null || !target.IsInWorld || target.IsDead()) return NextActivity;
            if (target.Owner == self.Owner) return NextActivity;

            if( !target.OccupiesSpace.OccupiedCells().Any( x => x.First == self.Location ) )
                return NextActivity;

            foreach (var t in target.TraitsImplementing<IAcceptSpy>())
                t.OnInfiltrate(target, self);

            if (self.HasTrait<DontDestroyWhenInfiltrating>())
                self.World.AddFrameEndTask(w =>
                {
                    if (self.Destroyed) return;
                    w.Remove(self);
                });
            else
                self.Destroy();

            if (target.HasTrait<Building>())
                Sound.PlayToPlayer(self.Owner, "bldginf1.aud");

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

示例8: Tick

        public override Activity Tick(Actor self)
        {
            Sound.Play(sound, self.CenterPosition);
            Sound.Play(sound, destination.CenterPosition);

            self.Trait<IPositionable>().SetPosition(self, destination);
            self.Generation++;

            if (killCargo && self.HasTrait<Cargo>())
            {
                var cargo = self.Trait<Cargo>();
                while (!cargo.IsEmpty(self))
                {
                    if (chronosphere != null && chronosphere.HasTrait<UpdatesPlayerStatistics>())
                        chronosphere.Owner.PlayerActor.Trait<PlayerStatistics>().UnitsKilled++;

                    var a = cargo.Unload(self);
                    if (a.HasTrait<UpdatesPlayerStatistics>())
                        a.Owner.PlayerActor.Trait<PlayerStatistics>().UnitsDead++;
                }
            }

            // Trigger screen desaturate effect
            foreach (var a in self.World.ActorsWithTrait<ChronoshiftPaletteEffect>())
                a.Trait.Enable();

            if (chronosphere != null && !chronosphere.Destroyed && chronosphere.HasTrait<RenderBuilding>())
                chronosphere.Trait<RenderBuilding>().PlayCustomAnim(chronosphere, "active");

            return NextActivity;
        }
开发者ID:TiriliPiitPiit,项目名称:OpenRA,代码行数:31,代码来源:Teleport.cs

示例9: IssueOrder

        public Order IssueOrder(Actor self, int2 xy, MouseInput mi, Actor underCursor)
        {
            if (underCursor != null && underCursor.HasTrait<RenderInfantry>())
                return new Order("Disguise", self, underCursor);

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

示例10: OnActivate

        protected override void OnActivate(Actor self)
        {
            if (!self.HasTrait<AttackBase>()) return;

            if (self.Trait<AttackBase>().IsAttacking)
                StopAttack(self);
        }
开发者ID:patthoyts,项目名称:OpenRA,代码行数:7,代码来源:UnitStanceHoldGround.cs

示例11: QueueAttack

        protected override void QueueAttack( Actor self, Order order )
        {
            if (self.HasTrait<Building>() && self.Trait<Building>().Disabled)
                return;

            const int RangeTolerance = 1;	/* how far inside our maximum range we should try to sit */
            /* todo: choose the appropriate weapon, when only one works against this target */
            var weapon = ChooseWeaponForTarget(Target.FromOrder(order));
            if (weapon == null)
                return;

            target = Target.FromOrder(order);

            if (self.HasTrait<Mobile>() && !self.Info.Traits.Get<MobileInfo>().OnRails)
                self.QueueActivity( new Follow( target,
                    Math.Max( 0, (int)weapon.Info.Range - RangeTolerance ) ) );
        }
开发者ID:mgatland,项目名称:OpenRA,代码行数:17,代码来源:AttackTurreted.cs

示例12: RenderGunboat

        public RenderGunboat(Actor self)
            : base(self, () => self.HasTrait<Turreted>() ? self.Trait<Turreted>().turretFacing : 0)
        {
            facing = self.Trait<IFacing>();

            anim.Play("left");
            anims.Add( "smoke", new AnimationWithOffset( new Animation( "smoke_m" ), null, () => !isSmoking ) );
        }
开发者ID:mgatland,项目名称:OpenRA,代码行数:8,代码来源:RenderGunboat.cs

示例13: Damaged

        public void Damaged(Actor self, AttackInfo e)
        {
            if (!Active) return;
            if (TargetType == ETargetType.None) return;
            if (IsReturning) return;
            if (!self.HasTrait<AttackBase>()) return;

            ReturnFire(self, e, false); // only triggers when standing still
        }
开发者ID:patthoyts,项目名称:OpenRA,代码行数:9,代码来源:UnitStanceDefensive.cs

示例14: RenderUnit

        public RenderUnit(Actor self)
            : base(self, () => self.HasTrait<IFacing>() ? self.Trait<IFacing>().Facing : 0)
        {
            canSmoke = self.Info.Traits.Get<RenderUnitInfo>().Smokes;

            anim.Play("idle");

            if (canSmoke)
                anims.Add( "smoke", new AnimationWithOffset( new Animation( "smoke_m" ), null, () => !isSmoking ) );
        }
开发者ID:geckosoft,项目名称:OpenRA,代码行数:10,代码来源:RenderUnit.cs

示例15: AppearsHostileTo

        public static bool AppearsHostileTo(this Actor self, Actor toActor)
        {
            var stance = toActor.Owner.Stances[self.Owner];
            if (stance == Stance.Ally)
                return false;		/* otherwise, we'll hate friendly disguised spies */

            if (self.EffectiveOwner != null && self.EffectiveOwner.Disguised && !toActor.HasTrait<IgnoresDisguise>())
                return toActor.Owner.Stances[self.EffectiveOwner.Owner] == Stance.Enemy;

            return stance == Stance.Enemy;
        }
开发者ID:rhamilton1415,项目名称:OpenRA,代码行数:11,代码来源:ActorExts.cs


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