本文整理汇总了C#中Input.WasMouseLeftJustPressed方法的典型用法代码示例。如果您正苦于以下问题:C# Input.WasMouseLeftJustPressed方法的具体用法?C# Input.WasMouseLeftJustPressed怎么用?C# Input.WasMouseLeftJustPressed使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Input
的用法示例。
在下文中一共展示了Input.WasMouseLeftJustPressed方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Update
public void Update(Input.InputState inputState)
{
selectedLevel = null;
float fCol = (inputState.MousePos.X - levelBasePos.X) / levelSpacing.X;
int Col = (int)fCol;
if (Col < 0 || Col >= chapters.Count)
{
hovering = null;
hoveringStar = false;
return;
}
List<LevelState> levels = chapters[Col];
float fRow = (inputState.MousePos.Y + levelSpacing.Y/3 - levelBasePos.Y) / levelSpacing.Y;
int Row = (int)fRow;
if (Row < 0 || Row >= levels.Count)
{
hovering = null;
hoveringStar = false;
return;
}
hovering = levels[Row];
hoveringStar = (fCol - Col) > 0.1f;
if (inputState.WasMouseLeftJustPressed())
{
selectedLevel = hovering;
}
}
示例2: Update
public void Update(Input.InputState inputState, Rectangle screenSize)
{
// for now, let's refresh the state every frame
NewGameState();
LayOutArea(viewingPlayer.Hand, new Rectangle(100, screenSize.Height - 100, screenSize.Width - 200, 100), handCardSize, 0);
int battlefieldHeight = (screenSize.Height - 130) / 2;
LayOutBattlefield(new Rectangle(10, battlefieldHeight, screenSize.Width-20, battlefieldHeight), viewingPlayer.Battlefield, false);
Player opponent = GetOpponent();
if(opponent != null)
{
LayOutBattlefield(new Rectangle(10, 0, screenSize.Width-20, battlefieldHeight), opponent.Battlefield, true);
}
Vector2 mousePos = inputState.MousePos;
if (hoveredCard != null)
{
if (!hoveredCard.Contains(mousePos))
hoveredCard = null;
}
bool hoveredCardMissing = (hoveredCard != null);
foreach (UICard c in gameStateRepresentation.Values)
{
if (c == hoveredCard)
hoveredCardMissing = false;
else if (hoveredCard == null && c.Contains(mousePos))
hoveredCard = c;
c.Update(hoveredCard == c);
}
if (hoveredCardMissing)
hoveredCard = null;
if (hoveredCard != null && inputState.WasMouseLeftJustPressed())
{
if (hoveredCard.card is HandCardReference)
{
viewingPlayer.Play((HandCardReference)hoveredCard.card);
}
else if (hoveredCard.card is BattlefieldCardReference)
{
bool activatedAnAbility = false;
foreach(AbilityInstance a in hoveredCard.card.Abilities)
{
if(a.ability is ActivatedAbility)
{
((ActivatedAbility)a.ability).Activate((BattlefieldCardReference)hoveredCard.card);
activatedAnAbility = true;
break;
}
}
if(!activatedAnAbility && hoveredCard.card.IsCreature && viewingPlayer.game.currentPhase == Phase.Attack)
{
BattlefieldCardReference battlefieldCard = (BattlefieldCardReference)hoveredCard.card;
if (viewingPlayer.IsAttacking(battlefieldCard))
{
viewingPlayer.WithdrawAttacker(battlefieldCard);
}
else
{
viewingPlayer.DeclareAttacker(battlefieldCard, GetOpponent());
}
}
// BattlefieldCardReference cardRef = ((BattlefieldCardReference)hoveredCard.card);
// cardRef.isTapped = !cardRef.isTapped;
}
}
foreach(UIButton button in buttons)
{
button.Update(inputState);
}
}