Пример #1
0
        private void Init()
        {
            Dependencies.Cache(this);

            GameSession.OnHardInit    += OnHardInit;
            GameSession.OnHardDispose += OnHardDispose;

            bgSprite = CreateChild <UguiSprite>("bg", 0);
            {
                bgSprite.Anchor     = AnchorType.Fill;
                bgSprite.Offset     = Offset.Zero;
                bgSprite.SpriteName = "gradation-bottom";
                bgSprite.Color      = new Color(0f, 0f, 0f, 0.75f);

                var shadow = bgSprite.CreateChild <UguiSprite>("shadow", 1);
                {
                    shadow.Anchor     = AnchorType.Fill;
                    shadow.Offset     = new Offset(-30f);
                    shadow.SpriteName = "glow-square-32-x2";
                    shadow.ImageType  = Image.Type.Sliced;

                    var gradient = shadow.AddEffect(new GradientEffect()).Component;
                    gradient.direction = UIGradient.Direction.Vertical;
                    gradient.color1    = new Color(0f, 0f, 0f, 0f);
                    gradient.color2    = Color.black;
                }
            }
            hitBarDisplay = CreateChild <HitBarDisplay>("hit-bar", 1);
            {
                hitBarDisplay.Anchor = AnchorType.BottomStretch;
                hitBarDisplay.SetOffsetHorizontal(0f);
                hitBarDisplay.Y      = HitPosition;
                hitBarDisplay.Height = HitPosition * 2f;
            }
            hitObjectHolder = CreateChild <HitObjectHolder>("obj-holder", 2);
            {
                hitObjectHolder.Anchor = AnchorType.Bottom;
                hitObjectHolder.Y      = 0f;
            }
            playAreaFader = CreateChild <PlayAreaFader>("fader", 3);
            {
                playAreaFader.Anchor = AnchorType.BottomStretch;
                playAreaFader.Pivot  = PivotType.Bottom;
                playAreaFader.SetOffsetHorizontal(0f);
                playAreaFader.Y      = FadeStartPos;
                playAreaFader.Height = 10000f;
            }
        }
