Exemplo n.º 1
0
    public static void Map_Load(string file_path, ref Map_Data map_data)
    {
        //StreamReader sr = new StreamReader(Application.dataPath + file_path);
        StreamReader sr         = new StreamReader(file_path);
        string       str_stream = sr.ReadToEnd();

        System.StringSplitOptions option = System.StringSplitOptions.RemoveEmptyEntries;

        string[] lines   = str_stream.Split(new char[] { '\r', '\n' }, option);
        char[]   spliter = new char[1] {
            ','
        };

        map_data.Height   = lines.Length;
        map_data.Width    = lines[0].Split(spliter, option).Length;
        map_data.Map_data = new int[map_data.Height, map_data.Width];

        for (int i = 0; i < map_data.Height; i++)
        {
            for (int j = 0; j < map_data.Width; j++)
            {
                string[] read_str_data = lines[i].Split(spliter, option);

                map_data.Map_data[i, j] = int.Parse(read_str_data[j]);

                //  デバッグ表示用
                //Debug.Log(map_data.Map_data[i, j]);
            }
        }
    }
Exemplo n.º 2
0
    void Start()
    {
        m_map_datas = new List <Map_Data>();

        //  全てのマップファイルのパスを追加する
        m_file_paths.Add("/Resources/Map1.csv");
        m_file_paths.Add("/Resources/Map2.csv");

        //  追加されたパス分マップ情報を読み込む
        foreach (var path in m_file_paths)
        {
            Map_Data data = new Map_Data();
            Map_Load(path, ref data);
            m_map_datas.Add(data);
        }

        //  指定したインデックスのマップを生成する
        m_map_index = 0;
        Create_Map(m_map_datas[m_map_index]);
    }
Exemplo n.º 3
0
 public void Load_Map_Data(string file_path, bool load = true)
 {
     foreach (Transform n in this.gameObject.transform)
     {
         Destroy(n.gameObject);
     }
     m_map_data  = new Map_Data();
     m_file_name = System.IO.Path.GetFileName(file_path);
     if (load)
     {
         MapLoader.Map_Load(file_path, ref m_map_data);
     }
     else
     {
         Create_Map_Data(ref m_map_data);
     }
     Set_File_Name(m_file_name);
     Show_Map(m_map_data);
     m_cursor.gameObject.GetComponent <CursorManager>().Reset_Offset();
     Debug.Log(m_file_name);
 }