示例#1
0
        public GravityBomb(GravityBombInfo info, ProjectileArgs args)
        {
            Args = args;
            altitude = args.srcAltitude;

            anim = new Animation(info.Image);
            if (anim.HasSequence("open"))
                anim.PlayThen("open", () => anim.PlayRepeating("idle"));
            else
                anim.PlayRepeating("idle");
        }
示例#2
0
        public GravityBomb(GravityBombInfo info, ProjectileArgs args)
        {
            this.info = info;
            this.args = args;
            pos = args.Source;
            velocity = new WVec(WRange.Zero, WRange.Zero, -info.Velocity);

            anim = new Animation(info.Image);
            if (anim.HasSequence("open"))
                anim.PlayThen("open", () => anim.PlayRepeating("idle"));
            else
                anim.PlayRepeating("idle");
        }
示例#3
0
文件: Bullet.cs 项目: Tsher/OpenRA
        public Bullet(BulletInfo info, ProjectileArgs args)
        {
            Info = info;
            Args = args;

            if (info.Inaccuracy > 0)
            {
                var factor = ((Args.dest - Args.src).ToCVec().Length) / args.weapon.Range;
                Args.dest += (PVecInt) (info.Inaccuracy * factor * args.firedBy.World.SharedRandom.Gauss2D(2)).ToInt2();
                Log.Write("debug", "Bullet with Inaccuracy; factor: #{0}; Projectile dest: {1}", factor, Args.dest);
            }

            if (Info.Image != null)
            {
                anim = new Animation(Info.Image, GetEffectiveFacing);
                anim.PlayRepeating("idle");
            }

            if (Info.ContrailLength > 0)
            {
                Trail = new ContrailHistory(Info.ContrailLength,
                    Info.ContrailUsePlayerColor ? ContrailHistory.ChooseColor(args.firedBy) : Info.ContrailColor,
                    Info.ContrailDelay);
            }
        }
示例#4
0
        public Missile(MissileInfo info, ProjectileArgs args)
        {
            this.info = info;
            this.args = args;

            pos = args.Source;
            facing = args.Facing;

            targetPosition = args.PassiveTarget;

            // Convert ProjectileArg definitions to world coordinates
            // TODO: Change the yaml definitions so we don't need this
            var inaccuracy = (int)(info.Inaccuracy * 1024 / Game.CellSize);
            speed = info.Speed * 1024 / (5 * Game.CellSize);

            if (info.Inaccuracy > 0)
                offset = WVec.FromPDF(args.SourceActor.World.SharedRandom, 2) * inaccuracy / 1024;

            if (info.Image != null)
            {
                anim = new Animation(info.Image, () => facing);
                anim.PlayRepeating("idle");
            }

            if (info.ContrailLength > 0)
            {
                var color = info.ContrailUsePlayerColor ? ContrailRenderable.ChooseColor(args.SourceActor) : info.ContrailColor;
                trail = new ContrailRenderable(args.SourceActor.World, color, info.ContrailLength, info.ContrailDelay, 0);
            }
        }
示例#5
0
        public Missile(MissileInfo info, ProjectileArgs args)
        {
            this.info = info;
            this.args = args;

            pos = args.Source;
            facing = args.Facing;

            targetPosition = args.PassiveTarget;

            var world = args.SourceActor.World;

            if (world.SharedRandom.Next(100) <= info.LockOnProbability)
                lockOn = true;

            if (info.Inaccuracy.Range > 0)
            {
                var inaccuracy = OpenRA.Traits.Util.ApplyPercentageModifiers(info.Inaccuracy.Range, args.InaccuracyModifiers);
                offset = WVec.FromPDF(world.SharedRandom, 2) * inaccuracy / 1024;
            }

            if (info.Image != null)
            {
                anim = new Animation(world, info.Image, () => facing);
                anim.PlayRepeating("idle");
            }

            if (info.ContrailLength > 0)
            {
                var color = info.ContrailUsePlayerColor ? ContrailRenderable.ChooseColor(args.SourceActor) : info.ContrailColor;
                trail = new ContrailRenderable(world, color, info.ContrailLength, info.ContrailDelay, 0);
            }
        }
