Пример #1
0
        protected IEnumerator RollAnimation(RollResult result)
        {
            ResultIterator iter = new ResultIterator(result);

            if (chained)
            {
                iter.GoToFirst();
            }
            else
            {
                iter.GoToFinal();
            }

            DiskSliceBase unit;

            do
            {
                float startZ, targetZ, offset;
                unit = sliceDict.ContainsKey(iter.CurrentSlot) ? sliceDict[iter.CurrentSlot] : null;

                SetAnimParameters(unit, out startZ, out targetZ, out offset);

                for (float tl = 0; tl < 1; tl += Time.deltaTime / rollDuration)
                {
                    float t = completionCurve.Evaluate(tl); //linear t to curve t
                    unitContainer.localEulerAngles = new Vector3(0, 0, startZ * (1 - t) + targetZ * t);
                    yield return(new WaitForEndOfFrame());
                }

                yield return(new WaitForSeconds(settleDelay));

                float finalPosWithOffset = unitContainer.localEulerAngles.z;
                for (float t = 0; t < 1; t += Time.deltaTime / settleDuration)
                {
                    unitContainer.localEulerAngles = new Vector3(0, 0, finalPosWithOffset + t * offset);
                    yield return(new WaitForEndOfFrame());
                }

                yield return(new WaitForSeconds(chainDelay));

                if (iter.HasNext())
                {
                    CreateWheel(iter.CurrentSlot.subslots);
                }
            } while (iter.TryMoveNext());

            if (hideUnchosen)
            {
                foreach (KeyValuePair <WheelBase, DiskSliceBase> pair in sliceDict)
                {
                    if (pair.Value != unit)
                    {
                        pair.Value.Toggle(state: false);
                    }
                }
            }

            unit.Highlight(blinking: true);
            highlighted        = unit;
            animationCoroutine = null;
            yield return(null);
        }