GrandLarceny.Player.moveDirectionInVentilation C# (CSharp) 메소드

moveDirectionInVentilation() 개인적인 메소드

private moveDirectionInVentilation ( Direction a_direction ) : List
a_direction Direction
리턴 List
        private List<Direction> moveDirectionInVentilation(Direction a_direction)
        {
            m_ventilationIdle = true;
            List<Direction> t_list = null;
            switch (a_direction)
            {
                case Direction.Up:
                {
                    if (((CollisionRectangle)m_collisionShape).m_xOffset != 0 && (!(m_lastVentilationDirection == Direction.Right) || KeyboardHandler.isKeyPressed(GameState.getUpKey())))
                    {
                        setSprite(m_currentVentilationImage);
                        m_position.plusXWith(((CollisionRectangle)m_collisionShape).m_xOffset);
                        Game.getInstance().m_camera.getPosition().plusXWith(-((CollisionRectangle)m_collisionShape).m_xOffset);
                        ((CollisionRectangle)m_collisionShape).setOffsetX(0);
                    }
                    if (KeyboardHandler.isKeyPressed(GameState.getUpKey()) && !KeyboardHandler.isKeyPressed(GameState.getDownKey()))
                    {
                        m_ventilationIdle = false;
                        m_currentVentilationImage = "hero_ventilation_vertical";
                        ((CollisionRectangle)m_collisionShape).setOffsetY(0);
                        ((CollisionRectangle)m_collisionShape).setOffsetX(0);
                        m_speed.Y = -PLAYERSPEED;
                        t_list = m_upDownList;
                        m_facingRight = false;
                        if (m_currentVentilation != null)
                        {
                            if (m_position.getGlobalX() - m_currentVentilation.getPosition().getGlobalX() > 3)
                            {
                                m_position.plusXWith(-3);
                            }
                            else if (m_position.getGlobalX() - m_currentVentilation.getPosition().getGlobalX() < -3)
                            {
                                m_position.plusXWith(3);
                            }
                            else
                            {
                                m_position.setGlobalX(m_currentVentilation.getPosition().getGlobalX());
            //					m_imgOffsetX = -((m_img.getSize().X / 2) - (m_currentVentilation.getImg().getSize().X / 2));
                                m_currentVentilation = null;
                            }
                        }
                        if (m_lastVentilationDirection == Direction.Left || m_lastVentilationDirection == Direction.Right || m_lastVentilationDirection == Direction.None)
                        {
                            m_position.plusYWith(-36);
                            Game.getInstance().m_camera.getPosition().plusYWith(36);
                        }
                        m_lastVentilationDirection = Direction.Up;
                    }
                    else if (!KeyboardHandler.isKeyPressed(GameState.getDownKey()) && m_currentVentilationImage == "hero_ventilation_vertical")
                    {
                        m_img.setAnimationSpeed(0);
                        m_lastVentilationDirection = Direction.Down;
                    }
                    break;
                }
                case Direction.Left:
                {
                    if (((CollisionRectangle)m_collisionShape).m_yOffset != 0 && (!(m_lastVentilationDirection == Direction.Down)) ||KeyboardHandler.isKeyPressed(GameState.getLeftKey()))
                    {
                        setSprite(m_currentVentilationImage);
                        m_position.plusYWith(((CollisionRectangle)m_collisionShape).m_yOffset);
                        Game.getInstance().m_camera.getPosition().plusYWith(-((CollisionRectangle)m_collisionShape).m_yOffset);
                        ((CollisionRectangle)m_collisionShape).setOffsetY(0);
                    }
                    if (KeyboardHandler.isKeyPressed(GameState.getLeftKey()) && !KeyboardHandler.isKeyPressed(GameState.getRightKey()))
                    {
                        if (m_lastVentilationDirection == Direction.Right && m_ventilationDirection.Count == 1)
                        {
                            m_position.plusXWith(-36);
                            Game.getInstance().m_camera.getPosition().plusXWith(36);
                        }
                        ((CollisionRectangle)m_collisionShape).setOffsetX(0);
                        ((CollisionRectangle)m_collisionShape).setOffsetY(0);
                        m_speed.X = -PLAYERSPEED;
                        t_list = m_leftRightList;
                        if (m_currentVentilation != null)
                        {
                            if (m_position.getGlobalY() - m_currentVentilation.getPosition().getGlobalY() > 3)
                            {
                                m_position.plusYWith(-3);
                            }
                            else if (m_position.getGlobalY() - m_currentVentilation.getPosition().getGlobalY() < -3)
                            {
                                m_position.plusYWith(3);
                            }
                            else
                            {
                                m_position.setGlobalY(m_currentVentilation.getPosition().getGlobalY());
            //					m_imgOffsetY = -((m_img.getSize().Y / 2) - (m_currentVentilation.getImg().getSize().Y / 2));
                                m_currentVentilation = null;
                            }
                        }
                        m_currentVentilationImage = "hero_ventilation_horizontal";
                        m_ventilationIdle = false;
                        m_facingRight = false;
                        if (m_lastVentilationDirection == Direction.Down || m_lastVentilationDirection == Direction.Up)
                        {
                            m_position.plusXWith(-36);
                            Game.getInstance().m_camera.getPosition().plusXWith(36);
                        }
                        m_lastVentilationDirection = Direction.Left;
                    }
                    break;
                }
                case Direction.Right:
                {
                    if (((CollisionRectangle)m_collisionShape).m_yOffset != 0 && (!(m_lastVentilationDirection == Direction.Down)) || KeyboardHandler.isKeyPressed(GameState.getRightKey()))
                    {
                        setSprite(m_currentVentilationImage);
                        m_position.plusYWith(((CollisionRectangle)m_collisionShape).m_yOffset);
                        Game.getInstance().m_camera.getPosition().plusYWith(-((CollisionRectangle)m_collisionShape).m_yOffset);
                        ((CollisionRectangle)m_collisionShape).setOffsetY(0);
                    }
                    if (KeyboardHandler.isKeyPressed(GameState.getRightKey()) && !KeyboardHandler.isKeyPressed(GameState.getLeftKey()))
                    {
                        ((CollisionRectangle)m_collisionShape).setOffsetX(36);
                        ((CollisionRectangle)m_collisionShape).setOffsetY(0);
                        m_speed.X = PLAYERSPEED;
                        t_list = m_leftRightList;
                        if (m_currentVentilation != null)
                        {
                            if (m_position.getGlobalY() - m_currentVentilation.getPosition().getGlobalY() > 3)
                            {
                                m_position.plusYWith(-3);
                            }
                            else if (m_position.getGlobalY() - m_currentVentilation.getPosition().getGlobalY() < -3)
                            {
                                m_position.plusYWith(3);
                            }
                            else
                            {
                                m_position.setGlobalY(m_currentVentilation.getPosition().getGlobalY());
                //				m_imgOffsetY = -((m_img.getSize().Y / 2) - (m_currentVentilation.getImg().getSize().Y / 2));
                                m_currentVentilation = null;
                            }
                        }
                        m_currentVentilationImage = "hero_ventilation_horizontal";
                        m_ventilationIdle = false;
                        m_facingRight = true;
                        m_lastVentilationDirection = Direction.Right;
                    }
                    break;
                }
                case Direction.Down:
                {
                    m_ventilationIdle = false;
                    m_currentVentilationImage = "hero_ventilation_vertical";
                    if (((CollisionRectangle)m_collisionShape).m_xOffset != 0 && (!(m_lastVentilationDirection == Direction.Right)) || KeyboardHandler.isKeyPressed(GameState.getDownKey()))
                    {
                        setSprite(m_currentVentilationImage);
                        m_position.plusXWith(((CollisionRectangle)m_collisionShape).m_xOffset);
                        Game.getInstance().m_camera.getPosition().plusXWith(-((CollisionRectangle)m_collisionShape).m_xOffset);
                        ((CollisionRectangle)m_collisionShape).setOffsetX(0);
                    }
                    if (KeyboardHandler.isKeyPressed(GameState.getDownKey()))
                    {
                        ((CollisionRectangle)m_collisionShape).setOffsetY(36);
                        ((CollisionRectangle)m_collisionShape).setOffsetX(0);
                        m_speed.Y = PLAYERSPEED;
                        t_list = m_upDownList;
                        m_facingRight = false;
                        if (m_currentVentilation != null)
                        {
                            if (m_position.getGlobalX() - m_currentVentilation.getPosition().getGlobalX() > 3)
                            {
                                m_position.plusXWith(-3);
                            }
                            else if (m_position.getGlobalX() - m_currentVentilation.getPosition().getGlobalX() < -3)
                            {
                                m_position.plusXWith(3);
                            }
                            else
                            {
                                m_position.setGlobalX(m_currentVentilation.getPosition().getGlobalX());
                //				m_imgOffsetX = -((m_img.getSize().X / 2) - (m_currentVentilation.getImg().getSize().X / 2));
                                m_currentVentilation = null;
                            }
                        }
                        m_lastVentilationDirection = Direction.Down;
                    }
                    else if (!KeyboardHandler.isKeyPressed(GameState.getUpKey()))
                    {
                        m_img.setAnimationSpeed(0);
                        m_lastVentilationDirection = Direction.Down;
                    }
                    break;
                }
            }

            return t_list;
        }