コード例 #1
0
            private void gen(int a, int b, int c)
            {
                Color[] cols = new Color[6];
                for (int i = 0; i < 6; i++)
                {
                    cols[i] = Color.Gray;
                }
                cols[Cube.L] = new Color[] { Color.Red, defcol, defcol }[a];
                cols[Cube.R] = new Color[] { defcol, defcol, Color.Orange }[a];
                cols[Cube.F] = new Color[] { Color.White, defcol, defcol }[b];
                cols[Cube.B] = new Color[] { defcol, defcol, Color.Yellow }[b];
                cols[Cube.D] = new Color[] { Color.Blue, defcol, defcol }[c];
                cols[Cube.U] = new Color[] { defcol, defcol, Color.Green }[c];
                int idx  = a * 9 + b * 3 + c;
                int pidx = idx * 8;

                this.cubes[idx] = new Cube(cols, this._points, pidx);
                for (int i = 0; i < 6; i++)
                {
                    int         index = idx * 6 + i;
                    Rect        rect  = cubes[idx].rects[i];
                    var         od    = new Odottedrect(rect, DOTCOUNT, 6f, SPRITESETTINGS);
                    FadeCommand fc    = new FadeCommand(start, start + 200, 0f, 1f);
                    od.addCommandOverride(fc);
                    this.dottedrects[index] = od;
                }
                vec3 basepoint = v3(a - 1, b - 1, c - 1) * SPACING + Zsc.mid;

                basepoint.z -= SIZE / 2;
                new Pcube(this.points, pidx).set(basepoint, SIZE, SIZE, SIZE);

                this.rots[new int[] { Cube.L, TMV, Cube.R }[a]].cubes[b * 3 + c] = this.cubes[idx];
                this.rots[new int[] { Cube.F, TMH, Cube.B }[b]].cubes[a * 3 + c] = this.cubes[idx];
                this.rots[new int[] { Cube.D, FM, Cube.U }[c]].cubes[a * 3 + b]  = this.cubes[idx];
            }
コード例 #2
0
        public FadeControl()
        {
            FadeCommand = new FadeCommand(this);


            //this.StartStories(null, this.Content as UIElement);
        }
コード例 #3
0
        /// <summary>
        /// 计算Fade时间轴,优化物件的FrameStartTime/EndTime,避免不必要的计算
        /// 点名批评 -> 181957
        ///
        ///
        ///Sprite,Foreground,Centre,"sb\light.png",320,240
        /// S,0,0,,0.22        <----Non-optimze obj.FrameStartTime
        /// MX,0,0,,278
        /// F,0,126739,,0            <----Kill by Optimzer
        /// F,0,208016,,0.7,1           <----Actual obj.FrameStartTime
        /// C,0,208016,,255,255,255
        /// P,0,208016,,A
        /// MY,0,208016,209286,520,-40   <----Actual obj.FrameEndTime
        ///
        /// </summary>
        /// <param name="Storyboard_objects"></param>
        /// <param name="effect_count"></param>
        public void TrimFrameTime(IEnumerable <StoryboardObject> Storyboard_objects, ref int effect_count)
        {
            var t = 0;

            ParallelableForeachExecutor.Foreach(true, Storyboard_objects, obj => {
                if (obj == null ||
                    obj is StoryboardAnimation || //qnmd
                    !obj.CommandMap.TryGetValue(Event.Fade, out var fade_list) ||
                    fade_list.Count == 0 ||
                    fade_list.Overlay ||
                    fade_list.Count <= 1
                    )
                {
                    return;
                }

                var first_fade = fade_list.First() as FadeCommand;

                if (first_fade != null)
                {
                    FadeCommand front_fade = null;

                    if ((first_fade.EndTime == 0 || first_fade.StartTime == first_fade.EndTime) && //是否为立即命令(dutation=0)
                        first_fade.EndValue == 0) //是否是隐藏的
                    {
                        if (fade_list.Skip(1).First() is FadeCommand second_fade)
                        {
                            front_fade = second_fade;
                        }
                    }
                    else if (first_fade.StartValue == 0)
                    {
                        front_fade = first_fade;
                    }

                    if (front_fade != null && obj.FrameStartTime <= front_fade.StartTime)
                    {
                        var trigger_time    = obj.ContainTrigger ? obj.CommandMap[Event.Trigger].Min(x => x.StartTime) : int.MaxValue;
                        var trim_start_time = Math.Min(trigger_time, front_fade.StartTime);

                        obj.BaseTransformResetAction += x => x.FrameStartTime = trim_start_time;
                        obj.FrameStartTime            = trim_start_time;
                        Suggest(obj, $"FrameTime可优化成{front_fade.StartTime}");
                        t++;
                    }
                }

                var last_fade = fade_list.Last() as FadeCommand;

                if (last_fade != null && last_fade.EndValue == 0)
                {
                    obj.FrameEndTime = last_fade.EndTime;
                    Suggest(obj, $"EndTime可优化成{last_fade.StartTime}.");
                    t++;
                }
            });

            effect_count = t;
        }
