Esempio n. 1
0
 public static void TestV2RV2()
 {
     AreEqual(V2RV2.Zero, ParseV2RV2("<>"));
     AreEqual(V2RV2.Angle(2 * M.IPHI), ParseV2RV2("<2h>"));
     AreEqual(V2RV2.Rot(4.0f, -2.5f, 2 * M.IPHI), ParseV2RV2("<4.0;-2.5:2h>"));
     ThrowsAny(() => ParseV2RV2("<gf;-2.5:2h>"));
     AreEqual(new V2RV2(2f, 3f, 4.0f, -2.5f, 2 * M.IPHI), ParseV2RV2("<2;3:4.0;-2.5:2h>"));
     AreEqual(new V2RV2(2f, 3f, 0, 0, 2 * M.IPHI), ParseV2RV2("<2;3:;:2h>"));
 }
Esempio n. 2
0
        public static void TCartesianRotNRot()
        {
            var      p   = "roffset px * 2 t".Into <VTP>();
            var      bpi = new ParametricInfo(Vector2.down, 3, 0, 0f);
            Movement v   = new Movement(p, Vector2.zero, V2RV2.Angle(25));

            v.UpdateDeltaAssignAcc(ref bpi, out var _, 1f);
            VecEq(bpi.loc, V2RV2.Rot(2, 0, 25).TrueLocation, "", err1);


            p   = "nroffset px * 2 t".Into <VTP>();
            bpi = new ParametricInfo(Vector2.down, 3, 0, 0f);
            v   = new Movement(p, Vector2.zero, V2RV2.Angle(25));
            v.UpdateDeltaAssignAcc(ref bpi, out var _, 1f);
            VecEq(bpi.loc, V2RV2.NRot(2, 0).TrueLocation, "", err1);
        }
Esempio n. 3
0
        private IEnumerator RunTutorial(Action cb)
        {
            IEnumerator wait(Func <bool> cond)
            {
                while (!cond())
                {
                    yield return(null);
                }
            }

            IEnumerator confirm()
            {
                yield return(null);

                yield return(wait(() => UIConfirm.Active && !EngineStateManager.IsPaused));
            }

            DependencyInjection.Find <IUIManager>()
            .SetSpellname("Reduced Tutorial (For Players Too Smart for the Normal Tutorial)");

            var mov = new Movement(new Vector2(-2, 2.5f), 0);

            BulletManager.RequestSimple("lcircle-red/", _ => 4f, null, mov, new ParametricInfo(in mov));
            var nrx = new RealizedLaserOptions(new LaserOptions(), GenCtx.New(this, V2RV2.Zero), FiringCtx.New(), new Vector2(3, 5),
                                               V2RV2.Angle(-90), Cancellable.Null);

            "sync _ <> relrect greenrect level <-2;2.5:1.4;1.4:0> witha 0.7 green".Into <StateMachine>()
            .Start(new SMHandoff(this, Cancellable.Null));
            Message(text10, mtcirc1(UIConfirm.Desc));
            yield return(confirm());

            BulletManager.ClearAllBullets();
            BehaviorEntity.GetExecForID("greenrect").InvokeCull();
            mov = new Movement(new Vector2(-3, 5), -90);
            BulletManager.RequestLaser(null, "mulaser-blue/b", mov, new ParametricInfo(in mov), 999, 0,
                                       ref nrx);
            mov = new Movement(new Vector2(-2, 5), -90);
            BulletManager.RequestLaser(null, "zonelaser-green/b", mov, new ParametricInfo(in mov), 999, 0,
                                       ref nrx);
            Message(text10, mtsafe2(UIConfirm.Desc));
            yield return(confirm());

            cb();
        }
Esempio n. 4
0
        public static void TPolar()
        {
            var      pivoter  = "polar * 2 t * 60 t".Into <VTP>();
            var      pivoter2 = "polar2 pxy * 2 t * 60 t".Into <VTP>();
            var      bpi      = new ParametricInfo(Vector2.zero, 1, 0, 0f);
            var      bpi2     = new ParametricInfo(Vector2.zero, 1, 0, 0f);
            Movement v        = new Movement(pivoter, Vector2.right, V2RV2.Angle(25));
            Movement v2       = new Movement(pivoter2, Vector2.right, V2RV2.Angle(25));

            v.UpdateDeltaAssignAcc(ref bpi, out var _, 1f);
            v2.UpdateDeltaAssignAcc(ref bpi2, out var _, 1f);
            VecEq(bpi.loc, V2(1, 0) + M.RotateVectorDeg(M.PolarToXY(2, 60), 25), "", err1);
            VecEq(bpi.loc, bpi2.loc);
            v  = new Movement(pivoter, Vector2.left, V2RV2.NRotAngled(1, 1, 25));
            v2 = new Movement(pivoter2, Vector2.left, V2RV2.NRotAngled(1, 1, 25));
            v.UpdateDeltaAssignAcc(ref bpi, out var _, 1f);
            v2.UpdateDeltaAssignAcc(ref bpi2, out var _, 1f);
            VecEq(bpi.loc, V2(0, 1) + M.RotateVectorDeg(M.PolarToXY(4, 120), 25), "", err1);
            VecEq(bpi.loc, bpi2.loc);
        }
