當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。