コード例 #4
0
    private void OnFadeIn(object fadeCommand)
    {
        FadeCommand command = (FadeCommand)(fadeCommand);

        if (command.gameObjectToFade != gameObject.name)
        {
            return;
        }

        gameObject.SetActive(true);
        fadingIn  = true;
        fadingOut = false;
        FadeIn(command.timeToFade);
    }
コード例 #5
0
ファイル: sprite.cs プロジェクト: yugecin/osusb1
            private void adjustLastFrame()
            {
                int actualendtime = endtime + framedelta;

                ICommand[] lastcmds =
                {
                    rotcmds.Last == null ? null : rotcmds.Last.Value,
                    movecmds.Last == null ? null : movecmds.Last.Value,
                    fadecmds.Last == null ? null : fadecmds.Last.Value,
                    colorcmds.Last == null ? null : colorcmds.Last.Value,
                    scalecmds.Last == null ? null : scalecmds.Last.Value,
                    vscalecmds.Last == null ? null : vscalecmds.Last.Value,
                };
                int lasttime = -1;

                for (int i = 0; i < lastcmds.Length; i++)
                {
                    if (lastcmds[i] != null)
                    {
                        int end = lastcmds[i].end;
                        if (end == actualendtime)
                        {
                            // nothing to do
                            return;
                        }
                        if (!lastcmds[i].From.Equals(lastcmds[i].To) || end < lasttime)
                        {
                            lastcmds[i] = null;
                            continue;
                        }
                        lasttime = lastcmds[i].end;
                    }
                }
                for (int i = 0; i < lastcmds.Length; i++)
                {
                    if (lastcmds[i] != null)
                    {
                        lastcmds[i].end = actualendtime;
                        return;
                    }
                }
                FadeCommand cmd = new FadeCommand(endtime, actualendtime, 1f, 1f);

                if (fadecmds.Last != null)
                {
                    cmd.to = cmd.from = fadecmds.Last.Value.to;
                }
                fadecmds.AddLast(cmd);
                allcmds.AddLast(cmd);
            }
コード例 #6
0
ファイル: PublicApis.cs プロジェクト: EmVerif/EmVerifPC
        public void Fade(
            string Trig,
            string VarName,
            double Target,
            double Time,
            string Next = null
            )
        {
            FadeCommand cmd = new FadeCommand(
                inVarName: VarName,
                inTarget: Target,
                inTime: Time,
                inNext: Next
                );

            PublicController.Instance.Register(Trig, cmd);
        }