示例#6
0
        public NukeLaunch(Player firedBy, string weapon, WPos launchPos, WPos targetPos, WDist velocity, int delay, bool skipAscent, string flashType)
        {
            this.firedBy = firedBy;
            this.weapon = weapon;
            this.delay = delay;
            this.turn = delay / 2;
            this.flashType = flashType;

            var offset = new WVec(WDist.Zero, WDist.Zero, velocity * turn);
            ascendSource = launchPos;
            ascendTarget = launchPos + offset;
            descendSource = targetPos + offset;
            descendTarget = targetPos;

            anim = new Animation(firedBy.World, weapon);
            anim.PlayRepeating("up");

            pos = launchPos;
            var weaponRules = firedBy.World.Map.Rules.Weapons[weapon.ToLowerInvariant()];
            if (weaponRules.Report != null && weaponRules.Report.Any())
                Sound.Play(weaponRules.Report.Random(firedBy.World.SharedRandom), pos);

            if (skipAscent)
                ticks = turn;
        }
示例#7
0
        public NukeLaunch(Player firedBy, string name, WeaponInfo weapon, string weaponPalette, string upSequence, string downSequence,
			WPos launchPos, WPos targetPos, WDist velocity, int delay, bool skipAscent, string flashType)
        {
            this.firedBy = firedBy;
            this.weapon = weapon;
            this.weaponPalette = weaponPalette;
            this.downSequence = downSequence;
            this.delay = delay;
            turn = delay / 2;
            this.flashType = flashType;

            var offset = new WVec(WDist.Zero, WDist.Zero, velocity * turn);
            ascendSource = launchPos;
            ascendTarget = launchPos + offset;
            descendSource = targetPos + offset;
            descendTarget = targetPos;

            anim = new Animation(firedBy.World, name);
            anim.PlayRepeating(upSequence);

            pos = launchPos;
            if (weapon.Report != null && weapon.Report.Any())
                Game.Sound.Play(weapon.Report.Random(firedBy.World.SharedRandom), pos);

            if (skipAscent)
                ticks = turn;
        }
示例#8
0
 public WithFire(Actor self)
 {
     var rs = self.Trait<RenderSimple>();
     var roof = new Animation(rs.GetImage(self));
     roof.PlayThen("fire-start", () => roof.PlayRepeating("fire-loop"));
     rs.anims.Add( "fire", new RenderSimple.AnimationWithOffset( roof, () => new float2(7,-15), null ) { ZOffset = 24 } );
 }
示例#9
0
        public Parachute(Actor cargo, WPos dropPosition)
        {
            this.cargo = cargo;

            parachutableInfo = cargo.Info.Traits.GetOrDefault<ParachutableInfo>();

            if (parachutableInfo != null)
                fallVector = new WVec(0, 0, parachutableInfo.FallRate);

            var parachuteSprite = parachutableInfo != null ? parachutableInfo.ParachuteSequence : null;
            if (parachuteSprite != null)
            {
                parachute = new Animation(cargo.World, parachuteSprite);
                parachute.PlayThen("open", () => parachute.PlayRepeating("idle"));
            }

            var shadowSprite = parachutableInfo != null ? parachutableInfo.ShadowSequence : null;
            if (shadowSprite != null)
            {
                shadow = new Animation(cargo.World, shadowSprite);
                shadow.PlayRepeating("idle");
            }

            if (parachutableInfo != null)
                parachuteOffset = parachutableInfo.ParachuteOffset;

            // Adjust x,y to match the target subcell
            cargo.Trait<IPositionable>().SetPosition(cargo, cargo.World.Map.CellContaining(dropPosition));
            var cp = cargo.CenterPosition;
            pos = new WPos(cp.X, cp.Y, dropPosition.Z);
        }
