コード例 #1
0
ファイル: MainForm_Core.cs プロジェクト: wuyaz/3DSRNGTool
        private void Search7_TimelineLeap()
        {
            int start      = (int)Frame_min.Value;
            int target     = (int)TargetFrame.Value;
            int Totaldelay = FuncUtil.CalcFrame(Seed.Value, start, target, Modelnum)[0];
            int mindelay   = (int)Math.Round(DelayMin.Value * 30);
            int maxdelay   = (int)Math.Round(DelayMax.Value * 30);
            int starttime  = Totaldelay - maxdelay;
            int endtime    = Totaldelay - mindelay;

            // Intialize
            SFMT sfmt = new SFMT(Seed.Value);

            for (int i = 0; i < start; i++)
            {
                sfmt.Next();
            }
            ModelStatus status = new ModelStatus(Modelnum, sfmt)
            {
                IsBoy = Boy.Checked
            };

            // Advance
            int frame = start;

            for (int i = 0; i < starttime; i++)
            {
                frame += status.NextState();
            }
            for (int i = start; i < frame; i++)
            {
                sfmt.Next();
            }

            getsetting(sfmt);

            List <int>         Framelist  = new List <int>();
            List <ModelStatus> statuslist = new List <ModelStatus>();
            List <int>         timelist   = new List <int>();

            // Search
            int         LeapType = getLeapType();
            int         frameadvance;
            int         Tmpframe, bakframe1, bakframe2 = 0;
            ModelStatus stmp, bak1, bak2 = null;

            for (int i = Math.Max(0, starttime); i < endtime; i++)
            {
                Tmpframe = frame;
                stmp     = status.Clone();

                // Leap!
                switch (LeapType)
                {
                case 0:     // WC7
                    for (int j = 0; j < 19; j++)
                    {
                        Tmpframe += stmp.NextState();
                    }
                    RNGPool.Rewind(Tmpframe - frame);
                    RNGPool.CopyStatus(stmp);
                    RNGPool.igenerator.Generate();
                    frameadvance = RNGPool.index - (Tmpframe - frame);
                    Tmpframe    += stmp.frameshift(frameadvance);
                    Tmpframe    += stmp.NextState();
                    break;

                case 1:     // Menu
                    stmp.fidget_cd = 3;
                    break;

                case 2:     // Dialogue
                    Tmpframe += stmp.NextState();
                    Tmpframe += stmp.NextState();
                    Tmpframe += stmp.frameshift(1);
                    Tmpframe += stmp.NextState();
                    break;
                }

                bak1      = stmp.Clone();
                bakframe1 = Tmpframe;

                // Check if hit
                while (Tmpframe < target)
                {
                    Tmpframe += stmp.NextState();
                }
                if (Tmpframe == target)
                {
                    Framelist.Add(frame);
                    timelist.Add(i);
                    bak2      = bak1.Clone();
                    bakframe2 = bakframe1;
                    statuslist.Add(stmp.Clone());
                }

                // Move to next state
                frameadvance = status.NextState();
                frame       += frameadvance;
                for (int j = 0; j < frameadvance; j++)
                {
                    RNGPool.AddNext(sfmt);
                }
            }

            if (Framelist.Count > 0)
            {
                int frame0 = Framelist.Last();
                Frame_max.Value = frame0;
                if (!IsEvent)
                {
                    JumpFrame.Value = frame0;
                }
                if (FormUtil.Prompt(MessageBoxButtons.YesNo, string.Format("Hit A at {0} (Frame1) and then at {1} (Frame2).\n\nYes: Check new timeline / No: Check the spread", frame0, target)) == DialogResult.Yes)
                {
                    Search7_TimelineLeap1(bakframe2, target, bak2, maxdelay);
                    foreach (var f in Frames)
                    {
                        f.Frame0 = frame0;
                    }
                }
                else
                {
                    Search7_TimelineLeap2(Framelist, statuslist, target, timelist);
                }
            }
            else
            {
                FormUtil.Error(StringItem.NORESULT_STR[StringItem.language]);
            }
        }