Пример #2
0
        private void Init()
        {
            mapTagRecycler = new ManagedRecycler <MapMetaTag>(CreateMapTag);

            OnTriggered += () =>
            {
                if (Active && Mapset != null)
                {
                    if (Model.SelectedMapset.Value != Mapset)
                    {
                        Model.SelectMapset(Mapset);
                    }
                    else
                    {
                        Model.NavigateToPrepare();
                    }
                }
            };

            container = CreateChild <UguiObject>("container");
            {
                container.Anchor = AnchorType.CenterStretch;
                container.SetOffsetVertical(5f);
                container.Width = UnfocusedWidth;

                highlight = container.CreateChild <UguiSprite>("highlight");
                {
                    highlight.Size       = new Vector2(1920f, 144f);
                    highlight.SpriteName = "glow-128";
                    highlight.Alpha      = UnfocusedHighlightAlpha;

                    highlight.IsRaycastTarget = false;

                    highlight.AddEffect(new AdditiveShaderEffect());
                }
                glow = container.CreateChild <UguiSprite>("glow");
                {
                    glow.Anchor     = AnchorType.Fill;
                    glow.RawSize    = new Vector2(30f, 30f);
                    glow.SpriteName = "glow-circle-32";
                    glow.ImageType  = Image.Type.Sliced;
                    glow.Color      = UnfocusedGlowColor;
                }
                thumbContainer = container.CreateChild <UguiSprite>("thumb");
                {
                    thumbContainer.Anchor     = AnchorType.Fill;
                    thumbContainer.RawSize    = Vector2.zero;
                    thumbContainer.SpriteName = "circle-32";
                    thumbContainer.ImageType  = Image.Type.Sliced;
                    thumbContainer.Color      = Color.black;

                    thumbContainer.AddEffect(new MaskEffect());

                    thumbImage = thumbContainer.CreateChild <UguiTexture>("image");
                    {
                        thumbImage.Anchor  = AnchorType.Fill;
                        thumbImage.RawSize = Vector2.zero;
                        thumbImage.Color   = UnfocusedThumbColor;
                    }
                }
                titleLabel = container.CreateChild <Label>("title");
                {
                    titleLabel.Anchor = AnchorType.TopStretch;
                    titleLabel.Pivot  = PivotType.Top;
                    titleLabel.Y      = -8f;
                    titleLabel.Height = 32f;
                    titleLabel.SetOffsetHorizontal(20f);
                    titleLabel.IsItalic  = true;
                    titleLabel.IsBold    = true;
                    titleLabel.WrapText  = true;
                    titleLabel.Alignment = TextAnchor.MiddleLeft;
                    titleLabel.FontSize  = 22;

                    titleShadow             = titleLabel.AddEffect(new ShadowEffect()).Component;
                    titleShadow.style       = ShadowStyle.Shadow;
                    titleShadow.effectColor = Color.black;
                    titleShadow.enabled     = false;
                }
                artistLabel = container.CreateChild <Label>("artist");
                {
                    artistLabel.Anchor = AnchorType.BottomStretch;
                    artistLabel.Pivot  = PivotType.Bottom;
                    artistLabel.Y      = 8f;
                    artistLabel.Height = 24f;
                    artistLabel.SetOffsetHorizontal(20f);
                    artistLabel.WrapText  = true;
                    artistLabel.Alignment = TextAnchor.MiddleLeft;
                    artistLabel.FontSize  = 18;

                    artistShadow             = artistLabel.AddEffect(new ShadowEffect()).Component;
                    artistShadow.style       = ShadowStyle.Shadow;
                    artistShadow.effectColor = Color.black;
                    artistShadow.enabled     = false;
                }
                creatorLabel = container.CreateChild <Label>("creator");
                {
                    creatorLabel.Anchor = AnchorType.BottomStretch;
                    creatorLabel.Pivot  = PivotType.Bottom;
                    creatorLabel.Y      = 8f;
                    creatorLabel.Height = 24f;
                    creatorLabel.SetOffsetHorizontal(20f);
                    creatorLabel.WrapText  = true;
                    creatorLabel.Alignment = TextAnchor.MiddleRight;
                    creatorLabel.FontSize  = 18;

                    creatorShadow             = creatorLabel.AddEffect(new ShadowEffect()).Component;
                    creatorShadow.style       = ShadowStyle.Shadow;
                    creatorShadow.effectColor = Color.black;
                    creatorShadow.enabled     = false;
                }
                mapTagGrid = container.CreateChild <UguiGrid>("map-tag-grid");
                {
                    mapTagGrid.Anchor = AnchorType.TopStretch;
                    mapTagGrid.Pivot  = PivotType.Top;
                    mapTagGrid.Y      = -8f;
                    mapTagGrid.Height = MapTagCellSize.y;
                    mapTagGrid.SetOffsetHorizontal(20f);
                    mapTagGrid.Alignment  = TextAnchor.MiddleRight;
                    mapTagGrid.Axis       = GridLayoutGroup.Axis.Horizontal;
                    mapTagGrid.SpaceWidth = 8f;
                    mapTagGrid.CellSize   = MapTagCellSize;
                    mapTagGrid.Limit      = 0;
                }
            }

            backgroundAgent = new CacherAgent <IMap, IMapBackground>(BackgroundCacher)
            {
                UseDelayedRemove = true,
                RemoveDelay      = 2f
            };
            backgroundAgent.OnFinished += OnBackgroundLoaded;

            OnEnableInited();
        }
        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();
            }
        }
Пример #4
0
        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();
        }
