예제 #1
0
    private void Addmenu(int id, string number, string thum, string title, string scene, int dis, int lat, int lon)
    {
        Vector3 position = ObjectAppear.GetPosition(dis, lat, lon);
        //GameObject menu = Resources.Load("menu/Menu") as GameObject;
        GameObject new_obj   = Instantiate(menu, Vector3.zero, Quaternion.Euler(0, 0, 0)) as GameObject;
        GameObject thum_obj  = new_obj.transform.Find("Thum").gameObject;
        GameObject num_obj   = new_obj.transform.Find("No").gameObject;
        GameObject title_obj = new_obj.transform.Find("Title").gameObject;
        GameObject go_obj    = new_obj.transform.Find("Go").gameObject;

        TextMesh tn = (TextMesh)num_obj.GetComponent(typeof(TextMesh));

        tn.text = number;

        TextMesh tt = (TextMesh)title_obj.GetComponent(typeof(TextMesh));

        tt.text = title;
        //Material mat1 = thum_obj.GetComponent<Renderer>().material;
        Texture img = Resources.Load("menu/thum/" + thum) as Texture;

        //mat1.mainTexture = img;
        thum_obj.GetComponent <Renderer>().material.mainTexture = img;
        go_obj.name = scene;

        new_obj.transform.position = position;
        new_obj.transform.LookAt(Vector3.zero);
        new_obj.transform.Rotate(new Vector3(90f, 0f, 0f));
    }
