Наследование: GrandLarceny.MovingObject
Пример #1
0
        private void updateState()
        {
            if (m_currentState != m_lastState)
            {
                if (!m_chase && m_runMode && (m_currentState != State.Walking && m_currentState != State.Jumping))
                {
                    toggleRunMode();
                }

                if ((m_lastState == State.Rolling || m_lastState == State.Hanging)
                    && m_currentState != State.Rolling && m_currentState != State.Hanging)
                {
                    if (m_currentState == State.Hiding && m_currentHidingImage == DUCKHIDINGIMAGE)
                    {
                        m_imgOffsetY = -(m_img.getSize().Y - m_rollHitBox.getOutBox().Height);
                        m_imgOffsetX = 0;
                        setLayer(0.725f);
                    }
                    else
                    {
                        m_imgOffsetX = 0;
                        m_imgOffsetY = 0;
                        m_collisionShape = m_standHitBox;
                        if (m_lastState == State.Rolling || m_lastState == State.Hiding)
                        {
                            m_position.setLocalY(m_position.getLocalY() - (m_standHitBox.getOutBox().Height - m_rollHitBox.getOutBox().Height) - 1);
                            Game.getInstance().m_camera.getPosition().plusYWith(m_standHitBox.getOutBox().Height - m_rollHitBox.getOutBox().Height);
                            if (m_lastState == State.Hiding)
                            {
                                setLayer(m_originalLayer);
                            }
                        }
                        else if (m_lastState == State.Hanging)
                        {
                            m_position.setLocalY(m_position.getLocalY() - (m_standHitBox.getOutBox().Height - m_hangHitBox.getOutBox().Height) - 1);
                            Game.getInstance().m_camera.getPosition().plusYWith(m_standHitBox.getOutBox().Height - m_hangHitBox.getOutBox().Height);
                        }
                    }

                }
                else if ((m_currentState == State.Rolling || (m_currentState == State.Hiding && m_currentHidingImage == DUCKHIDINGIMAGE) || m_currentState == State.Hanging)
                    && m_lastState != State.Rolling && m_lastState != State.Hiding && m_lastState != State.Hanging)
                {
                    if (m_currentState == State.Rolling || m_currentState == State.Hiding)
                    {
                        if (m_currentState == State.Rolling)
                        {
                            m_img.setAnimationSpeed(15);
                            m_img.setLooping(false);
                            if (m_facingRight)
                            {
                                m_imgOffsetX = -m_rollHitBox.getOutBox().Width;
                            }
                        }
                        else if (m_currentState == State.Hiding)
                        {
                            setLayer(0.725f);
                        }
                        m_imgOffsetY = -(m_img.getSize().Y - m_rollHitBox.getOutBox().Height);
                        m_position.setLocalY(m_position.getLocalY() + (m_standHitBox.getOutBox().Height - m_rollHitBox.getOutBox().Height));
                        Game.getInstance().m_camera.getPosition().plusYWith(-m_rollHitBox.getOutBox().Height);
                    }
                    else if (m_currentState == State.Hanging)
                    {
                        if (m_facingRight)
                        {
                            m_imgOffsetX = 4;
                        }
                        else
                        {
                            m_imgOffsetX = -4;
                        }
                        m_imgOffsetY = -2;
                    }
                    if (m_currentState == State.Hanging)
                    {
                        m_collisionShape = m_hangHitBox;
                    }
                    else
                    {
                        m_collisionShape = m_rollHitBox;
                    }
                }
                else if (m_currentState == State.Climbing)
                {
                    m_img.setAnimationSpeed(15);
                }
                if (m_lastState != State.Swinging && m_currentState != State.Swinging)
                {
                    if (m_rope != null && !m_rope.getHitBox().collides(m_collisionShape))
                        m_rope = null;
                }
                if (m_currentState == State.Swinging)
                {
                    m_rotationPoint.Y = 0;
                    m_rotationPoint.X = m_img.getSize().X / 2;
                    m_imgOffsetX = -m_img.getSize().X / 2;
                    m_collisionShape = m_swingHitBox;
                }
                else if (m_lastState == State.Swinging)
                {
                    m_rotationPoint.X = m_img.getSize().X / 2;
                    m_rotationPoint.Y = m_img.getSize().Y / 2;
                    changePositionToCartesian();
                    m_position.setParentPositionWithoutMoving(null);
                    m_rotate = 0;
                    m_rope.resetPosition();
                    m_swingSpeed = 0;
                    if (m_currentState != State.Ventilation)
                    {
                        m_imgOffsetX = 0;
                        m_position.setGlobalX(m_position.getGlobalX() - 36);
                        Game.getInstance().m_camera.getPosition().setGlobalX(Game.getInstance().m_camera.getPosition().getGlobalX() + 36);
                        m_collisionShape = m_standHitBox;
                    }
                }
                if (m_lastState == State.Ventilation)
                {
                    m_imgOffsetX = 0;
                    m_imgOffsetY = 0;
                    m_layer = 0.300f;
                    ((CollisionRectangle)m_collisionShape).setOffsetX(0);
                    ((CollisionRectangle)m_collisionShape).setOffsetY(0);
                    m_currentVentilationImage = "hero_ventilation_idle";
                    m_currentVentilation = null;
                    m_ventilationDirection = m_noneList;
                }
                else if (m_currentState == State.Ventilation)
                {
                    m_img.setAnimationSpeed(15);
                    m_layer = 0.6995f;
                    if (m_currentVentilation != null)
                    {
                        m_imgOffsetX = -((m_img.getSize().X / 2) - (m_currentVentilation.getImg().getSize().X / 2));
                        m_imgOffsetY = -((m_img.getSize().Y / 2) - (m_currentVentilation.getImg().getSize().Y / 2));
                    }
                    else
                    {
                        m_imgOffsetX = -((m_img.getSize().X / 2) - 36);
                        m_imgOffsetY = -((m_img.getSize().Y / 2) - 36);
                    }
                }
                if (m_lastState == State.Slide)
                {
                    m_slideSound.stop();
                    m_jumpSound.play();
                }
                else if (m_currentState == State.Slide)
                {
                    m_slideSound.play();
                }
                if (m_lastState == State.Jumping && (m_currentState == State.Walking || m_currentState == State.Stop))
                {
                    m_landSound.play();
                }
            }
        }
