Example #1
0
    //ロード関数
    public void Main_Load()
    {
        if (EventSystem.current == null)
        {
            return;
        }
        if (Input.GetMouseButtonDown(1))
        {
            state = EXTRAMENUSTATE.MENU;
            savemanager.save_BackGround.gameObject.SetActive(false);
            for (int i = 0; i < savemanager.save_load_page; i++)
            {
                for (int j = 0; j < savemanager.save_load; j++)
                {
                    savemanager.save_object[i][j].gameObject.SetActive(true);
                    Destroy(savemanager.save_object[i][j]);
                }
            }
            savemanager.nextpagebutton.gameObject.SetActive(false);
            savemanager.prevpagebutton.gameObject.SetActive(false);
            savemanager.page_number.gameObject.SetActive(false);
            Destroy(save_canvas.GetComponent <CanvasScaler>());
            Destroy(save_canvas.GetComponent <GraphicRaycaster>());
            Destroy(save_canvas.gameObject);
            Destroy(save_canvas);
        }
        for (int page = 0; page < savemanager.save_load_page; page++)
        {
            for (int i = 0; i < savemanager.save_load; i++)
            {
                savemanager.save_object[page][i].gameObject.SetActive(page == savemanager.now_page);
            }
        }
        PointerEventData eventDataCurrent = new PointerEventData(EventSystem.current);

        eventDataCurrent.position = Input.mousePosition;
        List <RaycastResult> raycast = new List <RaycastResult>();

        EventSystem.current.RaycastAll(eventDataCurrent, raycast);
        for (int j = 0; j < savemanager.save_load_page; j++)
        {
            for (int i = 0; i < savemanager.save_load; i++)
            {
                savemanager.save_object[j][i].GetComponent <Image>().color = Color.white;
            }
        }
        foreach (RaycastResult tmp in raycast)
        {
            for (int page = 0; page < savemanager.save_load_page; page++)
            {
                for (int i = 0; i < savemanager.save_load; i++)
                {
                    //if ((savemanager.sd[page][i]as NovelSave).reading_pos == -1) continue;
                    if (tmp.gameObject.name == savemanager.save_object[page][i].gameObject.name)
                    {
                        savemanager.save_object[page][i].GetComponent <Image>().color = Color.red;
                        if (Input.GetMouseButtonDown(0))
                        {
                            FileStream   fs = new FileStream(Application.streamingAssetsPath + "/SaveData/" + savemanager.save_object[page][i].gameObject.name + ".json", FileMode.Open, FileAccess.Read);
                            StreamReader sr = new StreamReader(fs);
                            //**注意**--------------------------------------------------------------------------------------------------------------------------------------------------------------
                            Encryption_Config ec = Resources.Load <Encryption_Config>("Prefab/Encryption");
                            //string source_file = ec.DecryptionSystem(sr.ReadToEnd(),false);
                            string source_file = ec.DecryptionSystem(sr.ReadToEnd(), true); //debug
                            ;
                            //**--------------------------------------------------------------------------------------------------------------------------------------------------------------------
                            NovelSave sd = JsonUtility.FromJson <NovelSave>(source_file);
                            sd.Load(); //パーティメンバーのロード
                            nextscene = sd.nameScene;

                            FileStream   fs2 = new FileStream(Application.streamingAssetsPath + "/SaveData/loadtemp", FileMode.Create, FileAccess.Write);
                            StreamWriter sw  = new StreamWriter(fs2);
                            sw.WriteLine(source_file);
                            sw.Flush();
                            fs2.Flush();
                            sw.Close();
                            fs2.Close();

                            sr.Close();
                            fs.Close();

                            //back_log.text = sd.backlog;
                            fadeout.FadeIn(fadeintime, () =>
                            {
                                gobjAllMenu.SetActive(false);
                                GameVal.nextscenename = nextscene;
                                SceneManager.LoadScene("BlackScene", LoadSceneMode.Single);
                                Resources.UnloadUnusedAssets();
                            });
                            savemanager.save_BackGround.gameObject.SetActive(false);
                            savemanager.nextpagebutton.gameObject.SetActive(false);
                            savemanager.prevpagebutton.gameObject.SetActive(false);
                            savemanager.page_number.gameObject.SetActive(false);
                            for (int k = 0; k < savemanager.save_load_page; k++)
                            {
                                for (int j = 0; j < savemanager.save_load; j++)
                                {
                                    savemanager.save_object[k][j].gameObject.SetActive(true);
                                    Destroy(savemanager.save_object[k][j]);
                                }
                            }
                            Destroy(save_canvas.GetComponent <CanvasScaler>());
                            Destroy(save_canvas.GetComponent <GraphicRaycaster>());
                            Destroy(save_canvas.gameObject);
                            Destroy(save_canvas);
                            gobjMenu.GetComponent <StageSelectMenuAlpha>().FadeOut();
                            state = EXTRAMENUSTATE.MENU;
                            return;
                        }
                    }
                }
            }
        }
    }