Esempio n. 5
0
        public static void TCartesian()
        {
            var      pivoter = "offset px * 2 p py * 2 t".Into <VTP>();
            var      bpi     = new ParametricInfo(Vector2.down, 3, 0, 0f);
            Movement v       = new Movement(pivoter, Vector2.zero, V2RV2.Angle(25));

            v.UpdateDeltaAssignAcc(ref bpi, out var _, 1f);
            VecEq(bpi.loc, new V2RV2(0, 2, 6, 0, 25).TrueLocation, "", err1);

            pivoter = "tp px * 2 p py * 2 t".Into <VTP>();
            bpi     = new ParametricInfo(Vector2.down, 3, 0, 0f);
            v       = new Movement(pivoter, Vector2.zero, V2RV2.Angle(25));
            v.UpdateDeltaAssignAcc(ref bpi, out var _, 2f);
            VecEq(bpi.loc, Vector2.down + new V2RV2(0, 4, 6, 0, 25).TrueLocation * 2f, "", err1);

            pivoter = "tp px * 2 p px * 2 t".Into <VTP>();
            bpi     = new ParametricInfo(Vector2.down, 3, 0, 0f);
            v       = new Movement(pivoter, Vector2.zero, V2RV2.Angle(25));
            v.FlipX();
            v.UpdateDeltaAssignAcc(ref bpi, out var _, 2f);
            VecEq(bpi.loc, Vector2.down + new V2RV2(-4, 0, 6, 0, 180 - 25).TrueLocation * 2f, "", err1);
        }
