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


C# Input.WasMouseLeftJustPressed方法代码示例

本文整理汇总了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;
            }
        }
开发者ID:LaurieCheers,项目名称:MagicChessPuzzles,代码行数:31,代码来源:LevelScreen.cs

示例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);
            }
        }
开发者ID:michaelcheers,项目名称:MagicTheGathering,代码行数:77,代码来源:MagicUI.cs


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