예제 #1
0
 protected override void updateMouse()
 {
     if (m_bounds.contains(MouseHandler.getCurPos()))
     {
         m_currentState = State.Hover;
         m_text.p_color = m_hoverColor;
         if (MouseHandler.lmbPressed())
         {
             m_currentState = State.Pressed;
             playDownSound();
             m_text.p_color = m_pressedColor;
         }
         if (MouseHandler.lmbUp())
         {
             playUpSound();
             if (m_clickEvent != null)
             {
                 m_clickEvent(this);
             }
             m_text.p_color = m_hoverColor;
         }
     }
     else if (!m_bounds.contains(MouseHandler.getCurPos()) && m_bounds.contains(MouseHandler.getPrePos()))
     {
         m_currentState = State.Normal;
         m_text.p_color = m_normalColor;
     }
 }
예제 #2
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;
     }
 }
예제 #3
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();
        }
예제 #4
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();
                }
            }
        }
예제 #5
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);
            }
        }
예제 #6
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);
     }
 }
예제 #7
0
파일: Game.cs 프로젝트: Joxe/TacticsRPG
        protected override void Update(GameTime a_gameTime)
        {
            if (!IsActive)
            {
                return;
            }
            KeyboardHandler.setCurrentKeyboard();
            MouseHandler.setCurrentMouse();
            m_currentGameTime = a_gameTime;

            if (KeyboardHandler.keyPressed(Keys.Escape))
            {
                this.Exit();
            }

            m_currentState.update();
            m_camera.update();
            base.Update(a_gameTime);

            m_previousGameTime = m_currentGameTime;
            KeyboardHandler.setPreviousKeyboard();
            MouseHandler.setPreviousMouse();
        }
예제 #8
0
        public static Vector2 previousWorldMouse()
        {
            Camera l_camera = Game.getInstance().m_camera;

            return(MouseHandler.getPrePos() / l_camera.p_zoom + l_camera.p_position - ((Game.getInstance().getResolution() / 2) / l_camera.p_zoom));
        }
예제 #9
0
        public static void cameraDrag()
        {
            Vector2 l_difference = (MouseHandler.getCurPos() - Game.getInstance().getResolution() / 2) / 20 / Game.getInstance().m_camera.p_zoom;

            Game.getInstance().m_camera.setPosition(Game.getInstance().m_camera.p_position + l_difference);
        }