示例#1
0
    void SpawnParticle()
    {
        string text = (m_sentencesRef != null && m_sentencesRef.Count > 0)
            ? m_sentencesRef[Random.Range(0, m_sentencesRef.Count)]
            : "";

        if (text == "")
        {
            return;
        }

        WOTParticle p = GetParticle();

        if (p != null)
        {
            Vector3 dir = Vector3.zero;
            dir.x = -1.0f + Random.Range(0.0f, 2.0f);
            dir.y = -1.0f + Random.Range(0.0f, 2.0f);
            dir.Normalize();

            float speed = m_particleSpeed + Random.Range(-0.5f, 0.5f);

            Vector3 local = transform.parent.position;
            local.x += -1.5f + Random.Range(0.0f, 3.0f);
            local.y += -0.5f + Random.Range(0.0f, 0.5f);

            p.Play(text, m_particleLifetime, 0.1f, 0.5f, m_colour, 0.5f, 1.0f, local, dir, speed, OnLifetimeParticleExpired);
        }
    }
示例#2
0
    void OnLifetimeParticleExpired(GameObject particleGO)
    {
        WOTParticle p = particleGO.GetComponent <WOTParticle>();

        if (p != null)
        {
            RecycleParticle(p);
        }
    }
示例#3
0
    WOTParticle GetParticle()
    {
        WOTParticle retParticle = null;

        for (int i = 0; i < m_maxParticles; ++i)
        {
            if (!m_pool[i].gameObject.activeSelf)
            {
                retParticle = m_pool[i];
                break;
            }
        }
        if (retParticle != null)
        {
            retParticle.gameObject.SetActive(true);
        }
        return(retParticle);
    }
示例#4
0
 void RecycleParticle(WOTParticle particle)
 {
     particle.transform.localPosition = Vector3.zero;
     particle.gameObject.SetActive(false);
 }