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


C# Actor.Trait方法代码示例

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


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

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

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

示例3: RenderUnitTurreted

        public RenderUnitTurreted(Actor self)
            : base(self)
        {
            var facing = self.Trait<IFacing>();
            var turreted = self.Trait<Turreted>();
            var attack = self.TraitOrDefault<AttackBase>();
            var attackInfo = self.Info.Traits.Get<AttackBaseInfo>();

            var turretAnim = new Animation(GetImage(self), () => turreted.turretFacing );
            turretAnim.Play( "turret" );

            for( var i = 0; i < attack.Turrets.Count; i++ )
            {
                var turret = attack.Turrets[i];
                anims.Add( "turret_{0}".F(i),
                    new AnimationWithOffset( turretAnim,
                        () => Combat.GetTurretPosition( self, facing, turret ),
                        null));

                if (attackInfo.MuzzleFlash)
                {
                    var muzzleFlash = new Animation(GetImage(self), () => turreted.turretFacing);
                    muzzleFlash.PlayFetchIndex("muzzle",
                        () => (int)(turret.Recoil * 5.9f)); /* hack: dumb crap */
                    anims.Add("muzzle_flash_{0}".F(i),
                        new AnimationWithOffset(muzzleFlash,
                            () => Combat.GetTurretPosition(self, facing, turret),
                            () => turret.Recoil <= 0));
                }
            }
        }
开发者ID:patthoyts,项目名称:OpenRA,代码行数:31,代码来源:RenderUnitTurreted.cs

示例4: VoxelHarvesterDockSequence

 public VoxelHarvesterDockSequence(Actor self, Actor proc)
 {
     this.proc = proc;
     state = State.Turn;
     harv = self.Trait<Harvester>();
     body = self.Trait<WithVoxelUnloadBody>();
 }
开发者ID:RobotCaleb,项目名称:OpenRA,代码行数:7,代码来源:VoxelHarvesterDockSequence.cs

示例5: DeliverGoods

 public DeliverGoods(Actor self)
 {
     trader = self.Trait<Trader>();
     traderInfo = self.Info.Traits.Get<TraderInfo>();
     move = self.Trait<IMove>();
     pathFinder = self.World.WorldActor.Trait<IPathFinder>();
 }
开发者ID:Holloweye,项目名称:OpenRA,代码行数:7,代码来源:DeliverGoods.cs

示例6: Tick

        public override Activity Tick( Actor self )
        {
            if( NextActivity != null )
                return NextActivity;

            var mobile = self.Trait<Mobile>();
            var harv = self.Trait<Harvester>();

            if (harv.LinkedProc == null || !harv.LinkedProc.IsInWorld)
                harv.ChooseNewProc(self, null);

            if (harv.LinkedProc == null)	// no procs exist; check again in 1s.
                return Util.SequenceActivities( new Wait(25), this );

            var proc = harv.LinkedProc;
            var iao = proc.Trait<IAcceptOre>();

            self.SetTargetLine(Target.FromActor(proc), Color.Green, false);
            if( self.Location != proc.Location + iao.DeliverOffset )
                return Util.SequenceActivities( mobile.MoveTo(proc.Location + iao.DeliverOffset, 0), this );

            if (!isDocking)
            {
                isDocking = true;
                iao.OnDock(self, this);
            }

            return Util.SequenceActivities( new Wait(10), this );
        }
开发者ID:jeff-1amstudios,项目名称:OpenRA,代码行数:29,代码来源:DeliverResources.cs

示例7: RenderInfantry

 public RenderInfantry(Actor self)
     : base(self, () => self.Trait<IFacing>().Facing)
 {
     anim.Play("stand");
     State = AnimationState.Idle;
     mobile = self.Trait<Mobile>();
 }
开发者ID:patthoyts,项目名称:OpenRA,代码行数:7,代码来源:RenderInfantry.cs

