Esempio n. 1
0
    //Special_script_parserの実際のコマンドを解析する関数
    void Special_script_parser_sub(string temp)
    {
        switch (temp[0])
        {
        case '!':
        {
            COMMAND_TYPE t = COMMAND_TYPE.WAIT_B;
            if (temp[1] == 'w')
            {
                t = COMMAND_TYPE.WAIT_W;
            }
            string timer = temp.Substring(2, temp.Length - 2);
            scriptions.Add(new WAIT_scription(Int32.Parse(timer), true, temp, t));
        }
        break;

        default:
            if (temp[0] == 'b' && temp[1] == 'g' && temp[2] == ' ')
            {
                string[] a    = temp.Split(' ');
                string[] b    = a[1].Split(',');
                int      time = 0;

                //アニメーション情報の指定
                ANIMATION_TYPE type = Animation_Type_Define(Int32.Parse(b[1]));
                if (type != ANIMATION_TYPE.ANIMATION_NO_TIME)
                {
                    time = Int32.Parse(b[2]);
                }
                if (b[0].Equals("white"))
                {
                    scriptions.Add(new COLOR_scription(Scripter.Color_Parser("#FFFFFF"), b[1], COMMAND_TYPE.BACKGROUND_COLOR));
                }
                else if (b[0].Equals("black"))
                {
                    scriptions.Add(new COLOR_scription(Scripter.Color_Parser("#000000"), b[1], COMMAND_TYPE.BACKGROUND_COLOR));
                }
                else if (b[0][0] == '#')
                {
                    scriptions.Add(new COLOR_scription(Scripter.Color_Parser(b[0]), b[1], COMMAND_TYPE.BACKGROUND_COLOR));
                }
                else
                {
                    string[] path = b[0].Split('\"');

                    scriptions.Add(new IMAGE_scription(null, type, b[1], time, path[1], COMMAND_TYPE.BACKGROUND_IMAGE));
                }
                break;
            }

            if (temp[0] == 'l' && temp[1] == 'd')
            {
                string[]     a           = temp.Split(' ');
                string[]     b           = a[1].Split(',');
                int          time        = 0;
                int          place       = 1;
                COMMAND_TYPE command_tmp = COMMAND_TYPE.STAND_IMAGE;
                switch (b[0][0])
                {
                case 'c':
                    place = 2;
                    //command_tmp = COMMAND_TYPE.STAND_IMAGE_CENTER;
                    break;

                case 'l':
                    place = 4;
                    //command_tmp = COMMAND_TYPE.STAND_IMAGE_RIGHT;
                    break;
                }
                string[] path = b[1].Split('\"');

                //アニメーション情報の指定
                ANIMATION_TYPE type = Animation_Type_Define(Int32.Parse(b[2]));

                //エフェクト番号0番、1番は時間を取得しない
                if (type != ANIMATION_TYPE.ANIMATION_NO_TIME && type != ANIMATION_TYPE.ANIMATION_SYNCHRO)
                {
                    time = Int32.Parse(b[3]);
                }
                scriptions.Add(new STAND_IMAGE_scription(place, null, type, b[1], time, path[1], command_tmp));
                break;
            }
            Debug.Log((temp));
            scriptions.Add(new Text_scription("", false, AddRuby(AddBreak(temp)), COMMAND_TYPE.NORMAL_TEXT_CONTINUE));
            break;
        }
    }
