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


C# Animation.Play方法代码示例

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


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

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

示例2: WithRoof

 public WithRoof(Actor self)
 {
     var rs = self.Trait<RenderSimple>();
     var roof = new Animation(rs.GetImage(self), () => self.Trait<IFacing>().Facing);
     roof.Play("roof");
     rs.anims.Add( "roof", new RenderSimple.AnimationWithOffset( roof ) { ZOffset = 24 } );
 }
开发者ID:djohe,项目名称:OpenRA,代码行数:7,代码来源:WithRoof.cs

示例3: RenderGunboat

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

            var wake = new Animation(anim.Name);
            wake.Play("left-wake");
            Func<float2> offset = () => new float2(((anims["wake"].Animation.CurrentSequence.Name == "left-wake") ? 1 : -1),2);
            anims.Add( "wake", new AnimationWithOffset( wake, offset, () => false ) { ZOffset = -2 } );
        }
开发者ID:Iran,项目名称:ClassicRA,代码行数:11,代码来源:RenderGunboat.cs

示例4: RallyPointIndicator

		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);
		}
开发者ID:Roger-luo,项目名称:OpenRA,代码行数:11,代码来源:RallyPointIndicator.cs

示例5: RallyPoint

        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");
        }
开发者ID:RunCraze,项目名称:OpenRA,代码行数:13,代码来源:RallyPoint.cs

示例6: Beacon

        // Player-placed beacons are removed after a delay
        public Beacon(Player owner, WPos position, int duration, string palettePrefix)
        {
            this.owner = owner;
            this.position = position;
            this.palettePrefix = palettePrefix;

            arrow = new Animation(owner.World, "beacon");
            circles = new Animation(owner.World, "beacon");

            arrow.Play("arrow");
            circles.Play("circles");

            if (duration > 0)
                owner.World.Add(new DelayedAction(duration, () => owner.World.Remove(this)));
        }
开发者ID:ushardul,项目名称:OpenRA,代码行数:16,代码来源:Beacon.cs

示例7: Draw

		public override void Draw()
		{
			var player = GetPlayer();
			if (player == null)
			{
				return;
			}
			var queues = world.ActorsWithTrait<ProductionQueue>()
				.Where(a => a.Actor.Owner == player)
				.Select((a, i) => new { a.Trait, i });
			foreach (var queue in queues)
			{
				if (!clocks.ContainsKey(queue.Trait))
				{
					clocks.Add(queue.Trait, new Animation(world, "clock"));
				}
			}

			var iconSize = new float2(IconWidth, IconHeight);
			foreach (var queue in queues)
			{
				var current = queue.Trait.CurrentItem();
				if (current == null)
					continue;

				var actor = queue.Trait.AllItems().FirstOrDefault(a => a.Name == current.Item);
				if (actor == null)
					continue;

				var icon = new Animation(world, RenderSimple.GetImage(actor));
				icon.Play(actor.Traits.Get<TooltipInfo>().Icon);
				var location = new float2(RenderBounds.Location) + new float2(queue.i * (IconWidth + IconSpacing), 0);
				WidgetUtils.DrawSHPCentered(icon.Image, location + 0.5f * iconSize, worldRenderer, 0.5f);

				var clock = clocks[queue.Trait];
				clock.PlayFetchIndex("idle",
					() => current.TotalTime == 0 ? 0 : ((current.TotalTime - current.RemainingTime)
					* (clock.CurrentSequence.Length - 1) / current.TotalTime));
				clock.Tick();
				WidgetUtils.DrawSHPCentered(clock.Image, location + 0.5f * iconSize, worldRenderer, 0.5f);

				var tiny = Game.Renderer.Fonts["Tiny"];
				var text = GetOverlayForItem(current);
				tiny.DrawTextWithContrast(text,
					location + new float2(16, 16) - new float2(tiny.Measure(text).X / 2, 0),
					Color.White, Color.Black, 1);
			}
		}
