Example #1
0
 void RestrictMovement()
 {
     if (m_isPressingUp && m_restrictedArea.IsOutOfRestrictionPosY(transform.position))
     {
         m_currentMoveDirection.y = 0;
     }
     if (m_isPressingDown && m_restrictedArea.IsOutOfRestrictionNegY(transform.position))
     {
         m_currentMoveDirection.y = 0;
     }
     if (m_isPressingLeft && m_restrictedArea.IsOutOfRestrictionNegX(transform.position))
     {
         m_currentMoveDirection.x = 0;
     }
     if (m_isPressingRight && m_restrictedArea.IsOutOfRestrictionPosX(transform.position))
     {
         m_currentMoveDirection.x = 0;
     }
 }
Example #2
0
    void GetForcVectorDc()
    {
        float[] inputData = GenerateInputData();

        bool isPressingLeft  = inputData[0] == 1;
        bool isPressingRight = inputData[1] == 1;
        bool isPressingUp    = false;
        bool isPressingDown  = false;

        if (inputData.Length > 3)
        {
            isPressingUp   = inputData[2] == 1;
            isPressingDown = inputData[3] == 1;
        }

        m_forceVector = Vector3.zero;
        if (isPressingLeft && !m_restrictedArea.IsOutOfRestrictionNegX(transform.position))
        {
            m_forceVector.x -= m_movementSpeed;// * (m_isPressingSlow ? m_slowFactor : 1);
        }
        if (isPressingRight && !m_restrictedArea.IsOutOfRestrictionPosX(transform.position))
        {
            m_forceVector.x += m_movementSpeed;// * (m_isPressingSlow ? m_slowFactor : 1);
        }
        if (inputData.Length > 3)
        {
            if (isPressingUp && !m_restrictedArea.IsOutOfRestrictionPosY(transform.position))
            {
                m_forceVector.y += m_movementSpeed;// * (m_isPressingSlow ? m_slowFactor : 1);
            }
            if (isPressingDown && !m_restrictedArea.IsOutOfRestrictionNegY(transform.position))
            {
                m_forceVector.y -= m_movementSpeed;// * (m_isPressingSlow ? m_slowFactor : 1);
            }
        }

        m_forceVector *= Time.deltaTime;
    }