Esempio n. 1
0
    void ScatterFractions()
    {
        float     volume      = trans.localScale.x * trans.localScale.y * trans.localScale.z;
        int       numFraction = (int)(volume * 1000.0f);
        Matrix4x4 mat         = trans.localToWorldMatrix;
        Vector3   zero        = Vector3.zero;

        MPAPI.mpScatterParticlesBoxTransform(ref mat, numFraction, ref zero, 3.0f);
    }
Esempio n. 2
0
    public void MPUpdate()
    {
        if (Time.deltaTime == 0.0f)
        {
            return;
        }
        Matrix4x4 mat = transform.localToWorldMatrix;

        switch (shape)
        {
        case Shape.Sphere:
            MPAPI.mpScatterParticlesSphereTransform(ref mat, emitCount, ref velosityBase, velosityDiffuse);
            break;

        case Shape.Box:
            MPAPI.mpScatterParticlesBoxTransform(ref mat, emitCount, ref velosityBase, velosityDiffuse);
            break;
        }
    }
Esempio n. 3
0
    void Update()
    {
        if (IsDead())
        {
            if (scatterFractions)
            {
                float     volume = trans.localScale.x * trans.localScale.y * trans.localScale.z;
                int       num    = (int)(volume * 500.0f);
                Matrix4x4 mat    = trans.localToWorldMatrix;
                MPWorld.s_instances[0].AddOneTimeAction(() => {
                    MPSpawnParams sp           = new MPSpawnParams();
                    sp.velocity_random_diffuse = 3.0f;
                    sp.lifetime = 30.0f;
                    MPAPI.mpScatterParticlesBoxTransform(MPWorld.s_instances[0].GetContext(), ref mat, num, ref sp);
                });
            }
            Destroy(gameObject);
        }
        if (Mathf.Abs(trans.position.x) > 30.0f ||
            Mathf.Abs(trans.position.z) > 30.0f)
        {
            Destroy(gameObject);
        }


        if (rigid)
        {
            Vector3 vel = rigid.velocity;
            vel.x         -= accel;
            vel.y          = 0.0f;
            rigid.velocity = vel;

            Vector3 pos = rigid.transform.position;
            pos.y *= 0.95f;
            rigid.transform.position = pos;

            float speed = rigid.velocity.magnitude;
            rigid.velocity = rigid.velocity.normalized * (Mathf.Min(speed, maxSpeed) * deccel);

            rigid.angularVelocity = rigid.angularVelocity * 0.98f;
        }
    }
Esempio n. 4
0
    public void MPUpdate()
    {
        if (m_emit_count_prev != m_emit_count)
        {
            m_emit_count_prev = m_emit_count;
            m_total_emit      = Mathf.FloorToInt(m_local_time * m_emit_count);
        }
        m_local_time += Time.deltaTime;
        int emit_total      = Mathf.FloorToInt(m_local_time * m_emit_count);
        int emit_this_frame = emit_total - m_total_emit;

        if (emit_this_frame == 0)
        {
            return;
        }
        m_total_emit = emit_total;

        m_params.velocity = m_velosity_base;
        m_params.velocity_random_diffuse = m_velosity_random_diffuse;
        m_params.lifetime = m_lifetime;
        m_params.lifetime_random_diffuse = m_lifetime_random_diffuse;
        m_params.userdata = m_userdata;
        m_params.handler  = m_spawn_handler;
        Matrix4x4 mat = transform.localToWorldMatrix;

        switch (m_shape)
        {
        case Shape.Sphere:
            EachTargets((w) =>
            {
                MPAPI.mpScatterParticlesSphereTransform(w.GetContext(), ref mat, emit_this_frame, ref m_params);
            });
            break;

        case Shape.Box:
            EachTargets((w) =>
            {
                MPAPI.mpScatterParticlesBoxTransform(w.GetContext(), ref mat, emit_this_frame, ref m_params);
            });
            break;
        }
    }