예제 #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
파일: GUI.cs 프로젝트: Joxe/TacticsRPG
        private void updateMouse()
        {
            if (MouseHandler.lmbPressed())
            {
                switch (m_state)
                {
                case GuiState.AttackTarget:
                    foreach (Champion l_champion in m_gameState.getChampions())
                    {
                        if (l_champion.getHitBox().contains(MouseHandler.worldMouse()) && l_champion.getTile().p_tileState == Tile.TileState.Toggle)
                        {
                            ((GameState)Game.getInstance().getCurrentState()).getSelectedChampion().attack(l_champion);
                            restoreStates();
                            break;
                        }
                    }
                    break;

                case GuiState.Move:
                    foreach (Tile l_tile in m_gameState.getTileMap().toLinkedList(Tile.TileState.Toggle))
                    {
                        if (l_tile != null && l_tile.getHitBox().contains(MouseHandler.worldMouse()))
                        {
                            m_gameState.getSelectedChampion().moveTo(l_tile);
                            restoreStates();
                            break;
                        }
                    }
                    break;

                case GuiState.SelectFacing:
                    foreach (Tile l_tile in m_gameState.getTileMap().toLinkedList(Tile.TileState.Toggle))
                    {
                        if (l_tile != null && l_tile.getHitBox().contains(MouseHandler.worldMouse()))
                        {
                            m_gameState.getSelectedChampion().faceTile(l_tile);
                            m_gameState.deselectChampion();
                            restoreStates();
                            break;
                        }
                    }
                    break;
                }
            }
            if (MouseHandler.rmbPressed())
            {
                if (m_state == GuiState.AttackTarget || m_state == GuiState.Move || m_state == GuiState.ActionMenu)
                {
                    restoreStates();
                }
            }
        }
예제 #4
0
        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);
            }
        }
예제 #5
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);
     }
 }