コード例 #7
0
        public void CommandTest()
        {
            var command = new FadeCommand();

            command.StartTime  = 1000;
            command.EndTime    = 2000;
            command.StartValue = 1;
            command.EndValue   = 0;
            command.Easing     = EasingTypes.None;

            MemoryStream stream = new MemoryStream();

            StringCacheTable cache = new StringCacheTable();

            using (var writer = new BinaryWriter(stream))
            {
                command.OnSerialize(writer, cache);
            }

            var bytes = stream.ToArray();

            stream.Dispose();

            stream = new MemoryStream(bytes);

            using (var reader = new BinaryReader(stream))
            {
                var fade = CommandDeserializtionFactory.Create(reader, cache);

                Assert.AreEqual(command.StartTime, fade.StartTime);
                Assert.AreEqual(command.EndTime, fade.EndTime);
                Assert.AreEqual(command.Event, fade.Event);

                var x = fade as FadeCommand;
                Assert.IsNotNull(x);

                Assert.AreEqual(command.StartValue, x.StartValue);
                Assert.AreEqual(command.EndValue, x.EndValue);
                Assert.AreEqual(command.Easing, x.Easing);
            }
        }
コード例 #8
0
ファイル: Class1.cs プロジェクト: tummyacid/VS2015
    public void SendCommand(FadeCommand command)
    {

        _serialPort.Write(command.ToArray(), 0, 4);
    }
コード例 #9
0
ファイル: ztunnel.cs プロジェクト: yugecin/osusb1
            public Ztunnel(int start, int stop)
            {
                this.start = start;
                this.stop  = stop;
                framedelta = 300;
                FRAMEDELTA = framedelta;

                lighttimes.Add(21000);
                lighttimes.Add(29750);
                lighttimes.Add(38350);
                lighttimes.Add(47050);

                const int ssettings =
                    Sprite.INTERPOLATE_MOVE | Sprite.EASE_FADE | Sprite.EASE_SCALE;

                points        = new vec3[CIRCLEAMOUNT * LENGTH];
                _points       = new vec3[points.Length];
                dots0         = new Odot[points.Length];
                dots          = new Odot[points.Length];
                pointfadetime = new int[points.Length];
                Random r = new Random("sunpy:3".GetHashCode());

                int[] fadeoffset = new int[CIRCLEAMOUNT];
                float y          = -FADEEND;

                for (int i = 0; i < LENGTH; i++)
                {
                    y += SPACING;
                    if (i % SEGLENGTH == 0)
                    {
                        y += (SEGSPACINGMOD - 1) * SPACING;
                        for (int j = 0; j < CIRCLEAMOUNT; j++)
                        {
                            fadeoffset[j] = -1;
                        }
                    }
                    float ang     = 0f;
                    int   k       = 0;
                    int   segment = 0;
                    for (int j = 0; j < CIRCLEAMOUNT; j++)
                    {
                        if (++k < SEGWIDTH)
                        {
                            ang += ANGINC;
                        }
                        else
                        {
                            k    = 0;
                            ang += ANGINC * (SEGWIDTH + 1);
                            segment++;
                            if (fadeoffset[segment] == -1)
                            {
                                int v = r.Next(FADEWINDOW - framedelta);
                                fadeoffset[segment] = sync(v);
                            }
                        }
                        int  idx = i * CIRCLEAMOUNT + j;
                        vec3 p   = v3(Zsc.mid);
                        p.x        += cos(ang) * Zsc.TUNNEL_RAD;
                        p.y        += y;
                        p.z        += sin(ang) * Zsc.TUNNEL_RAD;
                        points[idx] = p;
                        dots0[idx]  = new Odot(Sprite.SPRITE_DOT_6_12, ssettings);
                        dots[idx]   = new Odot(Sprite.SPRITE_DOT_6_12, ssettings | Sprite.SESDSM);
                        int ft = stop - FADEWINDOW + fadeoffset[segment];
                        pointfadetime[idx] = ft;
                        FadeCommand fc;
                        fc = new FadeCommand(ft, ft + FADETIME, 1f, 0f);
                        dots[idx].addCommandOverride(fc);
                        foreach (int lighttime in lighttimes)
                        {
                            int          lightstart = lightStartTime(p, lighttime, lighttime);
                            int          lightend   = lightstart + LIGHTFALLOFFTIME;
                            ColorCommand cc;
                            cc        = new ColorCommand(lightstart, lightend, v3(1f), color);
                            cc.easing = eq2num(eq_in_quad);
                            dots[idx].addCommandOverride(cc);
                        }
                    }
                }
                framedelta = 900;
            }
