示例#1
0
        /// <summary>
        /// 読み込み
        /// </summary>
        /// <param name="_data"></param>
        public void ReadData(List <RankingData> _data, int _stageNum)
        {
            // ない場合生成
            if (!Directory.Exists("save/"))
            {
                Directory.CreateDirectory("save/");
            }

            var path = "save/" + GetStageRankingDataPath(_stageNum);

            bool flag = false;

            flag = File.Exists(path);

            FileStream   file   = new FileStream(path, FileMode.OpenOrCreate, FileAccess.ReadWrite);
            BinaryReader reader = new BinaryReader(file);

            RankingData data = new RankingData();


            // 読み込み
            if (!flag)
            {
                ZeroClear(_data, file);
                return;
            }

            for (int i = 0; i < ORDER_MAX; ++i)
            {
                data.order   = reader.ReadInt32();
                data.name[0] = reader.ReadString();
                data.name[1] = reader.ReadString();
                data.name[2] = reader.ReadString();
                data.score   = reader.ReadInt32();
                _data.Add(data);
            }
            reader.Close();
            file.Close();
        }
示例#2
0
        void ZeroClear(List <RankingData> _data, FileStream _file)
        {
            BinaryWriter writer = new BinaryWriter(_file);

            RankingData work = new RankingData();

            for (int i = 0; i < ORDER_MAX; ++i)
            {
                work.order   = (i + 1);
                work.name[0] = "------";
                work.name[1] = "------";
                work.name[2] = "------";
                work.score   = 0;

                _data.Add(work);

                writer.Write(work.order);
                writer.Write(work.name[0]);
                writer.Write(work.name[1]);
                writer.Write(work.name[2]);
                writer.Write(work.score);
            }
            writer.Close();
        }