Example #2
0
    //Save画面を描画する関数
    public void SaveWindowOpen()
    {
        page_number.gameObject.SetActive(true);
        nextpagebutton.gameObject.SetActive(true);
        prevpagebutton.gameObject.SetActive(true);
        save_BackGround.gameObject.SetActive(true);
        save_menu_text.gameObject.SetActive(true);
        page_number.text = string.Format("{0}/{1}", now_page + 1, save_load_page);
        FileStream   fs;
        StreamReader sr;
        string       filename = "";

        save_object = new GameObject[save_load_page][];
        sd          = new Savedata[save_load_page][];
        float y = save_box.GetComponent <RectTransform>().sizeDelta.y + 5;

        for (int page = 0; page < save_load_page; page++)
        {
            save_object[page] = new GameObject[save_load];
            sd[page]          = new Savedata[save_load];
            for (int i = 1; i <= save_load; i++)
            {
                filename = Application.streamingAssetsPath + string.Format("/SaveData/{0}{1}.json", page, i);
                save_object[page][i - 1]      = Instantiate <GameObject>(save_box, Vector3.zero, Quaternion.identity, canvas.transform);
                save_object[page][i - 1].name = string.Format("{0}{1}", page, i);
                save_object[page][i - 1].transform.position = new Vector3(100, canvas.GetComponent <RectTransform>().sizeDelta.y - 5 - y * (i - 1) - 120, 0);
                if (!System.IO.File.Exists(filename))
                {
                    save_object[page][i - 1].GetComponentInChildren <Text>().text = " NO DATA";
                    save_object[page][i - 1].gameObject.SetActive(false);
                    continue;
                }
                fs = new FileStream(filename, FileMode.Open, FileAccess.Read);
                sr = new StreamReader(fs);

                //**注意**------------------------------------------------------------------------------------------------------------------------------------------------------
                Encryption_Config ec = Resources.Load <Encryption_Config>("Prefab/Encryption");

                //sd[page][i - 1] = JsonUtility.FromJson<Savedata>(ec.DecryptionSystem(sr.ReadToEnd(),false));
                sd[page][i - 1] = JsonUtility.FromJson <Savedata>(ec.DecryptionSystem(sr.ReadToEnd(), true));  //debug
                FileStream filestream = new FileStream(Application.streamingAssetsPath + string.Format("/SaveData/{0}{1}.png", page, i), FileMode.Open, FileAccess.Read);

                //**------------------------------------------------------------------------------------------------------------------------------------------------------------
                BinaryReader bin        = new BinaryReader(filestream);
                byte[]       readBinary = bin.ReadBytes((int)bin.BaseStream.Length);
                bin.Close();
                filestream.Dispose();
                filestream = null;
                Rect      rect    = save_object[page][i - 1].GetComponent <Image>().GetComponent <RectTransform>().rect;
                Texture2D texture = new Texture2D((int)rect.width, (int)rect.height);
                if (readBinary != null)
                {
                    //横サイズ
                    int pos   = 16;
                    int width = 0;
                    for (int k = 0; k < 4; k++)
                    {
                        width = width * 256 + readBinary[pos++];
                    }
                    //縦サイズ
                    int height = 0;
                    for (int k = 0; k < 4; k++)
                    {
                        height = height * 256 + readBinary[pos++];
                    }
                    //byteからTexture2D作成
                    texture = new Texture2D(width, height);
                    texture.LoadImage(readBinary);
                }
                readBinary = null;
                save_object[page][i - 1].GetComponentInChildren <Image>().sprite = Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), Vector2.zero);
                save_object[page][i - 1].GetComponentInChildren <Text>().text    = sd[page][i - 1].current_message;
                save_object[page][i - 1].gameObject.SetActive(false);
                sr.Close();
                fs.Close();
            }
        }
    }
