private void Init()
        {
            startupAnime = new Anime();
            startupAnime.AnimateColor((color) => this.Glow.Color = color)
            .AddTime(0f, new Color(1f, 1f, 1f, 0f), EaseType.QuadEaseOut)
            .AddTime(0.1f, new Color(1f, 1f, 1f, 1f), EaseType.QuadEaseIn)
            .AddTime(1f, new Color(0f, 0f, 0f, 1f))
            .Build();
            startupAnime.AnimateColor((color) => this.Outer.Color = color)
            .AddTime(0f, new Color(1f, 1f, 1f, 0f), EaseType.QuadEaseOut)
            .AddTime(0.1f, new Color(1f, 1f, 1f, 1f), EaseType.QuadEaseIn)
            .AddTime(1f, new Color(0.25f, 0.25f, 0.25f, 1f))
            .Build();
            startupAnime.AnimateColor((color) => this.Inner.Color = color)
            .AddTime(0.1f, new Color(1f, 1f, 1f, 0f), EaseType.QuadEaseIn)
            .AddTime(1f, new Color(0.25f, 0.25f, 0.25f, 1f))
            .Build();
            startupAnime.AnimateColor((color) => this.Title.Color = color)
            .AddTime(0.5f, new Color(), EaseType.QuartEaseIn)
            .AddTime(1f, new Color(0.75f, 0.75f, 0.75f, 1f))
            .Build();
            startupAnime.AddEvent(startupAnime.Duration, () => OnStartup?.Invoke());

            breatheAnime          = new Anime();
            breatheAnime.WrapMode = WrapModeType.Loop;
            breatheAnime.AnimateColor((color) => this.Glow.Color = color)
            .AddTime(0f, Color.black, EaseType.SineEaseOut)
            .AddTime(1.1f, Color.gray, EaseType.SineEaseIn)
            .AddTime(2.2f, Color.black)
            .Build();
            breatheAnime.AnimateColor((color) => this.Title.Color = color)
            .AddTime(0f, new Color(0.75f, 0.75f, 0.75f, 1f), EaseType.SineEaseOut)
            .AddTime(1.1f, Color.white, EaseType.SineEaseIn)
            .AddTime(2.2f, new Color(0.75f, 0.75f, 0.75f, 1f))
            .Build();

            endAnime = new Anime();
            endAnime.AnimateColor((color) => this.Glow.Color = color)
            .AddTime(0f, () => this.Glow.Color, EaseType.QuartEaseIn)
            .AddTime(1.5f, Color.white)
            .Build();
            endAnime.AnimateColor((color) => this.Outer.Color = color)
            .AddTime(0f, () => this.Outer.Color, EaseType.QuartEaseIn)
            .AddTime(1.5f, Color.white)
            .Build();
            endAnime.AnimateColor((color) => this.Inner.Color = color)
            .AddTime(0f, () => this.Inner.Color, EaseType.QuartEaseIn)
            .AddTime(1.5f, Color.white)
            .Build();
            endAnime.AnimateColor((color) => this.Title.Color = color)
            .AddTime(0f, () => this.Title.Color, EaseType.QuartEaseIn)
            .AddTime(1.5f, Color.white)
            .Build();
            endAnime.AnimateVector3((scale) => this.Scale = scale)
            .AddTime(0f, Vector3.one, EaseType.SineEaseOut)
            .AddTime(1.5f, new Vector3(1.1f, 1.1f, 1.1f))
            .Build();
            endAnime.AddEvent(endAnime.Duration, () => OnEnd?.Invoke());
        }
        private void Init()
        {
            darkSprite = CreateChild <UguiSprite>("dark", 0);
            {
                darkSprite.Anchor = AnchorType.Fill;
                darkSprite.Offset = new Offset(0f, MenuBarHeight, 0f, 0f);
                darkSprite.Color  = new Color(0f, 0f, 0f, 0.5f);

                closeTrigger = darkSprite.CreateChild <UguiTrigger>("close", 0);
                {
                    closeTrigger.Anchor  = AnchorType.Fill;
                    closeTrigger.RawSize = Vector2.zero;

                    closeTrigger.OnPointerDown += () =>
                    {
                        OverlayNavigator.Hide(this);
                    };
                }

                container = darkSprite.CreateChild <UguiTrigger>("container", 1);
                {
                    container.OnPointerEnter += () =>
                    {
                        outAni?.Stop();
                        hoverAni?.PlayFromStart();
                    };
                    container.OnPointerExit += () =>
                    {
                        hoverAni?.Stop();
                        outAni?.PlayFromStart();
                    };

                    if (UseGlow)
                    {
                        glowSprite = container.CreateChild <UguiSprite>("glow", -1);
                        {
                            glowSprite.Anchor     = AnchorType.Fill;
                            glowSprite.Offset     = new Offset(-15f);
                            glowSprite.SpriteName = "glow-square-32";
                            glowSprite.ImageType  = Image.Type.Sliced;
                            glowSprite.Color      = Color.black;
                        }
                    }
                }
            }

            if (UseGlow)
            {
                hoverAni = new Anime();
                hoverAni.AnimateColor(color => glowSprite.Color = color)
                .AddTime(0f, () => glowSprite.Color)
                .AddTime(0.25f, Color.gray)
                .Build();

                outAni = new Anime();
                outAni.AnimateColor(color => glowSprite.Color = color)
                .AddTime(0f, () => glowSprite.Color)
                .AddTime(0.25f, Color.black)
                .Build();
            }
        }
