コード例 #1
0
ファイル: PowerAuraOptions.cs プロジェクト: Bagoum/danmokou
        public RealizedPowerAuraOptions(PowerAuraOptions opts, GenCtx gcx, Vector2 unparentedOffset, ICancellee cT, Func <RealizedPowerAuraOptions, Action> next)
        {
            scale      = opts.scale?.Invoke(gcx);
            color      = opts.color;
            time       = opts.time?.Invoke(gcx) ?? 1f;
            iterations = opts.itrs?.Invoke(gcx) ?? 1f;
            sfx        = opts.sfx;
            layer      = opts.layer;
            this.cT    = cT;

            if (opts.static_)
            {
                parent = null;
                offset = unparentedOffset;
            }
            else
            {
                parent = gcx.exec;
                offset = Vector2.zero;
            }

            if (opts.next != null)
            {
                //Note that you must operate over GCX now, since it may be destroyed after this function is exited.
                continuation = next(new RealizedPowerAuraOptions(opts.next, gcx, unparentedOffset, cT, next));
            }
            else
            {
                continuation = null;
            }
        }
コード例 #2
0
 private void DoAIteration(AsyncPattern target, Action done, GenCtx baseGCX)
 {
     abh.ch   = new CommonHandoff(looper.Handoff.cT, looper.Handoff.bc, baseGCX);
     abh.done = done;
     //RunPrepend steps the coroutine and places it before the current one,
     //so we can continue running on the same frame that the child finishes (if using waitchild).
     abh.RunPrependRIEnumerator(target(abh));
 }
コード例 #3
0
            public void DoAIteration(AsyncPattern[] target)
            {
                //To prevent secondary sequential children from trying to copy this object's GCX
                // which will have already changed when the next loop starts.
                GenCtx base_gcx  = looper.GCX.Copy();
                bool   done      = false;
                Action loop_done = () => {
                    base_gcx.Dispose();
                    done = true;
                };

                if (waitChild)
                {
                    checkIsChildDone = () => done;
                    //On the frame that the child finishes, the waitstep will increment elapsedFrames
                    //even though it should not. However, it is difficult to tell the waitstep whether
                    //the child was finished or not finished before that frame. This is the easiest solution.
                    --elapsedFrames;
                }
                else
                {
                    checkIsChildDone = null;
                }

                if (looper.props.childSelect == null)
                {
                    if (sequential)
                    {
                        void DoNext(int ii)
                        {
                            if (ii >= target.Length || looper.Handoff.cT.Cancelled)
                            {
                                loop_done();
                            }
                            else
                            {
                                DoAIteration(target[ii], () => DoNext(ii + 1), base_gcx);
                            }
                        }

                        DoNext(0);
                    }
                    else
                    {
                        var loop_fragment_done = WaitingUtils.GetManyCallback(target.Length, loop_done);
                        for (int ii = 0; ii < target.Length; ++ii)
                        {
                            DoAIteration(target[ii], loop_fragment_done, base_gcx);
                        }
                    }
                }
                else
                {
                    DoAIteration(target[(int)looper.props.childSelect(looper.GCX) % target.Length], loop_done, base_gcx);
                }
            }
コード例 #4
0
            public void DoAIteration(ref float elapsedFrames, IReadOnlyList <StateMachine> target)
            {
                //See IPExecution tracker for comments on this code
                GenCtx base_gcx  = looper.GCX.Copy();
                bool   done      = false;
                Action loop_done = () => {
                    base_gcx.Dispose();
                    done = true;
                };

                if (waitChild)
                {
                    checkIsChildDone = () => done;
                    --elapsedFrames;
                }
                else
                {
                    checkIsChildDone = null;
                }

                if (looper.props.childSelect == null)
                {
                    if (sequential)
                    {
                        void DoNext(int ii)
                        {
                            if (ii >= target.Count || looper.Handoff.cT.Cancelled)
                            {
                                loop_done();
                            }
                            else
                            {
                                DoAIteration(target[ii], () => DoNext(ii + 1), base_gcx);
                            }
                        }

                        DoNext(0);
                    }
                    else
                    {
                        var loop_fragment_done = WaitingUtils.GetManyCallback(target.Count, loop_done);
                        for (int ii = 0; ii < target.Count; ++ii)
                        {
                            DoAIteration(target[ii], loop_fragment_done, base_gcx);
                        }
                    }
                }
                else
                {
                    DoAIteration(target[(int)looper.props.childSelect(looper.GCX) % target.Count], loop_done, base_gcx);
                }
            }
コード例 #5
0
            public void DoLastAIteration(IReadOnlyList <StateMachine> target)
            {
                //Unlike GIR, which hoists its cleanup code into a callback, GTR awaits its last child
                // and calls its cleanup code in Start.
                //Therefore, this code follows the wait-child pattern.
                GenCtx base_gcx = looper.GCX.Copy();
                bool   done     = false;

                checkIsChildDone = () => done;
                Action loop_done = () => {
                    base_gcx.Dispose();
                    done = true;
                    //AllDone called by Start code
                };

                if (looper.props.childSelect == null)
                {
                    if (sequential)
                    {
                        void DoNext(int ii)
                        {
                            if (ii >= target.Count || looper.Handoff.cT.Cancelled)
                            {
                                loop_done();
                            }
                            else
                            {
                                DoAIteration(target[ii], () => DoNext(ii + 1), base_gcx);
                            }
                        }

                        DoNext(0);
                    }
                    else
                    {
                        var loop_fragment_done = WaitingUtils.GetManyCallback(target.Count, loop_done);
                        for (int ii = 0; ii < target.Count; ++ii)
                        {
                            DoAIteration(target[ii], loop_fragment_done, base_gcx);
                        }
                    }
                }
                else
                {
                    DoAIteration(target[(int)looper.props.childSelect(looper.GCX) % target.Count], loop_done, base_gcx);
                }
            }
コード例 #6
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();
        }
コード例 #7
0
            public void DoLastAIteration(AsyncPattern[] target)
            {
                GenCtx base_gcx  = looper.GCX.Copy();
                Action loop_done = () => {
                    base_gcx.Dispose();
                    AllADone();
                };

                if (looper.props.childSelect == null)
                {
                    if (sequential)
                    {
                        void DoNext(int ii)
                        {
                            if (ii >= target.Length || looper.Handoff.cT.Cancelled)
                            {
                                loop_done();
                            }
                            else
                            {
                                DoAIteration(target[ii], () => DoNext(ii + 1), base_gcx);
                            }
                        }

                        DoNext(0);
                    }
                    else
                    {
                        var loop_fragment_done = WaitingUtils.GetManyCallback(target.Length, loop_done);
                        for (int ii = 0; ii < target.Length; ++ii)
                        {
                            DoAIteration(target[ii], loop_fragment_done, base_gcx);
                        }
                    }
                }
                else
                {
                    DoAIteration(target[(int)looper.props.childSelect(looper.GCX) % target.Length], loop_done, base_gcx);
                }
            }
コード例 #8
0
 public void Trigger(BehaviorEntity Exec, GenCtx gcx, ICancellee cT)
 {
     _ = Exec.GetINode("finish-triggered", null).RunExternalSM(SMRunner.Cull(this.states[0], cT, gcx));
 }
コード例 #9
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();
        }
コード例 #10
0
 private void DoAIteration(StateMachine target, Action childDone, GenCtx baseGCX)
 {
     smh.ch = new CommonHandoff(looper.Handoff.cT, looper.Handoff.bc, baseGCX);
     target.Start(smh).ContinueWithSync(childDone);
 }