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;
    }
Exemplo n.º 2
0
    private CameraState StartMoveCamera()
    {
        // Initialize the position of the pivot, relative to the location of the observed object.
        m_pivotPosition = m_observedOffset + m_observed[m_indexObserved].transform.position;

        // Move the location of the pivot to the position calculated above, offset from the location of the observed object.
        transform.parent.transform.position = m_pivotPosition;

        // Reset the local rotation, in case the camera was moved manually.
        transform.localRotation = Quaternion.Euler(m_initialLocalRotation.x, m_initialLocalRotation.y, m_initialLocalRotation.z);

        // Generate the target (pivot) rotation and the target (camera) local position for the camera.  In contrast
        // to the above values which are camera rotation and pivot position.  So we generate new images by rotation with the pivot
        // in the parent object, and changing local position in the camera object.  The other values (calculated above) should not
        // change, unless the camera is moved manually.
        m_targetRotation.x = m_pivotRotation.x + RandomUtils.GenerateRandom(m_elevationRangeDegrees);
        m_targetRotation.y = m_pivotRotation.y + RandomUtils.GenerateRandom(m_angleRangeDegrees);
        m_targetRotation.z = m_pivotRotation.z;
        m_targetRotationQt = Quaternion.Euler(m_targetRotation.x, m_targetRotation.y, m_targetRotation.z);

        m_targetTransform.x = m_pivotOffset.x + RandomUtils.GenerateRandom(m_offsetRangeMeters);
        m_targetTransform.y = m_pivotOffset.y + RandomUtils.GenerateRandom(m_altitudeRangeMeters);
        m_targetTransform.z = m_pivotOffset.z + RandomUtils.GenerateRandom(m_distanceRangeMeters);

        Debug.Log(string.Format("rot: elevation:{0},angle:{1}, pos: offset:{2},altitude:{3},distance:{4}",
                                m_targetRotation.x, m_targetRotation.y,
                                m_targetTransform.x, m_targetTransform.y, m_targetTransform.z));

        return(CameraState.InMotion);
    }