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


C# ActorInfo类代码示例

本文整理汇总了C#中ActorInfo的典型用法代码示例。如果您正苦于以下问题:C# ActorInfo类的具体用法?C# ActorInfo怎么用?C# ActorInfo使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


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

示例1: CalculateActorSelectionPriority

        static long CalculateActorSelectionPriority(ActorInfo info, Rectangle bounds, int2 selectionPixel)
        {
            var centerPixel = new int2(bounds.X, bounds.Y);
            var pixelDistance = (centerPixel - selectionPixel).Length;

            return ((long)-pixelDistance << 32) + info.SelectionPriority();
        }
开发者ID:CH4Code,项目名称:OpenRA,代码行数:7,代码来源:SelectableExts.cs

示例2: SetPreview

		public void SetPreview(ActorInfo actor, TypeDictionary td)
		{
			var init = new ActorPreviewInitializer(actor, worldRenderer, td);
			preview = actor.TraitInfos<IRenderActorPreviewInfo>()
				.SelectMany(rpi => rpi.RenderPreview(init))
				.ToArray();

			// Calculate the preview bounds
			PreviewOffset = int2.Zero;
			IdealPreviewSize = int2.Zero;

			var r = preview
				.SelectMany(p => p.Render(worldRenderer, WPos.Zero))
				.OrderBy(WorldRenderer.RenderableScreenZPositionComparisonKey)
				.Select(rr => rr.PrepareRender(worldRenderer));

			if (r.Any())
			{
				var b = r.First().ScreenBounds(worldRenderer);
				foreach (var rr in r.Skip(1))
					b = Rectangle.Union(b, rr.ScreenBounds(worldRenderer));

				IdealPreviewSize = new int2(b.Width, b.Height);
				PreviewOffset = -new int2(b.Left, b.Top) - IdealPreviewSize / 2;
			}
		}
开发者ID:Roger-luo,项目名称:OpenRA,代码行数:26,代码来源:ActorPreviewWidget.cs

示例3: RenderActor

        public static ActorTemplate RenderActor(ActorInfo info, TileSet tileset, Palette p)
        {
            var ri = info.Traits.Get<RenderSimpleInfo>();
            string image = null;
            if (ri.OverrideTheater != null)
                for (int i = 0; i < ri.OverrideTheater.Length; i++)
                    if (ri.OverrideTheater[i] == tileset.Id)
                        image = ri.OverrideImage[i];

            image = image ?? ri.Image ?? info.Name;
            using (var s = FileSystem.OpenWithExts(image, tileset.Extensions))
            {
                var shp = new ShpReader(s);
                var bitmap = RenderShp(shp, p);

                try
                {
                    using (var s2 = FileSystem.OpenWithExts(image + "2", tileset.Extensions))
                    {
                        var shp2 = new ShpReader(s2);
                        var roofBitmap = RenderShp(shp2, p);

                        using (var g = System.Drawing.Graphics.FromImage(bitmap))
                            g.DrawImage(roofBitmap, 0, 0);
                    }
                }
                catch { }

                return new ActorTemplate { Bitmap = bitmap, Info = info, Centered = !info.Traits.Contains<BuildingInfo>() };
            }
        }
开发者ID:pdovy,项目名称:OpenRA,代码行数:31,代码来源:RenderUtils.cs

示例4: OccupiedCells

		public IReadOnlyDictionary<CPos, SubCell> OccupiedCells(ActorInfo info, CPos location, SubCell subCell = SubCell.Any)
		{
			var occupied = OccupiesSpace ? new Dictionary<CPos, SubCell>() { { location, SubCell.FullCell } } :
				new Dictionary<CPos, SubCell>();

			return new ReadOnlyDictionary<CPos, SubCell>(occupied);
		}
开发者ID:Roger-luo,项目名称:OpenRA,代码行数:7,代码来源:Immobile.cs

示例5: Render

        public IEnumerable<IRenderable> Render(WorldRenderer wr, World w, ActorInfo ai, WPos centerPosition)
        {
            var jamsMissiles = ai.TraitInfoOrDefault<JamsMissilesInfo>();
            if (jamsMissiles != null)
            {
                yield return new RangeCircleRenderable(
                    centerPosition,
                    jamsMissiles.Range,
                    0,
                    Color.FromArgb(128, Color.Red),
                    Color.FromArgb(96, Color.Black));
            }

            var jamsRadar = ai.TraitInfoOrDefault<JamsRadarInfo>();
            if (jamsRadar != null)
            {
                yield return new RangeCircleRenderable(
                    centerPosition,
                    jamsRadar.Range,
                    0,
                    Color.FromArgb(128, Color.Blue),
                    Color.FromArgb(96, Color.Black));
            }

            foreach (var a in w.ActorsWithTrait<RenderJammerCircle>())
                if (a.Actor.Owner.IsAlliedWith(w.RenderPlayer))
                    foreach (var r in a.Trait.RenderAfterWorld(wr))
                        yield return r;
        }