Пример #5
0
        private void Init()
        {
            background = CreateChild <UguiSprite>("background", 1);
            {
                background.Anchor = AnchorType.Fill;
                background.Offset = Offset.Zero;
                background.Color  = ColorPreset.Background;
            }
            mask = CreateChild <UguiSprite>("mask", 3);
            {
                mask.Anchor     = AnchorType.Fill;
                mask.RawSize    = Vector2.zero;
                mask.Position   = Vector2.zero;
                mask.SpriteName = "box";

                var maskEffect = mask.AddEffect(new MaskEffect());
                maskEffect.Component.showMaskGraphic = false;

                loggedInView = mask.CreateChild <LoggedInView>("logged-in", 0);
                {
                    loggedInView.Anchor = AnchorType.Fill;
                    loggedInView.Offset = Offset.Zero;
                }
                loggedOutView = mask.CreateChild <LoggedOutView>("logged-out", 0);
                {
                    loggedOutView.Anchor = AnchorType.Fill;
                    loggedOutView.Offset = Offset.Zero;

                    loggedOutView.CurLoginView.OnNewValue += OnLoginProviderViewChange;
                }
            }
            blocker = CreateChild <Blocker>("blocker", 4);

            loggedInAni = new Anime();
            loggedInAni.AnimateFloat(alpha => loggedInView.Alpha = alpha)
            .AddTime(0f, () => loggedInView.Alpha)
            .AddTime(0.25f, 1f)
            .Build();
            loggedInAni.AnimateFloat(alpha => loggedOutView.Alpha = alpha)
            .AddTime(0f, () => loggedOutView.Alpha)
            .AddTime(0.25f, 0f)
            .Build();
            loggedInAni.AnimateFloat(height => this.Height = height)
            .AddTime(0f, () => this.Height)
            .AddTime(0.25f, LoggedInHeight)
            .Build();
            loggedInAni.AddEvent(0f, () => loggedInView.Active = blocker.Active = true);
            loggedInAni.AddEvent(loggedInAni.Duration, () => loggedOutView.Active = blocker.Active = false);

            loggedOutAni = new Anime();
            loggedOutAni.AnimateFloat(alpha => loggedInView.Alpha = alpha)
            .AddTime(0f, () => loggedInView.Alpha)
            .AddTime(0.25f, 0f)
            .Build();
            loggedOutAni.AnimateFloat(alpha => loggedOutView.Alpha = alpha)
            .AddTime(0f, () => loggedOutView.Alpha)
            .AddTime(0.25f, 1f)
            .Build();
            loggedOutAni.AnimateFloat(height => this.Height = height)
            .AddTime(0f, () => this.Height)
            .AddTime(0.25f, () => loggedOutView.DesiredHeight)
            .Build();
            loggedOutAni.AddEvent(0f, () => loggedOutView.Active = blocker.Active = true);
            loggedOutAni.AddEvent(loggedInAni.Duration, () => loggedInView.Active = blocker.Active = false);

            OnEnableInited();
        }
        private void Init(IColorPreset colorPreset)
        {
            container.Anchor = AnchorType.TopRight;
            container.Pivot  = PivotType.TopRight;
            container.X      = -16f;
            container.Y      = -16f;
            container.Width  = 400f;
            container.Height = 140f;

            mask = container.CreateChild <UguiSprite>("mask", 0);
            {
                mask.Anchor     = AnchorType.Fill;
                mask.RawSize    = Vector2.zero;
                mask.Position   = Vector2.zero;
                mask.SpriteName = "box";
                mask.Color      = Color.black;

                imageDisplay = mask.CreateChild <MapImageDisplay>("imageDisplay", 0);
                {
                    imageDisplay.Anchor  = AnchorType.Fill;
                    imageDisplay.RawSize = Vector2.zero;
                }
                gradient = mask.CreateChild <UguiSprite>("gradient", 1);
                {
                    gradient.Anchor     = AnchorType.Fill;
                    gradient.Offset     = new Offset(0f, -22f, 0f, 0f);
                    gradient.SpriteName = "gradation-bottom";
                    gradient.Color      = new Color(0f, 0f, 0f, 0.9f);
                }
                title = mask.CreateChild <Label>("title", 2);
                {
                    title.Anchor = AnchorType.BottomStretch;
                    title.SetOffsetHorizontal(16f);
                    title.Y        = 92f;
                    title.Height   = 30f;
                    title.IsBold   = true;
                    title.WrapText = true;
                    title.FontSize = 18;
                }
                artist = mask.CreateChild <Label>("artist", 3);
                {
                    artist.Anchor = AnchorType.BottomStretch;
                    artist.SetOffsetHorizontal(16f);
                    artist.Y        = 70f;
                    artist.Height   = 30f;
                    artist.WrapText = true;
                    artist.FontSize = 16;
                }
                randomButton = mask.CreateChild <ControlButton>("random", 4);
                {
                    randomButton.Anchor   = AnchorType.BottomLeft;
                    randomButton.X        = 36f;
                    randomButton.Y        = 36f;
                    randomButton.Size     = new Vector2(48f, 48f);
                    randomButton.IconName = "icon-random";
                    randomButton.IconSize = 24f;

                    randomButton.OnTriggered += model.RandomizeMusic;
                }
                prevButton = mask.CreateChild <ControlButton>("prev", 5);
                {
                    prevButton.Anchor   = AnchorType.Bottom;
                    prevButton.X        = -56f;
                    prevButton.Y        = 36f;
                    prevButton.Size     = new Vector2(48f, 48f);
                    prevButton.IconName = "icon-backward";
                    prevButton.IconSize = 24f;

                    prevButton.OnTriggered += model.PrevMusic;
                }
                playButton = mask.CreateChild <ControlButton>("play", 6);
                {
                    playButton.Anchor   = AnchorType.Bottom;
                    playButton.Y        = 36f;
                    playButton.Size     = new Vector2(48f, 48f);
                    playButton.IconName = "icon-play";
                    playButton.IconSize = 32f;

                    playButton.OnTriggered += model.TogglePlaying;
                }
                nextButton = mask.CreateChild <ControlButton>("next", 7);
                {
                    nextButton.Anchor   = AnchorType.Bottom;
                    nextButton.X        = 56f;
                    nextButton.Y        = 36f;
                    nextButton.Size     = new Vector2(48f, 48f);
                    nextButton.IconName = "icon-forward";
                    nextButton.IconSize = 24f;

                    nextButton.OnTriggered += model.NextMusic;
                }
                timeBar = mask.CreateChild <TimeBar>("timebar", 8);
                {
                    timeBar.Anchor = AnchorType.BottomStretch;
                    timeBar.Pivot  = PivotType.Bottom;
                    timeBar.SetOffsetHorizontal(0f);
                    timeBar.Y      = 0f;
                    timeBar.Height = 8f;
                }
            }

            OnEnableInited();
        }
