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


C# World.FindUnitsAtMouse方法代码示例

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


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

示例1: Order

        public IEnumerable<Order> Order( World world, int2 xy, MouseInput mi )
        {
            var underCursor = world.FindUnitsAtMouse(mi.Location)
                .Where(a => a.HasTrait<ITargetable>())
                .OrderByDescending(
                    a =>
                    a.Info.Traits.Contains<SelectableInfo>()
                        ? a.Info.Traits.Get<SelectableInfo>().Priority
                        : int.MinValue)
                .FirstOrDefault();

            var orders = world.Selection.Actors
                .Select(a => OrderForUnit(a, xy, mi, underCursor))
                .Where(o => o != null)
                .ToArray();

            var actorsInvolved = orders.Select(o => o.self).Distinct();
            if (actorsInvolved.Any())
                yield return new Order("CreateGroup", actorsInvolved.First().Owner.PlayerActor, false)
                {
                    TargetString = string.Join(",", actorsInvolved.Select(a => a.ActorID.ToString()).ToArray())
                };

            foreach (var o in orders)
                yield return CheckSameOrder(o.iot, o.trait.IssueOrder(o.self, o.iot, o.target, mi.Modifiers.HasModifier(Modifiers.Shift)));
        }
开发者ID:jeff-1amstudios,项目名称:OpenRA,代码行数:26,代码来源:UnitOrderGenerator.cs

示例2: GetCursor

        public string GetCursor( World world, int2 xy, MouseInput mi )
        {
            bool useSelect = false;

            var custom = world.WorldActor.TraitOrDefault<ICustomUnitOrderGenerator>();
            if (custom != null)
            {
               return custom.GetCursor(world, xy, mi);
            }

            var underCursor = world.FindUnitsAtMouse(mi.Location)
                .Where(a => a.HasTrait<ITargetable>())
                .OrderByDescending(a => a.Info.Traits.Contains<SelectableInfo>() ? a.Info.Traits.Get<SelectableInfo>().Priority : int.MinValue)
                .FirstOrDefault();

            if (mi.Modifiers.HasModifier(Modifiers.Shift) || !world.Selection.Actors.Any())
                if (underCursor != null)
                    useSelect = true;

            var orders = world.Selection.Actors
                .Select(a => OrderForUnit(a, xy, mi, underCursor))
                .Where(o => o != null)
                .ToArray();

            if( orders.Length == 0 ) return (useSelect) ? "select" : "default";

            return orders[0].cursor ?? ((useSelect) ? "select" : "default");
        }
开发者ID:gitTerebi,项目名称:OpenRA,代码行数:28,代码来源:UnitOrderGenerator.cs

示例3: Order

        public IEnumerable<Order> Order(World world, CPos xy, MouseInput mi)
        {
            var underCursor = world.FindUnitsAtMouse(mi.Location)
                .Where(a => a.HasTrait<ITargetable>())
                .OrderByDescending(a => a.Info.SelectionPriority())
                .FirstOrDefault();

            Target target;
            if (underCursor != null)
                target = Target.FromActor(underCursor);
            else
            {
                var frozen = world.FindFrozenActorsAtMouse(mi.Location)
                    .Where(a => a.Info.Traits.Contains<ITargetableInfo>())
                    .OrderByDescending(a => a.Info.SelectionPriority())
                    .FirstOrDefault();
                target = frozen != null ? Target.FromFrozenActor(frozen) : Target.FromCell(xy);
            }

            var orders = world.Selection.Actors
                .Select(a => OrderForUnit(a, target, mi))
                .Where(o => o != null)
                .ToArray();

            var actorsInvolved = orders.Select(o => o.self).Distinct();
            if (actorsInvolved.Any())
                yield return new Order("CreateGroup", actorsInvolved.First().Owner.PlayerActor, false)
                {
                    TargetString = actorsInvolved.Select(a => a.ActorID).JoinWith(",")
                };

            foreach (var o in orders)
                yield return CheckSameOrder(o.iot, o.trait.IssueOrder(o.self, o.iot, o.target, mi.Modifiers.HasModifier(Modifiers.Shift)));
        }
开发者ID:TiriliPiitPiit,项目名称:OpenRA,代码行数:34,代码来源:UnitOrderGenerator.cs