开发者ID:CH4Code,项目名称:OpenRA,代码行数:29,代码来源:RenderJammerCircle.cs

示例6: RenderActor

        public static ActorTemplate RenderActor(ActorInfo info, TileSet tileset, Palette p)
        {
            var image = RenderSimple.GetImage(info, tileset.Id);

            using (var s = FileSystem.OpenWithExts(image, tileset.Extensions))
            {
                var shp = new ShpReader(s);
                var bitmap = RenderShp(shp, p);

                try
                {
                    using (var s2 = FileSystem.OpenWithExts(image + "2", tileset.Extensions))
                    {
                        var shp2 = new ShpReader(s2);
                        var roofBitmap = RenderShp(shp2, p);

                        using (var g = System.Drawing.Graphics.FromImage(bitmap))
                            g.DrawImage(roofBitmap, 0, 0);
                    }
                }
                catch { }

                return new ActorTemplate
                {
                    Bitmap = bitmap,
                    Info = info,
                    Appearance = info.Traits.GetOrDefault<EditorAppearanceInfo>()
                };
            }
        }
开发者ID:katzsmile,项目名称:OpenRA,代码行数:30,代码来源:RenderUtils.cs

示例7: EditorActorBrush

        public EditorActorBrush(EditorViewportControllerWidget editorWidget, ActorInfo actor, PlayerReference owner, WorldRenderer wr)
        {
            this.editorWidget = editorWidget;
            worldRenderer = wr;
            world = wr.World;
            editorLayer = world.WorldActor.Trait<EditorActorLayer>();

            Actor = actor;
            this.owner = owner;

            preview = editorWidget.Get<ActorPreviewWidget>("DRAG_ACTOR_PREVIEW");
            preview.GetScale = () => worldRenderer.Viewport.Zoom;
            preview.IsVisible = () => editorWidget.CurrentBrush == this;

            var buildingInfo = actor.Traits.GetOrDefault<BuildingInfo>();
            if (buildingInfo != null)
            {
                locationOffset = -FootprintUtils.AdjustForBuildingSize(buildingInfo);
                previewOffset = FootprintUtils.CenterOffset(world, buildingInfo);
            }

            var td = new TypeDictionary();
            td.Add(new FacingInit(facing));
            td.Add(new TurretFacingInit(facing));
            td.Add(new OwnerInit(owner.Name));
            td.Add(new RaceInit(owner.Race));
            preview.SetPreview(actor, td);

            // The preview widget may be rendered by the higher-level code before it is ticked.
            // Force a manual tick to ensure the bounds are set correctly for this first draw.
            Tick();
        }
开发者ID:ushardul,项目名称:OpenRA,代码行数:32,代码来源:EditorActorBrush.cs

示例8: DoProduction

        public void DoProduction(Actor self, ActorInfo producee, ExitInfo exitinfo, string raceVariant)
        {
            var exit = self.Location + exitinfo.ExitCell;
            var spawn = self.CenterPosition + exitinfo.SpawnOffset;
            var to = self.World.Map.CenterOfCell(exit);

            var fi = producee.Traits.GetOrDefault<IFacingInfo>();
            var initialFacing = exitinfo.Facing < 0 ? Util.GetFacing(to - spawn, fi == null ? 0 : fi.GetInitialFacing()) : exitinfo.Facing;

            var exitLocation = rp.Value != null ? rp.Value.Location : exit;
            var target = Target.FromCell(self.World, exitLocation);

            var bi = producee.Traits.GetOrDefault<BuildableInfo>();
            if (bi != null && bi.ForceRace != null)
                raceVariant = bi.ForceRace;

            self.World.AddFrameEndTask(w =>
            {
                var td = new TypeDictionary
                {
                    new OwnerInit(self.Owner),
                    new LocationInit(exit),
                    new CenterPositionInit(spawn),
                    new FacingInit(initialFacing)
                };

                if (raceVariant != null)
                    td.Add(new RaceInit(raceVariant));

                var newUnit = self.World.CreateActor(producee.Name, td);

                var move = newUnit.TraitOrDefault<IMove>();
                if (move != null)
                {
                    if (exitinfo.MoveIntoWorld)
                    {
                        if (exitinfo.ExitDelay > 0)
                            newUnit.QueueActivity(new Wait(exitinfo.ExitDelay));

                        newUnit.QueueActivity(move.MoveIntoWorld(newUnit, exit));
                        newUnit.QueueActivity(new AttackMoveActivity(
                            newUnit, move.MoveTo(exitLocation, 1)));
                    }
                }

                newUnit.SetTargetLine(target, rp.Value != null ? Color.Red : Color.Green, false);

                if (!self.IsDead)
                    foreach (var t in self.TraitsImplementing<INotifyProduction>())
                        t.UnitProduced(self, newUnit, exit);

                var notifyOthers = self.World.ActorsWithTrait<INotifyOtherProduction>();
                foreach (var notify in notifyOthers)
                    notify.Trait.UnitProducedByOther(notify.Actor, self, newUnit);

                foreach (var t in newUnit.TraitsImplementing<INotifyBuildComplete>())
                    t.BuildingComplete(newUnit);
            });
        }
