Example #1
0
        /// <summary>
        /// Sets whether dragger is holding.
        /// </summary>
        public void SetHold(bool holding, float curTime)
        {
            if (this.isHolding == holding)
            {
                return;
            }
            // Show visual change only if there is currently a valid result for this hit object.
            if (!IsJudged)
            {
                return;
            }

            // Held down
            if (holding && !wasHolding)
            {
                isHolding = true;

                releaseAni.Stop();
                holdAni.PlayFromStart();
            }
            // Released
            else if (!holding && wasHolding)
            {
                isHolding   = false;
                releaseTime = curTime;

                if (!draggerView.IsFullyJudged)
                {
                    holdAni.Stop();
                    releaseAni.PlayFromStart();
                }
            }

            wasHolding = isHolding;
        }
        /// <summary>
        /// Shows this effect at specified position.
        /// </summary>
        public void Show(Vector3 worldPos, Color tint)
        {
            myTransform.position = worldPos;
            this.Tint            = tint;

            anime.PlayFromStart();
        }
        private void Init()
        {
            glowSprite = CreateChild <UguiSprite>("glow");
            {
                glowSprite.Size            = new Vector2(BaseSize + GlowSizeOffset, BaseSize + GlowSizeOffset);
                glowSprite.SpriteName      = "glow-square-32";
                glowSprite.ImageType       = Image.Type.Sliced;
                glowSprite.Color           = ColorPreset.SecondaryFocus;
                glowSprite.RotationZ       = 45f;
                glowSprite.IsRaycastTarget = false;
            }
            fillSprite = CreateChild <UguiSprite>("fill");
            {
                fillSprite.Anchor          = AnchorType.Fill;
                fillSprite.Offset          = Offset.Zero;
                fillSprite.Color           = ColorPreset.SecondaryFocus;
                fillSprite.RotationZ       = 45f;
                fillSprite.IsRaycastTarget = false;

                fillSprite.AddEffect(new AdditiveShaderEffect());
            }

            showAni = new Anime();
            showAni.AnimateFloat((alpha) => glowSprite.Alpha = alpha)
            .AddTime(0f, 0f)
            .AddTime(0.05f, 0f, EaseType.QuadEaseOut)
            .AddTime(0.15f, 1f)
            .Build();
            showAni.AnimateFloat((alpha) => fillSprite.Alpha = alpha)
            .AddTime(0f, 0.85f, EaseType.QuadEaseOut)
            .AddTime(0.15f, 0.25f)
            .Build();
            showAni.AnimateVector2((size) => fillSprite.Size = size)
            .AddTime(0f, new Vector2(BaseSize + ShowShrinkSize, BaseSize + ShowShrinkSize), EaseType.CubicEaseOut)
            .AddTime(0.15f, new Vector2(BaseSize, BaseSize))
            .Build();
            showAni.AddEvent(showAni.Duration, () => repeatAni.PlayFromStart());

            hideAni = new Anime();
            hideAni.AddEvent(0f, () => repeatAni.Pause());
            hideAni.AnimateFloat((alpha) => glowSprite.Alpha = alpha)
            .AddTime(0f, () => glowSprite.Alpha)
            .AddTime(0.25f, 0f)
            .Build();
            hideAni.AnimateFloat((alpha) => fillSprite.Alpha = alpha)
            .AddTime(0f, () => fillSprite.Alpha)
            .AddTime(0.25f, 0f)
            .Build();
            hideAni.AddEvent(hideAni.Duration, () => Recycler.Return(this));

            repeatAni = new Anime()
            {
                WrapMode = WrapModeType.Loop,
            };
            repeatAni.AnimateFloat((alpha) => fillSprite.Alpha = alpha)
            .AddTime(0f, 0.25f, EaseType.QuadEaseOut)
            .AddTime(0.4f, 0.75f, EaseType.QuadEaseIn)
            .AddTime(0.8f, 0.25f)
            .Build();
        }
Example #4
0
 /// <summary>
 /// Hides the combo label immediately.
 /// </summary>
 public void Hide()
 {
     if (comboAni.IsPlaying)
     {
         comboAni.Stop();
     }
     hideAni.PlayFromStart();
 }
        protected override void OnPointerExited()
        {
            base.OnPointerExited();

            if (hoverOutAni != null)
            {
                hoverOutAni.PlayFromStart();
            }
        }
Example #6
0
        protected override void OnEnableInited()
        {
            base.OnEnableInited();

            model.OnLoadSucceed += OnLoadSucceed;
            model.OnLoadFail    += OnLoadFail;

            componentShowAni.PlayFromStart();
        }
Example #7
0
 /// <summary>
 /// Event called when the game loading has succeeded.
 /// </summary>
 private void OnLoadSucceed()
 {
     // If the hide animation is playing, the player must've navigated out before this was executed.
     if (HideAnime.IsPlaying)
     {
         return;
     }
     componentHideAni.PlayFromStart();
 }