开发者ID:Berzeger,项目名称:OpenRA,代码行数:48,代码来源:ObserverProductionIconsWidget.cs

示例8: Beacon

        // Support power beacons are expected to clean themselves up
        public Beacon(Player owner, WPos position, bool isPlayerPalette, string palette, string posterCollection, string posterType, string posterPalette,
			string arrowSequence, string circleSequence, string clockSequence, Func<float> clockFraction)
            : this(owner, position, -1, palette, isPlayerPalette, posterCollection, arrowSequence, circleSequence)
        {
            this.posterPalette = posterPalette;

            if (posterType != null)
            {
                poster = new Animation(owner.World, posterCollection);
                poster.Play(posterType);

                if (clockFraction != null)
                {
                    clock = new Animation(owner.World, posterCollection);
                    clock.PlayFetchIndex(clockSequence, () => Exts.Clamp((int)(clockFraction() * (clock.CurrentSequence.Length - 1)), 0, clock.CurrentSequence.Length - 1));
                }
            }
        }
开发者ID:OpenRA,项目名称:OpenRA,代码行数:19,代码来源:Beacon.cs

示例9: Beacon

        // Player-placed beacons are removed after a delay
        public Beacon(Player owner, WPos position, int duration, string beaconPalette, bool isPlayerPalette, string beaconCollection, string arrowSprite, string circleSprite)
        {
            this.owner = owner;
            this.position = position;
            this.beaconPalette = beaconPalette;
            this.isPlayerPalette = isPlayerPalette;
            this.duration = duration;

            if (!string.IsNullOrEmpty(arrowSprite))
            {
                arrow = new Animation(owner.World, beaconCollection);
                arrow.Play(arrowSprite);
            }

            if (!string.IsNullOrEmpty(circleSprite))
            {
                circles = new Animation(owner.World, beaconCollection);
                circles.Play(circleSprite);
            }
        }
开发者ID:pchote,项目名称:OpenRA,代码行数:21,代码来源:Beacon.cs

示例10: RefreshIcons

		public void RefreshIcons()
		{
			icons = new Dictionary<Rectangle, ProductionIcon>();
			var producer = CurrentQueue != null ? CurrentQueue.MostLikelyProducer() : default(TraitPair<Production>);
			if (CurrentQueue == null || producer.Trait == null)
			{
				if (DisplayedIconCount != 0)
				{
					OnIconCountChanged(DisplayedIconCount, 0);
					DisplayedIconCount = 0;
				}

				return;
			}

			var oldIconCount = DisplayedIconCount;
			DisplayedIconCount = 0;

			var ks = Game.Settings.Keys;
			var rb = RenderBounds;
			var faction = producer.Trait.Faction;

			foreach (var item in AllBuildables.Skip(IconRowOffset * Columns).Take(MaxIconRowOffset * Columns))
			{
				var x = DisplayedIconCount % Columns;
				var y = DisplayedIconCount / Columns;
				var rect = new Rectangle(rb.X + x * (IconSize.X + IconMargin.X), rb.Y + y * (IconSize.Y + IconMargin.Y), IconSize.X, IconSize.Y);

				var rsi = item.TraitInfo<RenderSpritesInfo>();
				var icon = new Animation(World, rsi.GetImage(item, World.Map.Rules.Sequences, faction));
				icon.Play(item.TraitInfo<TooltipInfo>().Icon);

				var bi = item.TraitInfo<BuildableInfo>();

				var pi = new ProductionIcon()
				{
					Actor = item,
					Name = item.Name,
					Hotkey = ks.GetProductionHotkey(DisplayedIconCount),
					Sprite = icon.Image,
					Palette = worldRenderer.Palette(bi.IconPalette),
					IconClockPalette = worldRenderer.Palette(ClockPalette),
					IconDarkenPalette = worldRenderer.Palette(NotBuildablePalette),
					Pos = new float2(rect.Location),
					Queued = CurrentQueue.AllQueued().Where(a => a.Item == item.Name).ToList()
				};

				icons.Add(rect, pi);
				DisplayedIconCount++;
			}

			eventBounds = icons.Any() ? icons.Keys.Aggregate(Rectangle.Union) : Rectangle.Empty;

			if (oldIconCount != DisplayedIconCount)
				OnIconCountChanged(oldIconCount, DisplayedIconCount);
		}
