Пример #1
0
 public override void Awake(Scene scene)
 {
     base.Awake(scene);
     if (TimedSwitch.CheckLevelFlag(base.SceneAs <Level>()))
     {
         base.MoveTo(node);
         icon.Rate = 0f;
         icon.SetAnimationFrame(0);
         icon.Color = finishColor;
     }
     else
     {
         base.Add(new Coroutine(Sequence(node, false), true));
     }
 }
Пример #2
0
        public GhostTouchSwitch(Vector2 position, bool shortTimer, bool longTimer, bool veryLongTimer)
            : base(position)
        {
            if (shortTimer || longTimer || veryLongTimer)
            {
                timed = true;
                if (shortTimer)
                {
                    maxTimer = 5f;
                }
                if (longTimer)
                {
                    maxTimer = 10f;
                }
                if (veryLongTimer)
                {
                    maxTimer = 20f;
                }
            }

            base.Depth = 2000;
            if (!timed)
            {
                base.Add(Switch = new Switch(false));
            }
            else
            {
                base.Add(TimedSwitch = new TimedSwitch(false, maxTimer));
            }

            base.Add(new PlayerCollider(OnPlayer, null, new Hitbox(30f, 30f, -15f, -15f)));
            base.Add(icon);
            base.Add(bloom = new BloomPoint(0f, 16f));
            bloom.Alpha    = 0f;
            icon.Add("idle", "", 0f, default(int));
            icon.Add("spin", "", 0.1f, new Chooser <string>("spin", 1f), 0, 1, 2, 3, 4, 5);
            icon.Play("spin", false, false);
            icon.Color = inactiveColor;
            icon.CenterOrigin();
            base.Collider = new Hitbox(16f, 16f, -8f, -8f);
            base.Add(new TheoCrystalCollider(OnTheoCrystal, new Hitbox(20f, 20f, -10f, -10f)));
            base.Add(new SeekerCollider(OnSeeker, new Hitbox(24f, 24f, -12f, -12f)));

            if (!timed)
            {
                Switch.OnActivate = delegate
                {
                    wiggler.Start();
                    for (int i = 0; i < 32; i++)
                    {
                        float num = Calc.Random.NextFloat(6.28318548f);
                        //level.Particles.Emit(P_FireWhite, base.Position + Calc.AngleToVector(num, 6f), num);
                    }
                    icon.Rate = 4f;
                };

                Switch.OnDeactivate = delegate
                {
                    wiggler.StopAndClear();
                    icon.Rate = 0.1f;
                    icon.Play("spin", false, false);
                };

                Switch.OnFinish = delegate
                {
                    ease = 0f;
                };
                Switch.OnStartFinished = delegate
                {
                    icon.Rate = 0.1f;
                    icon.Play("spin", false, false);
                    icon.Color = finishColor;
                    ease       = 1f;
                };
            }
            else
            {
                TimedSwitch.OnActivate = delegate
                {
                    wiggler.Start();
                    for (int i = 0; i < 32; i++)
                    {
                        float num = Calc.Random.NextFloat(6.28318548f);
                        //level.Particles.Emit(P_FireWhite, base.Position + Calc.AngleToVector(num, 6f), num);
                    }
                    icon.Rate = 4f;
                };

                TimedSwitch.OnDeactivate = delegate
                {
                    icon.Color = inactiveColor;
                    icon.Rate  = 1f;
                };

                TimedSwitch.OnFinish = delegate
                {
                    ease      = 0f;
                    icon.Rate = 4f;
                };
                TimedSwitch.OnStartFinished = delegate
                {
                    icon.Color = finishColor;
                    ease       = 1f;
                };
            }
            base.Add(wiggler = Wiggler.Create(0.5f, 4f, delegate(float v)
            {
                pulse = Vector2.One * (1f + v * 0.25f);
            }, false, false));
            base.Add(new VertexLight(Color.White, 0.8f, 16, 32));
            base.Add(touchSfx = new SoundSource());
        }
Пример #3
0
        public static bool Check(Scene scene)
        {
            TimedSwitch component = scene.Tracker.GetComponent <TimedSwitch>();

            return(component?.Finished ?? false);
        }
