Exemplo n.º 1
0
        private IEnumerator Sequence()
        {
            while (true)
            {
                Player player = GetPlayerOnTop();
                bool   onTop;
                if (player != null)
                {
                    onTop = true;
                    Input.Rumble(RumbleStrength.Medium, RumbleLength.Medium);
                }
                else
                {
                    player = GetPlayerClimbing();
                    if (player == null)
                    {
                        yield return(null);

                        continue;
                    }
                    onTop = false;
                    Input.Rumble(RumbleStrength.Medium, RumbleLength.Medium);
                }
                Audio.Play("event:/game/general/platform_disintegrate", Center);
                shaker.ShakeFor(onTop ? crumbleTime + 0.4f : crumbleTime + 0.8f, removeOnFinish: false);
                foreach (Image img2 in images)
                {
                    SceneAs <Level>().Particles.Emit(P_Crumble, 2, Position + img2.Position + new Vector2(0f, 2f), Vector2.One * 3f);
                }
                for (int l = 0; l < (onTop ? 1 : 3); l++)
                {
                    yield return(0.2f);

                    foreach (Image img in images)
                    {
                        SceneAs <Level>().Particles.Emit(P_Crumble, 2, Position + img.Position + new Vector2(0f, 2f), Vector2.One * 3f);
                    }
                }
                float timer = crumbleTime;
                if (onTop)
                {
                    while (timer > 0f && GetPlayerOnTop() != null)
                    {
                        yield return(null);

                        timer -= Engine.DeltaTime;
                    }
                }
                else
                {
                    while (timer > 0f)
                    {
                        yield return(null);

                        timer -= Engine.DeltaTime;
                    }
                }
                outlineFader.Replace(OutlineFade(1f));
                occluder.Visible = false;
                Collidable       = false;
                float delay = 0.05f;
                for (int m = 0; m < 4; m++)
                {
                    for (int i = 0; i < images.Count; i++)
                    {
                        if (i % 4 - m == 0)
                        {
                            falls[i].Replace(TileOut(images[fallOrder[i]], delay * (float)m));
                        }
                    }
                }
                yield return(respawnTime);

                while (CollideCheck <Actor>() || CollideCheck <Solid>())
                {
                    yield return(null);
                }
                outlineFader.Replace(OutlineFade(0f));
                occluder.Visible = true;
                Collidable       = true;
                for (int k = 0; k < 4; k++)
                {
                    for (int j = 0; j < images.Count; j++)
                    {
                        if (j % 4 - k == 0)
                        {
                            falls[j].Replace(TileIn(j, images[fallOrder[j]], 0.05f * (float)k));
                        }
                    }
                }
            }
        }
        private IEnumerator customSequence()
        {
            while (true)
            {
                // wait until player is on top
                CustomizableCrumblePlatform triggeredPlatform = getOnePlatformWithPlayerOnTop();
                bool onTop;
                if (triggeredPlatform != null)
                {
                    onTop = true;
                    Input.Rumble(RumbleStrength.Medium, RumbleLength.Medium);
                }
                else
                {
                    triggeredPlatform = getOnePlatformWithPlayerClimbing();
                    if (triggeredPlatform == null)
                    {
                        yield return(null);

                        continue;
                    }
                    onTop = false;
                    Input.Rumble(RumbleStrength.Medium, RumbleLength.Medium);
                }

                // only emit sound if we should emit sound no matter what, or if the current platform is the one that got triggered.
                if (!onlyEmitSoundForPlayer || triggeredPlatform == this)
                {
                    Audio.Play("event:/game/general/platform_disintegrate", Center);
                }

                // make pieces shake and emit particles
                shaker.ShakeFor(onTop ? maxCrumbleDurationOnTop : crumbleDurationOnSide, removeOnFinish: false);
                foreach (Image image in images)
                {
                    SceneAs <Level>().Particles.Emit(P_Crumble, 2, Position + image.Position + new Vector2(0f, 2f), Vector2.One * 3f);
                }
                float targetTime = (onTop ? minCrumbleDurationOnTop : maxCrumbleDurationOnTop);
                for (float time = 0f; time < targetTime; time += 0.2f)
                {
                    yield return(Math.Min(0.2f, targetTime - time));

                    foreach (Image image in images)
                    {
                        SceneAs <Level>().Particles.Emit(P_Crumble, 2, Position + image.Position + new Vector2(0f, 2f), Vector2.One * 3f);
                    }
                }

                // wait for a bit more
                float timer = (onTop ? maxCrumbleDurationOnTop - minCrumbleDurationOnTop : crumbleDurationOnSide - maxCrumbleDurationOnTop);
                if (onTop)
                {
                    while (timer > 0f && getOnePlatformWithPlayerOnTop() != null)
                    {
                        yield return(null);

                        timer -= Engine.DeltaTime;
                    }
                }
                else
                {
                    while (timer > 0f)
                    {
                        yield return(null);

                        timer -= Engine.DeltaTime;
                    }
                }

                // make the platform disappear
                outlineFader.Replace((IEnumerator)crumblePlatformOutlineFade.Invoke(this, new object[] { 1f }));
                occluder.Visible = false;
                Collidable       = false;
                float delay = 0.05f;
                for (int m = 0; m < 4; m++)
                {
                    for (int i = 0; i < images.Count; i++)
                    {
                        if (i % 4 - m == 0)
                        {
                            falls[i].Replace((IEnumerator)crumblePlatformTileOut.Invoke(this, new object[] { images[fallOrder[i]], delay * (float)m }));
                        }
                    }
                }

                if (oneUse)
                {
                    // wait for the platform to animate for a bit (1 second) then delete it.
                    yield return(1f);

                    RemoveSelf();
                    yield break;
                }
                else
                {
                    // wait for the custom delay instead of 2 seconds.
                    yield return(respawnDelay);
                }

                // wait if something is where the platform is supposed to respawn
                while (CollideCheck <Actor>() || CollideCheck <Solid>() || isGroupCollidingWithSomething())
                {
                    yield return(null);
                }

                // make the platform reappear
                outlineFader.Replace((IEnumerator)crumblePlatformOutlineFade.Invoke(this, new object[] { 0f }));
                occluder.Visible = true;
                Collidable       = true;
                for (int m = 0; m < 4; m++)
                {
                    for (int i = 0; i < images.Count; i++)
                    {
                        if (i % 4 - m == 0)
                        {
                            // only emit sound if we should emit sound no matter what, or if the current platform is the one that got triggered.
                            if (!onlyEmitSoundForPlayer || triggeredPlatform == this)
                            {
                                falls[i].Replace((IEnumerator)crumblePlatformTileIn.Invoke(this, new object[] { i, images[fallOrder[i]], 0.05f * (float)m }));
                            }
                            else
                            {
                                falls[i].Replace(tileInNoSound(i, images[fallOrder[i]], 0.05f * (float)m));
                            }
                        }
                    }
                }
            }
        }