示例8: Tick

        public override Activity Tick(Actor self)
        {
            if (IsCanceled || !target.IsValidFor(self))
                return NextActivity;

            var limitedAmmo = self.TraitOrDefault<LimitedAmmo>();
            var reloads = self.TraitOrDefault<Reloads>();
            if (limitedAmmo != null && !limitedAmmo.HasAmmo() && reloads == null)
                return Util.SequenceActivities(new HeliReturn(), NextActivity);

            var helicopter = self.Trait<Helicopter>();
            var attack = self.Trait<AttackHeli>();
            var dist = target.CenterPosition - self.CenterPosition;

            // Can rotate facing while ascending
            var desiredFacing = Util.GetFacing(dist, helicopter.Facing);
            helicopter.Facing = Util.TickFacing(helicopter.Facing, desiredFacing, helicopter.ROT);

            if (HeliFly.AdjustAltitude(self, helicopter, helicopter.Info.CruiseAltitude))
                return this;

            // Fly towards the target
            if (!target.IsInRange(self.CenterPosition, attack.GetMaximumRange()))
                helicopter.SetPosition(self, helicopter.CenterPosition + helicopter.FlyStep(desiredFacing));

            attack.DoAttack(self, target);

            return this;
        }
开发者ID:RobotCaleb,项目名称:OpenRA,代码行数:29,代码来源:HeliAttack.cs

示例9: Tick

        public IActivity Tick( Actor self )
        {
            var facing = self.Trait<IFacing>();
            if (!Target.IsValid)
                return NextActivity;

            var targetCell = Util.CellContaining(Target.CenterLocation);

            if ((targetCell - self.Location).LengthSquared >= Range * Range)
                return new Move( Target, Range ) { NextActivity = this };

            var desiredFacing = Util.GetFacing((targetCell - self.Location).ToFloat2(), 0);
            var renderUnit = self.TraitOrDefault<RenderUnit>();
            var numDirs = (renderUnit != null)
                ? renderUnit.anim.CurrentSequence.Facings : 8;

            if (Util.QuantizeFacing(facing.Facing, numDirs)
                != Util.QuantizeFacing(desiredFacing, numDirs))
            {
                return new Turn( desiredFacing ) { NextActivity = this };
            }

            var attack = self.Trait<AttackBase>();
            attack.target = Target;
            attack.DoAttack(self);
            return this;
        }
开发者ID:mgatland,项目名称:OpenRA,代码行数:27,代码来源:Attack.cs

示例10: InnerTick

        protected virtual Activity InnerTick( Actor self, AttackBase attack )
        {
            if (IsCanceled) return NextActivity;
            var facing = self.Trait<IFacing>();
            if (!Target.IsValid)
                return NextActivity;

            if (targetable != null && !targetable.TargetableBy(Target.Actor, self))
                return NextActivity;

            if (!Combat.IsInRange(self.CenterLocation, Range, Target))
            {
                if (--nextPathTime > 0)
                    return this;

                nextPathTime = self.World.SharedRandom.Next(delayBetweenPathingAttempts - delaySpread,
                    delayBetweenPathingAttempts + delaySpread);

                return (AllowMovement) ? Util.SequenceActivities(self.Trait<Mobile>().MoveWithinRange(Target, Range), this) : NextActivity;
            }

            var desiredFacing = Util.GetFacing(Target.CenterLocation - self.CenterLocation, 0);
            if (facing.Facing != desiredFacing)
                return Util.SequenceActivities( new Turn( desiredFacing ), this );

            attack.DoAttack(self, Target);
            return this;
        }
开发者ID:katzsmile,项目名称:OpenRA,代码行数:28,代码来源:Attack.cs

示例11: RAHarvesterDockSequence

 public RAHarvesterDockSequence(Actor self, Actor proc)
 {
     this.proc = proc;
     state = State.Turn;
     harv = self.Trait<Harvester>();
     ru = self.Trait<RenderUnit>();
 }
开发者ID:patthoyts,项目名称:OpenRA,代码行数:7,代码来源:RAHarvesterDockSequence.cs