Пример #7
0
        private void Init()
        {
            hoverSprite.Depth      = 1;
            hoverSprite.Anchor     = AnchorType.Fill;
            hoverSprite.RawSize    = new Vector2(28f, 30f);
            hoverSprite.Color      = Color.black;
            hoverSprite.SpriteName = "glow-parallel-64";
            hoverSprite.ImageType  = Image.Type.Sliced;
            hoverSprite.AddEffect(new FlipEffect()).Component.horizontal = true;

            mask = CreateChild <UguiSprite>("mask", 0);
            {
                mask.Anchor     = AnchorType.Fill;
                mask.RawSize    = Vector2.zero;
                mask.Color      = HexColor.Create("2A313A");
                mask.SpriteName = "parallel-64";
                mask.ImageType  = Image.Type.Sliced;

                mask.AddEffect(new MaskEffect());
                mask.AddEffect(new FlipEffect()).Component.horizontal = true;

                imageDisplay = mask.CreateChild <MapImageDisplay>("imageDisplay", 0);
                {
                    imageDisplay.Anchor  = AnchorType.Fill;
                    imageDisplay.RawSize = Vector2.zero;

                    imageGradient = imageDisplay.CreateChild <UguiSprite>("gradient", 100);
                    {
                        imageGradient.Anchor     = AnchorType.Fill;
                        imageGradient.RawSize    = Vector2.zero;
                        imageGradient.SpriteName = "gradation-left";
                        imageGradient.Color      = new Color(0f, 0f, 0f, 0.5f);
                    }
                }
                progressBar = mask.CreateChild <UguiProgressBar>("progress", 1);
                {
                    progressBar.Anchor = AnchorType.BottomStretch;
                    progressBar.Pivot  = PivotType.Bottom;
                    progressBar.SetOffsetHorizontal(22f, 0f);
                    progressBar.Height = 6f;
                    progressBar.Y      = 0f;

                    progressBar.Background.Color = new Color(0f, 0f, 0f, 0.5f);
                    progressBar.Foreground.SetOffsetTop(2f);
                }
                titleLabel = mask.CreateChild <Label>("title", 2);
                {
                    titleLabel.Anchor = AnchorType.TopStretch;
                    titleLabel.Pivot  = PivotType.Top;
                    titleLabel.SetOffsetHorizontal(20f, 32f);
                    titleLabel.Y         = -8f;
                    titleLabel.Height    = 30f;
                    titleLabel.IsBold    = true;
                    titleLabel.FontSize  = 22;
                    titleLabel.Alignment = TextAnchor.UpperLeft;
                    titleLabel.WrapText  = true;

                    var shadow = titleLabel.AddEffect(new ShadowEffect()).Component;
                    shadow.style          = ShadowStyle.Outline;
                    shadow.effectDistance = Vector2.one;
                    shadow.effectColor    = new Color(0f, 0f, 0f, 0.5f);
                }
                artistLabel = mask.CreateChild <Label>("artist", 3);
                {
                    artistLabel.Anchor = AnchorType.BottomStretch;
                    artistLabel.Pivot  = PivotType.Bottom;
                    artistLabel.SetOffsetHorizontal(32f, 20f);
                    artistLabel.Y         = 8f;
                    artistLabel.Height    = 30f;
                    artistLabel.Alignment = TextAnchor.LowerLeft;
                    artistLabel.WrapText  = true;

                    var shadow = artistLabel.AddEffect(new ShadowEffect()).Component;
                    shadow.style          = ShadowStyle.Outline;
                    shadow.effectDistance = Vector2.one;
                    shadow.effectColor    = new Color(0f, 0f, 0f, 0.5f);
                }
            }

            hoverInAni = new Anime();
            hoverInAni.AnimateColor(color => hoverSprite.Color = color)
            .AddTime(0f, () => hoverSprite.Color)
            .AddTime(0.25f, () => MapSelection.Background.Value.Highlight)
            .Build();
            hoverInAni.AnimateFloat(alpha => imageGradient.Alpha = alpha)
            .AddTime(0f, () => imageGradient.Alpha)
            .AddTime(0.25f, 0f)
            .Build();

            hoverOutAni = new Anime();
            hoverOutAni.AnimateColor(color => hoverSprite.Color = color)
            .AddTime(0f, () => hoverSprite.Color)
            .AddTime(0.25f, Color.black)
            .Build();
            hoverOutAni.AnimateFloat(alpha => imageGradient.Alpha = alpha)
            .AddTime(0f, () => imageGradient.Alpha)
            .AddTime(0.25f, 0.5f)
            .Build();

            OnEnableInited();
        }