示例4: OrderInner

        IEnumerable<Order> OrderInner(World world, int2 xy, MouseInput mi)
        {
            if (mi.Button == MouseButton.Left)
            {
                var underCursor = world.FindUnitsAtMouse(mi.Location)
                    .Where(a => a.Owner == world.LocalPlayer
                        && a.traits.Contains<CanPowerDown>())
                        .FirstOrDefault();

                if (underCursor != null)
                    yield return new Order("PowerDown", underCursor);
            }
        }
开发者ID:comradpara,项目名称:OpenRA,代码行数:13,代码来源:PowerDownOrderGenerator.cs

示例5: OrderInner

        IEnumerable<Order> OrderInner(World world, int2 xy, MouseInput mi)
        {
            if (mi.Button == MouseButton.Left)
            {
                var underCursor = world.FindUnitsAtMouse(mi.Location)
                    .Where(a => a.Owner == world.LocalPlayer
                        && a.HasTrait<Building>()
                        && a.HasTrait<Selectable>()).FirstOrDefault();

                var building = underCursor != null ? underCursor.Info.Traits.Get<BuildingInfo>() : null;

                if (building != null && !building.Unsellable)
                    yield return new Order("Sell", underCursor, false);
            }
        }
开发者ID:FMode,项目名称:OpenRA,代码行数:15,代码来源:SellOrderGenerator.cs

示例6: OrderInner

        IEnumerable<Order> OrderInner(World world, int2 xy, MouseInput mi)
        {
            if (mi.Button == MouseButton.Left)
            {
                var underCursor = world.FindUnitsAtMouse(mi.Location)
                    .Where(a => a.AppearsFriendlyTo(world.LocalPlayer.PlayerActor) && a.HasTrait<RepairableBuilding>()).FirstOrDefault();

                if (underCursor == null)
                    yield break;

                if (underCursor.Info.Traits.Contains<RepairableBuildingInfo>()
                    && underCursor.GetDamageState() > DamageState.Undamaged)
                    yield return new Order("RepairBuilding", world.LocalPlayer.PlayerActor, false) { TargetActor = underCursor };
            }
        }
开发者ID:sonygod,项目名称:OpenRA-Dedicated-20120504,代码行数:15,代码来源:RepairOrderGenerator.cs

示例7: OrderInner

        IEnumerable<Order> OrderInner(World world, int2 xy, MouseInput mi)
        {
            if (mi.Button == MouseButton.Left)
            {
                var underCursor = world.FindUnitsAtMouse(mi.Location)
                    .Where(a => a.Owner == world.LocalPlayer
                        && a.traits.Contains<Building>()
                        && a.traits.Contains<Selectable>()).FirstOrDefault();

                var building = underCursor != null ? underCursor.Info.Traits.Get<BuildingInfo>() : null;

                if (building != null && building.Repairable && underCursor.Health < building.HP)
                    yield return new Order("Repair", underCursor);
            }
        }
开发者ID:comradpara,项目名称:OpenRA,代码行数:15,代码来源:RepairOrderGenerator.cs

示例8: OrderInner

        IEnumerable<Order> OrderInner(World world, int2 xy, MouseInput mi)
        {
            if (mi.Button == MouseButton.Left)
            {
                var underCursor = world.FindUnitsAtMouse(mi.Location)
                    .Where(a => a.Owner == world.LocalPlayer && a.HasTrait<RepairableBuilding>()).FirstOrDefault();

                if (underCursor == null)
                    yield break;

                if (underCursor.Info.Traits.Contains<RepairableBuildingInfo>()
                    && underCursor.GetDamageState() > DamageState.Undamaged)
                    yield return new Order("Repair", underCursor);
            }
        }
开发者ID:pdovy,项目名称:OpenRA,代码行数:15,代码来源:RepairOrderGenerator.cs

示例9: GetCursor

        public string GetCursor( World world, int2 xy, MouseInput mi )
        {
            if (mi.Modifiers.HasModifier(Modifiers.Shift) || !world.Selection.Actors.Any())
            {
                var underCursor = world.FindUnitsAtMouse(mi.Location)
                    .Where(a => a.Info.Traits.Contains<SelectableInfo>())
                    .Any();

                if (underCursor)
                    return "select";
            }

            var c = Order(world, xy, mi)
                .Select(o => o.Subject.TraitsImplementing<IOrderCursor>()
                    .Select(pc => pc.CursorForOrder(o.Subject, o)).FirstOrDefault(a => a != null))
                .FirstOrDefault(a => a != null);

            return c ?? "default";
        }
开发者ID:subspace,项目名称:OpenRA,代码行数:19,代码来源:UnitOrderGenerator.cs