示例#10
0
文件: Missile.cs 项目: kaott/OpenRA
        public Missile(MissileInfo info, ProjectileArgs args)
        {
            Info = info;
            Args = args;

            SubPxPosition = 1024 * Args.src;
            Altitude = Args.srcAltitude;
            Facing = Args.facing;

            if (info.Inaccuracy > 0)
                offset = (info.Inaccuracy * args.firedBy.World.SharedRandom.Gauss2D(2)).ToInt2();

            if (Info.Image != null)
            {
                anim = new Animation(Info.Image, () => Facing);
                anim.PlayRepeating("idle");
            }

            if (Info.ContrailLength > 0)
            {
                Trail = new ContrailHistory(Info.ContrailLength,
                    Info.ContrailUsePlayerColor ? ContrailHistory.ChooseColor(args.firedBy) : Info.ContrailColor,
                    Info.ContrailDelay);
            }
        }
示例#11
0
        public Missile(MissileInfo info, ProjectileArgs args)
        {
            this.info = info;
            this.args = args;

            pos = args.Source;
            facing = args.Facing;

            targetPosition = args.PassiveTarget;

            if (info.Inaccuracy.Range > 0)
                offset = WVec.FromPDF(args.SourceActor.World.SharedRandom, 2) * info.Inaccuracy.Range / 1024;

            if (info.Image != null)
            {
                anim = new Animation(args.SourceActor.World, info.Image, () => facing);
                anim.PlayRepeating("idle");
            }

            if (info.ContrailLength > 0)
            {
                var color = info.ContrailUsePlayerColor ? ContrailRenderable.ChooseColor(args.SourceActor) : info.ContrailColor;
                trail = new ContrailRenderable(args.SourceActor.World, color, info.ContrailLength, info.ContrailDelay, 0);
            }
        }
示例#12
0
        public GpsSatellite(World world, WPos pos)
        {
            this.pos = pos;

            anim = new Animation(world, "sputnik");
            anim.PlayRepeating("idle");
        }
示例#13
0
        public PowerdownIndicator(Actor a)
        {
            this.a = a;

            anim = new Animation(a.World, "poweroff");
            anim.PlayRepeating("offline");
        }
示例#14
0
        public PowerdownIndicator(Actor a)
        {
            this.a = a;
            canPowerDown = a.Trait<CanPowerDown>();

            anim = new Animation(a.World, canPowerDown.Info.IndicatorImage);
            anim.PlayRepeating(canPowerDown.Info.IndicatorSequence);
        }
示例#15
0
 public NukeLaunch(Actor silo, string weapon, int2 targetLocation)
 {
     this.silo = silo;
     this.targetLocation = targetLocation;
     anim = new Animation("nuke");
     anim.PlayRepeating("up");
     pos = silo.CenterLocation;
 }
示例#16
0
        public GpsSatellite(World world, WPos pos, string image, string sequence, string palette)
        {
            this.palette = palette;
            this.pos = pos;

            anim = new Animation(world, image);
            anim.PlayRepeating(sequence);
        }
示例#17
0
		public override IEnumerable<IRenderable> RenderPreview(World world, ActorInfo building, PaletteReference pr)
		{
			var p = BaseBuildingPreview(world, building, pr);
			var anim = new Animation(world, RenderSprites.GetImage(building), () => 0);
			anim.PlayRepeating("idle-top");

			return p.Concat(anim.Render(WPos.Zero, WVec.Zero, 0, pr, Scale));
		}
