示例#1
0
    public void OnDebugRender()
    {
        if (On(behaviour_type.wander))
        {
            Vector3 m_vTCC = MathUtil.PointToWorldSpace(m_fWanderDistance * Vector3.forward,
                                                        m_entity.Heading(),
                                                        m_entity.Side(),
                                                        m_entity.VPos());

            //draw the wander circle
            DebugExtension.DrawCircle(m_vTCC, Color.green, m_fWanderRadius);

            Vector3 target = (m_vWanderTarget + m_fWanderDistance * Vector3.forward);

            target = MathUtil.PointToWorldSpace(
                target,
                m_entity.Heading(),
                m_entity.Side(),
                m_entity.VPos());

            DebugExtension.DrawLineArrow(m_entity.VPos(), target);

            DebugExtension.DrawCircle(target, Color.red, 3);
        }

        if (On(behaviour_type.arrive) || On(behaviour_type.flee))
        {
            DebugExtension.DrawLineArrow(m_entity.VPos(), m_entity.VTarget());
            DebugExtension.DrawCircle(m_entity.VTarget(), Color.red, 3);
        }

        if (On(behaviour_type.follow_path))
        {
            m_pPath.OnDebugRender();
        }

        if (On(behaviour_type.obstacle_avoidance))
        {
            float length = Prm.MinDetectionBoxLength
                           + (m_entity.Speed() / m_entity.MaxSpeed())
                           * Prm.MinDetectionBoxLength;

            Matrix4x4 matTransform = Matrix4x4.TRS(m_entity.VPos(), Quaternion.LookRotation(m_entity.Heading(), Vector3.up), Vector3.one);

            Vector3 size = Vector3.zero;
            size.x = m_entity.BRadius();
            size.y = 0f;
            size.z = length;
            Vector3 center = Vector3.zero;
            center.x = 0f;
            center.y = 0f;
            center.z = length * 0.5f;

            DebugExtension.DrawLocalCube(matTransform, size, Color.black, center);
        }
    }