本文整理汇总了C#中InputState.WentInactive方法的典型用法代码示例。如果您正苦于以下问题:C# InputState.WentInactive方法的具体用法?C# InputState.WentInactive怎么用?C# InputState.WentInactive使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类InputState
的用法示例。
在下文中一共展示了InputState.WentInactive方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Update
public void Update(InputState input)
{
if (input.WentActive(Keys.F1))
{
_dialogMgr.Add(new Prompt(Console.WriteLine));
}
AABB selectionBox = new AABB(_selectionBoxP1, _selectionBoxP2);
int id;
if (_provinces.TryGetProvinceFromPoint(input.Mouse, out id))
{
if (input.WentActive(Buttons.LeftButton) &&
_labelClickableBoundaries.ContainsKey(id) &&
_labelClickableBoundaries[id].IsPointInside(input.ScreenMouse) &&
_units.IsPlayerArmy(id))
{
_unitsSelection.Select(id, input.IsActive(Keys.LeftControl));
}
// Only handle new selections.
else if (input.WentActive(Buttons.LeftButton))
{
_provinceSelection.Select(id);
}
else if (input.WentInactive(Buttons.LeftButton)
&& selectionBox.Area < _minimumSelectionSize
&& _unitsSelection.Count > 0)
{
_units.AddOrder(_unitsSelection.Set, id);
}
SwapInstrs(_provinceSelection.Hovering);
_provinceSelection.Hover(id);
SwapInstrs(id);
}
else
{
SwapInstrs(_provinceSelection.Hovering);
_provinceSelection.StopHovering();
}
if (input.WentActive(Keys.G)) MergeSelectedArmies();
if (input.WentActive(Keys.Escape)) _unitsSelection.DeselectAll();
if (input.WentActive(Keys.Delete)) DeleteSelectedArmies();
if (input.WentInactive(Buttons.LeftButton) && selectionBox.Area > _minimumSelectionSize)
{
_unitsSelection.DeselectAll();
// Find all units within the area and select them.
_labelClickableBoundaries
.FindAll(p => _units.IsPlayerArmy(p.Key) && p.Value.Intersects(selectionBox))
.ForEach(p => _unitsSelection.Select(p.Key, true));
}
UpdateSelectionBox(input);
if (_unitsSelection.Count > 0)
{
Debug.WriteToScreen("Armies", _unitsSelection.Set.Join(", "));
}
}
示例2: UpdateSelectionBox
public void UpdateSelectionBox(InputState input)
{
if (input.WentInactive(Buttons.LeftButton))
{
_selectionBoxP1 = Vector2.Zero;
_selectionBoxP2 = Vector2.Zero;
} else if (input.WentActive(Buttons.LeftButton))
{
_selectionBoxP1 = input.ScreenMouse;
_selectionBoxP2 = input.ScreenMouse;
}
else if (input.IsActive(Buttons.LeftButton))
{
_selectionBoxP2 = input.ScreenMouse;
}
}