示例#18
0
        public GravityBomb(GravityBombInfo info, ProjectileArgs args)
        {
            this.info = info;
            this.args = args;
            pos = args.Source;
            velocity = new WVec(WDist.Zero, WDist.Zero, -info.Velocity);
            acceleration = new WVec(WDist.Zero, WDist.Zero, info.Acceleration);

            if (!string.IsNullOrEmpty(info.Image))
            {
                anim = new Animation(args.SourceActor.World, info.Image);

                if (!string.IsNullOrEmpty(info.OpenSequence))
                    anim.PlayThen(info.OpenSequence, () => anim.PlayRepeating(info.Sequence));
                else
                    anim.PlayRepeating(info.Sequence);
            }
        }
示例#19
0
        public RepairIndicator(Actor building, string palettePrefix, Player player)
        {
            this.building = building;
            this.player = player;
            this.palettePrefix = palettePrefix;

            rb = building.TraitOrDefault<RepairableBuilding>();
            anim = new Animation(building.World, "allyrepair");
            anim.PlayRepeating("repair");
        }
示例#20
0
文件: Rank.cs 项目: ushardul/OpenRA
        public Rank(Actor self, string paletteName)
        {
            this.self = self;
            this.paletteName = paletteName;

            var xp = self.Trait<GainsExperience>();
            anim = new Animation(self.World, "rank");
            anim.PlayRepeating("rank");
            anim.PlayFetchIndex("rank", () => xp.Level == 0 ? 0 : xp.Level - 1);
        }
示例#21
0
        public GpsSatellite(World world, WPos pos, string image, string sequence, string palette, int revealDelay, Player launcher)
        {
            this.palette = palette;
            this.pos = pos;
            this.launcher = launcher;
            this.revealDelay = revealDelay;

            anim = new Animation(world, image);
            anim.PlayRepeating(sequence);
        }
示例#22
0
文件: GpsDot.cs 项目: Tsher/OpenRA
        public GpsDot(Actor self, GpsDotInfo info)
        {
            this.self = self;
            this.info = info;
            anim = new Animation("gpsdot");
            anim.PlayRepeating(info.String);

            self.World.AddFrameEndTask(w => w.Add(this));
            if (self.World.LocalPlayer != null)
                watcher = self.World.LocalPlayer.PlayerActor.Trait<GpsWatcher>();
        }
示例#23
0
		public RallyPointIndicator(Actor building, RallyPoint rp)
		{
			this.building = building;
			this.rp = rp;

			flag = new Animation(building.World, rp.Info.Image);
			flag.PlayRepeating(rp.Info.FlagSequence);

			circles = new Animation(building.World, rp.Info.Image);
			circles.Play(rp.Info.CirclesSequence);
		}
示例#24
0
        public WithRotor(Actor self, WithRotorInfo info)
        {
            var rs = self.Trait<RenderSimple>();
            var facing = self.Trait<IFacing>();

            rotorAnim = new Animation(rs.GetImage(self));
            rotorAnim.PlayRepeating("rotor");
            rs.anims.Add(info.Id, new RenderSimple.AnimationWithOffset(
                rotorAnim,
                () => Combat.GetTurretPosition( self, facing, new Turret(info.Offset)),
                null ) { ZOffset = 1 } );
        }
示例#25
0
        public RenderUnitSpinner(Actor self)
            : base(self)
        {
            var info = self.Info.Traits.Get<RenderUnitSpinnerInfo>();

            var spinnerAnim = new Animation(GetImage(self));
            spinnerAnim.PlayRepeating("spinner");
            anims.Add("spinner", new AnimationWithOffset(
                spinnerAnim,
                () => Combat.GetTurretPosition( self, self.Trait<IFacing>(), new Turret(info.Offset)),
                null ) { ZOffset = 1 } );
        }
示例#26
0
        public RallyPoint(Actor building, string palettePrefix)
        {
            this.building = building;
            this.palettePrefix = palettePrefix;

            rp = building.Trait<RA.RallyPoint>();

            flag = new Animation(building.World, "rallypoint");
            circles = new Animation(building.World, "rallypoint");

            flag.PlayRepeating("flag");
            circles.Play("circles");
        }