Esempio n. 2
0
    //スクリプトを構文解析する関数
    void Script_parser(string temp)
    {
        Debug.Log("Script_parser");
        if (temp.Length <= 0)
        {
            return;
        }
        switch (temp[0])
        {
        //コメント
        case ';':
            break;

        case '!':
        {
            COMMAND_TYPE t = COMMAND_TYPE.WAIT_B;
            if (temp[1] == 'w')
            {
                t = COMMAND_TYPE.WAIT_W;
            }
            if (temp[1] == 's')
            {
                t = COMMAND_TYPE.WAIT_S;
            }
            string timer    = temp.Substring(2, temp.Length - 2);
            bool   skipflag = true;
            scriptions.Add(new WAIT_scription(Int32.Parse(timer), skipflag, temp, t));
        }
        break;

        case '[':
        {
            Special_script_parser(temp);
        }
        break;

        case '#':
            scriptions.Add(new COLOR_scription(Scripter.Color_Parser(temp), "", COMMAND_TYPE.COLOR));
            break;

        case '*':
            Debug.Log(temp);
            label_line.Add(temp, scriptions.Count);
            label_filename.Add(temp, "");
            break;

        default:
            string[] a = temp.Split(' ');               //命令コマンドと引数を分離
            //bg命令
            if (a[0] == "bg")
            {
                //string[] a = temp.Split(' ');   //命令コマンドと引数を分離
                string[] b    = a[1].Split(',');    //引数をカンマで各取得
                int      time = 0;

                //アニメーション情報の指定
                ANIMATION_TYPE type = Animation_Type_Define(Int32.Parse(b[1]));
                if (type != ANIMATION_TYPE.ANIMATION_NO_TIME && type != ANIMATION_TYPE.ANIMATION_SYNCHRO)
                {
                    time = Int32.Parse(b[2]);
                }

                //命令第一引数で、背景の指定を変化(色or画像)
                if (b[0].Equals("white"))
                {
                    scriptions.Add(new COLOR_scription(Scripter.Color_Parser("#FFFFFF"), b[1], time, type, COMMAND_TYPE.BACKGROUND_COLOR));
                }
                else if (b[0].Equals("black"))
                {
                    scriptions.Add(new COLOR_scription(Scripter.Color_Parser("#000000"), b[1], time, type, COMMAND_TYPE.BACKGROUND_COLOR));
                }
                else if (b[0][0] == '#')
                {
                    scriptions.Add(new COLOR_scription(Scripter.Color_Parser(b[0]), b[1], time, type, COMMAND_TYPE.BACKGROUND_COLOR));
                }
                else
                {
                    string[] path = b[0].Split('\"');
                    scriptions.Add(new IMAGE_scription(null, type, b[1], time, path[1], COMMAND_TYPE.BACKGROUND_IMAGE));
                }

                break;
            }
            //bgm命令
            else if (a[0] == "bgm")
            {
                string[] b = a[1].Split('\"');
                scriptions.Add(new AUDIO_scription(Resources.Load <AudioClip>(b[1]), "", b[1], COMMAND_TYPE.AUDIO_BGM));
                break;
            }
            //bgmstop命令
            else if (a[0] == "bgmstop")
            {
                scriptions.Add(new Scription("bgmstop", COMMAND_TYPE.AUDIO_BGM_STOP));
                break;
            }

            //cl命令
            if (a[0] == "cl")
            {
                //string[] a = temp.Split(' ');
                string[] b     = a[1].Split(',');
                int      place = 1; //r 001
                int      time  = 0;
                switch (b[0][0])
                {
                case 'c':           //010
                    place = 2;
                    break;

                case 'l':           //100
                    place = 4;
                    break;

                case 'a':           //111
                    place = 7;
                    break;
                }
                //アニメーション情報の指定
                ANIMATION_TYPE type = Animation_Type_Define(Int32.Parse(b[1]));
                if (type != ANIMATION_TYPE.ANIMATION_NO_TIME && type != ANIMATION_TYPE.ANIMATION_SYNCHRO)
                {
                    time = Int32.Parse(b[2]);
                }

                scriptions.Add(new IMAGE_clear_scription(place, type, time, b[1], COMMAND_TYPE.STAND_IMAGE_CLEAR));
                break;
            }
            //partyadd命令
            // partyadd scobjname,level  レベルは無くてもよい
            if (a[0] == "partyadd")
            {
                string[] b         = a[1].Split(',');
                string   scobjname = b[0];
                int      level     = 0;
                //levelがかかれていた場合
                if (b.Length >= 2)
                {
                    level = int.Parse(b[1]);
                }

                scriptions.Add(new PARTY_scription(scobjname, level, "PARTY ADD", COMMAND_TYPE.PARTY_ADD));
                break;
            }
            //partyremove命令
            // partyremove scobjname
            if (a[0] == "partyremove")
            {
                string scobjname = a[1];
                scriptions.Add(new PARTY_scription(scobjname, 0, "PARTY REMOVE", COMMAND_TYPE.PARTY_REMOVE));
                break;
            }
            //delay命令
            if (a[0] == "delay")
            {
                //string[] a = temp.Split(' ');
                scriptions.Add(new WAIT_scription(Int32.Parse(a[1]), true, "", COMMAND_TYPE.WAIT));
                break;
            }
            //jump命令
            if (a[0] == "jump")
            {
                //string[] a = temp.Split(' ');
                scriptions.Add(new JUMP_scription(a[1], 0, "", "", COMMAND_TYPE.JUMP));
                break;
            }
            //ld命令
            if (a[0] == "ld")
            {
                //string[] a = temp.Split(' ');
                string[]     b           = a[1].Split(',');
                int          time        = 0;
                int          place       = 1; // r  001
                COMMAND_TYPE command_tmp = COMMAND_TYPE.STAND_IMAGE;
                switch (b[0][0])
                {
                case 'c':
                    place = 2;         //010
                    //command_tmp = COMMAND_TYPE.STAND_IMAGE_CENTER;
                    break;

                case 'l':
                    place = 4;         //100
                    //command_tmp = COMMAND_TYPE.STAND_IMAGE_RIGHT;
                    break;
                }
                string[] path = b[1].Split('\"');

                //アニメーション情報の指定
                ANIMATION_TYPE type = Animation_Type_Define(Int32.Parse(b[2]));
                if (type != ANIMATION_TYPE.ANIMATION_NO_TIME && type != ANIMATION_TYPE.ANIMATION_SYNCHRO)
                {
                    time = Int32.Parse(b[3]);
                }

                scriptions.Add(new STAND_IMAGE_scription(place, null, type, b[2], time, path[1], command_tmp));
                break;
            }
            //monocro命令
            //monocro #COLOR で色調マスクをON、色変更
            //monocro offでマスクを解除
            if (a[0] == "monocro")
            {
                //string[] a = temp.Split(' ');   //命令コマンドと引数を分離
                if (a[1] == "off")
                {
                    scriptions.Add(new Scription("monocro off", COMMAND_TYPE.MONOCRO_OFF));
                }
                else
                {
                    scriptions.Add(new COLOR_scription(Scripter.Color_Parser(a[1]), "monocro on", COMMAND_TYPE.MONOCRO_ON));
                }
                break;
            }
            //return命令
            if (a[0] == "return")
            {
                scriptions.Add(new Scription("finish", COMMAND_TYPE.RETURN));
                break;
            }
            //sestop命令
            if (a[0] == "sestop")
            {
                scriptions.Add(new Scription("sestop", COMMAND_TYPE.AUDIO_SE_STOP));
                break;
            }
            //setwindow命令
            else if (a[0] == "setwindow")
            {
                //string[] a = temp.Split(' ');
                string[] b = a[1].Split(',');

                string imgsource = b[0].Split('\"')[1];
                float  x         = float.Parse(b[1]);
                float  y         = float.Parse(b[2]);

                scriptions.Add(new UI_IMAGE_scription(x, y, imgsource, COMMAND_TYPE.SETWINDOW));

                break;
            }
            //se命令
            else if (a[0] == "seloop")
            {
                //string[] a = temp.Split('\"');
                string[] b = a[1].Split('\"');
                scriptions.Add(new AUDIO_scription(Resources.Load <AudioClip>(b[1]), "loop", b[1], COMMAND_TYPE.AUDIO_SE));
                break;
            }
            //se命令
            else if (a[0] == "se")
            {
                //string[] a = temp.Split('\"');
                string[] b = a[1].Split('\"');
                scriptions.Add(new AUDIO_scription(Resources.Load <AudioClip>(b[1]), "", b[1], COMMAND_TYPE.AUDIO_SE));
                break;
            }
            //texton命令
            if (a[0] == "texton")
            {
                scriptions.Add(new Scription("texton", COMMAND_TYPE.TEXTON));
                break;
            }
            //textoff命令
            else if (a[0] == "textoff")
            {
                scriptions.Add(new Scription("textoff", COMMAND_TYPE.TEXTOFF));
                break;
            }

            //voicestop命令
            if (a[0] == "voicestop")
            {
                scriptions.Add(new Scription("voicestop", COMMAND_TYPE.AUDIO_VOICE_STOP));
                break;
            }
            //voice命令
            else if (a[0] == "voice")
            {
                //string[] a = temp.Split('\"');
                string[] b = a[1].Split('\"');
                scriptions.Add(new AUDIO_scription(Resources.Load <AudioClip>(b[1]), "voice", b[1], COMMAND_TYPE.AUDIO_VOICE));
                break;
            }

            //wait命令
            if (a[0] == "wait")
            {
                //string[] a = temp.Split(' ');
                scriptions.Add(new WAIT_scription(Int32.Parse(a[1]), false, "", COMMAND_TYPE.WAIT));
                break;
            }
            Special_script_parser(temp);
            break;
        }
    }