Exemplo n.º 1
0
    public override IEnumerator SetParticles(ParticleSystem.Particle[] particles)
    {
        maxVal = 0.0f;
        minVal = 0.0f;
        currentVal = 0.0f;

        switch (Direction)
        {
        case PercolationDirection.Up:
            if (particles.Length > 0)
            {
                maxVal = particles.Max(arg => arg.position.y);
                currentVal = maxVal;
                yield return null;
                minVal = particles.Min(arg => arg.position.y);
            }
            break;
        case PercolationDirection.Right:
            if (particles.Length > 0)
            {
                maxVal = particles.Max(arg => arg.position.x);
                currentVal = maxVal;
                yield return null;
                minVal = particles.Min(arg => arg.position.x);
            }
            break;
        case PercolationDirection.Down:
            if (particles.Length > 0)
            {
                maxVal = particles.Min(arg => arg.position.y);
                currentVal = maxVal;
                yield return null;
                minVal = particles.Max(arg => arg.position.y);
            }
            break;
        case PercolationDirection.Left:
            if (particles.Length > 0)
            {
                maxVal = particles.Min(arg => arg.position.x);
                currentVal = maxVal;
                yield return null;
                minVal = particles.Max(arg => arg.position.x);
            }
            break;
        }
        IsReady = true;
        yield break;
    }