开发者ID:CH4Code,项目名称:OpenRA,代码行数:56,代码来源:ProductionPaletteWidget.cs

示例11: Draw

        public override void Draw()
        {
            var player = GetPlayer();
            if (player == null)
                return;

            var queues = world.ActorsWithTrait<ProductionQueue>()
                .Where(a => a.Actor.Owner == player)
                .Select((a, i) => new { a.Trait, i });

            foreach (var queue in queues)
                if (!clocks.ContainsKey(queue.Trait))
                    clocks.Add(queue.Trait, new Animation(world, ClockAnimation));

            var iconSize = new float2(IconWidth, IconHeight);
            foreach (var queue in queues)
            {
                var current = queue.Trait.CurrentItem();
                if (current == null)
                    continue;

                var faction = queue.Trait.Actor.Owner.Faction.InternalName;
                var actor = queue.Trait.AllItems().FirstOrDefault(a => a.Name == current.Item);
                if (actor == null)
                    continue;

                var rsi = actor.TraitInfo<RenderSpritesInfo>();
                var icon = new Animation(world, rsi.GetImage(actor, world.Map.Rules.Sequences, faction));
                icon.Play(actor.TraitInfo<TooltipInfo>().Icon);
                var bi = actor.TraitInfo<BuildableInfo>();
                var location = new float2(RenderBounds.Location) + new float2(queue.i * (IconWidth + IconSpacing), 0);
                WidgetUtils.DrawSHPCentered(icon.Image, location + 0.5f * iconSize, worldRenderer.Palette(bi.IconPalette), 0.5f);

                var pio = queue.Trait.Actor.Owner.PlayerActor.TraitsImplementing<IProductionIconOverlay>()
                    .FirstOrDefault(p => p.IsOverlayActive(actor));
                if (pio != null)
                    WidgetUtils.DrawSHPCentered(pio.Sprite, location + 0.5f * iconSize + pio.Offset(0.5f * iconSize),
                        worldRenderer.Palette(pio.Palette), 0.5f);

                var clock = clocks[queue.Trait];
                clock.PlayFetchIndex(ClockSequence,
                    () => current.TotalTime == 0 ? 0 : ((current.TotalTime - current.RemainingTime)
                    * (clock.CurrentSequence.Length - 1) / current.TotalTime));
                clock.Tick();
                WidgetUtils.DrawSHPCentered(clock.Image, location + 0.5f * iconSize, worldRenderer.Palette(ClockPalette), 0.5f);

                var tiny = Game.Renderer.Fonts["Tiny"];
                var text = GetOverlayForItem(current, timestep);
                tiny.DrawTextWithContrast(text,
                    location + new float2(16, 16) - new float2(tiny.Measure(text).X / 2, 0),
                    Color.White, Color.Black, 1);
            }
        }
开发者ID:OpenRA,项目名称:OpenRA,代码行数:53,代码来源:ObserverProductionIconsWidget.cs

