本文整理汇总了C#中MouseInput类的典型用法代码示例。如果您正苦于以下问题:C# MouseInput类的具体用法?C# MouseInput怎么用?C# MouseInput使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
MouseInput类属于命名空间,在下文中一共展示了MouseInput类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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
};
}
}
示例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;
}
示例3: Order
public IEnumerable<Order> Order(World world, int2 xy, MouseInput mi)
{
if (mi.Button == MouseButton.Right)
world.CancelInputMode();
return OrderInner(world, xy, mi);
}
示例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;
}
示例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);
}
示例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>());
}
示例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);
}
示例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)));
}
示例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;
}
示例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)));
}
示例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");
}
示例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;
}
}
}
示例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 };
}
示例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;
}
示例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;
}