Пример #4
0
        private IEnumerator Sequence(Vector2 node, bool reverse)
        {
            Vector2 start = base.Position;

            if (reverse)
            {
                while (TimedSwitch.Check(Scene))
                {
                    yield return((object)null);
                }
            }
            else
            {
                while (!TimedSwitch.Check(Scene))
                {
                    yield return((object)null);
                }
            }
            if (persistent)
            {
                TimedSwitch.SetLevelFlag(SceneAs <Level>());
            }
            yield return((object)0.1f);

            openSfx.Play("event:/game/general/touchswitch_gate_open", null, 0f);
            StartShaking(0.5f);
            while (icon.Rate < 1f)
            {
                icon.Color = Color.Lerp(inactiveColor, activeColor, icon.Rate);
                icon.Rate += Engine.DeltaTime * 2f;
                yield return((object)null);
            }
            yield return((object)0.1f);

            int   particleAt = 0;
            Tween tween      = Tween.Create(Tween.TweenMode.Oneshot, Ease.CubeOut, 2f, true);

            tween.OnUpdate = delegate(Tween t)
            {
                MoveTo(Vector2.Lerp(start, node, t.Eased));
                if (Scene.OnInterval(0.1f))
                {
                    particleAt++;
                    particleAt %= 2;
                    for (int n = 0; (float)n < Width / 8f; n++)
                    {
                        for (int num2 = 0; (float)num2 < Height / 8f; num2++)
                        {
                            if ((n + num2) % 2 == particleAt)
                            {
                                //SceneAs<Level>().ParticlesBG.Emit(P_Behind, base.Position + new Vector2((float)(n * 8), (float)(num2 * 8)) + Calc.Random.Range(Vector2.One * 2f, Vector2.One * 6f));
                            }
                        }
                    }
                }
            };
            Add(tween);
            yield return((object)1.8f);

            bool collidable = base.Collidable;

            base.Collidable = false;
            if (node.X <= start.X)
            {
                Vector2 value = new Vector2(0f, 2f);
                for (int i = 0; (float)i < Height / 8f; i++)
                {
                    Vector2 vector = new Vector2(Left - 1f, Top + 4f + (float)(i * 8));
                    Vector2 point  = vector + Vector2.UnitX;
                    if (Scene.CollideCheck <Solid>(vector) && !Scene.CollideCheck <Solid>(point))
                    {
                        //SceneAs<Level>().ParticlesFG.Emit(P_Dust, vector + value, 3.14159274f);
                        //SceneAs<Level>().ParticlesFG.Emit(P_Dust, vector - value, 3.14159274f);
                    }
                }
            }
            if (node.X >= start.X)
            {
                Vector2 value2 = new Vector2(0f, 2f);
                for (int j = 0; (float)j < Height / 8f; j++)
                {
                    Vector2 vector2 = new Vector2(Right + 1f, Top + 4f + (float)(j * 8));
                    Vector2 point2  = vector2 - Vector2.UnitX * 2f;
                    if (Scene.CollideCheck <Solid>(vector2) && !Scene.CollideCheck <Solid>(point2))
                    {
                        //SceneAs<Level>().ParticlesFG.Emit(P_Dust, vector2 + value2, 0f);
                        //SceneAs<Level>().ParticlesFG.Emit(P_Dust, vector2 - value2, 0f);
                    }
                }
            }
            if (node.Y <= start.Y)
            {
                Vector2 value3 = new Vector2(2f, 0f);
                for (int k = 0; (float)k < Width / 8f; k++)
                {
                    Vector2 vector3 = new Vector2(Left + 4f + (float)(k * 8), Top - 1f);
                    Vector2 point3  = vector3 + Vector2.UnitY;
                    if (Scene.CollideCheck <Solid>(vector3) && !Scene.CollideCheck <Solid>(point3))
                    {
                        //SceneAs<Level>().ParticlesFG.Emit(P_Dust, vector3 + value3, -1.57079637f);
                        //SceneAs<Level>().ParticlesFG.Emit(P_Dust, vector3 - value3, -1.57079637f);
                    }
                }
            }
            if (node.Y >= start.Y)
            {
                Vector2 value4 = new Vector2(2f, 0f);
                for (int l = 0; (float)l < Width / 8f; l++)
                {
                    Vector2 vector4 = new Vector2(Left + 4f + (float)(l * 8), Bottom + 1f);
                    Vector2 point4  = vector4 - Vector2.UnitY * 2f;
                    if (Scene.CollideCheck <Solid>(vector4) && !Scene.CollideCheck <Solid>(point4))
                    {
                        //SceneAs<Level>().ParticlesFG.Emit(P_Dust, vector4 + value4, 1.57079637f);
                        //SceneAs<Level>().ParticlesFG.Emit(P_Dust, vector4 - value4, 1.57079637f);
                    }
                }
            }
            base.Collidable = collidable;
            Audio.Play("event:/game/general/touchswitch_gate_finish", base.Position);
            StartShaking(0.2f);
            bool collidable2 = base.Collidable;

            base.Collidable = false;
            base.Collidable = collidable2;
            if (!reverse)
            {
                base.Add(new Coroutine(Sequence(ogPosition, true), true));
            }
            else
            {
                base.Add(new Coroutine(Sequence(ogTarget, false), true));
            }
        }