예제 #1
0
    // Use this for initialization
    void Start()
    {
        Angle     = new float[Num];
        R         = new float[Num];
        before    = new float[Num];
        after     = new float[Num];
        particles = new ParticleSystem.Particle[Num];

        particleSystem.maxParticles = Num;
        particleSystem.Emit(Num);
        particleSystem.GetParticles(particles);

        Ndistribution nd = new Ndistribution();

        // 每个粒子在初始化的时候都设定好收缩前和收缩后的粒子半径
        for (int i = 0; i < Num; i++)
        {
            float r     = (float)nd.getNormalDistribution((minR + maxR) * 0.5f, 1);
            float angle = UnityEngine.Random.Range(0.0f, 360.0f);
            Angle[i] = angle;
            R[i]     = r;

            before[i] = r;
            after[i]  = 0.7f * r;

            if (after[i] < minR * 1.1f)
            {
                float midRadius = minR * 1.05f;
                after[i] = UnityEngine.Random.Range(UnityEngine.Random.Range(minR, midRadius), (minR * 1.1f));
            }
        }
    }
예제 #2
0
    void Start()
    {
        particleAngle = new float[particleNum];
        particleR     = new float[particleNum];
        before        = new float[particleNum];
        after         = new float[particleNum];
        particles     = new ParticleSystem.Particle[particleNum];

        particleSystem.maxParticles = particleNum;
        particleSystem.Emit(particleNum);
        particleSystem.GetParticles(particles);

        Ndistribution nd = new Ndistribution();

        for (int i = 0; i < particleNum; i++)
        {
            float r     = (float)nd.getNormalDistribution((minRadius + maxRadius) * 0.5f, 1);
            float angle = UnityEngine.Random.Range(0.0f, 360.0f);
            particleAngle[i] = angle;
            particleR[i]     = r;

            before[i] = r;
            after[i]  = 0.1f * r;

            if (after[i] < minRadius * 1.1f)
            {
                float midRadius = minRadius * 2f;
                after[i] = UnityEngine.Random.Range(UnityEngine.Random.Range(minRadius, midRadius), (minRadius * 1.1f));
            }
        }
    }
예제 #3
0
    // Use this for initialization
    void Start()
    {
        particles     = new ParticleSystem.Particle[particleNum];
        particleDatas = new ParticleData[particleNum];          //新建粒子数据数组
        particleSystem.maxParticles = particleNum;

        particleSystem.Emit(particleNum);
        particleSystem.GetParticles(particles);

        Ndistribution nd = new Ndistribution();

        // 每个粒子在初始化的时候都设定好收缩前和收缩后的粒子半径
        for (int i = 0; i < particleNum; i++)
        {
            float angle  = UnityEngine.Random.Range(0.0f, 360.0f);
            float radius = (float)nd.getNormalDistribution((minRadius + maxRadius) * 0.5f, 1);
            float before = radius;
            float after  = 0.7f * radius;

            if (after < minRadius * 1.1f)
            {
                float midRadius = minRadius * 1.2f;
                after = UnityEngine.Random.Range(UnityEngine.Random.Range(minRadius, midRadius), (minRadius * 1.1f));
            }
            particleDatas[i] = new ParticleData(angle, radius, before, after);
        }
    }