Esempio n. 6
0
        private IEnumerator RunTutorial(int skips)
        {
            while (SceneIntermediary.LOADING)
            {
                yield return(null);
            }
            bool canSkip() => skips-- > 0;

            IEnumerator wait(Func <bool> cond)
            {
                if (!canSkip())
                {
                    while (!cond())
                    {
                        yield return(null);
                    }
                }
            }

            IEnumerator waitlf(Func <bool> cond) => wait(() => ETime.FirstUpdateForScreen && cond());

            IEnumerator waiti(IInputHandler ih)
            {
                yield return(null);

                yield return(waitlf(() => ih.Active));
            }

            IEnumerator waitir(IInputHandler ih)
            {
                yield return(null);

                yield return(waitlf(() => !ih.Active));
            }

            IEnumerator confirm() => waiti(UIConfirm);

            DependencyInjection.Find <IUIManager>().SetSpellname("Tutorial");
            Message(text10, welcome1(UIConfirm.Desc));
            yield return(confirm());

            Prompt(text10, blue2(Pause.Desc));
            yield return(waitlf(() => EngineStateManager.IsPaused));

            UIManager.PauseMenu !.GoToOption(0);
            const float menuLeft = -4.8f;

            Message(text00, pause3, x: menuLeft);
            yield return(confirm());

            Message(text00, shaders4, x: menuLeft);
            yield return(confirm());

            Prompt(text00, shaders5, 1.2f, x: menuLeft);
            var sd = SaveData.s.Shaders;

            yield return(waitlf(() => SaveData.s.Shaders != sd));

            Prompt(text00, res6, 0.85f, x: menuLeft);
            var r = SaveData.s.Resolution;

            yield return(waitlf(() => SaveData.s.Resolution != r));

            Message(text00, refresh7, 0.5f, x: menuLeft);
            yield return(confirm());

            Message(text00, fullscreen8, 0.15f, x: menuLeft);
            yield return(confirm());

            Message(text00, vsync9, -0.25f, x: menuLeft);
            yield return(confirm());

            Message(text00, inputsmooth10, -0.7f, x: menuLeft);
            yield return(confirm());

            Prompt(text00, unpause11(Pause.Desc), x: menuLeft);
            yield return(waitlf(() => !EngineStateManager.IsLoadingOrPaused));

            var mov = new Movement(new Vector2(-2, 2.5f), 0);

            BulletManager.RequestSimple("lcircle-red/", _ => 4f, null, mov, new ParametricInfo(in mov));
            var nrx = new RealizedLaserOptions(new LaserOptions(), GenCtx.New(this, V2RV2.Zero), FiringCtx.New(), new Vector2(3, 5),
                                               V2RV2.Angle(-90), Cancellable.Null);

            mov = new Movement(new Vector2(2, 5), -90);
            BulletManager.RequestLaser(null, "mulaser-blue/b", mov, new ParametricInfo(in mov), 999, 0, ref nrx);
            mov = new Movement(new Vector2(3, 5), -90);
            BulletManager.RequestLaser(null, "zonelaser-green/b", mov, new ParametricInfo(in mov), 999, 0,
                                       ref nrx);
            "sync _ <> relrect greenrect level <-2;2.5:1.4;1.4:0> witha 0.7 green".Into <StateMachine>()
            .Start(new SMHandoff(this));
            Message(text10, redcircle12);
            yield return(confirm());

            Message(text10, legacy13);
            yield return(confirm());

            Message(text10, safelaser14);
            yield return(confirm());

            BulletManager.ClearAllBullets();
            BehaviorEntity.GetExecForID("greenrect").InvokeCull();

            Prompt(text10, fire15(ShootHold.Desc));
            yield return(waitir(ShootHold));

            yield return(waiti(ShootHold));

            Prompt(text10, move16);
            yield return(waitlf(() => Math.Abs(HorizontalSpeed01) > 0.1 || Math.Abs(VerticalSpeed01) > 0.1));

            Prompt(text10, focus17(FocusHold.Desc));
            yield return(waiti(FocusHold));

            var bcs  = new Cancellable();
            var boss = GameObject.Instantiate(tutorialBoss).GetComponent <BehaviorEntity>();

            boss.Initialize(SMRunner.CullRoot(StateMachine.CreateFromDump(bossSM.text), bcs));
            IEnumerator phase()
            {
                while (boss.PhaseShifter == null)
                {
                    yield return(null);
                }
                var pct = boss.PhaseShifter;

                if (canSkip())
                {
                    boss.ShiftPhase();
                }
                else
                {
                    yield return(wait(() => pct.Cancelled));
                }
                for (int ii = 0; ii < 244; ++ii)
                {
                    yield return(null); //phase delay

                    if (EngineStateManager.IsRunning)
                    {
                        ++ii;
                    }
                }
            }

            IEnumerator shift()
            {
                boss.ShiftPhase();
                for (int ii = 0; ii < 4; ++ii)
                {
                    yield return(null);                       //phase delay
                }
            }

            for (int ii = 0; ii < 8; ++ii)
            {
                yield return(null);                       //start delay
            }
            Message(text10, boss18);
            yield return(confirm());

            Message(text10, hpbar19);
            yield return(confirm());

            yield return(shift());

            Prompt(text10, ns20);
            yield return(phase());

            Prompt(text10, nss21);
            yield return(phase());

            Prompt(text10, spell22);
            yield return(phase());

            Prompt(text10, survival23);
            yield return(phase());

            Message(text10, items24);
            yield return(confirm());

            Message(text10, bullets25);
            yield return(confirm());

            yield return(shift());

            Prompt(text10, shoot26);
            yield return(phase());

            Message(text10, lives27, 0.3f);
            yield return(confirm());

            Instance.SetLives(10);
            Message(text10, dots28);
            yield return(confirm());

            Instance.SetLives(15);
            Message(text10, dots29);
            yield return(confirm());

            Instance.SetLives(1);
            Message(text10, dots30);
            yield return(confirm());

            Message(text10, nobombs31);
            yield return(confirm());

            yield return(shift());

            Prompt(text10, pleasedie32);
            yield return(waitlf(() => EngineStateManager.IsDeath));

            Prompt(text00, deathscreen33, x: menuLeft);
            yield return(waitlf(() => !EngineStateManager.IsDeath));

            yield return(shift());

            Message(text10, lifeitems34, -0.3f);
            yield return(confirm());

            yield return(shift());

            Prompt(text10, lifeitems35);
            int currLives = Instance.Lives;

            yield return(waitlf(() => Instance.Lives > currLives));

            yield return(shift());

            Message(text10, valueitems36(InstanceData.valueItemPoints));
            yield return(confirm());

            yield return(shift());

            Prompt(text10, points37);
            yield return(waitlf(() => Instance.Score > 75000));

            yield return(shift());

            Message(text00, scoremult38);
            yield return(confirm());

            Message(text00, faith39(InstanceData.pivFallStep));
            yield return(confirm());

            Message(text00, faithblue40);
            yield return(confirm());

            Message(text10, graze41);
            yield return(confirm());

            yield return(shift());

            Prompt(text10, scoremult42);
            yield return(waitlf(() => Instance.PIV >= 1.11));

            yield return(shift());

            yield return(waitlf(() => Instance.PIV <= 1.0));

            Message(text10, scoreext43);
            yield return(confirm());

            yield return(shift());

            Prompt(text10, scoreext44);
            yield return(waitlf(() => Instance.Score > 2000000));

            yield return(shift());

            Message(text10, ability45);
            yield return(confirm());

            yield return(shift());

            Prompt(text10, ability46(Meter.Desc));
            GameManagement.Instance.AddGems(100);
            yield return(waitlf(() => InputManager.IsMeter));

            yield return(shift());

            Message(text10, ability47);
            yield return(confirm());

            Message(text10, meter48);
            yield return(confirm());

            yield return(shift());

            Message(text10, hitbox49);
            yield return(confirm());

            yield return(shift());

            Message(text10, hitbox50);
            yield return(confirm());

            yield return(shift());

            Message(text10, safelaser51);
            yield return(confirm());

            yield return(shift());

            Prompt(text10, end52);
            SaveData.r.CompleteTutorial();
        }