本文整理汇总了C#中MouseInput类的典型用法代码示例。如果您正苦于以下问题:C# MouseInput类的具体用法?C# MouseInput怎么用?C# MouseInput使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MouseInput类属于命名空间,在下文中一共展示了MouseInput类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: InnerOrder
IEnumerable<Order> InnerOrder(World world, CPos xy, MouseInput mi)
{
if (world.Paused)
yield break;
if (mi.Button == MouseButton.Left)
{
var topLeft = xy - FootprintUtils.AdjustForBuildingSize(BuildingInfo);
if (!world.CanPlaceBuilding(Building, BuildingInfo, topLeft, null)
|| !BuildingInfo.IsCloseEnoughToBase(world, Producer.Owner, Building, topLeft))
{
Sound.PlayNotification(world.Map.Rules, Producer.Owner, "Speech", "BuildingCannotPlaceAudio", Producer.Owner.Country.Race);
yield break;
}
var isLineBuild = world.Map.Rules.Actors[Building].Traits.Contains<LineBuildInfo>();
yield return new Order(isLineBuild ? "LineBuild" : "PlaceBuilding", Producer.Owner.PlayerActor, false)
{
TargetLocation = topLeft,
TargetActor = Producer,
TargetString = Building,
SuppressVisualFeedback = true
};
}
}
开发者ID:JackKucan,项目名称:OpenRA,代码行数:25,代码来源:PlaceBuildingOrderGenerator.cs
示例2: IssueOrder
public Order IssueOrder(Actor self, int2 xy, MouseInput mi, Actor underCursor)
{
if (underCursor != null && underCursor.HasTrait<RenderInfantry>())
return new Order("Disguise", self, underCursor);
return null;
}
开发者ID:mgatland,项目名称:OpenRA,代码行数:7,代码来源:RenderSpy.cs
示例3: Order
public IEnumerable<Order> Order(World world, int2 xy, MouseInput mi)
{
if (mi.Button == MouseButton.Right)
world.CancelInputMode();
return OrderInner(world, xy, mi);
}
开发者ID:pdovy,项目名称:OpenRA,代码行数:7,代码来源:RepairOrderGenerator.cs
示例4: HandleMouseInput
public bool HandleMouseInput(MouseInput mi)
{
// Exclusively uses left and right mouse buttons, but nothing else
if (mi.Button != MouseButton.Left && mi.Button != MouseButton.Right)
return false;
if (mi.Button == MouseButton.Right)
{
if (mi.Event == MouseInputEvent.Up)
{
editorWidget.ClearBrush();
return true;
}
return false;
}
var cell = worldRenderer.Viewport.ViewToWorld(mi.Location);
if (mi.Button == MouseButton.Left && AllowResourceAt(cell))
{
var type = (byte)ResourceType.ResourceType;
var index = (byte)ResourceType.MaxDensity;
world.Map.MapResources.Value[cell] = new ResourceTile(type, index);
}
return true;
}
开发者ID:Roger-luo,项目名称:OpenRA,代码行数:28,代码来源:EditorResourceBrush.cs
示例5: Order
public IEnumerable<Order> Order(World world, int2 xy, MouseInput mi)
{
if (mi.Button == MouseButton.Right)
Game.controller.CancelInputMode();
return InnerOrder(world, xy, mi);
}
开发者ID:comradpara,项目名称:OpenRA,代码行数:7,代码来源:PlaceBuildingOrderGenerator.cs
示例6: FriendlyGuardableUnits
static IEnumerable<Actor> FriendlyGuardableUnits(World world, MouseInput mi)
{
return world.ScreenMap.ActorsAt(mi)
.Where(a => !world.FogObscures(a) && !a.IsDead &&
a.AppearsFriendlyTo(world.LocalPlayer.PlayerActor) &&
a.Info.HasTraitInfo<GuardableInfo>());
}
开发者ID:CH4Code,项目名称:OpenRA,代码行数:7,代码来源:GuardOrderGenerator.cs
示例7: WriteInputStats
private void WriteInputStats(ref FormattedText target, MouseInput input)
{
// Initialize the formatted text block we'll write to
this.PrepareFormattedText(ref target);
// Determine all pressed mouse buttons
string activeButtons = "";
foreach (MouseButton button in Enum.GetValues(typeof(MouseButton)))
{
if (input.ButtonPressed(button))
{
if (activeButtons.Length != 0)
activeButtons += ", ";
activeButtons += button.ToString();
}
}
// Compose the formatted text to display
target.SourceText =
"/f[1]Mouse Stats/f[0]/n/n" +
string.Format("Description: /cFF8800FF{0}/cFFFFFFFF/n", input.Description) +
string.Format("IsAvailable: /cFF8800FF{0}/cFFFFFFFF/n", input.IsAvailable) +
string.Format("X: /c44AAFFFF{0,4}/cFFFFFFFF | XSpeed: /c44AAFFFF{1,4}/cFFFFFFFF/n", input.X, input.XSpeed) +
string.Format("Y: /c44AAFFFF{0,4}/cFFFFFFFF | YSpeed: /c44AAFFFF{1,4}/cFFFFFFFF/n", input.Y, input.YSpeed) +
string.Format("Wheel: /c44AAFFFF{0,4}/cFFFFFFFF | WheelSpeed: /c44AAFFFF{1,4}/cFFFFFFFF/n", input.WheelPrecise, input.WheelSpeedPrecise) +
string.Format("Buttons: /c44AAFFFF{0}/cFFFFFFFF/n", activeButtons);
}
开发者ID:ChrisLakeZA,项目名称:duality,代码行数:27,代码来源:InputMonitor.cs
示例8: 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
示例9: InputOverridesSelection
// Used for classic mouse orders, determines whether or not action at xy is move or select
public virtual bool InputOverridesSelection(World world, int2 xy, MouseInput mi)
{
var actor = world.ScreenMap.ActorsAt(xy).WithHighestSelectionPriority(xy);
if (actor == null)
return true;
var target = Target.FromActor(actor);
var cell = world.Map.CellContaining(target.CenterPosition);
var actorsAt = world.ActorMap.GetActorsAt(cell).ToList();
var underCursor = world.Selection.Actors.WithHighestSelectionPriority(xy);
var o = OrderForUnit(underCursor, target, actorsAt, cell, mi);
if (o != null)
{
var modifiers = TargetModifiers.None;
if (mi.Modifiers.HasModifier(Modifiers.Ctrl))
modifiers |= TargetModifiers.ForceAttack;
if (mi.Modifiers.HasModifier(Modifiers.Shift))
modifiers |= TargetModifiers.ForceQueue;
if (mi.Modifiers.HasModifier(Modifiers.Alt))
modifiers |= TargetModifiers.ForceMove;
if (o.Order.TargetOverridesSelection(modifiers))
return true;
}
return false;
}
开发者ID:pchote,项目名称:OpenRA,代码行数:29,代码来源:UnitOrderGenerator.cs
示例10: Order
public IEnumerable<Order> Order(World world, CPos xy, MouseInput mi)
{
var underCursor = world.ScreenMap.ActorsAt(mi)
.Where(a => !world.FogObscures(a) && a.HasTrait<ITargetable>())
.WithHighestSelectionPriority();
Target target;
if (underCursor != null)
target = Target.FromActor(underCursor);
else
{
var frozen = world.ScreenMap.FrozenActorsAt(world.RenderPlayer, mi)
.Where(a => a.Info.Traits.Contains<ITargetableInfo>() && !a.Footprint.All(world.ShroudObscures))
.WithHighestSelectionPriority();
target = frozen != null ? Target.FromFrozenActor(frozen) : Target.FromCell(world, xy);
}
var orders = world.Selection.Actors
.Select(a => OrderForUnit(a, target, mi))
.Where(o => o != null)
.ToList();
var actorsInvolved = orders.Select(o => o.Actor).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.Order, o.Trait.IssueOrder(o.Actor, o.Order, o.Target, mi.Modifiers.HasModifier(Modifiers.Shift)));
}
开发者ID:zombie-einstein,项目名称:OpenRA,代码行数:32,代码来源:UnitOrderGenerator.cs
示例11: GetCursor
public string GetCursor(World world, CPos xy, MouseInput mi)
{
var useSelect = false;
var underCursor = world.ScreenMap.ActorsAt(mi)
.Where(a => !world.FogObscures(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.ScreenMap.FrozenActorsAt(world.RenderPlayer, mi)
.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:Generalcamo,项目名称:OpenRA,代码行数:35,代码来源:UnitOrderGenerator.cs
示例12: GameClass
public GameClass(bool startFullScreen, Size size, bool enableNetwork)
{
this.startFullscreen = startFullScreen;
this.Size = size;
this.networkEnabled = enableNetwork;
this.Text = "SpaceWar3D-Step12";
statusMessageTimer = Constants.StatusMessageDisplayTime;
drawingFont = new GraphicsFont( "Verdana", System.Drawing.FontStyle.Regular);
input = new InputClass(this);
mouseInput = new MouseInput(this);
this.MouseMove +=new MouseEventHandler(GameClass_MouseMove);
this.Cursor = Cursors.NoMove2D;
camera = new Camera();
soundHandler = new SoundHandler(this);
if (networkEnabled) {
peer = new PlayClass(this);
if (peer.IsHost) {
hullColor = HullColors.Red;
}
}
}
开发者ID:timdetering,项目名称:BeginningNetGameProgramming,代码行数:25,代码来源:GameClass.cs
示例13: OrderInner
static IEnumerable<Order> OrderInner(World world, MouseInput mi)
{
if (mi.Button != MouseButton.Left)
yield break;
var underCursor = world.ScreenMap.ActorsAt(mi)
.FirstOrDefault(a => a.AppearsFriendlyTo(world.LocalPlayer.PlayerActor) && !world.FogObscures(a));
if (underCursor == null)
yield break;
if (underCursor.GetDamageState() == DamageState.Undamaged)
yield break;
// Repair a building.
if (underCursor.Info.HasTraitInfo<RepairableBuildingInfo>())
yield return new Order("RepairBuilding", world.LocalPlayer.PlayerActor, false) { TargetActor = underCursor };
// Don't command allied units
if (underCursor.Owner != world.LocalPlayer)
yield break;
// Test for generic Repairable (used on units).
var repairable = underCursor.TraitOrDefault<Repairable>();
if (repairable == null)
yield break;
// Find a building to repair at.
var repairBuilding = repairable.FindRepairBuilding(underCursor);
if (repairBuilding == null)
yield break;
yield return new Order("Repair", underCursor, false) { TargetActor = repairBuilding };
}
开发者ID:CH4Code,项目名称:OpenRA,代码行数:34,代码来源:RepairOrderGenerator.cs
示例14: IssueOrder
public Order IssueOrder(Actor self, int2 xy, MouseInput mi, Actor underCursor)
{
if (mi.Button == MouseButton.Right && xy == self.Location && chargeTick <= 0)
return new Order("Deploy", self);
return null;
}
开发者ID:comradpara,项目名称:OpenRA,代码行数:7,代码来源:ChronoshiftDeploy.cs
示例15: OnMouseUp
public override bool OnMouseUp(Widget w, MouseInput mi)
{
if (w.Id == "MAINMENU_BUTTON_CREATE")
{
Game.chrome.rootWidget.ShowMenu("CREATESERVER_BG");
return true;
}
if (w.Id == "CREATESERVER_BUTTON_CANCEL")
{
Game.chrome.rootWidget.ShowMenu("MAINMENU_BG");
return true;
}
if (w.Id == "CREATESERVER_BUTTON_START")
{
Game.chrome.rootWidget.ShowMenu(null);
Log.Write("Creating server");
Server.Server.ServerMain(AdvertiseServerOnline, Game.Settings.MasterServer,
Game.Settings.GameName, Game.Settings.ListenPort,
Game.Settings.ExternalPort, Game.Settings.InitialMods);
Log.Write("Joining server");
Game.JoinServer(IPAddress.Loopback.ToString(), Game.Settings.ListenPort);
return true;
}
return false;
}
开发者ID:comradpara,项目名称:OpenRA,代码行数:30,代码来源:CreateServerMenuDelegate.cs
示例16: HandleMouseInput
public override bool HandleMouseInput(MouseInput mi)
{
if (ClickThrough) return false;
if (!Draggable || moving && (!TakeFocus(mi) || mi.Button != MouseButton.Left)) return true;
if (prevMouseLocation == null)
prevMouseLocation = mi.Location;
var vec = mi.Location - (int2)prevMouseLocation;
prevMouseLocation = mi.Location;
switch (mi.Event)
{
case MouseInputEvent.Up:
moving = false;
LoseFocus(mi);
break;
case MouseInputEvent.Down:
moving = true;
Bounds = new Rectangle(Bounds.X + vec.X, Bounds.Y + vec.Y, Bounds.Width, Bounds.Height);
break;
case MouseInputEvent.Move:
if (moving)
Bounds = new Rectangle(Bounds.X + vec.X, Bounds.Y + vec.Y, Bounds.Width, Bounds.Height);
break;
}
return true;
}
开发者ID:Tsher,项目名称:OpenRA,代码行数:25,代码来源:BackgroundWidget.cs
示例17: HandleMouseInput
public override bool HandleMouseInput(MouseInput mi)
{
if (CurrentBrush.HandleMouseInput(mi))
return true;
return base.HandleMouseInput(mi);
}
开发者ID:Roger-luo,项目名称:OpenRA,代码行数:7,代码来源:EditorViewportControllerWidget.cs
示例18: 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
示例19: HandleMouseInput
public override bool HandleMouseInput(MouseInput mi)
{
if (mi.Button != MouseButton.Left) return false;
if (IsDisabled()) return false;
if (mi.Event == MouseInputEvent.Down && !TakeFocus(mi)) return false;
if (!Focused) return false;
switch( mi.Event )
{
case MouseInputEvent.Up:
isMoving = false;
LoseFocus(mi);
break;
case MouseInputEvent.Down:
isMoving = true;
/* todo: handle snapping to ticks properly again */
/* todo: handle nudge via clicking outside the thumb */
UpdateValue(ValueFromPx(mi.Location.X - RenderBounds.Left));
break;
case MouseInputEvent.Move:
if (isMoving)
UpdateValue(ValueFromPx(mi.Location.X - RenderBounds.Left));
break;
}
return ThumbRect.Contains(mi.Location);
}
开发者ID:earthpig,项目名称:OpenRA-ep,代码行数:29,代码来源:SliderWidget.cs
示例20: OnMouseDown
public override bool OnMouseDown(Widget w, MouseInput mi)
{
if (w.Id == "SETTINGS_CHECKBOX_UNITDEBUG")
{
Game.Settings.UnitDebug = !Game.Settings.UnitDebug;
return true;
}
if (w.Id == "SETTINGS_CHECKBOX_PATHDEBUG")
{
Game.Settings.PathDebug = !Game.Settings.PathDebug;
return true;
}
if (w.Id == "SETTINGS_CHECKBOX_INDEXDEBUG")
{
Game.Settings.IndexDebug = !Game.Settings.IndexDebug;
return true;
}
if (w.Id == "SETTINGS_CHECKBOX_PERFGRAPH")
{
Game.Settings.PerfGraph = !Game.Settings.PerfGraph;
return true;
}
if (w.Id == "SETTINGS_CHECKBOX_PERFTEXT")
{
Game.Settings.PerfText = !Game.Settings.PerfText;
return true;
}
return false;
}
开发者ID:comradpara,项目名称:OpenRA,代码行数:34,代码来源:SettingsMenuDelegate.cs
注:本文中的MouseInput类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论