Пример #1
0
 static public int ElasticOut_s(IntPtr l)
 {
     try {
                     #if DEBUG
         var    method     = System.Reflection.MethodBase.GetCurrentMethod();
         string methodName = GetMethodName(method);
                     #if UNITY_5_5_OR_NEWER
         UnityEngine.Profiling.Profiler.BeginSample(methodName);
                     #else
         Profiler.BeginSample(methodName);
                     #endif
                     #endif
         System.Single a1;
         checkType(l, 1, out a1);
         var ret = Ease.ElasticOut(a1);
         pushValue(l, true);
         pushValue(l, ret);
         return(2);
     }
     catch (Exception e) {
         return(error(l, e));
     }
             #if DEBUG
     finally {
                     #if UNITY_5_5_OR_NEWER
         UnityEngine.Profiling.Profiler.EndSample();
                     #else
         Profiler.EndSample();
                     #endif
     }
             #endif
 }
Пример #2
0
        public override void Render()
        {
            base.Render();

            string[] emotes = GhostNetModule.Settings.EmoteFavs;

            // Update can halt in the pause menu.

            if (Shown)
            {
                Angle = GhostNetModule.Instance.JoystickEmoteWheel.Value.Angle();
                float angle = (float)((Angle + Math.PI * 2f) % (Math.PI * 2f));
                float start = (-0.5f / emotes.Length) * 2f * (float)Math.PI;
                if (2f * (float)Math.PI + start < angle)
                {
                    // Angle should be start < angle < 0, but is (TAU + start) < angle < TAU
                    angle -= 2f * (float)Math.PI;
                }
                for (int i = 0; i < emotes.Length; i++)
                {
                    float min = ((i - 0.5f) / emotes.Length) * 2f * (float)Math.PI;
                    float max = ((i + 0.5f) / emotes.Length) * 2f * (float)Math.PI;
                    if (min <= angle && angle <= max)
                    {
                        Selected = i;
                        break;
                    }
                }
            }

            time += Engine.RawDeltaTime;

            if (!Shown)
            {
                Selected = -1;
            }
            selectedTime += Engine.RawDeltaTime;
            if (PrevSelected != Selected)
            {
                selectedTime = 0f;
                PrevSelected = Selected;
            }

            float popupAlpha;
            float popupScale;

            popupTime += Engine.RawDeltaTime;
            if (Shown && !popupShown)
            {
                popupTime = 0f;
            }
            else if ((Shown && popupTime > 1f) ||
                     (!Shown && popupTime < 1f))
            {
                popupTime = 1f;
            }
            popupShown = Shown;

            if (popupTime < 0.1f)
            {
                float t = popupTime / 0.1f;
                // Pop in.
                popupAlpha = Ease.CubeOut(t);
                popupScale = Ease.ElasticOut(t);
            }
            else if (popupTime < 1f)
            {
                // Stay.
                popupAlpha = 1f;
                popupScale = 1f;
            }
            else
            {
                float t = (popupTime - 1f) / 0.2f;
                // Fade out.
                popupAlpha = 1f - Ease.CubeIn(t);
                popupScale = 1f - 0.2f * Ease.CubeIn(t);
            }

            float alpha = Alpha * popupAlpha;

            if (alpha <= 0f)
            {
                return;
            }

            if (Tracking == null)
            {
                return;
            }

            Level level = SceneAs <Level>();

            if (level == null)
            {
                return;
            }

            if (Camera == null)
            {
                Camera = level.Camera;
            }
            if (Camera == null)
            {
                return;
            }

            Vector2 pos = Tracking.Position;

            pos.Y -= 8f;

            pos -= level.Camera.Position;
            pos *= 6f; // 1920 / 320

            float radius = BG.Width * 0.5f * 0.75f * popupScale;

            pos = pos.Clamp(
                0f + radius, 0f + radius,
                1920f - radius, 1080f - radius
                );

            // Draw.Circle(pos, radius, Color.Black * 0.8f * alpha * alpha, radius * 0.6f * (1f + 0.2f * (float) Math.Sin(time)), 8);
            BG.DrawCentered(
                pos,
                Color.White * alpha * alpha * alpha,
                Vector2.One * popupScale
                );

            Indicator.DrawCentered(
                pos,
                Color.White * alpha * alpha * alpha,
                Vector2.One * popupScale,
                Angle
                );

            float selectedScale = 1.2f - 0.2f * Calc.Clamp(Ease.CubeOut(selectedTime / 0.1f), 0f, 1f) + (float)Math.Sin(time * 1.8f) * 0.05f;

            for (int i = 0; i < emotes.Length; i++)
            {
                Line.DrawCentered(
                    pos,
                    Color.White * alpha * alpha * alpha,
                    Vector2.One * popupScale,
                    ((i + 0.5f) / emotes.Length) * 2f * (float)Math.PI
                    );

                string emote = emotes[i];
                if (string.IsNullOrEmpty(emote))
                {
                    continue;
                }

                float   a        = (i / (float)emotes.Length) * 2f * (float)Math.PI;
                Vector2 emotePos = pos + new Vector2(
                    (float)Math.Cos(a),
                    (float)Math.Sin(a)
                    ) * radius;

                if (GhostNetEmote.IsIcon(emote))
                {
                    MTexture icon = GhostNetEmote.GetIcon(emote, Selected == i ? selectedTime : 0f);
                    if (icon == null)
                    {
                        continue;
                    }

                    Vector2 iconSize  = new Vector2(icon.Width, icon.Height);
                    float   iconScale = (GhostNetEmote.Size / Math.Max(iconSize.X, iconSize.Y)) * 0.24f * popupScale;

                    icon.DrawCentered(
                        emotePos,
                        Color.White * (Selected == i ? (Calc.BetweenInterval(selectedTime, 0.1f) ? 0.9f : 1f) : 0.7f) * alpha,
                        Vector2.One * (Selected == i ? selectedScale : 1f) * iconScale
                        );
                }
                else
                {
                    Vector2 textSize  = ActiveFont.Measure(emote);
                    float   textScale = (GhostNetEmote.Size / Math.Max(textSize.X, textSize.Y)) * 0.24f * popupScale;

                    ActiveFont.DrawOutline(
                        emote,
                        emotePos,
                        new Vector2(0.5f, 0.5f),
                        Vector2.One * (Selected == i ? selectedScale : 1f) * textScale,
                        (Selected == i ? (Calc.BetweenInterval(selectedTime, 0.1f) ? TextSelectColorA : TextSelectColorB) : Color.LightSlateGray) * alpha,
                        2f,
                        Color.Black * alpha * alpha * alpha
                        );
                }
            }
        }
Пример #3
0
        public override void Render()
        {
            base.Render();

            float popupAlpha = 1f;
            float popupScale = 1f;

            if (Tracking?.Scene != Scene)
            {
                PopOut = true;
            }

            // Update can halt in the pause menu.
            if (PopIn || FadeOut || PopOut)
            {
                AnimationTime += Engine.RawDeltaTime;
                if (AnimationTime < 0.1f && PopIn)
                {
                    float t = AnimationTime / 0.1f;
                    // Pop in.
                    popupAlpha = Ease.CubeOut(t);
                    popupScale = Ease.ElasticOut(t);
                }
                else if (AnimationTime < 1f)
                {
                    // Stay.
                    popupAlpha = 1f;
                    popupScale = 1f;
                }
                else if (FadeOut)
                {
                    // Fade out.
                    if (AnimationTime < 2f)
                    {
                        float t = AnimationTime - 1f;
                        popupAlpha = 1f - Ease.CubeIn(t);
                        popupScale = 1f - 0.4f * Ease.CubeIn(t);
                    }
                    else
                    {
                        // Destroy.
                        RemoveSelf();
                        return;
                    }
                }
                else if (PopOut)
                {
                    // Pop out.
                    if (AnimationTime < 1.1f)
                    {
                        float t = (AnimationTime - 1f) / 0.1f;
                        popupAlpha  = 1f - Ease.CubeIn(t);
                        popupAlpha *= popupAlpha;
                        popupScale  = 1f - 0.4f * Ease.BounceIn(t);
                    }
                    else
                    {
                        // Destroy.
                        RemoveSelf();
                        return;
                    }
                }
                else
                {
                    AnimationTime = 1f;
                }
            }

            time += Engine.RawDeltaTime;

            MTexture icon = null;
            string   text = null;

            if (IsIcon(Value))
            {
                icon = GetIcon(Value, time);
            }
            else
            {
                text = Value;
            }

            float alpha = Alpha * popupAlpha;

            if (alpha <= 0f || (icon == null && string.IsNullOrWhiteSpace(text)))
            {
                return;
            }

            if (Tracking == null)
            {
                return;
            }

            Level level = SceneAs <Level>();

            if (level == null)
            {
                return;
            }

            if (Camera == null)
            {
                Camera = level.Camera;
            }
            if (Camera == null)
            {
                return;
            }

            Vector2 pos = Tracking.Position;

            // - name offset - popup offset
            pos.Y -= 16f + 4f;

            pos -= level.Camera.Position;
            pos *= 6f; // 1920 / 320

            if (Float)
            {
                pos.Y -= (float)Math.Sin(time * 2f) * 4f;
            }

            if (icon != null)
            {
                Vector2 size  = new Vector2(icon.Width, icon.Height);
                float   scale = (Size / Math.Max(size.X, size.Y)) * 0.5f * popupScale;
                size *= scale;

                pos = pos.Clamp(
                    0f + size.X * 0.5f, 0f + size.Y * 1f,
                    1920f - size.X * 0.5f, 1080f
                    );

                icon.DrawJustified(
                    pos,
                    new Vector2(0.5f, 1f),
                    Color.White * alpha,
                    Vector2.One * scale
                    );
            }
            else
            {
                Vector2 size  = ActiveFont.Measure(text);
                float   scale = (Size / Math.Max(size.X, size.Y)) * 0.5f * popupScale;
                size *= scale;

                pos = pos.Clamp(
                    0f + size.X * 0.5f, 0f + size.Y * 1f,
                    1920f - size.X * 0.5f, 1080f
                    );

                ActiveFont.DrawOutline(
                    text,
                    pos,
                    new Vector2(0.5f, 1f),
                    Vector2.One * scale,
                    Color.White * alpha,
                    2f,
                    Color.Black * alpha * alpha * alpha
                    );
            }
        }