Exemple #3
0
        private void Init(IGameSession gameSession)
        {
            gameSession.OnSoftInit += () =>
            {
                gameSession.ScoreProcessor.Combo.Bind(OnComboChanged);
            };
            gameSession.OnSoftDispose += () =>
            {
                comboAni.Stop();
                hideAni.Stop();
                effectComboLabel.Alpha  = 0f;
                persistComboLabel.Alpha = 0f;
            };

            effectComboLabel = CreateChild <Label>("effect");
            {
                effectComboLabel.IsBold   = true;
                effectComboLabel.FontSize = 48;
                effectComboLabel.Color    = Color.black;

                effectComboLabel.AddEffect(new AdditiveShaderEffect());
            }
            persistComboLabel = CreateChild <Label>("persisting");
            {
                persistComboLabel.IsBold   = true;
                persistComboLabel.FontSize = 48;
                persistComboLabel.Color    = new Color(0.3f, 0.3f, 0.3f, 1f);

                persistComboLabel.AddEffect(new AdditiveShaderEffect());
            }

            comboAni = new Anime();
            comboAni.AnimateColor((color) => effectComboLabel.Color = color)
            .AddTime(0f, Color.black)
            .AddTime(0.05f, MaxEffectColor, EaseType.QuadEaseOut)
            .AddTime(0.25f, Color.black)
            .Build();
            comboAni.AnimateVector3((scale) => effectComboLabel.Scale = scale)
            .AddTime(0f, MinEffectScale, EaseType.CubicEaseOut)
            .AddTime(0.25f, MaxEffectScale)
            .Build();
            comboAni.AnimateColor((color) => persistComboLabel.Color = color)
            .AddTime(0f, () => persistComboLabel.Color)
            .AddTime(0.04f, MaxPersistColor, EaseType.QuadEaseIn)
            .AddTime(0.2f, MinPersistColor)
            .Build();
            comboAni.AnimateVector3((scale) => persistComboLabel.Scale = scale)
            .AddTime(0f, Vector3.one, EaseType.QuadEaseOut)
            .AddTime(0.1f, MaxPersistScale, EaseType.QuadEaseIn)
            .AddTime(0.2f, Vector3.one)
            .Build();

            hideAni = new Anime();
            hideAni.AnimateColor((color) => effectComboLabel.Color = color)
            .AddTime(0f, () => effectComboLabel.Color)
            .AddTime(0.25f, Color.black)
            .Build();
            hideAni.AnimateColor((color) => persistComboLabel.Color = color)
            .AddTime(0f, () => persistComboLabel.Color)
            .AddTime(0.25f, Color.black)
            .Build();
        }
        private void Init(IGameSession gameSession)
        {
            gameSession.OnSoftInit += () =>
            {
                scoreProcessor = gameSession.ScoreProcessor;
                scoreProcessor.Health.BindAndTrigger(OnHealthChange);
                SetFailingForce(false);
            };
            gameSession.OnSoftDispose += () =>
            {
                ProgressBar.Value = 0f;
            };

            ProgressBar = CreateChild <UguiProgressBar>("progress", 0);
            {
                fgSprite       = ProgressBar.Foreground;
                fgSprite.Color = ColorPreset.PrimaryFocus.Base;

                thumbSprite            = ProgressBar.Thumb;
                thumbSprite.Active     = true;
                thumbSprite.SpriteName = "glow-128";
                thumbSprite.Color      = ColorPreset.PrimaryFocus.Alpha(0f);
                thumbSprite.Size       = new Vector2(36f, 88f);

                pinEffectSprite = thumbSprite.CreateChild <UguiSprite>("effect");
                {
                    pinEffectSprite.Color      = ColorPreset.PrimaryFocus.Alpha(0f);
                    pinEffectSprite.SpriteName = "glow-128";
                    pinEffectSprite.Size       = thumbSprite.Size * 6.5f;

                    pinEffectSprite.AddEffect(new AdditiveShaderEffect());
                }
            }
            Indicator = CreateChild <UguiSprite>("indicator", 1);
            {
                Indicator.Color = ColorPreset.PrimaryFocus.Base;
            }

            changeAni = new Anime();
            changeAni.AnimateFloat((progress) => ProgressBar.Value = progress)
            .AddTime(0f, () => ProgressBar.Value)
            .AddTime(0.2f, () => curHealth)
            .Build();
            changeAni.AnimateColor((tint) => fgSprite.Tint = tint)
            .AddTime(0f, () => barTintFromColor)
            .AddTime(0.35f, () => barTintToColor)
            .Build();

            pinAni = new Anime();
            // Thumb sprite fade and scale
            pinAni.AnimateFloat((alpha) => thumbSprite.Alpha = alpha)
            .AddTime(0f, 0f)
            .AddTime(0.05f, 1f, EaseType.QuadEaseIn)
            .AddTime(0.25f, 0f)
            .Build();
            pinAni.AnimateVector3((scale) => thumbSprite.Scale = scale)
            .AddTime(0f, new Vector3(1.1f, 1.1f), EaseType.QuadEaseIn)
            .AddTime(0.25f, Vector3.one)
            .Build();
            // Pin effect fade and scale
            pinAni.AnimateFloat((alpha) => pinEffectSprite.Alpha = alpha)
            .AddTime(0f, 1f, EaseType.QuadEaseOut)
            .AddTime(0.25f, 0f)
            .Build();
            pinAni.AnimateVector3((scale) => pinEffectSprite.Scale = scale)
            .AddTime(0f, Vector3.zero, EaseType.CubicEaseOut)
            .AddTime(0.25f, Vector3.one)
            .Build();
        }