开发者ID:zombie-einstein,项目名称:OpenRA,代码行数:59,代码来源:Production.cs

示例9: RenderPreview

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

示例10: CanTargetActor

        // TODO: This can be removed after the legacy and redundant 0% = not targetable
        // assumption has been removed from the yaml definitions
        public override bool CanTargetActor(ActorInfo victim, Actor firedBy)
        {
            var health = victim.Traits.GetOrDefault<HealthInfo>();
            if (health == null)
                return false;

            return DamageVersus(victim) > 0;
        }
开发者ID:rhamilton1415,项目名称:OpenRA,代码行数:10,代码来源:DamageWarhead.cs

示例11: CreateActor

    public int CreateActor(ActorInfo info, ActorConfig config, OnFinish finish)
    {
        //int id = PlayScript.Instance.director.entityManager.CreateID();
        int id = director.entityManager.CreateID();
        Actor actor = new Actor(info, config, id, director);


        return id;
    }
开发者ID:1001ye-qiang,项目名称:Core,代码行数:9,代码来源:DirectorHelper.cs

示例12: GetImage

        public static string GetImage(ActorInfo actor, string Tileset)
        {
            var Info = actor.Traits.Get<RenderSimpleInfo>();
            if (Info.OverrideTileset != null && Tileset != null)
                for (int i = 0; i < Info.OverrideTileset.Length; i++)
                    if (Info.OverrideTileset[i] == Tileset)
                        return Info.OverrideImage[i];

            return Info.Image ?? actor.Name;
        }
开发者ID:katzsmile,项目名称:OpenRA,代码行数:10,代码来源:RenderSimple.cs

示例13: ValidActor

		bool ValidActor(ActorInfo a, IEnumerable<CPos> cells)
		{
			foreach (var c in cells)
			{
				var mi = a.TraitInfoOrDefault<MobileInfo>();
				if (mi != null && mi.CanEnterCell(self.World, self, c))
					return true;
			}

			return false;
		}
开发者ID:GraionDilach,项目名称:OpenRA.Mods.AS,代码行数:11,代码来源:GiveRandomActorCrateAction.cs

示例14: GetImage

		public string GetImage(ActorInfo actor, SequenceProvider sequenceProvider, string faction)
		{
			if (FactionImages != null && !string.IsNullOrEmpty(faction))
			{
				string factionImage = null;
				if (FactionImages.TryGetValue(faction, out factionImage) && sequenceProvider.HasSequence(factionImage))
					return factionImage;
			}

			return (Image ?? actor.Name).ToLowerInvariant();
		}
开发者ID:Roger-luo,项目名称:OpenRA,代码行数:11,代码来源:RenderSprites.cs

示例15: Render

        public void Render(WorldRenderer wr, World w, ActorInfo ai, WPos centerPosition)
        {
            wr.DrawRangeCircleWithContrast(
                Color.FromArgb(128, Color.Cyan),
                wr.ScreenPxPosition(centerPosition),
                ai.Traits.Get<CreatesShroudInfo>().Range,
                Color.FromArgb(96, Color.Black));

            foreach (var a in w.ActorsWithTrait<RenderShroudCircle>())
                if (a.Actor.Owner == a.Actor.World.LocalPlayer)
                    a.Trait.RenderAfterWorld(wr);
        }
开发者ID:Generalcamo,项目名称:OpenRA,代码行数:12,代码来源:RenderShroudCircle.cs


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