示例12: Tick

        public override Activity Tick(Actor self)
        {
            if (IsCanceled) return NextActivity;
            if (!target.IsValid) return NextActivity;

            var limitedAmmo = self.TraitOrDefault<LimitedAmmo>();
            var reloads = self.TraitOrDefault<Reloads>();
            if (limitedAmmo != null && !limitedAmmo.HasAmmo() && reloads == null)
                return Util.SequenceActivities( new HeliReturn(), NextActivity );

            var aircraft = self.Trait<Aircraft>();
            var info = self.Info.Traits.Get<HelicopterInfo>();
            if (aircraft.Altitude != info.CruiseAltitude)
            {
                aircraft.Altitude += Math.Sign(info.CruiseAltitude - aircraft.Altitude);
                return this;
            }

            var attack = self.Trait<AttackHeli>();
            var dist = target.CenterLocation - self.CenterLocation;

            var desiredFacing = Util.GetFacing(dist, aircraft.Facing);
            aircraft.Facing = Util.TickFacing(aircraft.Facing, desiredFacing, aircraft.ROT);

            if (!Combat.IsInRange(self.CenterLocation, attack.GetMaximumRange(), target))
                aircraft.TickMove(PSubPos.PerPx * aircraft.MovementSpeed, desiredFacing);

            attack.DoAttack( self, target );

            return this;
        }
开发者ID:nevelis,项目名称:OpenRA,代码行数:31,代码来源:HeliAttack.cs

示例13: Tick

        public IActivity Tick( Actor self )
        {
            if( NextActivity != null )
                return NextActivity;

            var mobile = self.Trait<Mobile>();
            var harv = self.Trait<Harvester>();

            if (harv.LinkedProc == null || !harv.LinkedProc.IsInWorld)
                harv.ChooseNewProc(self, null);

            if (harv.LinkedProc == null)	// no procs exist; check again in 1s.
                return Util.SequenceActivities( new Wait(25), this );

            var proc = harv.LinkedProc;

            if( self.Location != proc.Location + proc.Trait<IAcceptOre>().DeliverOffset )
            {
                return Util.SequenceActivities( mobile.MoveTo(proc.Location + proc.Trait<IAcceptOre>().DeliverOffset, 0), this );
            }
            else if (!isDocking)
            {
                isDocking = true;
                proc.Trait<IAcceptOre>().OnDock(self, this);
            }
            return Util.SequenceActivities( new Wait(10), this );
        }
开发者ID:patthoyts,项目名称:OpenRA,代码行数:27,代码来源:DeliverOre.cs

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

示例15: Tick

        public override IActivity Tick(Actor self)
        {
            if (IsCanceled) return NextActivity;
            if (!target.IsValid) return NextActivity;

            var limitedAmmo = self.TraitOrDefault<LimitedAmmo>();
            if (limitedAmmo != null && !limitedAmmo.HasAmmo())
                return Util.SequenceActivities( new HeliReturn(), NextActivity );

            var aircraft = self.Trait<Aircraft>();
            var info = self.Info.Traits.Get<HelicopterInfo>();
            if (aircraft.Altitude != info.CruiseAltitude)
            {
                aircraft.Altitude += Math.Sign(info.CruiseAltitude - aircraft.Altitude);
                return this;
            }

            var attack = self.Trait<AttackHeli>();
            var range = attack.GetMaximumRange() - 1;
            var dist = target.CenterLocation - self.CenterLocation;

            var desiredFacing = Util.GetFacing(dist, aircraft.Facing);
            aircraft.Facing = Util.TickFacing(aircraft.Facing, desiredFacing, aircraft.ROT);

            if( !float2.WithinEpsilon( float2.Zero, dist, range * Game.CellSize ) )
                aircraft.TickMove( 1024 * aircraft.MovementSpeed, desiredFacing );

            attack.DoAttack( self, target );

            return this;
        }
开发者ID:patthoyts,项目名称:OpenRA,代码行数:31,代码来源:HeliAttack.cs


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