예제 #1
0
        private void DoTransition(BackgroundTransition bgt)
        {
            if (FromBG == null)
            {
                return;
            }
            if (ToBG == null)
            {
                throw new Exception("Cannot do transition when target BG is null");
            }
            var   pb      = new MaterialPropertyBlock();
            var   mat     = Instantiate(baseMixerMaterial);
            float timeout = bgt.TimeToFinish();
            var   cts     = new Cancellable();

            transitionCTS.Add(cts);
            Func <bool>?condition = null;

            if (bgt.type == BackgroundTransition.EffectType.WipeTex)
            {
                bgt.WipeTex.Apply(mat);
                CombinerKeywords.Apply(mat, CombinerKeywords.WIPE_TEX);
            }
            else if (bgt.type == BackgroundTransition.EffectType.Wipe1)
            {
                bgt.Wipe1.Apply(mat);
                CombinerKeywords.Apply(mat, CombinerKeywords.WIPE1);
            }
            else if (bgt.type == BackgroundTransition.EffectType.WipeFromCenter)
            {
                bgt.WipeFromCenter.Apply(mat);
                CombinerKeywords.Apply(mat, CombinerKeywords.WIPEFROMCENTER);
            }
            else if (bgt.type == BackgroundTransition.EffectType.Shatter4)
            {
                Action cb = WaitingUtils.GetCondition(out condition);
                FromBG.Shatter4(bgt.Shatter4, false, cb);
                CombinerKeywords.Apply(mat, CombinerKeywords.TO_ONLY);
            }
            else if (bgt.type == BackgroundTransition.EffectType.WipeY)
            {
                bgt.WipeY.Apply(mat);
                CombinerKeywords.Apply(mat, CombinerKeywords.WIPEY); //TODO apply these two generics from within the BGT scope.
            }
            BackgroundCombiner.SetMaterial(mat, pb);
            void Finish()
            {
                if (!cts.Cancelled)
                {
                    FinishTransition();
                }
                transitionCTS.Remove(cts);
            }

            if (condition == null)
            {
                if (timeout > 0)
                {
                    WaitingUtils.WaitThenCBEvenIfCancelled(this, cts, timeout, false, Finish);
                }
                else
                {
                    throw new Exception("Cannot wait for transition without a timeout or condition");
                }
            }
            else
            {
                WaitingUtils.WaitThenCBEvenIfCancelled(this, cts, timeout, condition, Finish);
            }
        }
예제 #2
0
 public void QueueTransition(BackgroundTransition bgt) => nextRequestedTransition = bgt;