private void FixedUpdate()
    {
        TrackLaneRing[] rings       = manager.rings;
        TrackLaneRing[] mirrorRings = mirrorManager?.rings;
        for (int i = activeEffects.Count - 1; i >= 0; i--)
        {
            RingRotationEffect effect = activeEffects[i];
            int progress = (int)effect.progressPos;
            while (progress < effect.progressPos + effect.rotationPropagationSpeed && progress < rings.Length)
            {
                float destZ = effect.rotationAngle + progress * effect.rotationStep;
                rings[progress].SetRotation(destZ, effect.rotationFlexySpeed);

                if (mirrorRings != null)
                {
                    mirrorRings[progress].SetRotation(destZ, effect.rotationFlexySpeed);
                }

                progress++;
            }
            effect.progressPos += effect.rotationPropagationSpeed;
            if (effect.progressPos >= rings.Length)
            {
                RecycleRingRotationEffect(activeEffects[i]);
                activeEffects.RemoveAt(i);
            }
        }
    }
Пример #2
0
    public void AddRingRotationEvent(float angle, float step, float propagationSpeed, float flexySpeed)
    {
        RingRotationEffect effect = SpawnRingRotationEffect();

        effect.progressPos              = 0;
        effect.rotationAngle            = angle;
        effect.rotationStep             = step;
        effect.rotationPropagationSpeed = propagationSpeed;
        effect.rotationFlexySpeed       = flexySpeed;
        activeEffects.Add(effect);
    }
    private RingRotationEffect SpawnRingRotationEffect()
    {
        RingRotationEffect result;

        if (effectsPool.Count > 0)
        {
            result = effectsPool[0];
            effectsPool.RemoveAt(0);
        }
        else
        {
            result = new RingRotationEffect();
        }
        return(result);
    }
    public void AddRingRotationEvent(float angle, float step, int propagationSpeed, float flexySpeed, JSONNode customData = null)
    {
        RingRotationEffect effect = SpawnRingRotationEffect();
        int multiplier            = Random.value < 0.5f ? 1 : -1;

        effect.progressPos              = 0;
        effect.rotationStep             = step;
        effect.rotationPropagationSpeed = propagationSpeed;
        effect.rotationFlexySpeed       = flexySpeed;
        if (customData != null)
        {
            effect.rotationStep             *= customData["_stepMult"] ?? 1;
            effect.rotationPropagationSpeed *= Mathf.CeilToInt(customData["_propMult"] ?? 1);
            effect.rotationFlexySpeed       *= customData["_speedMult"] ?? 1;
            multiplier = customData["_direction"] ?? multiplier;
        }
        effect.rotationAngle = angle * multiplier;
        activeEffects.Add(effect);
    }
 private void FixedUpdate()
 {
     TrackLaneRing[] rings = manager.rings;
     for (int i = activeEffects.Count - 1; i >= 0; i--)
     {
         RingRotationEffect effect = activeEffects[i];
         int progress = effect.progressPos;
         while (progress < effect.progressPos + effect.rotationPropagationSpeed && progress < rings.Length)
         {
             rings[progress].SetRotation(effect.rotationAngle + (float)progress * effect.rotationStep, effect.rotationFlexySpeed);
             progress++;
         }
         effect.progressPos += effect.rotationPropagationSpeed;
         if (effect.progressPos >= rings.Length)
         {
             RecycleRingRotationEffect(activeEffects[i]);
             activeEffects.RemoveAt(i);
         }
     }
 }
Пример #6
0
 private void Update()
 {
     effectIndicesToDelete.Clear();
     for (int i = 0; i < activeEffects.Count; i++)
     {
         for (int j = i + 1; j < activeEffects.Count; j++)
         {
             if (activeEffects[i].progressPos < activeEffects[j].progressPos)
             {
                 effectIndicesToDelete.Add(i);
                 break;
             }
         }
     }
     for (int k = 0; k < effectIndicesToDelete.Count; k++)
     {
         int index = effectIndicesToDelete[k];
         RecycleRingRotationEffect(activeEffects[index]);
         activeEffects.RemoveAt(index);
     }
     TrackLaneRing[] rings = manager.rings;
     for (int l = activeEffects.Count - 1; l >= 0; l--)//todo: convert to foreach if possible
     {
         RingRotationEffect ringRotationEffect = activeEffects[l];
         float progressPos = ringRotationEffect.progressPos;
         ringRotationEffect.progressPos += Time.deltaTime * ringRotationEffect.rotationPropagationSpeed;
         for (int m = 0; m < rings.Length; m++)
         {
             float num = (float)m / rings.Length;
             if (num >= progressPos && num < ringRotationEffect.progressPos)
             {
                 rings[m].SetRotation(ringRotationEffect.rotationAngle + m * ringRotationEffect.rotationStep, ringRotationEffect.rotationFlexySpeed);
             }
         }
         if (ringRotationEffect.progressPos > 1f)
         {
             RecycleRingRotationEffect(activeEffects[l]);
             activeEffects.RemoveAt(l);
         }
     }
 }
 private void RecycleRingRotationEffect(RingRotationEffect effect)
 {
     effectsPool.Add(effect);
 }