Пример #1
0
 private void RecreateTextures()
 {
     if (FromBG == null)
     {
         MaybeCreateFirst();
     }
     else
     {
         if (SaveData.s.Backgrounds)
         {
             FromBG.Show();
             if (ToBG != null)
             {
                 ToBG.Show();
             }
             FromBG.capturer.RecreateTexture();
             if (ToBG != null)
             {
                 ToBG.capturer.RecreateTexture();
             }
         }
         else
         {
             FromBG.Hide();
             if (ToBG != null)
             {
                 ToBG.Hide();
             }
         }
     }
 }
Пример #2
0
 private void FinishTransition()
 {
     if (ToBG != null && FromBG != null)
     {
         FromBG.Hide();
         FromBG = ToBG;
         ToBG   = null;
     }
 }
Пример #3
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);
            }
        }