コード例 #1
0
    public void OnScoredPoint(Events.IScore obj)
    {
        for (int j = 0; j < noOfActiveParticleSystems; j++)
        {
            ParticleSystemStruct selected = Systems[j];

            selected.setup();

            selected.System.Emit(Random.Range(2, 5));

            ParticleSystem.Particle p;
            int     pmcount = selected.System.GetParticles(selected.Particles);
            Vector3 dir;
            Vector3 newPos;
            for (int i = 0; i < pmcount; i++)
            {
                p = selected.Particles[i];
                if (p.velocity == Vector3.zero)
                {
                    dir                   = Util.Common.AngleToVector(angle + Random.Range(arcSize / -2f, arcSize / 2f));
                    newPos                = (dir * radius) + transform.position;
                    newPos.z              = -3f;
                    p.startSize           = 0.5f;
                    p.startLifetime       = 0.5f;
                    p.velocity            = dir * Random.Range(0.9f, 4f);
                    p.rotation            = Random.Range(0, 360f);
                    selected.Particles[i] = p;
                }
            }

            selected.System.SetParticles(selected.Particles, pmcount);
        }
    }
コード例 #2
0
    /// <summary>
    /// Trigged when the user has clicked and the ball has done it's actions
    /// This function create the particles that give feedback when the player clicks
    /// </summary>
    /// <param name="obj">Givven parameter that contains the ball direction and the current ball position</param>
    private void OnBallMoveParticle(Events.IBallMove obj)
    {
        for (int j = 0; j < noOfActiveParticleSystems; j++)
        {
            ParticleSystemStruct selected = Systems[j];

            selected.setup();

            selected.System.Emit(Random.Range(2, 5));

            ParticleSystem.Particle p;
            int pmcount = selected.System.GetParticles(selected.Particles);

            Vector2 dir;
            dir = obj.direction;

            float angle = Util.Common.VectorToAngle(dir);
            angle -= 180;

            for (int i = 0; i < pmcount; i++)
            {
                p = selected.Particles[i];
                if (p.velocity == Vector3.zero)
                {
                    dir                   = Util.Common.AngleToVector(angle + Random.Range(-10f, 10f));
                    p.position            = (dir * radius) + obj.position;
                    p.startSize           = 0.5f;
                    p.startLifetime       = 0.5f;
                    p.velocity            = dir * Random.Range(0.3f, 2f);
                    p.rotation            = Random.Range(0, 360f);
                    selected.Particles[i] = p;
                }
            }

            selected.System.SetParticles(selected.Particles, pmcount);
        }
    }