Exemplo n.º 1
0
    /// <summary>
    /// Initiate the randomization of the appearance of the particle system for this object.  This is
    /// accomplished by changing the value of certain settings using random values within a predefined
    /// range.
    /// </summary>
    public void Randomize()
    {
        Vector2 minMax;

        ParticleSystem.MinMaxCurve curve = new ParticleSystem.MinMaxCurve();
        curve.mode = ParticleSystemCurveMode.TwoConstants;

        minMax = RandomUtils.GenerateRandomRange(new Vector2(m_main.startLifetime.constantMin, m_main.startLifetime.constantMax),
                                                 m_startLifetimePercentVariation);
        curve.constantMin    = minMax.x;
        curve.constantMax    = minMax.y;
        m_main.startLifetime = curve;

        minMax = RandomUtils.GenerateRandomRange(new Vector2(m_main.startSpeed.constantMin, m_main.startSpeed.constantMax),
                                                 m_startSpeedPercentVariation);
        curve.constantMin = minMax.x;
        curve.constantMax = minMax.y;
        m_main.startSpeed = curve;

        minMax = RandomUtils.GenerateRandomRange(new Vector2(m_main.startSize.constantMin, m_main.startSize.constantMax),
                                                 m_startSizePercentVariation);
        curve.constantMin = minMax.x;
        curve.constantMax = minMax.y;
        m_main.startSize  = curve;

        // Initialize the period of time to wait for the particle flow to be completed, and the
        // time scale to accelerate the flow and reduce the wait time.
        m_ps.Clear();
        m_currentWaitTimeSecsForRandomize = RandomUtils.GenerateRandom(m_waitTimeSecsForRandomize, m_particleFlowTimePercentVariation);
        Time.timeScale = 90f;
    }