Example #1
0
        public static BlockExpression RotateLerp(Ex target, Ex source, TExArgCtx bpi, bool isRate, bool isTrue, Ex rate)
        {
            if (isRate)
            {
                rate = rate.Mul(M.degRad);
            }
            if (isTrue)
            {
                rate = rate.Mul(ETime.FRAME_TIME);
            }
            TExV2       v   = TExV2.Variable();
            TEx <float> ang = ExUtils.VFloat();

            Expression[] exprs = new Expression[3];
            exprs[1] = ang.Is(RadDiff(target, v));
            if (isTrue)
            {
                var key = bpi.Ctx.NameWithSuffix("_RotateLerpKey");
                exprs[0] = v.Is(
                    Ex.Condition(FiringCtx.Contains <Vector2>(bpi, key),
                                 FiringCtx.GetValue <Vector2>(bpi, key),
                                 FiringCtx.SetValue <Vector2>(bpi, key, source)
                                 ));
                exprs[2] =
                    FiringCtx.SetValue <Vector2>(bpi, key, RotateRad(isRate ? (Ex)Limit(rate, ang) : ang.Mul(rate), v));
            }
            else
            {
                exprs[0] = v.Is(source);
                exprs[2] = RotateRad(isRate ?
                                     (Ex)Limit(bpi.t.Mul(rate), ang) :
                                     ang.Mul(Min(bpi.t.Mul(rate), E1)), v);
            }
            return(Ex.Block(new ParameterExpression[] { v, ang }, exprs));
        }
Example #2
0
        public static void LocalReset()
        {
            //AudioTrackService.ClearAllAudio();
            SFXService.ClearConstructed();
            Events.Event0.DestroyAll();
            ETime.Slowdown.RevokeAll(MultiOp.Priority.CLEAR_SCENE);
            ETime.Timer.DestroyAll();
            BehaviorEntity.DestroyAllSummons();
            PublicDataHoisting.DestroyAll();
            FiringCtx.ClearNames();
            ReflWrap.ClearWrappers();
            StateMachineManager.ClearCachedSMs();
            BulletManager.ClearPoolControls();
            BulletManager.ClearEmpty();
            BulletManager.ClearAllBullets();
            BulletManager.DestroyCopiedPools();
            InstanceData.CampaignDataUpdated.Proc();
#if UNITY_EDITOR || ALLOW_RELOAD
            Events.LocalReset.Proc();
#endif
            //Ordered last so cancellations from HardCancel will occur under old data
            Instance = new InstanceData(InstanceMode.NULL);
            Debug.Log($"Reloading level: {Difficulty.Describe()} is the current difficulty");
            UIManager.UpdateTags();
        }
Example #3
0
 /// <summary>
 /// Nest a predicate such that it only returns True once for a single bullet.
 /// </summary>
 /// <param name="pred"></param>
 /// <returns></returns>
 public static ExPred OnlyOnce(ExPred pred) =>
 bpi => {
     var b   = V <bool>();
     var key = bpi.Ctx.NameWithSuffix("_OnlyOnce_Set");
     return(Ex.Condition(FiringCtx.Contains <int>(bpi, key),
                         ExC(false),
                         Ex.Block(new[] { b },
                                  Ex.IfThen(b.Is(pred(bpi)), FiringCtx.SetValue <int>(bpi, key, ExC(1))),
                                  b
                                  )
                         ));
 };
Example #4
0
 public static ExTP LSaveNearestEnemy() => b => {
     var key    = b.Ctx.NameWithSuffix("_LSaveNearestEnemyKey");
     var eid_in = ExUtils.V <int?>();
     var eid    = ExUtils.V <int>();
     var loc    = new TExV2();
     return(Ex.Block(new[] { eid_in, eid, loc },
                     eid_in.Is(Ex.Condition(FiringCtx.Contains <int>(b, key),
                                            FiringCtx.GetValue <int>(b, key).As <int?>(),
                                            Ex.Constant(null).As <int?>())
                               ),
                     Ex.IfThenElse(Enemy.findNearestSave.Of(b.loc, eid_in, eid, loc),
                                   FiringCtx.SetValue <int>(b, key, eid),
                                   loc.Is(Ex.Constant(new Vector2(0f, 50f)))
                                   ),
                     loc
                     ));
 };
Example #5
0
 public static void ClearForScene()
 {
     AudioTrackService.ClearAllAudio(false);
     SFXService.ClearConstructed();
     BulletManager.ClearPoolControls();
     Events.Event0.DestroyAll();
     ETime.Slowdown.RevokeAll(MultiOp.Priority.CLEAR_SCENE);
     ETime.Timer.DestroyAll();
     BulletManager.OrphanAll();
     PublicDataHoisting.DestroyAll();
     FiringCtx.ClearNames();
     //SMs may have links to data hoisting, so we destroy both of them on phase end.
     ReflWrap.ClearWrappers();
     StateMachineManager.ClearCachedSMs();
     BehaviorEntity.ClearPointers();
     AyaPhoto.ClearTextures();
 }
Example #6
0
 public Expression FCtxSet <T>(string key, Expression val) => FiringCtx.SetValue <T>(this, key, val);
Example #7
0
 public Expression FCtxGet <T>(string key) => FiringCtx.GetValue <T>(this, key);
Example #8
0
 public Expression FCtxHas <T>(string key) => FiringCtx.Contains <T>(this, key);
Example #9
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();
        }
Example #10
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();
        }