Example #3
0
    public void start_Novel(string novel_name, int pos)
    {
        //スクリーンショット取得
        StartCoroutine(LoadScreenshot());
        //フロントスクリーン・バックスクリーンのロード
        FrontScreen = new NovelScreen(frontscreen_inspector);
        BackScreen  = new NovelScreen(backscreen_inspector);
        FrontScreen.gobj.SetActive(true);
        BackScreen.gobj.SetActive(false);

        if (skeltonsprite == null)
        {
            skeltonsprite = Resources.Load <Sprite>("stand/skelton");
        }

        //ノベルスクリプトの取得
        string path = "";

        if (Debug.isDebugBuild)
        {
            path += "/debug/";
        }
        else
        {
            path += "/compiled/";
        }
        StreamReader sr = new StreamReader(Application.streamingAssetsPath + path + novel_name, System.Text.Encoding.GetEncoding("utf-8"));

        text.color          = chara_color = Color_Parser("000000");
        characterText.color = Color_Parser("000000");
        namebox.gameObject.SetActive(false);
        PageChangeAnim.gameObject.SetActive(false);
        PageWaitAnim.gameObject.SetActive(false);
        back_log_Stage.gameObject.SetActive(false);
        back_log.text = "";
        anim_timer    = 0;

        Debug.Log("Scripter Start Call");

        string            temp;
        Encryption_Config ec = Resources.Load <Encryption_Config>("Prefab/Encryption");

        while (sr.Peek() != -1)
        {
            temp = ec.DecryptionSystem(sr.ReadLine(), false);
            Scription test = JsonUtility.FromJson <Scription>(temp);
            switch (test.type)
            {
            case COMMAND_TYPE.AUDIO_BGM:
            case COMMAND_TYPE.AUDIO_VOICE:
            case COMMAND_TYPE.AUDIO_SE:
            {
                AUDIO_scription audio = JsonUtility.FromJson <AUDIO_scription>(temp);
                scriptions.Add(new AUDIO_scription(audio, Resources.Load <AudioClip>(audio.audio_name), audio.text, audio.type));
            }
            break;

            case COMMAND_TYPE.BACKGROUND:
            case COMMAND_TYPE.BACKGROUND_IMAGE:
            {
                IMAGE_scription image = JsonUtility.FromJson <IMAGE_scription>(temp);
                scriptions.Add(new IMAGE_scription(image, Resources.Load <Sprite>(image.imagename), image.text, image.type));
            }
            break;

            case COMMAND_TYPE.STAND_IMAGE:
            {
                STAND_IMAGE_scription image = JsonUtility.FromJson <STAND_IMAGE_scription>(temp);
                scriptions.Add(new STAND_IMAGE_scription(image.place, image, Resources.Load <Sprite>(image.imagename), image.text, image.type));
            }
            break;

            case COMMAND_TYPE.COLOR:
            case COMMAND_TYPE.BACKGROUND_COLOR:
                scriptions.Add(JsonUtility.FromJson <COLOR_scription>(temp));
                break;

            case COMMAND_TYPE.NORMAL_TEXT:
            case COMMAND_TYPE.NORMAL_TEXT_CONTINUE:
                scriptions.Add(JsonUtility.FromJson <Text_scription>(temp));
                break;

            case COMMAND_TYPE.WAIT_B:
            case COMMAND_TYPE.WAIT_S:
            case COMMAND_TYPE.WAIT_W:
            case COMMAND_TYPE.WAIT:
                scriptions.Add(JsonUtility.FromJson <WAIT_scription>(temp));
                break;

            case COMMAND_TYPE.STAND_IMAGE_CLEAR:
                scriptions.Add(JsonUtility.FromJson <IMAGE_clear_scription>(temp));
                break;

            case COMMAND_TYPE.AUDIO_BGM_STOP:
            case COMMAND_TYPE.AUDIO_SE_STOP:
            case COMMAND_TYPE.AUDIO_VOICE_STOP:
            case COMMAND_TYPE.TEXTOFF:
            case COMMAND_TYPE.TEXTON:
                scriptions.Add(JsonUtility.FromJson <Scription>(temp));
                break;

            case COMMAND_TYPE.SETWINDOW:
                scriptions.Add(JsonUtility.FromJson <UI_IMAGE_scription>(temp));
                break;

            case COMMAND_TYPE.RETURN:
                scriptions.Add(JsonUtility.FromJson <Scription>(temp));
                break;
            }
        }
        reading_pos = pos;
        now         = scriptions[reading_pos];
        state       = NOVEL_STATUS.NEXT;
    }