コード例 #10
0
ファイル: sprite.cs プロジェクト: yugecin/osusb1
            private void processOverrides()
            {
                // TODO complete this when actually needed
                int actualendtime = endtime;

                if ((settings & INTERPOLATE_MOVE) == 0 && (settings & NO_ADJUST_LAST) == 0)
                {
                    actualendtime += framedelta;
                }
                foreach (ICommand o in overrides)
                {
                    if (o is ColorCommand)
                    {
                        ColorCommand c = (ColorCommand)o;
                        if (c.end <= starttime || c.start >= actualendtime)
                        {
                            continue;
                        }
                        if (c.start < starttime)
                        {
                            Eq    e = num2eq(c.easing);
                            float x = e(progress(c.start, c.end, starttime));
                            c.start = starttime;
                            c.from  = lerp(c.from, c.to, x);
                        }
                        if (c.end > actualendtime)
                        {
                            Eq    e = num2eq(c.easing);
                            float x = e(progress(c.start, c.end, actualendtime));
                            c.end = actualendtime;
                            c.to  = lerp(c.from, c.to, x);
                        }
                        colorcmds.AddLast(c);
                        addOrdened(c);
                    }
                    if (o is FadeCommand)
                    {
                        FadeCommand f = (FadeCommand)o;
                        if (f.end <= starttime || f.start >= actualendtime)
                        {
                            continue;
                        }
                        if (f.start < starttime)
                        {
                            Eq    e = num2eq(f.easing);
                            float x = e(progress(f.start, f.end, starttime));
                            f.start = starttime;
                            f.from  = lerp(f.from, f.to, x);
                        }
                        if (f.end > actualendtime)
                        {
                            Eq    e = num2eq(f.easing);
                            float x = e(progress(f.start, f.end, actualendtime));
                            f.end = actualendtime;
                            f.to  = lerp(f.from, f.to, x);
                        }
                        fadecmds.AddLast(f);
                        addOrdened(f);
                    }
                }
            }
コード例 #11
0
ファイル: sprite.cs プロジェクト: yugecin/osusb1
 public void addFade(FadeCommand cmd)
 {
     fadecmds.AddLast(cmd);
     allcmds.AddLast(cmd);
 }
