Example #1
0
        override public void RenderResult(object sender, RollResult result)
        {
            base.RenderResult(sender, result);
            if (result.RootSlot == null)
            {
                return;
            }

            if (highlighted)
            {
                highlighted.Dehighlight();
                highlighted = null;
            }

            if (chained)
            {
                if (needsReset)
                {
                    CreateWheel(result.RootSlot.subslots);
                }

                needsReset = true;
            }

            if (hideUnchosen)
            {
                foreach (KeyValuePair <WheelBase, DiskSliceBase> slicePair in sliceDict)
                {
                    slicePair.Value.Toggle(state: true);
                }
            }

            animationCoroutine = StartCoroutine(RollAnimation(result));
        }
Example #2
0
        protected void SetAnimParameters(UnitRenderer unit, out float start, out float target, out float offset)
        {
            float targetPos = unit ? GetUnitRotation(unit) : 0;

            start   = unitContainer.localEulerAngles.z;
            target  = -targetPos + pegAngle;
            offset  = Random.Range(-0.45f, 0.45f) * arc;
            target -= offset;
            target -= minimumFullTurns * 360;
        }
Example #3
0
        protected IEnumerator RollAnimation(RollResult result)
        {
            List <WheelBase> leaves = wheel.LeafSlots;
            int target = leaves.IndexOf(result.FinalSlot);

            if (target < 0)
            {
                yield break;
            }

            float f       = 0;
            float time    = Time.time;
            float rawTime = 0;

            for (float i = 0; i < steps; i++)
            {
                rawTime += sequenceIntervals.Evaluate(i / steps);
            }

            for (float i = 0; i < steps; i++)
            {
                float t = sequenceIntervals.Evaluate(i / steps);
                t /= rawTime / sequenceDuration;
                f += t;

                int randEntry = Random.Range(0, leaves.Count);
                MakeUnit(randEntry, leaves[randEntry]);

                wheelotronLoad += (wheelotronMax - wheelotronLoad) * 0.1f; //FX
                yield return(new WaitForSeconds(t));
            }

            UnitRenderer final = MakeUnit(target, leaves[target]);

            final.Highlight(blinking: true);

            //FX
            while (wheelotronLoad > 0)
            {
                wheelotronLoad -= Random.Range(5f, 15f);
                yield return(new WaitForSeconds(0.2f));
            }

            wheelotronLoad = 0;
            initSequenceButton.interactable = true;
            animationCoroutine = null;
            yield return(null);
        }
Example #4
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);
        }
Example #5
0
 protected float GetUnitRotation(UnitRenderer unit) => unit.transform.localEulerAngles.z;