示例#27
0
        public RenderUnitSpinner( Actor self )
            : base(self)
        {
            var unit = self.traits.Get<Unit>();
            var info = self.Info.Traits.Get<RenderUnitSpinnerInfo>();

            var spinnerAnim = new Animation( GetImage(self) );
            spinnerAnim.PlayRepeating( "spinner" );
            anims.Add( "spinner", new AnimationWithOffset(
                spinnerAnim,
                () => Util.GetTurretPosition( self, unit, info.Offset, 0 ),
                null ) { ZOffset = 1 } );
        }
示例#28
0
        public Parachute(Actor cargo, PPos location, int altitude)
        {
            this.location = location;
            this.altitude = altitude;
            this.cargo = cargo;

            var pai = cargo.Info.Traits.GetOrDefault<ParachuteAttachmentInfo>();
            paraAnim = new Animation(pai != null ? pai.ParachuteSprite : "parach");
            paraAnim.PlayThen("open", () => paraAnim.PlayRepeating("idle"));

            if (pai != null) offset = pai.Offset;

            cargo.Trait<ITeleportable>().SetPxPosition(cargo, location);
        }
示例#29
0
        public NukeLaunch(Player firedBy, Actor silo, string weapon, WPos launchPos, CPos targetLocation)
        {
            this.firedBy = firedBy;
            this.targetLocation = targetLocation;
            this.weapon = weapon;
            anim = new Animation(weapon);
            anim.PlayRepeating("up");

            pos = launchPos;
            var weaponRules = Rules.Weapons[weapon.ToLowerInvariant()];
            if (weaponRules.Report != null && weaponRules.Report.Any())
                Sound.Play(weaponRules.Report.Random(firedBy.World.SharedRandom), pos);
            if (silo == null)
                StartDescent(firedBy.World);
        }
示例#30
0
文件: Bullet.cs 项目: pchote/OpenRA
        public Bullet(BulletInfo info, ProjectileArgs args)
        {
            this.info = info;
            this.args = args;
            pos = args.Source;

            var world = args.SourceActor.World;

            if (info.LaunchAngle.Length > 1)
                angle = new WAngle(world.SharedRandom.Next(info.LaunchAngle[0].Angle, info.LaunchAngle[1].Angle));
            else
                angle = info.LaunchAngle[0];

            if (info.Speed.Length > 1)
                speed = new WDist(world.SharedRandom.Next(info.Speed[0].Length, info.Speed[1].Length));
            else
                speed = info.Speed[0];

            target = args.PassiveTarget;
            if (info.Inaccuracy.Length > 0)
            {
                var inaccuracy = Util.ApplyPercentageModifiers(info.Inaccuracy.Length, args.InaccuracyModifiers);
                var range = Util.ApplyPercentageModifiers(args.Weapon.Range.Length, args.RangeModifiers);
                var maxOffset = inaccuracy * (target - pos).Length / range;
                target += WVec.FromPDF(world.SharedRandom, 2) * maxOffset / 1024;
            }

            facing = (target - pos).Yaw.Facing;
            length = Math.Max((target - pos).Length / speed.Length, 1);

            if (!string.IsNullOrEmpty(info.Image))
            {
                anim = new Animation(world, info.Image, new Func<int>(GetEffectiveFacing));
                anim.PlayRepeating(info.Sequences.Random(world.SharedRandom));
            }

            if (info.ContrailLength > 0)
            {
                var color = info.ContrailUsePlayerColor ? ContrailRenderable.ChooseColor(args.SourceActor) : info.ContrailColor;
                contrail = new ContrailRenderable(world, color, info.ContrailWidth, info.ContrailLength, info.ContrailDelay, info.ContrailZOffset);
            }

            trailPalette = info.TrailPalette;
            if (info.TrailUsePlayerPalette)
                trailPalette += args.SourceActor.Owner.InternalName;

            smokeTicks = info.TrailDelay;
        }