Beispiel #1
0
    public override E_PLAYER_STATES Colide(E_DIRECTIONS _dir, string _tag)
    {
        if (_dir == E_DIRECTIONS.TOP && m_data.GetVelocity().y > 0.0f)
        {
            RaycastHit hit;

            //if (Physics.Raycast(transform.position, transform.up * 0.6f, out hit))
            if (Physics.Raycast(transform.position + (transform.up * 1.5f), transform.up * 0.1f, out hit))
            {
                if (hit.collider.tag != "Player")
                {
                    Debug.Log("Hit ceiling");
                    //m_data.m_velocityY = 0.0f;
                }
            }
        }
        else if (_dir == E_DIRECTIONS.BOTTOM && m_enableGroundCollisionCount == 0)
        {
            return(E_PLAYER_STATES.ON_GROUND);
        }
        //else if (( _dir == E_DIRECTIONS.LEFT || _dir == E_DIRECTIONS.RIGHT) && !m_inputs.GetInput(E_INPUTS.JUMP))
        //{
        //    return E_PLAYER_STATES.WALL_SLIDEING;
        //}

        return(E_PLAYER_STATES.IN_AIR);
    }
    public override E_PLAYER_STATES Colide(E_DIRECTIONS _dir, string _tag)
    {
        if (_dir == E_DIRECTIONS.BOTTOM && m_enableGroundCollisionCount == 0)
        {
            return(E_PLAYER_STATES.ON_GROUND);
        }

        return(E_PLAYER_STATES.USEING_LADDER);
    }
    public override E_PLAYER_STATES Colide(E_DIRECTIONS _dir, string _tag)
    {
        base.Colide(_dir, _tag);

        if (_tag != "Box" && (_dir == E_DIRECTIONS.LEFT || _dir == E_DIRECTIONS.RIGHT))
        {
            return(E_PLAYER_STATES.ON_GROUND);
        }

        return(E_PLAYER_STATES.MOVEING_BLOCK);
    }
Beispiel #4
0
    public virtual void OnCollisionStay(Collision Other)
    {
        float angle = Vector2.Angle(Other.contacts[0].normal, Vector2.up);

        E_DIRECTIONS dir = E_DIRECTIONS.TOP;

        if (Mathf.Approximately(angle, 0.0f))
        {
            dir = E_DIRECTIONS.BOTTOM;

            Rigidbody rigb = Other.gameObject.GetComponent <Rigidbody>();

            if (!rigb && gameObject.transform.parent)
            {
                rigb = gameObject.transform.parent.GetComponent <Rigidbody>();
            }

            if (rigb && Other.gameObject.tag != "Box")
            {
                //m_data.m_velocity.y += rigb.velocity.y;
                m_data.AddVelocity(0.0f, rigb.velocity.y, 0.0f);

                if (m_data.m_use3D)
                {
                    Vector3 platformVelToLocalVel = transform.InverseTransformDirection(rigb.velocity);
                    //m_data.m_velocity.x += platformVelToLocalVel.z;
                    //m_data.m_velocity.z += platformVelToLocalVel.x;
                    m_data.AddVelocity(platformVelToLocalVel.z, 0.0f, platformVelToLocalVel.x);
                }
                else
                {
                    //m_data.m_velocity.x += rigb.velocity.x;
                    //m_data.m_velocity.z += rigb.velocity.z;
                    m_data.AddVelocity(rigb.velocity.x, 0.0f, rigb.velocity.z);
                }
            }
        }
        else if (Mathf.Approximately(angle, 180.0f))
        {
            dir = E_DIRECTIONS.TOP;
        }

        m_newState = GetCurrentState().Colide(dir, Other.gameObject.tag);
        CheckState();
    }
Beispiel #5
0
    public override E_PLAYER_STATES Colide(E_DIRECTIONS _dir, string _tag)
    {
        if (_dir == E_DIRECTIONS.TOP && m_data.GetVelocity().y > 0.0f)
        {
            RaycastHit hit;

            if (!Physics.Raycast(transform.position + new Vector3(0.0f, 1.4f, 0.0f) + (-transform.forward * 0.1f), new Vector3(0.0f, 1.0f, 0.0f), out hit, 0.25f))
            {
                Debug.Log("Hit ceiling");
                //m_data.m_velocityY = 0.0f;
            }
        }
        else if (_dir == E_DIRECTIONS.BOTTOM && m_enableGroundCollisionCount == 0)
        {
            return(E_PLAYER_STATES.ON_GROUND);
        }
        //else if ((_dir == E_DIRECTIONS.LEFT || _dir == E_DIRECTIONS.RIGHT) && !m_inputs.GetInput(E_INPUTS.JUMP))
        //{
        //    return E_PLAYER_STATES.WALL_SLIDEING;
        //}

        return(E_PLAYER_STATES.IN_AIR);
    }
Beispiel #6
0
 public virtual E_PLAYER_STATES Colide(E_DIRECTIONS _dir, string _tag)
 {
     return(E_PLAYER_STATES.NULL);
 }