• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C# ActorInfo类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: DamageVersus

        public int DamageVersus(ActorInfo victim)
        {
            var armor = victim.Traits.GetOrDefault<ArmorInfo>();
            if (armor != null && armor.Type != null)
            {
                int versus;
                if (Versus.TryGetValue(armor.Type, out versus))
                    return versus;
            }

            return 100;
        }
开发者ID:rhamilton1415,项目名称:OpenRA,代码行数:12,代码来源:DamageWarhead.cs


示例17: Render

        public void Render(WorldRenderer wr, World w, ActorInfo ai, WPos centerPosition)
        {
            wr.DrawRangeCircleWithContrast(
                Color.FromArgb(128, Color.Yellow), wr.ScreenPxPosition(centerPosition),
                ai.Traits.WithInterface<ArmamentInfo>()
                    .Select(a => Rules.Weapons[a.Weapon.ToLowerInvariant()].Range).Max(),
                Color.FromArgb(96, Color.Black));

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


示例18: Produce

        public override bool Produce(Actor self, ActorInfo producee, string factionVariant)
        {
            var owner = self.Owner;
            var aircraftInfo = self.World.Map.Rules.Actors[info.ActorType].TraitInfo<AircraftInfo>();

            // WDist required to take off or land
            var landDistance = aircraftInfo.CruiseAltitude.Length * 1024 / aircraftInfo.MaximumPitch.Tan();

            // Start a fixed distance away: the width of the map.
            // This makes the production timing independent of spawnpoint
            var startPos = self.Location + new CVec(owner.World.Map.Bounds.Width, 0);
            var endPos = new CPos(owner.World.Map.Bounds.Left - 2 * landDistance / 1024, self.Location.Y);

            // Assume a single exit point for simplicity
            var exit = self.Info.TraitInfos<ExitInfo>().First();

            foreach (var tower in self.TraitsImplementing<INotifyDelivery>())
                tower.IncomingDelivery(self);

            owner.World.AddFrameEndTask(w =>
            {
                if (!self.IsInWorld || self.IsDead)
                    return;

                var actor = w.CreateActor(info.ActorType, new TypeDictionary
                {
                    new CenterPositionInit(w.Map.CenterOfCell(startPos) + new WVec(WDist.Zero, WDist.Zero, aircraftInfo.CruiseAltitude)),
                    new OwnerInit(owner),
                    new FacingInit(64)
                });

                actor.QueueActivity(new Fly(actor, Target.FromPos(self.CenterPosition + new WVec(landDistance, 0, 0))));
                actor.QueueActivity(new Land(actor, Target.FromActor(self)));
                actor.QueueActivity(new CallFunc(() =>
                {
                    if (!self.IsInWorld || self.IsDead)
                        return;

                    foreach (var cargo in self.TraitsImplementing<INotifyDelivery>())
                        cargo.Delivered(self);

                    self.World.AddFrameEndTask(ww => DoProduction(self, producee, exit, factionVariant));
                    Game.Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Speech", info.ReadyAudio, self.Owner.Faction.InternalName);
                }));

                actor.QueueActivity(new Fly(actor, Target.FromCell(w, endPos)));
                actor.QueueActivity(new RemoveSelf());
            });

            return true;
        }
开发者ID:pchote,项目名称:OpenRA,代码行数:51,代码来源:ProductionAirdrop.cs


示例19: Produce

        public override bool Produce(Actor self, ActorInfo producee, string raceVariant)
        {
            var owner = self.Owner;

            // Start a fixed distance away: the width of the map.
            // This makes the production timing independent of spawnpoint
            var startPos = self.Location + new CVec(owner.World.Map.Bounds.Width, 0);
            var endPos = new CPos(owner.World.Map.Bounds.Left - 5, self.Location.Y);

            // Assume a single exit point for simplicity
            var exit = self.Info.Traits.WithInterface<ExitInfo>().First();

            foreach (var tower in self.TraitsImplementing<INotifyDelivery>())
                tower.IncomingDelivery(self);

            var info = (ProductionAirdropInfo)Info;
            var actorType = info.ActorType;

            owner.World.AddFrameEndTask(w =>
            {
                if (!self.IsInWorld || self.IsDead)
                    return;

                var altitude = self.World.Map.Rules.Actors[actorType].Traits.Get<PlaneInfo>().CruiseAltitude;
                var actor = w.CreateActor(actorType, new TypeDictionary
                {
                    new CenterPositionInit(w.Map.CenterOfCell(startPos) + new WVec(WRange.Zero, WRange.Zero, altitude)),
                    new OwnerInit(owner),
                    new FacingInit(64)
                });

                actor.QueueActivity(new Fly(actor, Target.FromCell(w, self.Location + new CVec(9, 0))));
                actor.QueueActivity(new Land(actor, Target.FromActor(self)));
                actor.QueueActivity(new CallFunc(() =>
                {
                    if (!self.IsInWorld || self.IsDead)
                        return;

                    foreach (var cargo in self.TraitsImplementing<INotifyDelivery>())
                        cargo.Delivered(self);

                    self.World.AddFrameEndTask(ww => DoProduction(self, producee, exit, raceVariant));
                    Sound.PlayNotification(self.World.Map.Rules, self.Owner, "Speech", info.ReadyAudio, self.Owner.Country.Race);
                }));

                actor.QueueActivity(new Fly(actor, Target.FromCell(w, endPos)));
                actor.QueueActivity(new RemoveSelf());
            });

            return true;
        }
开发者ID:ushardul,项目名称:OpenRA,代码行数:51,代码来源:ProductionAirdrop.cs


示例20: Produce

        public override bool Produce(Actor self, ActorInfo producee, string raceVariant)
        {
            var location = self.World.Map.ChooseClosestEdgeCell(self.Location);
            var pos = self.World.Map.CenterOfCell(location);

            // If aircraft, spawn at cruise altitude
            var aircraftInfo = producee.Traits.GetOrDefault<AircraftInfo>();
            if (aircraftInfo != null)
                pos += new WVec(0, 0, aircraftInfo.CruiseAltitude.Range);

            var initialFacing = self.World.Map.FacingBetween(location, self.Location, 0);

            self.World.AddFrameEndTask(w =>
                {
                    var td = new TypeDictionary
                    {
                        new OwnerInit(self.Owner),
                        new LocationInit(location),
                        new CenterPositionInit(pos),
                        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)
                        newUnit.QueueActivity(move.MoveIntoWorld(newUnit, self.Location));

                    newUnit.SetTargetLine(Target.FromCell(self.World, self.Location), Color.Green, false);

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

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

                    var bi = newUnit.Info.Traits.GetOrDefault<BuildableInfo>();
                    if (bi != null && bi.InitialActivity != null)
                        newUnit.QueueActivity(Game.CreateObject<Activity>(bi.InitialActivity));

                    foreach (var t in newUnit.TraitsImplementing<INotifyBuildComplete>())
                        t.BuildingComplete(newUnit);
                });

            return true;
        }
开发者ID:ushardul,项目名称:OpenRA,代码行数:51,代码来源:ProductionFromMapEdge.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# ActorInitializer类代码示例发布时间:2022-05-24
下一篇:
C# ActorController类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap