Пример #1
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
                    );
            }
        }
Пример #2
0
 public override void Render()
 {
     Draw.Rect(-10f, -10f, 1940f, 1100f, Color.Black * Ease.CubeOut(Alpha));
     RenderTextMenu();
     if (remappingEase > 0f)
     {
         Draw.Rect(-10f, -10f, 1940f, 1100f, Color.Black * 0.95f * Ease.CubeInOut(remappingEase));
         Vector2 value = new Vector2(1920f, 1080f) * 0.5f;
         ActiveFont.Draw(additiveRemap ? Dialog.Get("KEY_CONFIG_ADDING") : Dialog.Get("KEY_CONFIG_CHANGING"), value + new Vector2(0f, -8f), new Vector2(0.5f, 1f), Vector2.One * 0.7f, Color.LightGray * Ease.CubeIn(remappingEase));
         ActiveFont.Draw(Label(remappingKey), value + new Vector2(0f, 8f), new Vector2(0.5f, 0f), Vector2.One * 2f, Color.White * Ease.CubeIn(remappingEase));
     }
 }
Пример #3
0
        public override IEnumerator Enter(Oui from)
        {
            TextInput.OnInput += OnTextInput;

            Overworld.ShowInputUI = false;

            selectingOptions = false;
            optionsIndex     = 0;
            index            = 0;
            line             = 0;

            string letterChars = Dialog.Clean("name_letters");

            letters = letterChars.Split('\n');

            foreach (char c in letterChars)
            {
                float width = ActiveFont.Measure(c).X;
                if (width > widestLetter)
                {
                    widestLetter = width;
                }
            }

            widestLineCount = 0;
            foreach (string letter in letters)
            {
                if (letter.Length > widestLineCount)
                {
                    widestLineCount = letter.Length;
                }
            }

            widestLine  = widestLineCount * widestLetter;
            letterChars = null;

            lineHeight     = ActiveFont.LineHeight;
            lineSpacing    = ActiveFont.LineHeight * 0.1f;
            boxPadding     = widestLetter;
            optionsScale   = 0.75f;
            cancel         = Dialog.Clean("name_back");
            space          = Dialog.Clean("name_space");
            backspace      = Dialog.Clean("name_backspace");
            accept         = Dialog.Clean("name_accept");
            cancelWidth    = ActiveFont.Measure(cancel).X *optionsScale;
            spaceWidth     = ActiveFont.Measure(space).X *optionsScale;
            backspaceWidth = ActiveFont.Measure(backspace).X *optionsScale;
            beginWidth     = ActiveFont.Measure(accept).X *optionsScale;
            optionsWidth   = cancelWidth + spaceWidth + backspaceWidth + beginWidth + widestLetter * 3f;
            boxWidth       = Math.Max(widestLine, optionsWidth) + boxPadding * 2f;
            boxHeight      = (letters.Length + 1f) * lineHeight + letters.Length * lineSpacing + boxPadding * 3f;

            Visible = true;

            Vector2 posFrom = Position;
            Vector2 posTo   = Vector2.Zero;

            for (float t = 0f; t < 1f; t += Engine.DeltaTime * 2f)
            {
                ease     = Ease.CubeIn(t);
                Position = posFrom + (posTo - posFrom) * Ease.CubeInOut(t);
                yield return(null);
            }
            ease    = 1f;
            posFrom = Vector2.Zero;
            posTo   = Vector2.Zero;

            yield return(0.2f);

            Focused = true;

            yield return(0.2f);

            wiggler.Start();
        }
Пример #4
0
        private void Render(On.Celeste.SpeedrunTimerDisplay.orig_Render orig, SpeedrunTimerDisplay self)
        {
            SpeedrunToolSettings settings = SpeedrunToolModule.Settings;

            if (!settings.Enabled || settings.RoomTimerType == RoomTimerType.Off || self.DrawLerp <= 0f)
            {
                orig(self);
                return;
            }

            RoomTimerType roomTimeType  = SpeedrunToolModule.Settings.RoomTimerType;
            RoomTimerData roomTimerData = roomTimeType == RoomTimerType.NextRoom ? nextRoomTimerData : currentRoomTimerData;

            string roomTimeString = roomTimerData.TimeString;
            string pbTimeString   = roomTimerData.PbTimeString;

            pbTimeString = "PB " + pbTimeString;

            const float topBlackBarWidth = 32f;
            const float topTimeHeight    = 38f;
            const float pbWidth          = 100;
            const float timeMarginLeft   = 32f;
            const float pbScale          = 0.6f;

            MTexture bg = GFX.Gui["strawberryCountBG"];
            float    x  = -300f * Ease.CubeIn(1f - self.DrawLerp);

            Draw.Rect(x, self.Y, topBlackBarWidth + 2, topTimeHeight, Color.Black);
            bg.Draw(new Vector2(x + topBlackBarWidth, self.Y));

            float roomTimeScale = 1f;

            if (roomTimerData.IsCompleted)
            {
                Wiggler wiggler = (Wiggler)self.GetFieldValue("wiggler");
                if (wiggler != null)
                {
                    roomTimeScale = 1f + wiggler.Value * 0.15f;
                }
            }

            SpeedrunTimerDisplay.DrawTime(new Vector2(x + timeMarginLeft, self.Y + 44f), roomTimeString, roomTimeScale,
                                          true,
                                          roomTimerData.IsCompleted, roomTimerData.BeatBestTime);

            if (roomTimerData.IsCompleted)
            {
                string comparePbString = ComparePb(roomTimerData.Time, roomTimerData.LastPbTime);
                DrawTime(
                    new Vector2(x + timeMarginLeft + SpeedrunTimerDisplay.GetTimeWidth(roomTimeString) + 10,
                                self.Y + 36f),
                    comparePbString, 0.5f,
                    roomTimerData.IsCompleted, roomTimerData.BeatBestTime);
            }

            // 遮住上下两块的间隙,游戏原本的问题
            Draw.Rect(x, self.Y + topTimeHeight - 1, pbWidth + bg.Width * pbScale, 1f, Color.Black);

            Draw.Rect(x, self.Y + topTimeHeight, pbWidth + 2, bg.Height * pbScale + 1f, Color.Black);
            bg.Draw(new Vector2(x + pbWidth, self.Y + topTimeHeight), Vector2.Zero, Color.White, pbScale);
            DrawTime(new Vector2(x + timeMarginLeft, (float)(self.Y + 66.4)), pbTimeString, pbScale, false, false, 0.6f);
        }
Пример #5
0
        private IEnumerator CollectRoutine(Player player)
        {
            collecting = true;
            Level level = Scene as Level;
            CassetteBlockManager cbm = Scene.Tracker.GetEntity <CassetteBlockManager>();

            level.PauseLock = true;
            level.Frozen    = true;
            Tag             = Tags.FrozenUpdate;
            // TODO: attribute for setting this?
            level.Session.Cassette     = true;
            level.Session.RespawnPoint = level.GetSpawnPoint(nodes[1]);
            level.Session.UpdateLevelStartDashes();
            if (!string.IsNullOrEmpty(altSideToUnlock))
            {
                AltSidesHelperModule.AltSidesSaveData.UnlockedAltSideIDs.Add(altSideToUnlock);
            }
            cbm?.StopBlocks();
            Depth = -1000000;
            level.Shake();
            level.Flash(Color.White);
            level.Displacement.Clear();
            Vector2 camWas = level.Camera.Position;
            Vector2 camTo  = (Position - new Vector2(160f, 90f)).Clamp(level.Bounds.Left - 64, level.Bounds.Top - 32, level.Bounds.Right + 64 - 320, level.Bounds.Bottom + 32 - 180);

            level.Camera.Position = camTo;
            level.ZoomSnap((Position - level.Camera.Position).Clamp(60f, 60f, 260f, 120f), 2f);
            sprite.Play("spin", restart: true);
            sprite.Rate = 2f;
            for (float p3 = 0f; p3 < 1.5f; p3 += Engine.DeltaTime)
            {
                sprite.Rate += Engine.DeltaTime * 4f;
                yield return(null);
            }

            sprite.Rate = 0f;
            sprite.SetAnimationFrame(0);
            scaleWiggler.Start();
            yield return(0.25f);

            Vector2 from      = Position;
            Vector2 to        = new Vector2(X, level.Camera.Top - 16f);
            float   duration2 = 0.4f;

            for (float p3 = 0f; p3 < 1f; p3 += Engine.DeltaTime / duration2)
            {
                sprite.Scale.X = MathHelper.Lerp(1f, 0.1f, p3);
                sprite.Scale.Y = MathHelper.Lerp(1f, 3f, p3);
                Position       = Vector2.Lerp(from, to, Ease.CubeIn(p3));
                yield return(null);
            }

            Visible  = false;
            remixSfx = Audio.Play("event:/game/general/cassette_preview", "remix", level.Session.Area.ID);
            UnlockedAltSideCutscene message = new UnlockedAltSideCutscene(unlockText, menuSprite);

            Scene.Add(message);
            yield return(message.EaseIn());

            while (message.textIndex < message.text.Length)
            {
                while (!Input.MenuConfirm.Pressed)
                {
                    yield return(null);
                }
                if (message.textIndex != message.text.Length - 1)
                {
                    yield return(message.NextText());
                }
                else
                {
                    break;
                }
            }

            Audio.SetParameter(remixSfx, "end", 1f);
            yield return(message.EaseOut());

            duration2 = 0.25f;
            Add(new Coroutine(level.ZoomBack(duration2 - 0.05f)));
            for (float p3 = 0f; p3 < 1f; p3 += Engine.DeltaTime / duration2)
            {
                level.Camera.Position = Vector2.Lerp(camTo, camWas, Ease.SineInOut(p3));
                yield return(null);
            }

            if (!player.Dead && nodes != null && nodes.Length >= 2)
            {
                Audio.Play("event:/game/general/cassette_bubblereturn", level.Camera.Position + new Vector2(160f, 90f));
                player.StartCassetteFly(nodes[1], nodes[0]);
            }

            foreach (SandwichLava item in level.Entities.FindAll <SandwichLava>())
            {
                item.Leave();
            }

            level.Frozen = false;
            yield return(0.25f);

            cbm?.Finish();
            level.PauseLock = false;
            level.ResetZoom();
            RemoveSelf();
        }
Пример #6
0
        private static IEnumerator ChapterPanelSwapRoutine(OuiChapterPanel self, DynData <OuiChapterPanel> data)
        {
            float fromHeight = data.Get <float>("height");
            int   toHeight   = Dialog.Has(new DynData <Overworld>(overworldWrapper.WrappedScene).Get <AreaData>("collabInGameForcedArea").Name + "_collabcredits") ? 730 : 300;

            data["resizing"] = true;
            m_PlayExpandSfx.Invoke(self, new object[] { fromHeight, (float)toHeight });

            float offset = 800f;

            for (float p = 0f; p < 1f; p += Engine.DeltaTime * 4f)
            {
                yield return(null);

                data["contentOffset"] = new Vector2(440f + offset * Ease.CubeIn(p), data.Get <Vector2>("contentOffset").Y);
                data["height"]        = MathHelper.Lerp(fromHeight, toHeight, Ease.CubeOut(p * 0.5f));
            }

            data["selectingMode"] = false;

            IList checkpoints = data.Get <IList>("checkpoints");

            checkpoints.Clear();

            bool hasContinueOption = CollabModule.Instance.SaveData.SessionsPerLevel.ContainsKey(self.Area.GetSID());

            checkpoints.Add(DynamicData.New(t_OuiChapterPanelOption)(new {
                Label              = Dialog.Clean("overworld_start", null),
                BgColor            = Calc.HexToColor("eabe26"),
                Icon               = GFX.Gui["areaselect/startpoint"],
                CheckpointRotation = Calc.Random.Choose(-1, 1) * Calc.Random.Range(0.05f, 0.2f),
                CheckpointOffset   = new Vector2(Calc.Random.Range(-16, 16), Calc.Random.Range(-16, 16)),
                Large              = false,
                Siblings           = hasContinueOption ? 2 : 1
            }));

            if (hasContinueOption)
            {
                checkpoints.Add(DynamicData.New(t_OuiChapterPanelOption)(new {
                    Label = Dialog.Clean("file_continue", null),
                    Icon  = GFX.Gui["areaselect/checkpoint"],
                    CheckpointRotation = Calc.Random.Choose(-1, 1) * Calc.Random.Range(0.05f, 0.2f),
                    CheckpointOffset   = new Vector2(Calc.Random.Range(-16, 16), Calc.Random.Range(-16, 16)),
                    Large               = false,
                    Siblings            = 2,
                    CheckpointLevelName = "collabutils_continue"
                }));
            }

            data["option"] = 0;

            for (int i = 0; i < checkpoints.Count; i++)
            {
                new DynamicData(checkpoints[i]).Invoke("SlideTowards", i, checkpoints.Count, true);
            }

            new DynamicData(checkpoints[0]).Set("Pop", 1f);
            for (float p = 0f; p < 1f; p += Engine.DeltaTime * 4f)
            {
                yield return(null);

                data["height"]        = MathHelper.Lerp(fromHeight, toHeight, Ease.CubeOut(Math.Min(1f, 0.5f + p * 0.5f)));
                data["contentOffset"] = new Vector2(440f + offset * (1f - Ease.CubeOut(p)), data.Get <Vector2>("contentOffset").Y);
            }

            data["contentOffset"] = new Vector2(440f, data.Get <Vector2>("contentOffset").Y);
            data["height"]        = (float)toHeight;
            self.Focused          = true;
            data["resizing"]      = false;
        }
Пример #7
0
        private void startCombineAnimation(Image silverBerry, Vector2 centerPos, float time, ParticleSystem particleSystem)
        {
            Vector2 position   = silverBerry.Position;
            float   startAngle = Calc.Angle(centerPos, position);
            Tween   tween      = Tween.Create(Tween.TweenMode.Oneshot, Ease.BigBackIn, time, start: true);

            // the tween should pull the silver towards the center and rotate it at the same time.
            tween.OnUpdate = t => {
                float angleRadians = MathHelper.Lerp(startAngle, startAngle - (float)Math.PI * 2f, Ease.CubeIn(t.Percent));
                float length       = MathHelper.Lerp(25f, 0f, t.Eased);
                silverBerry.Position = centerPos + Calc.AngleToVector(angleRadians, length);
            };

            // when done, emit particles and make the seed disappear.
            tween.OnComplete = delegate {
                silverBerry.Visible = false;
                for (int i = 0; i < 6; i++)
                {
                    float particleDirection = Calc.Random.NextFloat((float)Math.PI * 2f);
                    particleSystem.Emit(StrawberrySeed.P_Burst, 1, silverBerry.Position + Calc.AngleToVector(particleDirection, 4f), Vector2.Zero, particleDirection);
                }
                silverBerry.RemoveSelf();
            };

            Add(tween);
        }
Пример #8
0
        public override void Render()
        {
            Draw.Rect(-10f, -10f, 1940f, 1100f, Color.Black * Ease.CubeOut(Alpha));
            Vector2 center = new Vector2(1920f, 1080f) * 0.5f;

            if (Input.GuiInputController())
            {
                RenderTextMenu();
                if (remappingEase > 0f)
                {
                    Draw.Rect(-10f, -10f, 1940f, 1100f, Color.Black * 0.95f * Ease.CubeInOut(remappingEase));
                    ActiveFont.Draw(Dialog.Get("BTN_CONFIG_CHANGING"), center + new Vector2(0f, -8f), new Vector2(0.5f, 1f), Vector2.One * 0.7f, Color.LightGray * Ease.CubeIn(remappingEase));
                    ActiveFont.Draw(GetLabel(currentlyRemapping), center + new Vector2(0f, 8f), new Vector2(0.5f, 0f), Vector2.One * 2f, Color.White * Ease.CubeIn(remappingEase));
                }
            }
            else
            {
                ActiveFont.Draw(Dialog.Clean("BTN_CONFIG_NOCONTROLLER"), center, new Vector2(0.5f, 0.5f), Vector2.One, Color.White * Ease.CubeOut(Alpha));
            }
        }
Пример #9
0
        public void StartCombineAnimation(Vector2 centerPos, float time, ParticleSystem particleSystem, Level level, bool spin)
        {
            collectSfx.Stop(allowFadeout: false);
            float startAngle = Calc.Angle(centerPos, Position);
            Tween tween      = Tween.Create(Tween.TweenMode.Oneshot, Ease.BigBackIn, time, start: true);

            tween.OnUpdate = t => {
                Vector2 oldPos = Center;
                float   angle  = spin ? MathHelper.Lerp(startAngle, startAngle - Calc.Circle, Ease.CubeIn(t.Percent)) : startAngle;
                float   length = MathHelper.Lerp(spin ? 30f : 5f + 45f * t.Percent, 0f, t.Eased);
                Position = centerPos + Calc.AngleToVector(angle, length);

                if (level.OnInterval(.03f))
                {
                    particleSystem.Emit(StrawberrySeed.P_Burst, 1, Center, Vector2.One, (Center - oldPos).Angle());
                }

                if (t.Percent > 0.5f)
                {
                    level.Shake((t.Percent - .5f) * .5f);
                }
            };
            tween.OnComplete = delegate {
                Visible = false;
                for (int i = 0; i < 6; i++)
                {
                    float angle = Calc.Random.NextFloat(Calc.Circle);
                    particleSystem.Emit(StrawberrySeed.P_Burst, 1, Position + Calc.AngleToVector(angle, 4f), Vector2.Zero, angle);
                }
                RemoveSelf();
            };
            Add(tween);
        }
Пример #10
0
        private IEnumerator LookRoutine(Player player)
        {
            Level        level        = SceneAs <Level>();
            SandwichLava sandwichLava = Scene.Entities.FindFirst <SandwichLava>();

            if (sandwichLava != null)
            {
                sandwichLava.Waiting = true;
            }

            if (player.Holding != null)
            {
                player.Drop();
            }

            player.StateMachine.State = Player.StDummy;
            yield return(player.DummyWalkToExact((int)X, walkBackwards: false, 1f, cancelOnFall: true));

            if (Math.Abs(X - player.X) > 4f || player.Dead || !player.OnGround())
            {
                if (!player.Dead)
                {
                    player.StateMachine.State = Player.StNormal;
                }
                yield break;
            }

            Audio.Play("event:/game/general/lookout_use", Position);

            if (player.Facing == Facings.Right)
            {
                sprite.Play(animPrefix + "lookRight");
            }
            else
            {
                sprite.Play(animPrefix + "lookLeft");
            }

            player.Sprite.Visible = player.Hair.Visible = false;
            yield return(0.2f);

            nodePercent = 0f;
            node        = 0;

            Audio.Play("event:/ui/game/lookout_on");

            float accel    = 800f;
            float maxSpeed = 240f;

            Vector2 cam            = level.Camera.Position;
            Vector2 speed          = Vector2.Zero;
            Vector2 lastDir        = Vector2.Zero;
            Vector2 camStart       = level.Camera.Position;
            Vector2 camStartCenter = camStart + new Vector2(160f, 90f);

            while (!Input.MenuCancel.Pressed && !Input.MenuConfirm.Pressed && !Input.Dash.Pressed && !Input.Jump.Pressed && interacting)
            {
                Vector2 value = Input.Aim.Value;
                if (onlyY)
                {
                    value.X = 0f;
                }

                if (Math.Sign(value.X) != Math.Sign(lastDir.X) || Math.Sign(value.Y) != Math.Sign(lastDir.Y))
                {
                    Audio.Play("event:/game/general/lookout_move", Position);
                }

                lastDir = value;

                if (sprite.CurrentAnimationID != "lookLeft" && sprite.CurrentAnimationID != "lookRight")
                {
                    if (value.X == 0f)
                    {
                        if (value.Y == 0f)
                        {
                            sprite.Play(animPrefix + "looking");
                        }
                        else if (value.Y > 0f)
                        {
                            sprite.Play(animPrefix + "lookingDown");
                        }
                        else
                        {
                            sprite.Play(animPrefix + "lookingUp");
                        }
                    }
                    else if (value.X > 0f)
                    {
                        if (value.Y == 0f)
                        {
                            sprite.Play(animPrefix + "lookingRight");
                        }
                        else if (value.Y > 0f)
                        {
                            sprite.Play(animPrefix + "lookingDownRight");
                        }
                        else
                        {
                            sprite.Play(animPrefix + "lookingUpRight");
                        }
                    }
                    else if (value.X < 0f)
                    {
                        if (value.Y == 0f)
                        {
                            sprite.Play(animPrefix + "lookingLeft");
                        }
                        else if (value.Y > 0f)
                        {
                            sprite.Play(animPrefix + "lookingDownLeft");
                        }
                        else
                        {
                            sprite.Play(animPrefix + "lookingUpLeft");
                        }
                    }
                }

                if (nodes == null)
                {
                    speed += accel * value * Engine.DeltaTime;
                    if (value.X == 0f)
                    {
                        speed.X = Calc.Approach(speed.X, 0f, accel * 2f * Engine.DeltaTime);
                    }
                    if (value.Y == 0f)
                    {
                        speed.Y = Calc.Approach(speed.Y, 0f, accel * 2f * Engine.DeltaTime);
                    }
                    if (speed.Length() > maxSpeed)
                    {
                        speed = speed.SafeNormalize(maxSpeed);
                    }

                    List <Entity> lookoutBlockers = Scene.Tracker.GetEntities <LookoutBlocker>();

                    Vector2 vector = cam;

                    cam.X += speed.X * Engine.DeltaTime;
                    if (cam.X < level.Bounds.Left || cam.X + 320f > level.Bounds.Right)
                    {
                        speed.X = 0f;
                    }
                    cam.X = Calc.Clamp(cam.X, level.Bounds.Left, level.Bounds.Right - 320);

                    foreach (Entity item in lookoutBlockers)
                    {
                        if (cam.X + 320f > item.Left && cam.Y + 180f > item.Top && cam.X < item.Right && cam.Y < item.Bottom)
                        {
                            cam.X   = vector.X;
                            speed.X = 0f;
                        }
                    }

                    cam.Y += speed.Y * Engine.DeltaTime;
                    if (cam.Y < level.Bounds.Top || cam.Y + 180f > level.Bounds.Bottom)
                    {
                        speed.Y = 0f;
                    }
                    cam.Y = Calc.Clamp(cam.Y, level.Bounds.Top, level.Bounds.Bottom - 180);

                    foreach (Entity item2 in lookoutBlockers)
                    {
                        if (cam.X + 320f > item2.Left && cam.Y + 180f > item2.Top && cam.X < item2.Right && cam.Y < item2.Bottom)
                        {
                            cam.Y   = vector.Y;
                            speed.Y = 0f;
                        }
                    }

                    level.Camera.Position = cam;
                }
                else
                {
                    Vector2 from = (node <= 0) ? camStartCenter : nodes[node - 1];
                    Vector2 to   = nodes[node];

                    float d = (from - to).Length();

                    if (nodePercent < 0.25f && node > 0)
                    {
                        Vector2 begin = Vector2.Lerp((node <= 1) ? camStartCenter : nodes[node - 2], from, 0.75f);
                        Vector2 end   = Vector2.Lerp(from, to, 0.25f);

                        SimpleCurve simpleCurve = new SimpleCurve(begin, end, from);
                        level.Camera.Position = simpleCurve.GetPoint(0.5f + nodePercent / 0.25f * 0.5f);
                    }
                    else if (nodePercent > 0.75f && node < nodes.Count - 1)
                    {
                        Vector2 nodeVec = nodes[node + 1];
                        Vector2 begin   = Vector2.Lerp(from, to, 0.75f);
                        Vector2 end     = Vector2.Lerp(to, nodeVec, 0.25f);

                        SimpleCurve simpleCurve = new SimpleCurve(begin, end, to);
                        level.Camera.Position = simpleCurve.GetPoint((nodePercent - 0.75f) / 0.25f * 0.5f);
                    }
                    else
                    {
                        level.Camera.Position = Vector2.Lerp(from, to, nodePercent);
                    }

                    level.Camera.Position += new Vector2(-160f, -90f);

                    nodePercent -= value.Y * (maxSpeed / d) * Engine.DeltaTime;
                    if (nodePercent < 0f)
                    {
                        if (node > 0)
                        {
                            node--;
                            nodePercent = 1f;
                        }
                        else
                        {
                            nodePercent = 0f;
                        }
                    }
                    else if (nodePercent > 1f)
                    {
                        if (node < nodes.Count - 1)
                        {
                            node++;
                            nodePercent = 0f;
                        }
                        else
                        {
                            nodePercent = 1f;
                            if (summit)
                            {
                                break;
                            }
                        }
                    }

                    float num2 = 0f;
                    float num3 = 0f;

                    for (int i = 0; i < nodes.Count; i++)
                    {
                        float num4 = (((i == 0) ? camStartCenter : nodes[i - 1]) - nodes[i]).Length();
                        num3 += num4;

                        if (i < node)
                        {
                            num2 += num4;
                        }
                        else if (i == node)
                        {
                            num2 += num4 * nodePercent;
                        }
                    }
                }

                yield return(null);
            }

            player.Sprite.Visible = (player.Hair.Visible = true);
            sprite.Play(animPrefix + "idle");
            Audio.Play("event:/ui/game/lookout_off");

            bool atSummitTop = summit && node >= nodes.Count - 1 && nodePercent >= 0.95f;

            if (atSummitTop)
            {
                yield return(0.5f);

                float duration = 3f;
                float approach = 0f;

                Coroutine component = new Coroutine(level.ZoomTo(new Vector2(160f, 90f), 2f, duration));
                Add(component);

                while (!Input.MenuCancel.Pressed && !Input.MenuConfirm.Pressed && !Input.Dash.Pressed && !Input.Jump.Pressed && interacting)
                {
                    approach = Calc.Approach(approach, 1f, Engine.DeltaTime / duration);
                    Audio.SetMusicParam("escape", approach);
                    yield return(null);
                }
            }

            if ((camStart - level.Camera.Position).Length() > 600f)
            {
                Vector2 was       = level.Camera.Position;
                Vector2 direction = (was - camStart).SafeNormalize();

                float approach = atSummitTop ? 1f : 0.5f;
                new FadeWipe(Scene, wipeIn: false).Duration = approach;
                for (float t = 0f; t < 1f; t += Engine.DeltaTime / approach)
                {
                    level.Camera.Position = was - direction * MathHelper.Lerp(0f, 64f, Ease.CubeIn(t));
                    yield return(null);
                }
                level.Camera.Position = camStart + direction * 32f;
                new FadeWipe(Scene, wipeIn: true);
            }

            Audio.SetMusicParam("escape", 0f);

            level.ZoomSnap(Vector2.Zero, 1f);
            interacting = false;
            yield return(.1f);

            player.StateMachine.State = Player.StNormal;
        }
Пример #11
0
        public void StartCombineAnimation(Vector2 centerPos, float time, ParticleSystem particleSystem)
        {
            Vector2 position   = this.Position;
            float   startAngle = Calc.Angle(centerPos, position);
            Tween   tween      = Tween.Create(Tween.TweenMode.Oneshot, Ease.BigBackIn, time, true);

            tween.OnUpdate = delegate(Tween t)
            {
                float angleRadians = MathHelper.Lerp(startAngle, startAngle - 6.2831855f, Ease.CubeIn(t.Percent));
                float length       = MathHelper.Lerp(25f, 0f, t.Eased);
                this.Position = centerPos + Calc.AngleToVector(angleRadians, length);
            };
            tween.OnComplete = delegate(Tween t)
            {
                this.Visible = false;
                for (int i = 0; i < 6; i++)
                {
                    float num = Calc.Random.NextFloat(6.2831855f);
                    particleSystem.Emit(GenericStrawberrySeed.P_Burst, 1, this.Position + Calc.AngleToVector(num, 4f), Vector2.Zero, num);
                }
                this.RemoveSelf();
            };
            base.Add(tween);
        }
Пример #12
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
                        );
                }
            }
        }