Example #8
0
 private void SwitchView(bool isLoggedIn, bool animate = true)
 {
     // No animation
     if (!animate)
     {
         if (isLoggedIn)
         {
             Height               = LoggedInHeight;
             loggedInView.Alpha   = 1f;
             loggedInView.Active  = true;
             loggedOutView.Alpha  = 0f;
             loggedOutView.Active = false;
         }
         else
         {
             Height               = loggedOutView.DesiredHeight;
             loggedInView.Alpha   = 0f;
             loggedInView.Active  = false;
             loggedOutView.Alpha  = 1f;
             loggedOutView.Active = true;
         }
         blocker.Active = false;
     }
     // Animate
     else
     {
         if (isLoggedIn)
         {
             if (!loggedInView.Active)
             {
                 loggedOutAni.Stop();
                 loggedInAni.PlayFromStart();
             }
         }
         else
         {
             if (!loggedOutView.Active)
             {
                 loggedInAni.Stop();
                 loggedOutAni.PlayFromStart();
             }
         }
     }
 }
        /// <summary>
        /// Forcefully hides the touch effect while disintegrating with the current cursor.
        /// </summary>
        public void Hide()
        {
            UnbindCursor();

            if (Active)
            {
                showAni?.Pause();
                hideAni?.PlayFromStart();
            }
        }
        /// <summary>
        /// Shows the touch effect for the specified cursor.
        /// </summary>
        public void Show(ICursor cursor, IInputResultReporter resultReporter)
        {
            UnbindCursor();
            BindCursor(cursor, resultReporter);

            // Set initial position.
            Position = cursor.Position;

            showAni?.PlayFromStart();
        }
Example #11
0
        /// <summary>
        /// Closes this dropdown menu.
        /// </summary>
        public void CloseMenu()
        {
            if (!Active || IsAnimating)
            {
                return;
            }

            listContainer.TotalItems = 0;
            context = null;

            hideAni.PlayFromStart();
        }
 /// <summary>
 /// Event called when the triggered state is changed.
 /// </summary>
 private void OnTriggeredChange(bool isTriggered)
 {
     if (isTriggered)
     {
         hideAni.Stop();
         showAni.PlayFromStart();
     }
     else
     {
         showAni.Stop();
         hideAni.PlayFromStart();
     }
 }
 /// <summary>
 /// Event called when the detailed information display mode is changed.
 /// </summary>
 private void OnDetailedModeChange(bool isDetailed)
 {
     if (isDetailed)
     {
         infoBriefAni.Stop();
         infoDetailAni.PlayFromStart();
     }
     else
     {
         infoDetailAni.Stop();
         infoBriefAni.PlayFromStart();
     }
 }
Example #14
0
        /// <summary>
        /// Shows the combo change animation with the specified combo value.
        /// </summary>
        public void Show(int combo)
        {
            if (hideAni.IsPlaying)
            {
                hideAni.Stop();
            }

            string comboString = combo.ToString("N0");;

            effectComboLabel.Text  = comboString;
            persistComboLabel.Text = comboString;
            comboAni.PlayFromStart();
        }
 /// <summary>
 /// Sets hit bar sprite's visual state for specified flag.
 /// </summary>
 public void SetHold(bool isHolding)
 {
     if (isHolding)
     {
         releaseAni.Stop();
         holdAni.PlayFromStart();
     }
     else
     {
         holdAni.Stop();
         releaseAni.PlayFromStart();
     }
 }
 /// <summary>
 /// Event called on records retrieving flag change.
 /// </summary>
 private void OnRetrievingRecordsChange(bool isRetrieving)
 {
     if (isRetrieving)
     {
         loadHideAni.Pause();
         loadShowAni.PlayFromStart();
     }
     else
     {
         loadShowAni.Pause();
         loadHideAni.PlayFromStart();
     }
 }
        public override JudgementResult SetResult(HitResultType hitResult, float offset)
        {
            var judgement = base.SetResult(hitResult, offset);

            if (judgement.IsHit)
            {
                hitAni.PlayFromStart();
            }
            else
            {
                Active = false;
            }
            return(judgement);
        }
Example #18
0
        /// <summary>
        /// Adjusts display component positions based on menubar existence.
        /// </summary>
        private void AdjustForMenubar(bool hasMenubar)
        {
            menubarShowAni.Stop();
            menubarHideAni.Stop();

            if (hasMenubar)
            {
                menubarShowAni.PlayFromStart();
            }
            else
            {
                menubarHideAni.PlayFromStart();
            }
        }