Пример #2
0
 internal void setRope(Rope a_rope)
 {
     m_rope = a_rope;
 }
Пример #3
0
        private void updateState()
        {
            if (m_currentState != m_lastState)
            {
                if ((m_lastState == State.Rolling || (m_lastState == State.Hiding && m_currentHidingImage == DUCKHIDINGIMAGE) || m_lastState == State.Hanging)
                    && m_currentState != State.Rolling && m_currentState != State.Hanging)
                {
                    if (m_currentState == State.Hiding && m_currentHidingImage == DUCKHIDINGIMAGE)
                    {
                        m_imgOffsetY = -(m_img.getSize().Y - m_rollHitBox.getOutBox().Height);
                        m_imgOffsetX = 0;
                        setLayer(0.725f);
                    }
                    else
                    {
                        m_imgOffsetX = 0;
                        m_imgOffsetY = 0;
                        m_collisionShape = m_standHitBox;
                        if (m_lastState == State.Rolling || m_lastState == State.Hiding)
                        {
                            m_position.setLocalY(m_position.getLocalY() - (m_standHitBox.getOutBox().Height - m_rollHitBox.getOutBox().Height) -1);
                            Game.getInstance().m_camera.getPosition().plusYWith(m_standHitBox.getOutBox().Height - m_rollHitBox.getOutBox().Height);
                            if (m_lastState == State.Hiding)
                            {
                                setLayer(m_originalLayer);
                            }
                        }
                        else if (m_lastState == State.Hanging)
                        {
                            m_position.setLocalY(m_position.getLocalY() - (m_standHitBox.getOutBox().Height - m_hangHitBox.getOutBox().Height) - 1);
                            Game.getInstance().m_camera.getPosition().plusYWith(m_standHitBox.getOutBox().Height - m_hangHitBox.getOutBox().Height);
                        }
                    }

                }
                else if ((m_currentState == State.Rolling || (m_currentState == State.Hiding && m_currentHidingImage == DUCKHIDINGIMAGE) || m_currentState == State.Hanging)
                    && m_lastState != State.Rolling && m_lastState != State.Hiding && m_lastState != State.Hanging)
                {
                    if (m_currentState == State.Rolling || m_currentState == State.Hiding)
                    {
                        if (m_currentState == State.Rolling)
                        {
                            m_img.setAnimationSpeed(15);
                            m_img.setLooping(false);
                            if (m_facingRight)
                                m_imgOffsetX = -m_rollHitBox.getOutBox().Width;
                        }
                        else if (m_currentState == State.Hiding)
                        {
                            setLayer(0.725f);
                        }
                        m_imgOffsetY = -(m_img.getSize().Y - m_rollHitBox.getOutBox().Height);
                        m_position.setLocalY(m_position.getLocalY() + (m_standHitBox.getOutBox().Height - m_rollHitBox.getOutBox().Height));
                        Game.getInstance().m_camera.getPosition().plusYWith(-m_rollHitBox.getOutBox().Height);
                    }
                    else if (m_currentState == State.Hanging)
                    {
                        if (m_facingRight)
                        {
                            m_imgOffsetX = 4;
                        }
                        else
                        {
                            m_imgOffsetX = -4;
                        }
                        m_imgOffsetY = -2;
                    }
                    if (m_currentState == State.Hanging)
                    {
                        m_collisionShape = m_hangHitBox;
                    }
                    else
                    {
                        m_collisionShape = m_rollHitBox;
                    }
                }
                if (m_lastState == State.Jumping && m_currentState != State.Swinging)
                {
                    m_rope = null;
                }
                if (m_currentState == State.Swinging)
                {
                    m_rotationPoint.Y = 0;
                    m_rotationPoint.X = m_img.getSize().X / 2;
                    m_imgOffsetX = -m_img.getSize().X / 2;
                }
                else if (m_lastState == State.Swinging)
                {
                    m_imgOffsetX = 0;
                    m_rotationPoint.X = m_img.getSize().X / 2;
                    m_rotationPoint.Y = m_img.getSize().Y / 2;
                }
            }
        }