コード例 #12
0
    void CustomCommand( string command, bool pushCommand = false )
    {
        char[] delimiter = new char[3];
        delimiter[0] = ' ';
        delimiter[1] = '\t';
        delimiter[2] = '%';
        string[] parsedCommand = command.Split( delimiter, System.StringSplitOptions.RemoveEmptyEntries );
        switch( parsedCommand[0].ToLower() )
        {
            case "bgm":
                {

                    if (parsedCommand.Length > 1)
                    {
                        Debug.Log("<color=green>[StringParser]</color> CREATED NEW BGM COMMAND + " + parsedCommand[1].ToLower());
                        MusicCommand BGM = new MusicCommand();
                        BGM.Set(parsedCommand[1].ToLower());
                        CommandManager.Instance.AddCommand(BGM);
                    }
                }
                break;
        //NOTE(Hendry)::Add command here
        case "bg":
        BgCommand bgc = new BgCommand();
        if( parsedCommand.Length == 2 )
        {
            bgc.SetBg(parsedCommand[1].ToLower());
            if (parsedCommand.Length == 3)
            {
                bgc.SetSpd(int.Parse(parsedCommand[2]));
            }
            if( pushCommand )
            {
                CommandManager.Instance.AddPushCommand(bgc);
            }
            else
            {
                CommandManager.Instance.AddCommand( bgc );
            }
        }

        break;

        case "show":
        ShowCharacterCommand character = new ShowCharacterCommand();
        if( parsedCommand.Length >= 3 )
        {
            character.SetCharacterName( parsedCommand[1].ToLower() );
            character.SetSpawnLocation( parsedCommand[2].ToLower() );
            if( pushCommand )
            {
                CommandManager.Instance.AddPushCommand( character );
            }
            else
            {
                CommandManager.Instance.AddCommand( character );
            }
            if (parsedCommand.Length >= 4)
            {
                character.SetFacing( parsedCommand[3].ToLower() );
            }
        }
        break;

        case "pose":
        ChangePoseCommand newPoseCommand = new ChangePoseCommand();
        newPoseCommand.SetNewPose( parsedCommand[1].ToLower(), parsedCommand[2].ToLower() );
        if( pushCommand )
        {
            CommandManager.Instance.AddPushCommand( newPoseCommand );
        }
        else
        {
            CommandManager.Instance.AddCommand( newPoseCommand );
        }
        break;

        case "location":
        if( parsedCommand.Length == 3 )
        {
            bool set = false;
            if( parsedCommand[2].ToLower() == "on" )
            {
                set = true;
            }
            else if( parsedCommand[2].ToLower() == "off" )
            {
                set = false;
            }
            else
            {
                Debug.Log( "[String Parser]<color=red>wrong command</color> !! the format is icon iconName on/off" );
                //Debug.Break();
            }
            locationManager.Instance.SetButton(parsedCommand[1], set);
        }
        else
        {
            Debug.Log( "[String Parser]<color=red>wrong command</color> !! the format is icon iconName on/off" );
            //Debug.Break();
        }
        break;

        case "eff":
        EffectCommand newEffect = new EffectCommand();
        newEffect.SetEffect( parsedCommand[1] );
        if( pushCommand )
        {
            CommandManager.Instance.AddPushCommand( newEffect );
        }
        else
        {
            CommandManager.Instance.AddCommand( newEffect );
        }
        break;

        case "item":
        if(!GameManager.instance.IsDemoMode())
        ItemManager.Instance.AddItem( parsedCommand[1].ToLower() );
        break;

        case "icon":
        //Note(Hendry) : format is -> icon itemName position scale
        // position[] = middle/mid/m left/l right/r
        // scale float value
        // to destroy -> icon destroy
        IconCommand iconCommand;
        if( parsedCommand[1].ToLower() == "destroy" )
        {
            iconCommand = new IconCommand( true );
        }
        else
        {
            iconCommand = new IconCommand( parsedCommand[1], parsedCommand[2], float.Parse( parsedCommand[3] ) );
        }
        CommandManager.Instance.AddCommand( iconCommand );
        break;

        case "prompt":
        // note : prompt will call the menu then open evidence tab
        // format -> prompt itemName
        CommandManager.Instance.correctItem = parsedCommand[1];
        OpenMenuCommand menuCommand = new OpenMenuCommand();
        CommandManager.Instance.AddCommand( menuCommand );
        break;

        case "advquest":
        if (!GameManager.instance.IsDemoMode())
        SceneManager.Instance.AdvQuest();
        break;

        case "load":
        LoadCommand dialogue = new LoadCommand();
        if( parsedCommand.Length == 2 )
        {
            dialogue.SetLoad( parsedCommand[1].ToLower() );
            CommandManager.Instance.AddCommand( dialogue );
        }
        break;
            case"fade":
                {
                    if (parsedCommand.Length > 2)
                    {
                        FadeCommand foo = new FadeCommand();

                        if (parsedCommand[1].ToLower() == "in")
                            foo.SetFade(-1, float.Parse(parsedCommand[2]));
                        else
                            foo.SetFade(1, float.Parse(parsedCommand[2]));

                        CommandManager.Instance.AddCommand(foo);
                    }
                    else if(parsedCommand.Length > 1)
                    {
                        FadeCommand foo = new FadeCommand();

                        if (parsedCommand[1].ToLower() == "in")
                            foo.SetFade(-1);
                        else
                            foo.SetFade(1);

                        CommandManager.Instance.AddCommand(foo);
                    }
                    else
                    {
                        Debug.Log("STRING PARSER - FADE COMMAND NOT LONG ENOUGH");
                    }
                }
                break;
        }
    }
