예제 #1
0
    void DefineDirection()
    {
        //Front or back
        if (m_Up || m_Down)
        {
            if (m_Up == true)
            {
                m_MoveSpeed = m_MoveMaxSpeed;
            }
            if (m_Down == true)
            {
                m_MoveSpeed = m_MoveMaxSpeed * -1;
            }

            //If the ship is damn
            if (m_Ship.m_IsDamn == true)
            {
                m_MoveSpeed = m_MoveSpeed * -1;
            }

            m_IsMoving = true;
        }
        else
        {
            m_IsMoving           = false;
            m_Rigidbody.velocity = Vector3.zero;
            m_MoveSpeed          = 0;
        }

        if (m_Left ^ m_Right)
        {
            //If the ship is damn
            if (m_Ship.m_IsDamn == true)
            {
                if (!m_Left && m_Right)
                {
                    transform.Rotate(Vector3.down, m_RotateSpeed * Time.deltaTime);
                    m_IsRotatingLeft  = true;
                    m_IsRotatingRight = false;

                    //Camera to the left
                    m_ShipCameraBehavior.MoveCamera("left");
                }

                if (m_Left && !m_Right)
                {
                    transform.Rotate(Vector3.up, m_RotateSpeed * Time.deltaTime);
                    m_IsRotatingLeft  = false;
                    m_IsRotatingRight = true;

                    //Camera to the right
                    m_ShipCameraBehavior.MoveCamera("right");
                }
            }
            else
            {
                if (m_Left && !m_Right)
                {
                    transform.Rotate(Vector3.down, m_RotateSpeed * Time.deltaTime);
                    m_IsRotatingLeft  = true;
                    m_IsRotatingRight = false;

                    //Camera to the left
                    m_ShipCameraBehavior.MoveCamera("left");
                }

                if (!m_Left && m_Right)
                {
                    transform.Rotate(Vector3.up, m_RotateSpeed * Time.deltaTime);
                    m_IsRotatingLeft  = false;
                    m_IsRotatingRight = true;

                    //Camera to the right
                    m_ShipCameraBehavior.MoveCamera("right");
                }
            }
        }
        else
        {
            m_IsRotatingLeft  = false;
            m_IsRotatingRight = false;

            //Camera to the idle
            m_ShipCameraBehavior.MoveCamera("idle");
        }
    }