Beispiel #1
0
        static internal bool TryGetComonentCreateIfMissing(string type, out ImageEffectBase component, out bool alreadyEnabled, GameObject target)
        {
            Type componentType;

            Shader[] shaders;
            alreadyEnabled = false;
            if (!TryParse(type, out componentType, out shaders))
            {
                Debug.LogError(type + " is not find in Image effect patterns");
                component = null;
                return(false);
            }

            component = target.GetComponent(componentType) as ImageEffectBase;
            if (component == null)
            {
                component = target.gameObject.AddComponent(componentType) as ImageEffectBase;
                component.SetShaders(shaders);
            }
            else
            {
                alreadyEnabled = component.enabled;
            }
            return(true);
        }
Beispiel #2
0
 void Complete(ImageEffectBase imageEffect, AdvScenarioThread thread)
 {
     if (inverse)
     {
         imageEffect.enabled = false;
     }
     OnComplete(thread);
 }
Beispiel #3
0
 void Complete(ImageEffectBase imageEffect, AdvScenarioThread thread)
 {
     if (inverse)
     {
         //                imageEffect.enabled = false;
         UnityEngine.Object.DestroyImmediate(imageEffect);
     }
     OnComplete(thread);
 }
Beispiel #4
0
 //セーブデータ用のバイナリ書き込み
 public void Write(BinaryWriter writer)
 {
     writer.Write(Version);
     writer.WriteLocalTransform(this.transform);
     writer.WriteBuffer(LetterBoxCamera.Write);
     ImageEffectBase[] list = LetterBoxCamera.GetComponents <ImageEffectBase>();
     writer.Write(list.Length);
     for (int i = 0; i < list.Length; ++i)
     {
         ImageEffectBase effect = list[i];
         string          type   = ImageEffectUtil.ToImageEffectType(effect.GetType());
         writer.Write(type);
         writer.WriteBuffer(list[i].Write);
     }
 }
Beispiel #5
0
        protected override void OnStartEffect(GameObject target, AdvEngine engine, AdvScenarioThread thread)
        {
            Camera camera = target.GetComponentInChildren <Camera>(true);

            float                start, end;
            ImageEffectBase      imageEffect    = null;
            IImageEffectStrength effectStrength = null;

            if (string.IsNullOrEmpty(ruleImage))
            {
                bool alreadyEnabled;
                bool ruleEnabled = camera.gameObject.GetComponent <RuleFade>();
                if (ruleEnabled)
                {
                    camera.gameObject.SafeRemoveComponent <RuleFade>();
                }
                ImageEffectUtil.TryGetComonentCreateIfMissing(ImageEffectType.ColorFade.ToString(), out imageEffect, out alreadyEnabled, camera.gameObject);
                effectStrength = imageEffect as IImageEffectStrength;
                ColorFade colorFade = imageEffect as ColorFade;
                if (inverse)
                {
                    //画面全体のフェードイン(つまりカメラのカラーフェードアウト)
                    //					start = colorFade.color.a;
                    start = (ruleEnabled) ? 1 : colorFade.color.a;
                    end   = 0;
                }
                else
                {
                    //画面全体のフェードアウト(つまりカメラのカラーフェードイン)
                    //colorFade.Strengthで、すでにフェードされているのでそちらの値をつかう
                    start = alreadyEnabled ? colorFade.Strength : 0;
                    end   = this.color.a;
                }
                colorFade.enabled = true;
                colorFade.color   = color;
            }
            else
            {
                bool alreadyEnabled;
                camera.gameObject.SafeRemoveComponent <ColorFade>();
                ImageEffectUtil.TryGetComonentCreateIfMissing(ImageEffectType.RuleFade.ToString(), out imageEffect, out alreadyEnabled, camera.gameObject);
                effectStrength = imageEffect as IImageEffectStrength;
                RuleFade ruleFade = imageEffect as RuleFade;
                ruleFade.ruleTexture = engine.EffectManager.FindRuleTexture(ruleImage);
                ruleFade.vague       = vague;
                if (inverse)
                {
                    start = 1;
                    end   = 0;
                }
                else
                {
                    start = alreadyEnabled ? ruleFade.Strength : 0;
                    end   = 1;
                }
                ruleFade.enabled = true;
                ruleFade.color   = color;
            }

            Timer timer = camera.gameObject.AddComponent <Timer>();

            timer.AutoDestroy = true;
            timer.StartTimer(
                engine.Page.ToSkippedTime(this.time),
                engine.Time.Unscaled,
                (x) =>
            {
                effectStrength.Strength = x.GetCurve(start, end);
            },
                (x) =>
            {
                OnComplete(thread);
                if (inverse)
                {
                    imageEffect.enabled = false;
                    imageEffect.RemoveComponentMySelf();
                }
            });
        }