コード例 #1
0
ファイル: Button.cs プロジェクト: Joxe/TacticsRPG
 protected virtual void updateMouse()
 {
     if (m_bounds.contains(MouseHandler.worldMouse()))
     {
         m_currentState = State.Hover;
         if (MouseHandler.lmbDown() && m_currentState != State.Pressed)
         {
             playDownSound();
             m_currentState = State.Pressed;
         }
         if (m_currentState != State.Pressed && MouseHandler.lmbUp())
         {
             playUpSound();
             m_currentState = State.Hover;
             if (m_clickEvent != null)
             {
                 m_clickEvent(this);
             }
         }
     }
     else
     {
         m_currentState = State.Normal;
     }
 }
コード例 #2
0
ファイル: Tile.cs プロジェクト: Joxe/TacticsRPG
        public override void update()
        {
            m_hitbox.update();
            bool l_collided = CollisionManager.hexagonContains(this, MouseHandler.worldMouse(), TILE_WIDTH, TILE_HEIGHT);

            if (l_collided && !m_ignoreMouse && !m_tileMap.p_ignoreMouse)
            {
                m_tileMap.p_hover = this;
                if (m_tileAbove != null)
                {
                    m_tileAbove.ignoreMouse(true);
                }
                switch (m_tileState)
                {
                case TileState.Normal:
                    m_tileState = TileState.Hover;
                    break;

                case TileState.Hover:
                    if (MouseHandler.lmbDown())
                    {
                        m_tileState = TileState.Pressed;
                    }
                    break;

                case TileState.Pressed:
                    if (MouseHandler.lmbUp())
                    {
                        m_tileState = TileState.Hover;
                    }
                    break;

                case TileState.Toggle:
                    if (MouseHandler.lmbUp())
                    {
                        m_tileState = TileState.Normal;
                    }
                    m_tileState = TileState.Hover;
                    break;
                }
            }
            else
            {
                if (m_hoverOverToggle)
                {
                    m_tileState = TileState.Toggle;
                }
                else
                {
                    m_tileState = TileState.Normal;
                }
                if (m_tileAbove != null)
                {
                    m_tileAbove.ignoreMouse(false);
                }
            }
            base.update();
        }
コード例 #3
0
ファイル: TextField.cs プロジェクト: Joxe/TacticsRPG
        public override void update()
        {
            if (MouseHandler.lmbDown())
            {
                if (getHitBox().contains(MouseHandler.worldMouse()))
                {
                    m_writing         = true;
                    m_lastPressedKeys = new Dictionary <Keys, TimeSpan>();
                }
                else
                {
                    m_writing = false;
                }
            }

            if (m_writing)
            {
                foreach (KeyValuePair <Keys, TimeSpan> l_keyPair in m_lastPressedKeys)
                {
                    if (!KeyboardHandler.keyPressed(l_keyPair.Key))
                    {
                        m_repeatKeys.Add(l_keyPair.Key);
                    }
                    else if (l_keyPair.Value + m_repeatTime < Game.getInstance().getGameTime().TotalGameTime)
                    {
                        m_repeatKeys.Add(l_keyPair.Key);
                    }
                }
                foreach (Keys l_key in m_repeatKeys)
                {
                    m_lastPressedKeys.Remove(l_key);
                }
                m_repeatKeys.Clear();

                if (m_currentLocale.Equals("euSv"))
                {
                    updateSweden(Game.getInstance().getGameTime());
                }
                if (m_maxLength != 0 && m_textToShow.p_text.Length > m_maxLength)
                {
                    m_textToShow.erase(m_textToShow.p_text.Length - m_maxLength);
                }
                else
                {
                    while (m_textToShow.measureString().X > m_box.getWidth())
                    {
                        m_textToShow.erase(1);
                    }
                }
                m_caret.setXOffset(m_textToShow.measureString().X + 5);
            }
        }
コード例 #4
0
 private void updateMouse()
 {
     if (m_gameGui.collidedWithGUI())
     {
         return;
     }
     if (MouseHandler.mmbPressed())
     {
         CameraHandler.cameraDrag();
     }
     if (MouseHandler.lmbDown())
     {
         if (m_gameGui.getState() != GUI.GuiState.AttackTarget)
         {
             foreach (Champion l_champion in m_champions.Values)
             {
                 if (l_champion.getHitBox().contains(MouseHandler.worldMouse()))
                 {
                     selectChampion(l_champion);
                 }
             }
         }
     }
     if (MouseHandler.rmbDown())
     {
         //TODO DEBUG!!!
         if (m_selectedChampion != null)
         {
             deselectChampion();
         }
     }
     if (MouseHandler.scrollUp())
     {
         CameraHandler.zoomIn(0.1f);
     }
     else if (MouseHandler.scrollDown())
     {
         CameraHandler.zoomOut(0.1f);
     }
 }