예제 #2
0
    // Update is called once per frame
    void Update()
    {
        //新しいシーンに移った時の処理
        if (scene != scene_before)
        {
            Debug.Log("next scene");
            Debug.Log(scene);
            //scene before 更新
            scene_before = scene;
            //このシーンで消すべきもの
            //TODO(シーン単位ではなく、時間で決めるかも)
            for (int i = 0; i < delete_list[scene].Count; i++)
            {
                if (delete_list[scene].ElementAt(i) == "text")
                {
                    ObjectAppear.insideText.SetActive(false);
                }
                else
                {
                    ObjectAppear.Deleteobj(delete_list[scene].ElementAt(i));
                }
            }
            //時間を新しくカウントし始める
            scene_start_time = TimeManager.time;
            scene_timer      = 0;

            //plotを1つ進める
            plot_count++;
        }

        //正規表現により,で分割するため
        string pattern = ",(?=(?:[^\"]*\"[^\"]*\")*[^\"]*$)";
        Regex  reg     = new Regex(pattern);

        //plotが進められた時
        if (plot_count_before != plot_count)
        {
            //更新
            plot_count_before = plot_count;

            //メモリ節約のため一行ずつ解析する
            //separators = new char[] { ',' };
            //plots = plotLine[plot_count].Split(separators, StringSplitOptions.RemoveEmptyEntries);

            plots = reg.Split(plotLine[plot_count]).Where(s => s != String.Empty).ToArray <string>();
            Debug.Log(plots[0]);
            Debug.Log(plots[1]);
            Debug.Log(plots[2]);
            Debug.Log(plots[3]);
            Debug.Log(plots[4]);
            //0:scene 1:time 2:type 3:content 4:size 5:d 6:lon 7:lat 8:rotate_p 9lotate_y 10:delete 11:eng 12:color
            //2/quote/1/台詞@改行あり/6/20/10/2/english/-120/0
            string src;

            switch (plots[2])
            {
            case "bg":
                src = folder_name + "/" + plots[3];
                ChangeImage.ChangeBg(src);
                break;

            case "img":
                //パラメータの取得
                //0:scene 1:time 2:type 3:content 4:size 5:d 6:lon 7:lat 8:rotate_p 9lotate_y 10:delete 11:eng 12:color
                src = folder_name + "/" + plots[3];
                float scalei   = float.Parse(plots[4]);
                float disi     = float.Parse(plots[5]);
                int   loni     = int.Parse(plots[6]);
                int   lati     = int.Parse(plots[7]);
                int   rotatei  = int.Parse(plots[8]);
                int   rotate2i = int.Parse(plots[9]);
                int   deletei  = int.Parse(plots[10]);

                ObjectAppear.Addimg(img_id, src, disi, lati, loni, scalei, rotatei, rotate2i);
                delete_list[deletei].Add("img" + img_id);
                //delete_list[deletei].Add(src);
                img_id++;
                break;

            case "quote":
                string[] lines;
                //パラメータの取得
                //0:scene 1:time 2:type 3:content 4:size 5:d 6:lon 7:lat 8:rotate_p 9lotate_y 10:delete 11:eng 12:color
                if (LanguageButton.language_flag == 0)
                {
                    //改行コードで分割
                    lines = plots[3].Split(new string[] { "\n", "\r", "@" }, StringSplitOptions.None);
                }
                else
                {
                    lines = plots[11].Split(new string[] { "\n", "\r", "@" }, StringSplitOptions.None);
                }
                string textq = lines[0];
                for (int i = 1; i < lines.Length; i++)
                {
                    textq += "\n";
                    textq += lines[i];
                }
                float scaleq  = float.Parse(plots[4]);
                float disq    = float.Parse(plots[5]);
                int   lonq    = int.Parse(plots[6]);
                int   latq    = int.Parse(plots[7]);
                int   fromq   = int.Parse(plots[8]); //use rotate_p
                int   deleteq = int.Parse(plots[10]);

                Debug.Log("quote check");
                Debug.Log(textq);

                ObjectAppear.Addquote(quote_id, textq, disq, latq, lonq, scaleq, fromq);
                delete_list[deleteq].Add("quote" + quote_id);
                quote_id++;
                break;

            case "next":
                //パラメータの取得
                //0:scene 1:time 2:type 3:content 4:size 5:d 6:lon 7:lat 8:rotate_p 9lotate_y 10:delete 11:eng 12:color
                float disn    = float.Parse(plots[5]);
                int   lonn    = int.Parse(plots[6]);
                int   latn    = int.Parse(plots[7]);
                int   deleten = int.Parse(plots[10]);

                /*
                 * if (plots.Length > 10)
                 * {
                 *  NextButton.transition_type[next_id] = plots[10];
                 * }
                 * else
                 * {
                 *  NextButton.transition_type[next_id] = "nothing";
                 * }*/
                ObjectAppear.Addnext(next_id, disn, latn, lonn);
                delete_list[scene + 1].Add("next" + next_id);
                next_id++;
                break;

            /*case "obj": //object(assset)
             *  src = plots[3]; //folder_name + "/" + plots[3];
             *  float diso = float.Parse(plots[4]);
             *  int lato = int.Parse(plots[5]);
             *  int lono = int.Parse(plots[6]);
             *  int rotateo = int.Parse(plots[9]);
             *  int deleteo = int.Parse(plots[7]);
             *  ObjectAppear.Addobj(obj_id, src, diso, lato, lono, rotateo);
             *  //delete_list[deleteo].Add("obj" + obj_id);
             *  delete_list[deleteo].Add(src);
             *  obj_id++;
             *  break;
             */
            case "sphere":
                //パラメータの取得
                //0:scene 1:time 2:type 3:content 4:size 5:d 6:lon 7:lat 8:rotate_p 9lotate_y 10:delete 11:eng 12:color
                src = folder_name + "/" + plots[3];
                float scales  = float.Parse(plots[4]);
                int   rotates = int.Parse(plots[8]);
                int   deletes = int.Parse(plots[10]);
                ObjectAppear.Addsphere(sphere_id, src, scales, rotates);
                delete_list[deletes].Add("sphere" + sphere_id);
                //delete_list[deletes].Add(src);
                sphere_id++;
                break;

            case "text":
                string[] linest;
                //パラメータの取得
                //0:scene 1:time 2:type 3:content 4:size 5:d 6:lon 7:lat 8:rotate_p 9lotate_y 10:delete 11:eng 12:color
                if (LanguageButton.language_flag == 0)
                {
                    linest = plots[3].Split(new string[] { "\n", "\r", "@" }, StringSplitOptions.None);
                }
                else
                {
                    linest = plots[11].Split(new string[] { "\n", "\r", "@" }, StringSplitOptions.None);
                }
                string textt = linest[0];
                for (int i = 1; i < linest.Length; i++)
                {
                    textt += "\n";
                    textt += linest[i];
                }
                int    deletet = int.Parse(plots[10]);
                string colort  = plots[12];
                ObjectAppear.ChangeInsideText(textt, colort);
                delete_list[deletet].Add("text");
                break;

            /*
             * case "delete":
             *  src = plots[3]; //folder_name + "/" + plots[3];
             *  for (int i = 0; i < scene_max; i++)
             *  {
             *      if (delete_list[i].Contains(src) == true)
             *      {
             *          delete_list[i].Remove(src);
             *          ObjectAppear.Deleteobj(src);
             *      }
             *  }
             *  break;
             */
            case "end":
                SceneManager.LoadScene("menu", LoadSceneMode.Single);
                break;

            default:
                Debug.Log("Default case");
                break;
            }
        }

        //plot_countを進める条件(時間)
        if (plots[2] != "next")
        {
            if (plot_count < plotLine.Length)
            {
                //next_time = int.Parse(plotLine[plot_count + 1].Split(separators, StringSplitOptions.RemoveEmptyEntries)[0]);
                string[] next_plots = reg.Split(plotLine[plot_count + 1]).Where(s => s != String.Empty).ToArray <string>();
                next_time = int.Parse(next_plots[1]);
                //Debug.Log("lengthOK nextTime " + next_time +" nowtime " + (TimeManager.time - scene_start_time));
                if ((TimeManager.time - scene_start_time) >= next_time)
                {
                    //Debug.Log("TimeOK");
                    plot_count++;
                }
            }
        }

        if (Input.GetKeyDown(KeyCode.Space))
        {
            while (plots[2] != "next")
            {
                plot_count++;
                //plots = plotLine[plot_count].Split(new char[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries);
            }
            scene++;
        }
    }