Example #19
0
        /// <summary>
        /// Event called on songs list scrolled down.
        /// </summary>
        private void OnScrolledDown(bool isScrolledDown)
        {
            scrollButtonShowAni.Stop();
            scrollButtonHideAni.Stop();

            if (isScrolledDown)
            {
                scrollButtonShowAni.PlayFromStart();
            }
            else
            {
                scrollButtonHideAni.PlayFromStart();
            }
        }
Example #20
0
 protected override void OnUnfocusAniPlay(bool animate)
 {
     base.OnUnfocusAniPlay(animate);
     if (unhighlightAni != null)
     {
         if (animate)
         {
             unhighlightAni.PlayFromStart();
         }
         else
         {
             unhighlightAni.Seek(unhighlightAni.Duration);
         }
     }
 }
Example #21
0
        /// <summary>
        /// Sets up the dropdown menu for specified context and makes the menu visible.
        /// </summary>
        public void OpenMenu(DropdownContext context)
        {
            if (Active || IsAnimating)
            {
                return;
            }

            this.context = context;

            // Clamp menu height so it doesn't go over half of screen height.
            holder.Height = Mathf.Min(ItemSize.y * context.Datas.Count, GetMaxHolderHeight());

            listContainer.TotalItems = context.Datas.Count;

            showAni.PlayFromStart();
        }
Example #22
0
        /// <summary>
        /// Displays label values based on current state.
        /// </summary>
        private void SetupLabels()
        {
            var  map           = Model.SelectedMap.Value;
            bool preferUnicode = Model.PreferUnicode.Value;

            if (map == null)
            {
                title.Text = artist.Text = creator.Text = "";
            }
            else
            {
                title.Text  = map.Metadata.GetTitle(preferUnicode);
                artist.Text = map.Metadata.GetArtist(preferUnicode);
            }
            creator.Text = $"mapped by {map.Metadata.Creator}";
            fadeAni.PlayFromStart();
        }
Example #23
0
        public void ToggleDisplay(bool enable)
        {
            if ((enable && showAni.IsPlaying) ||
                (!enable && hideAni.IsPlaying))
            {
                return;
            }

            showAni.Stop();
            hideAni.Stop();

            if (enable)
            {
                showAni.PlayFromStart();
            }
            else
            {
                hideAni.PlayFromStart();
            }
        }
Example #24
0
        private void Init(IColorPreset colorPreset)
        {
            OnPointerDown += () =>
            {
                isControlling = true;

                upAni.Stop();
                downAni.PlayFromStart();
            };
            OnPointerUp += () =>
            {
                isControlling = false;

                downAni.Stop();
                upAni.PlayFromStart();
            };
            OnChange += (value) =>
            {
                var audio = MusicController.Audio;
                if (isControlling && audio != null)
                {
                    MusicController.Seek(value * audio.Duration);
                }
            };

            background.Color = Color.black;
            foreground.Color = colorPreset.SecondaryFocus;
            thumb.Active     = false;

            downAni = new Anime();
            downAni.AnimateFloat(y => ScaleY = y)
            .AddTime(0f, () => ScaleY)
            .AddTime(0.25f, 2f)
            .Build();

            upAni = new Anime();
            upAni.AnimateFloat(y => ScaleY = y)
            .AddTime(0f, () => ScaleY)
            .AddTime(0.25f, 1f)
            .Build();
        }
Example #25
0
        /// <summary>
        /// Sets folded state on the menu.
        /// </summary>
        public void SetFold(bool isFolded)
        {
            if (this.isFolded == isFolded)
            {
                return;
            }

            this.isFolded = isFolded;

            foldAni.Stop();
            unfoldAni.Stop();

            if (isFolded)
            {
                foldAni.PlayFromStart();
            }
            else
            {
                unfoldAni.PlayFromStart();
            }
        }
        /// <summary>
        /// Event called on health change.
        /// </summary>
        private void OnHealthChange(float health, float prevHealth)
        {
            // Change overall color theme of the bar based on health state.
            SetFailing(scoreProcessor.IsFailed);

            if (health < prevHealth)
            {
                barTintFromColor = barDecColor;
            }
            else
            {
                // Show pin ani only on incremental change.
                pinAni.PlayFromStart();

                barTintFromColor = barIncColor;
            }

            // Animate health change
            curHealth = health;
            changeAni.PlayFromStart();
        }
        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();
            }
        }
Example #28
0
 public void Hide() => hideAni.PlayFromStart();
 /// <summary>
 /// Plays the logo hide animation.
 /// </summary>
 public void PlayEnd()
 {
     startupAnime.Stop();
     breatheAnime.Stop();
     endAnime.PlayFromStart();
 }
 /// <summary>
 /// Plays the initial logo animation.
 /// </summary>
 public void PlayStartup()
 {
     breatheAnime.Stop();
     endAnime.Stop();
     startupAnime.PlayFromStart();
 }