示例10: Order

        public IEnumerable<Order> Order( World world, int2 xy, MouseInput mi )
        {
            var underCursor = world.FindUnitsAtMouse(mi.Location)
                .Where(a => a.Info.Traits.Contains<TargetableInfo>())
                .OrderByDescending(a => a.Info.Traits.Contains<SelectableInfo>() ? a.Info.Traits.Get<SelectableInfo>().Priority : int.MinValue)
                .FirstOrDefault();

            var orders = world.Selection.Actors
                .Select(a => a.Order(xy, mi, underCursor))
                .Where(o => o != null)
                .ToArray();

            var actorsInvolved = orders.Select(o => o.Subject).Distinct();
            if (actorsInvolved.Any())
                yield return new Order("CreateGroup", actorsInvolved.First().Owner.PlayerActor,
                    string.Join(",", actorsInvolved.Select(a => a.ActorID.ToString()).ToArray()));

            foreach (var o in orders)
                yield return o;
        }
开发者ID:subspace,项目名称:OpenRA,代码行数:20,代码来源:UnitOrderGenerator.cs

示例11: GetCursor

        public string GetCursor( World world, int2 xy, MouseInput mi )
        {
            var underCursor = world.FindUnitsAtMouse(mi.Location)
                .Where(a => a.Info.Traits.Contains<TargetableInfo>())
                .OrderByDescending(a => a.Info.Traits.Contains<SelectableInfo>() ? a.Info.Traits.Get<SelectableInfo>().Priority : int.MinValue)
                .FirstOrDefault();

            if( mi.Modifiers.HasModifier( Modifiers.Shift ) || !world.Selection.Actors.Any() )
                if( underCursor != null )
                    return "select";

            var orders = world.Selection.Actors
                .Select(a => OrderForUnit(a, xy, mi, underCursor))
                .Where(o => o != null)
                .ToArray();

            if( orders.Length == 0 ) return "default";

            return orders[ 0 ].cursor ?? "default";
        }
开发者ID:pdovy,项目名称:OpenRA,代码行数:20,代码来源:UnitOrderGenerator.cs

示例12: GetCursor

        public string GetCursor(World world, CPos xy, MouseInput mi)
        {
            bool useSelect = false;

            var underCursor = world.FindUnitsAtMouse(mi.Location)
                .Where(a => a.HasTrait<ITargetable>())
                .OrderByDescending(a => a.SelectionPriority())
                .FirstOrDefault();

            if (mi.Modifiers.HasModifier(Modifiers.Shift) || !world.Selection.Actors.Any())
                if (underCursor != null && underCursor.HasTrait<Selectable>())
                    useSelect = true;

            var orders = world.Selection.Actors
                .Select(a => OrderForUnit(a, xy, mi, underCursor))
                .Where(o => o != null)
                .ToArray();

            var cursorName = orders.Select(o => o.cursor).FirstOrDefault();
            return cursorName ?? (useSelect ? "select" : "default");
        }
开发者ID:Iran,项目名称:ClassicRA,代码行数:21,代码来源:UnitOrderGenerator.cs

示例13: GetCursor

        public string GetCursor(World world, CPos xy, MouseInput mi)
        {
            bool useSelect = false;

            var underCursor = world.FindUnitsAtMouse(mi.Location)
                .Where(a => a.HasTrait<ITargetable>())
                .OrderByDescending(a => a.Info.SelectionPriority())
                .FirstOrDefault();

            if (underCursor != null && (mi.Modifiers.HasModifier(Modifiers.Shift) || !world.Selection.Actors.Any()))
            {
                var selectable = underCursor.TraitOrDefault<Selectable>();
                if (selectable != null && selectable.Info.Selectable)
                    useSelect = true;
            }

            Target target;
            if (underCursor != null)
                target = Target.FromActor(underCursor);
            else
            {
                var frozen = world.FindFrozenActorsAtMouse(mi.Location)
                    .Where(a => a.Info.Traits.Contains<ITargetableInfo>())
                    .OrderByDescending(a => a.Info.SelectionPriority())
                    .FirstOrDefault();
                target = frozen != null ? Target.FromFrozenActor(frozen) : Target.FromCell(xy);
            }

            var orders = world.Selection.Actors
                .Select(a => OrderForUnit(a, target, mi))
                .Where(o => o != null)
                .ToArray();

            var cursorName = orders.Select(o => o.cursor).FirstOrDefault();
            return cursorName ?? (useSelect ? "select" : "default");
        }