コード例 #13
0
            public Ztor(int start, int stop)
            {
                this.start        = start;
                this.stop         = stop;
                framedelta        = 125;
                phantomframedelta = 25;

                string text = "Lacking creativity to make a better storyboard"
                              + "... hope you enjoyed this!";

                txtpoints = new vec2[font.calcPointCount(text)];
                txtdots   = new Odot[txtpoints.Length];
                const float FONTSPACING = 2f;
                int         pointidx    = 0;
                vec2        fonttopleft = v2(UPPERBOUND, 260 - font.charheight / 2f * FONTSPACING);

                for (int i = 0; i < text.Length; i++)
                {
                    int  c   = text[i] - 32;
                    vec2 pos = v2(fonttopleft);
                    for (int j = 0; j < font.charheight; j++)
                    {
                        int cw = font.charwidth[c];
                        for (int k = 0; k < font.charwidth[c]; k++)
                        {
                            if (((font.chardata[c][j] >> k) & 1) == 1)
                            {
                                int idx = pointidx++;
                                txtpoints[idx] = pos + v2(k * FONTSPACING, 0f);
                                txtdots[idx]   = new Odot(
                                    Sprite.SPRITE_SQUARE_2_2,
                                    Sprite.INTERPOLATE_MOVE | Sprite.COMPRESS_MOVE
                                    );
                            }
                        }
                        pos.y += FONTSPACING;
                    }
                    fonttopleft.x += (font.charwidth[c] + 1) * FONTSPACING;
                }

                this.rects   = new Rect[DIVH * DIVV];
                this.points  = new vec3[DIVH * DIVV];
                dots         = new Odot[rects.Length];
                this._points = new vec3[DIVH * DIVV];
                const float INTH = 360f / DIVH;
                const float INTV = 360f / DIVV;

                for (int a = 0; a < DIVH; a++)
                {
                    vec3  p1   = v3(mid);
                    float anga = rad(INTH * a);
                    for (int b = 0; b < DIVV; b++)
                    {
                        var s = Sprite.EASE_ALL | Sprite.SESDSM | Sprite.SESDSC;
                        var d = new Odot(Sprite.SPRITE_DOT_6_12, s);
                        var c = new FadeCommand(stop - 500, stop, 1f, 0f);
                        d.addCommandOverride(c);
                        dots[a * DIVV + b] = d;
                        float angb = rad(INTV * b);
                        float dist = RH - RV * cos(angb);
                        vec3  p    = mid + v3(dist * cos(anga), dist * sin(anga), RV * sin(angb));
                        this.points[a * DIVV + b] = p;

                        int a_ = (a + 1) % DIVH;
                        int b_ = (b + 1) % DIVV;

                        int _1 = a * DIVV + b;
                        int _2 = a_ * DIVV + b;
                        int _3 = a * DIVV + b_;
                        int _4 = a_ * DIVV + b_;

                        Rect r = new Rect(this, Color.Green, this._points, _1, _2, _3, _4);
                        this.rects[a * DIVV + b] = r;
                    }
                }

                vec3[] rpts =
                {
                    // I have no clue really
                    mid + v3(-100, -70,  80),
                    mid + v3(100,  -70,  80),
                    mid + v3(-100, -70, -80),
                    mid + v3(100,  -70, -80),
                };
                textplane = new Rect(null, Color.Red, rpts, 0, 1, 2, 3);
            }