Example #4
0
    // csvファイルからマップデータを構成
    public static void  MapReader(string csvname)
    {
        //BattleValの初期化
        BattleVal.mapdata     = new List <List <List <int> > >();
        BattleVal.unitlist    = new List <Unitdata>();
        CharaSetup.partyForce = new Dictionary <int, bool>();

        if (Debug.isDebugBuild)
        {
            csvname = "/debug/" + csvname;
        }
        else
        {
            csvname = "/compiled/" + csvname;
        }

        StreamReader sr = new StreamReader(Application.streamingAssetsPath + csvname, Encoding.GetEncoding("utf-8")); //読み込んだ文字列の格納
        string       loading;

        //生データを取得
        BattleVal.mapdata.Add(new List <List <int> >());
        //読み込みループ
        Encryption_Config ec = Resources.Load <Encryption_Config>("Prefab/Encryption");

        while (sr.Peek() != -1)
        {
            loading = sr.ReadLine();
            //**注意**---------------------------------------------------------------------
            loading = ec.DecryptionSystem(loading, false);
            //**---------------------------------------------------------------------------
            //1行読み込み分のテンポラリ
            List <int> tmpfield = new List <int>();
            //区切り文字
            string[] str   = loading.Split(',');
            int      num   = 0;
            bool     check = false;
            for (int i = 0; i < str.Length; i++)
            {
                if (int.TryParse(str[i], out num))
                {
                    check = true;
                    tmpfield.Add(num);
                }
            }
            if (check)
            {
                BattleVal.mapdata[(int)MapdataList.MAPORIGINAL].Add(tmpfield);
            }
        }

        //csv生データからMAPHEIGHT情報、MAPTEXTURE情報を取得
        //MAPHEIGHT: マスの高さ情報(0は選択不可マス)10の位,1の位(0~99)
        //MAPTEXTURE:マスに張るmaterialの配列番号10000の位,100の位(0~999)
        //MAPUNIT:マスに最初にいるユニットの配列番号+1(0はキャラ不在)1000000の位,100000の位(0~99)

        //マップサイズ取得
        int mapy = BattleVal.mapdata[(int)MapdataList.MAPORIGINAL].Count;
        int mapx = BattleVal.mapdata[(int)MapdataList.MAPORIGINAL][0].Count;

        foreach (MapdataList listnum in System.Enum.GetValues(typeof(MapdataList)))
        {
            if (listnum != MapdataList.MAPORIGINAL)
            {
                BattleVal.mapdata.Add(new List <List <int> >());
                //result[(int)listnum] = new List<List<int>>(mapy);
            }
        }


        for (int i = 0; i < mapy; i++)
        {
            foreach (MapdataList listnum in System.Enum.GetValues(typeof(MapdataList)))
            {
                if (listnum != MapdataList.MAPORIGINAL)
                {
                    BattleVal.mapdata[(int)listnum].Add(new List <int>());
                    //result[(int)listnum][i] = new List<int>(mapx);
                }
            }

            for (int j = 0; j < mapx; j++)
            {
                int  temp            = BattleVal.mapdata[(int)MapdataList.MAPORIGINAL][i][j];
                bool partymemberflag = false;
                if (temp < 0)
                {
                    BattleVal.mapdata[(int)MapdataList.PARTY_CHECK][i].Add(1);
                    temp           *= -1;
                    partymemberflag = true;
                }
                else
                {
                    BattleVal.mapdata[(int)MapdataList.PARTY_CHECK][i].Add(0);
                }
                //10の位、1の位を取得
                BattleVal.mapdata[(int)MapdataList.MAPHEIGHT][i].Add(temp % 100);
                temp = temp / 100;
                //100,1000,10000の位以上を保存
                BattleVal.mapdata[(int)MapdataList.MAPTEXTURE][i].Add(temp % 1000);
                temp = temp / 1000;
                //100000,1000000の位を保存
                BattleVal.mapdata[(int)MapdataList.MAPUNIT][i].Add(temp % 100);
                temp = temp / 100;
                //10000000の位を保存
                BattleVal.mapdata[(int)MapdataList.MAPDIRECT][i].Add(temp % 10);
                temp = temp / 10;
                //100000000の位を保存
                BattleVal.mapdata[(int)MapdataList.MAPUNITSET][i].Add(temp % 10);
                temp = temp / 10;
                //1000000000の位を保存
                if (partymemberflag)
                {
                    if (temp != 0)
                    {
                        CharaSetup.partyForce.Add(BattleVal.mapdata[(int)MapdataList.MAPUNIT][i][j], true);
                    }
                    else
                    {
                        CharaSetup.partyForce.Add(BattleVal.mapdata[(int)MapdataList.MAPUNIT][i][j], false);
                    }
                }
            }
        }
    }