예제 #3
0
    // Update is called once per frame
    void Update()
    {
        if (scene != scene_before)
        {
            scene_before = scene;
            //このsceneでdeleteすべきものがあれば消す

            for (int i = 0; i < delete_list[scene].Count; i++)
            {
                if (delete_list[scene].ElementAt(i) == "text")
                {
                    ObjectAppear.insideText.SetActive(false);
                }
                else
                {
                    ObjectAppear.Deleteobj(delete_list[scene].ElementAt(i));
                }
            }
            scene_start_time = TimeManager.time;
            plot_count++;
        }
        if (plot_count_before != plot_count)
        {
            plot_count_before = plot_count;
            separators        = new char[] { '/' };
            plots             = plotLine[plot_count].Split(separators, StringSplitOptions.RemoveEmptyEntries);
            string src;
            switch (plots[1])
            {
            case "bg":
                src = plots[3];     //folder_name + "/" + plots[3];
                ChangeImage.ChangeBg(src);
                break;

            case "img":
                src = plots[3];     //folder_name + "/" + plots[3];
                float scalei  = float.Parse(plots[2]);
                float disi    = float.Parse(plots[4]);
                int   lati    = int.Parse(plots[5]);
                int   loni    = int.Parse(plots[6]);
                int   rotatei = int.Parse(plots[9]);
                int   rotate2i;
                if (plots.Length > 10)
                {
                    rotate2i = int.Parse(plots[10]);
                }
                else
                {
                    rotate2i = 0;
                }
                int deletei = int.Parse(plots[7]);
                ObjectAppear.Addimg(img_id, src, disi, lati, loni, scalei, rotatei, rotate2i);
                delete_list[deletei].Add(src);
                img_id++;
                break;

            case "quote":
                string[] lines;
                if (LanguageButton.language_flag == 0)
                {
                    lines = plots[3].Split(new string[] { "\n", "\r", "@" }, StringSplitOptions.None);
                }
                else
                {
                    lines = plots[8].Split(new string[] { "\n", "\r", "@" }, StringSplitOptions.None);
                }
                string textq = lines[0];
                for (int i = 1; i < lines.Length; i++)
                {
                    textq += "\n";
                    textq += lines[i];
                }
                float disq    = float.Parse(plots[4]);
                int   latq    = int.Parse(plots[5]);
                int   lonq    = int.Parse(plots[6]);
                float scaleq  = float.Parse(plots[2]);
                int   fromq   = int.Parse(plots[9]);
                int   deleteq = int.Parse(plots[7]);
                ObjectAppear.Addquote(quote_id, textq, disq, latq, lonq, scaleq, fromq);
                delete_list[deleteq].Add("quote" + quote_id);
                quote_id++;
                break;

            case "next":
                float disn    = float.Parse(plots[4]);
                int   latn    = int.Parse(plots[5]);
                int   lonn    = int.Parse(plots[6]);
                int   deleten = int.Parse(plots[7]);
                if (plots.Length > 10)
                {
                    NextButton.transition_type[next_id] = plots[10];
                    Debug.Log("transision set!: " + next_id + " " + plots[10]);
                }
                else
                {
                    NextButton.transition_type[next_id] = "nothing";
                }
                ObjectAppear.Addnext(next_id, disn, latn, lonn);
                delete_list[deleten].Add("next" + next_id);
                next_id++;
                break;

            case "obj":
                src = plots[3];     //folder_name + "/" + plots[3];
                float diso    = float.Parse(plots[4]);
                int   lato    = int.Parse(plots[5]);
                int   lono    = int.Parse(plots[6]);
                int   rotateo = int.Parse(plots[9]);
                int   deleteo = int.Parse(plots[7]);
                ObjectAppear.Addobj(obj_id, src, diso, lato, lono, rotateo);
                //delete_list[deleteo].Add("obj" + obj_id);
                delete_list[deleteo].Add(src);
                obj_id++;
                break;

            case "sphere":
                src = plots[3];     //folder_name + "/" + plots[3];
                float scales = float.Parse(plots[2]);
                //float diss = float.Parse(plots[4]);
                //int lats = int.Parse(plots[5]);
                //int lons = int.Parse(plots[6]);
                int rotates = int.Parse(plots[9]);
                int deletes = int.Parse(plots[7]);
                ObjectAppear.Addsphere(sphere_id, src, scales, rotates);
                //delete_list[deletes].Add("sphere" + sphere_id);
                delete_list[deletes].Add(src);
                sphere_id++;
                break;

            case "text":
                string[] linest;
                if (LanguageButton.language_flag == 0)
                {
                    linest = plots[3].Split(new string[] { "\n", "\r", "@" }, StringSplitOptions.None);
                }
                else
                {
                    linest = plots[8].Split(new string[] { "\n", "\r", "@" }, StringSplitOptions.None);
                }
                string textt = linest[0];
                for (int i = 1; i < linest.Length; i++)
                {
                    textt += "\n";
                    textt += linest[i];
                }
                int    deletet = int.Parse(plots[7]);
                string colort  = plots[10];
                ObjectAppear.ChangeInsideText(textt, colort);
                delete_list[deletet].Add("text");
                break;

            case "delete":
                src = plots[3];     //folder_name + "/" + plots[3];
                for (int i = 0; i < scene_max; i++)
                {
                    if (delete_list[i].Contains(src) == true)
                    {
                        delete_list[i].Remove(src);
                        ObjectAppear.Deleteobj(src);
                    }
                }
                break;

            case "end":
                SceneManager.LoadScene("menu", LoadSceneMode.Single);
                break;

            default:
                Console.WriteLine("Default case");
                break;
            }
            separators = new char[] { '/' };
            //次の行を読む

            /*
             * if (plot_count < plotLine.Length-1)
             * {
             *  plots = plotLine[plot_count + 1].Split(separators, StringSplitOptions.RemoveEmptyEntries);
             *  next_time = int.Parse(plots[0]);
             * }*/
        }
        //plot_countを進める条件(時間)
        if (plots[1] != "next")
        {
            //Debug.Log("plot " + plot_count +" type "+plots[1]);
            if (plot_count < plotLine.Length)
            {
                next_time = int.Parse(plotLine[plot_count + 1].Split(separators, StringSplitOptions.RemoveEmptyEntries)[0]);
                //Debug.Log("lengthOK nextTime " + next_time +" nowtime " + (TimeManager.time - scene_start_time));
                if ((TimeManager.time - scene_start_time) >= next_time)
                {
                    //Debug.Log("TimeOK");
                    plot_count++;
                }
            }
        }

        /*
         * if((next_time > 0)&&(TimeManager.time-scene_start_time) >= next_time){
         *  plot_count++;
         * }*/
        if (Input.GetKeyDown(KeyCode.Space))
        {
            while (plots[1] != "next")
            {
                separators = new char[] { '/' };
                plot_count++;
                plots = plotLine[plot_count].Split(separators, StringSplitOptions.RemoveEmptyEntries);
            }
            scene++;
        }
    }