示例12: DrawPalette

        int DrawPalette(ProductionQueue queue)
        {
            buttons.Clear();

            string paletteCollection = "palette-" + world.LocalPlayer.Country.Race;
            float2 origin = new float2(paletteOrigin.X + 9, paletteOrigin.Y + 9);
            var iconOffset = 0.5f * new float2(IconWidth, IconHeight);
            var x = 0;
            var y = 0;

            if (queue != null)
            {
                var buildableItems = queue.BuildableItems().ToArray();
                var allBuildables = queue.AllItems().OrderBy(a => a.Traits.Get<BuildableInfo>().BuildPaletteOrder).ToArray();

                var overlayBits = new List<Pair<Sprite, float2>>();
                var textBits = new List<Pair<float2, string>>();
                numActualRows = Math.Max((allBuildables.Count() + Columns - 1) / Columns, Rows);

                // Palette Background
                WidgetUtils.DrawRGBA(ChromeProvider.GetImage(paletteCollection, "top"), new float2(origin.X - 9, origin.Y - 9));
                for (var w = 0; w < numActualRows; w++)
                    WidgetUtils.DrawRGBA(
                        ChromeProvider.GetImage(paletteCollection, "bg-" + (w % 4)),
                        new float2(origin.X - 9, origin.Y + IconHeight * w));
                WidgetUtils.DrawRGBA(ChromeProvider.GetImage(paletteCollection, "bottom"),
                    new float2(origin.X - 9, origin.Y - 1 + IconHeight * numActualRows));

                // Icons
                string tooltipItem = null;
                foreach (var item in allBuildables)
                {
                    var rect = new RectangleF(origin.X + x * IconWidth, origin.Y + IconHeight * y, IconWidth, IconHeight);
                    var drawPos = new float2(rect.Location);
                    var icon = new Animation(world, RenderSimple.GetImage(item));
                    icon.Play(item.Traits.Get<TooltipInfo>().Icon);
                    WidgetUtils.DrawSHPCentered(icon.Image, drawPos + iconOffset, worldRenderer);

                    var firstOfThis = queue.AllQueued().FirstOrDefault(a => a.Item == item.Name);

                    if (rect.Contains(Viewport.LastMousePos))
                        tooltipItem = item.Name;

                    var overlayPos = drawPos + new float2(32, 16);

                    if (firstOfThis != null)
                    {
                        clock.PlayFetchIndex("idle",
                            () => (firstOfThis.TotalTime - firstOfThis.RemainingTime)
                                * (clock.CurrentSequence.Length - 1) / firstOfThis.TotalTime);
                        clock.Tick();
                        WidgetUtils.DrawSHPCentered(clock.Image, drawPos + iconOffset, worldRenderer);

                        if (queue.CurrentItem() == firstOfThis)
                            textBits.Add(Pair.New(overlayPos, GetOverlayForItem(firstOfThis)));

                        var repeats = queue.AllQueued().Count(a => a.Item == item.Name);
                        if (repeats > 1 || queue.CurrentItem() != firstOfThis)
                            textBits.Add(Pair.New(overlayPos + new float2(-24, -14), repeats.ToString()));
                    }
                    else
                        if (buildableItems.All(a => a.Name != item.Name))
                            overlayBits.Add(Pair.New(cantBuild.Image, drawPos));

                    var closureName = buildableItems.Any(a => a.Name == item.Name) ? item.Name : null;
                    buttons.Add(Pair.New(new Rectangle((int)rect.X, (int)rect.Y, (int)rect.Width, (int)rect.Height), HandleClick(closureName, world)));

                    if (++x == Columns) { x = 0; y++; }
                }
                if (x != 0) y++;

                foreach (var ob in overlayBits)
                    WidgetUtils.DrawSHPCentered(ob.First, ob.Second + iconOffset, worldRenderer);

                var font = Game.Renderer.Fonts["TinyBold"];
                foreach (var tb in textBits)
                {
                    var size = font.Measure(tb.Second);
                    font.DrawTextWithContrast(tb.Second, tb.First - new float2(size.X / 2, 0),
                        Color.White, Color.Black, 1);
                }

                // Tooltip
                if (tooltipItem != null && !paletteAnimating && paletteOpen)
                    DrawProductionTooltip(world, tooltipItem,
                        new float2(Game.Renderer.Resolution.Width, origin.Y + numActualRows * IconHeight + 9).ToInt2());
            }

            // Palette Dock
            WidgetUtils.DrawRGBA(ChromeProvider.GetImage(paletteCollection, "dock-top"),
                new float2(Game.Renderer.Resolution.Width - 14, origin.Y - 23));

            for (int i = 0; i < numActualRows; i++)
                WidgetUtils.DrawRGBA(ChromeProvider.GetImage(paletteCollection, "dock-" + (i % 4)),
                    new float2(Game.Renderer.Resolution.Width - 14, origin.Y + IconHeight * i));

            WidgetUtils.DrawRGBA(ChromeProvider.GetImage(paletteCollection, "dock-bottom"),
                new float2(Game.Renderer.Resolution.Width - 14, origin.Y - 1 + IconHeight * numActualRows));

            return IconHeight * y + 9;
//.........这里部分代码省略.........
开发者ID:RunCraze,项目名称:OpenRA,代码行数:101,代码来源:BuildPaletteWidget.cs

示例13: RefreshIcons

        public void RefreshIcons()
        {
            icons = new Dictionary<Rectangle, ProductionIcon>();
            if (CurrentQueue == null)
                return;

            var allBuildables = CurrentQueue.AllItems().OrderBy(a => a.Traits.Get<BuildableInfo>().BuildPaletteOrder);
            var i = 0;
            var rb = RenderBounds;
            foreach (var item in allBuildables)
            {
                var x = i % Columns;
                var y = i / Columns;
                var rect = new Rectangle(rb.X + x * 64 + 1, rb.Y + y * 48 + 1, 64, 48);
                var icon = new Animation(World, RenderSimple.GetImage(item));
                icon.Play(item.Traits.Get<TooltipInfo>().Icon);
                var pi = new ProductionIcon()
                {
                    Name = item.Name,
                    Sprite = icon.Image,
                    Pos = new float2(rect.Location),
                    Queued = CurrentQueue.AllQueued().Where(a => a.Item == item.Name).ToList(),
                };
                icons.Add(rect, pi);
                i++;
            }

            eventBounds = icons.Keys.Aggregate(Rectangle.Union);
        }
开发者ID:RunCraze,项目名称:OpenRA,代码行数:29,代码来源:ProductionPaletteWidget.cs

示例14: RefreshIcons

		public void RefreshIcons()
		{
			icons = new Dictionary<Rectangle, ProductionIcon>();
			if (CurrentQueue == null)
			{
				if (IconCount != 0)
				{
					OnIconCountChanged(IconCount, 0);
					IconCount = 0;
				}

				return;
			}

			var allBuildables = CurrentQueue.AllItems().OrderBy(a => a.Traits.Get<BuildableInfo>().BuildPaletteOrder);

			var oldIconCount = IconCount;
			IconCount = 0;

			var ks = Game.Settings.Keys;
			var rb = RenderBounds;
			foreach (var item in allBuildables)
			{
				var x = IconCount % Columns;
				var y = IconCount / Columns;
				var rect = new Rectangle(rb.X + x * (IconSize.X + IconMargin.X), rb.Y + y * (IconSize.Y + IconMargin.Y), IconSize.X, IconSize.Y);
				var icon = new Animation(World, RenderSimple.GetImage(item));
				icon.Play(item.Traits.Get<TooltipInfo>().Icon);

				var pi = new ProductionIcon()
				{
					Actor = item,
					Name = item.Name,
					Hotkey = ks.GetProductionHotkey(IconCount),
					Sprite = icon.Image,
					Pos = new float2(rect.Location),
					Queued = CurrentQueue.AllQueued().Where(a => a.Item == item.Name).ToList(),
				};

				icons.Add(rect, pi);
				IconCount++;
			}

			eventBounds = icons.Any() ? icons.Keys.Aggregate(Rectangle.Union) : Rectangle.Empty;

			if (oldIconCount != IconCount)
				OnIconCountChanged(oldIconCount, IconCount);
		}
开发者ID:RobotCaleb,项目名称:OpenRA,代码行数:48,代码来源:ProductionPaletteWidget.cs


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