Example #5
0
    public override void OnInspectorGUI()
    {
        NovelSetCompiler test_data = target as NovelSetCompiler;

        line_counts     = EditorGUILayout.IntField("一行に表示する文字数", line_counts);
        rubycorrect_int = EditorGUILayout.FloatField("ルビ補正(ルビ文字間隔)", rubycorrect_int);
        rubycorrect_sp  = EditorGUILayout.FloatField("ルビ補正(ルビ文字配置位置)", rubycorrect_sp);
        GUILayout.BeginHorizontal();
        test_data.data = EditorGUILayout.TextField("ファイル名", test_data.data);
        scriptions.Clear();
        FileStream   fs;
        StreamReader sr;

        if (GUILayout.Button("Apply"))
        {
            string data = test_data.data;
            try
            {
                fs = new FileStream(Application.streamingAssetsPath + "/" + data, FileMode.Open, FileAccess.Read);

                sr = new StreamReader(fs);
                string[] type_temp = data.Split('.');

                if (type_temp[type_temp.Length - 1].Equals("csv"))
                {
                    Encryption_Config ec    = Resources.Load <Encryption_Config>("Prefab/Encryption");
                    string            plain = "";
                    while (sr.Peek() != -1)
                    {
                        plain += ec.EncryptionSystem(sr.ReadLine(), true) + '\n';
                    }
                    sr.Close();
                    fs = new FileStream(Application.streamingAssetsPath + "/compiled/" + data, FileMode.Create, FileAccess.Write);
                    StreamWriter sw = new StreamWriter(fs);
                    sw.WriteLine(plain);
                    sw.Flush();
                    sw.Close();
                    fs.Close();
                    fs    = new FileStream(Application.streamingAssetsPath + "/" + data, FileMode.Open, FileAccess.Read);
                    sr    = new StreamReader(fs);
                    plain = "";
                    while (sr.Peek() != -1)
                    {
                        plain += sr.ReadLine() + "\n";
                    }
                    sr.Close();
                    fs = new FileStream(Application.streamingAssetsPath + "/debug/" + data, FileMode.Create, FileAccess.Write);
                    sw = new StreamWriter(fs);
                    sw.WriteLine(plain);
                    sw.Flush();
                    sw.Close();
                    fs.Close();
                }
                else
                {
                    label_line     = new Dictionary <string, int>();
                    label_filename = new Dictionary <string, string>();
                    string temp;
                    while (sr.Peek() >= 0)
                    {
                        temp = sr.ReadLine();
                        if (temp.Length == 0)
                        {
                            continue;
                        }
                        while (temp[temp.Length - 1] == '/')
                        {
                            temp  = temp.Split('/')[0];
                            temp += sr.ReadLine();
                        }
                        Script_parser(temp);
                    }
                    sr.Close();
                    fs.Close();
                    fs = new FileStream(Application.streamingAssetsPath + "/compiled/" + data, FileMode.Create, FileAccess.Write);
                    if (fs == null)
                    {
                        Debug.Log("失敗しました");
                    }
                    StreamWriter sw = new StreamWriter(fs);
                    //**注意**--------------------------------------------------------------------------------------------------------------------------------------------------------------
                    Encryption_Config ec = Resources.Load <Encryption_Config>("Prefab/Encryption");
                    Debug.Log(ec.cipher_code);
                    for (int k = 0; k < scriptions.Count; k++)
                    {
                        sw.WriteLine(ec.EncryptionSystem(JsonUtility.ToJson(scriptions[k]), true));
                    }
                    //**--------------------------------------------------------------------------------------------------------------------------------------------------------------------
                    sw.Flush();
                    sw.Close();
                    fs.Close();
                    fs = new FileStream(Application.streamingAssetsPath + "/debug/" + data, FileMode.Create, FileAccess.Write);
                    if (fs == null)
                    {
                        Debug.Log("失敗しました");
                    }
                    sw = new StreamWriter(fs);
                    for (int k = 0; k < scriptions.Count; k++)
                    {
                        sw.WriteLine(JsonUtility.ToJson(scriptions[k]));
                    }
                    sw.Flush();
                    sw.Close();
                    fs.Close();
                    //*********完成版用のコンパイラ--------------------------------------------------------------------------------------------
                    Debug.Log("開始");
                    if (System.IO.File.Exists(Application.streamingAssetsPath + "/compiled/" + "Label_Table.db"))
                    {
                        fs = new FileStream(Application.streamingAssetsPath + "/compiled/" + "Label_Table.db", FileMode.Open);
                        sr = new StreamReader(fs);
                        string temp_label;
                        while (!sr.EndOfStream)
                        {
                            temp_label = ec.DecryptionSystem(sr.ReadLine(), true);
                            Debug.Log(temp_label);
                            string[] label = temp_label.Split(',');
                            Debug.Log(label[0] + label[1] + label[2]);
                            if (label_line.ContainsKey(label[0]))
                            {
                                continue;
                            }
                            label_line.Add(label[0], int.Parse(label[1]));
                            label_filename.Add(label[0], label[2]);
                        }
                        sr.Close();
                        fs.Close();
                    }
                    Debug.Log("更新");
                    fs = new FileStream(Application.streamingAssetsPath + "/compiled/" + "Label_Table.db", FileMode.Create);
                    sw = new StreamWriter(fs);
                    string name = "";
                    foreach (string label in label_line.Keys)
                    {
                        name = label_filename[label];
                        if (name == "")
                        {
                            name = data;
                        }
                        sw.WriteLine(ec.EncryptionSystem(string.Format("{0},{1},{2}", label, label_line[label], name), true));
                    }
                    sw.Flush();
                    fs.Flush();
                    sw.Close();
                    fs.Close();
                    //****************************************************************************************************************************
                    //**デバッグ用のコンパイラ----------------------------------------------------------------------------------------------------
                    Debug.Log("開始");
                    if (System.IO.File.Exists(Application.streamingAssetsPath + "/debug/" + "Label_Table.db"))
                    {
                        fs = new FileStream(Application.streamingAssetsPath + "/debug/" + "Label_Table.db", FileMode.Open);
                        sr = new StreamReader(fs);
                        string temp_label;
                        while (!sr.EndOfStream)
                        {
                            temp_label = sr.ReadLine();
                            Debug.Log(temp_label);
                            string[] label = temp_label.Split(',');
                            Debug.Log(label[0] + label[1] + label[2]);
                            if (label_line.ContainsKey(label[0]))
                            {
                                continue;
                            }
                            label_line.Add(label[0], int.Parse(label[1]));
                            label_filename.Add(label[0], label[2]);
                        }
                        sr.Close();
                        fs.Close();
                    }
                    Debug.Log("更新");
                    fs   = new FileStream(Application.streamingAssetsPath + "/debug/" + "Label_Table.db", FileMode.Create);
                    sw   = new StreamWriter(fs);
                    name = "";
                    foreach (string label in label_line.Keys)
                    {
                        name = label_filename[label];
                        if (name == "")
                        {
                            name = data;
                        }
                        sw.WriteLine(string.Format("{0},{1},{2}", label, label_line[label], name));
                    }
                    sw.Flush();
                    fs.Flush();
                    sw.Close();
                    fs.Close();
                    //****************************************************************************************************************************
                }
                EditorUtility.DisplayDialog("", "コンパイル完了しました", "ok");
            }
            catch (IOException e)
            {
                Debug.Log(e);
            }
        }
        GUILayout.EndHorizontal();
    }