开发者ID:TiriliPiitPiit,项目名称:OpenRA,代码行数:36,代码来源:UnitOrderGenerator.cs

示例14: DrawInner

        public override void DrawInner(World world)
        {
            if (Viewport.TicksSinceLastMove < TooltipDelay || world == null || world.LocalPlayer == null)
                return;

            var cell = Game.viewport.ViewToWorld(Viewport.LastMousePos).ToInt2();
            if (!world.Map.IsInMap(cell)) return;

            if (!world.LocalPlayer.Shroud.IsExplored(cell))
            {
                var utext = "Unexplored Terrain";
                var usz = Game.Renderer.BoldFont.Measure(utext) + new int2(20, 24);

                WidgetUtils.DrawPanel("dialog4", Rectangle.FromLTRB(
                    Viewport.LastMousePos.X + 20, Viewport.LastMousePos.Y + 20,
                    Viewport.LastMousePos.X + usz.X + 20, Viewport.LastMousePos.Y + usz.Y + 20));

                Game.Renderer.BoldFont.DrawText(utext,
                    new float2(Viewport.LastMousePos.X + 30, Viewport.LastMousePos.Y + 30), Color.White);

                return;
            }

            var actor = world.FindUnitsAtMouse(Viewport.LastMousePos).FirstOrDefault();
            if (actor == null || !actor.IsVisible(world.LocalPlayer))
                return;

            var text = actor.Info.Traits.Contains<TooltipInfo>()
                ? actor.Info.Traits.Get<TooltipInfo>().Name
                : actor.Info.Name;
            var text2 = (actor.Owner.NonCombatant)
                ? "" : "{0}".F(actor.Owner.PlayerName);
            var text3 = (actor.Owner == world.LocalPlayer || actor.Owner.NonCombatant)
                ? "" : " ({0})".F(world.LocalPlayer.Stances[actor.Owner]);

            var sz = Game.Renderer.BoldFont.Measure(text);
            var sz2 = Game.Renderer.RegularFont.Measure(text2);
            var sz3 = Game.Renderer.RegularFont.Measure(text3);

            sz.X = Math.Max(sz.X, sz2.X + sz3.X + 35);

            if (text2 != "") sz.Y += sz2.Y + 2;

            sz.X += 20;
            sz.Y += 24;

            WidgetUtils.DrawPanel("dialog4", Rectangle.FromLTRB(
                Viewport.LastMousePos.X + 20, Viewport.LastMousePos.Y + 20,
                Viewport.LastMousePos.X + sz.X + 20, Viewport.LastMousePos.Y + sz.Y + 20));

            Game.Renderer.BoldFont.DrawText(text,
                new float2(Viewport.LastMousePos.X + 30, Viewport.LastMousePos.Y + 30), Color.White);

            if (text2 != "")
            {
                Game.Renderer.RegularFont.DrawText(text2,
                    new float2(Viewport.LastMousePos.X + 65, Viewport.LastMousePos.Y + 50), actor.Owner.Color);

                Game.Renderer.RegularFont.DrawText(text3,
                    new float2(Viewport.LastMousePos.X + 65 + sz2.X, Viewport.LastMousePos.Y + 50), Color.White);

                WidgetUtils.DrawRGBA(
                    ChromeProvider.GetImage("flags", actor.Owner.Country.Race),
                    new float2(Viewport.LastMousePos.X + 30, Viewport.LastMousePos.Y + 50));
            }
        }
开发者ID:pdovy,项目名称:OpenRA,代码行数:66,代码来源:WorldTooltipWidget.cs

示例15: Order

            public IEnumerable<Order> Order(World world, CPos xy, MouseInput mi)
            {
                if (mi.Button == Game.mouseButtonPreference.Cancel)
                {
                    world.CancelInputMode();
                    yield break;
                }

                var underCursor = world.FindUnitsAtMouse(mi.Location)
                    .OrderByDescending(a => a.Info.Traits.Contains<SelectableInfo>()
                        ? a.Info.Traits.Get<SelectableInfo>().Priority : int.MinValue)
                    .FirstOrDefault();

                if (mi.Button == Game.mouseButtonPreference.Action && underCursor == null)
                {
                    minelayer.World.CancelInputMode();
                    yield return new Order("PlaceMinefield", minelayer, false) { TargetLocation = xy };
                }
            }
开发者ID:Tsher,项目名称:OpenRA,代码行数:19,代码来源:Minelayer.cs


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