Example #1
0
        public static void LoadFromBinanry(byte[] bytes)
        {
            System.IO.MemoryStream ms = new System.IO.MemoryStream(bytes);
            System.IO.BinaryReader br = new System.IO.BinaryReader(ms);
            int length = br.ReadInt32();

            for (int i = 0; i < length; i++)
            {
                br.ReadByte();
            }

            int looplength = br.ReadInt32();

            for (int i = 0; i < looplength; i++)
            {
                spawnplayer dataspawnplayer = new spawnplayer();
                dataspawnplayer.id                   = br.ReadInt32();
                dataspawnplayer.mapid                = br.ReadInt32();
                dataspawnplayer.stage                = br.ReadInt32();
                dataspawnplayer.idlist               = br.ReadString();
                dataspawnplayer.numberofplayer       = br.ReadInt32();
                dataspawnplayer.condition            = br.ReadInt32();
                dataspawnplayer.spawncenter          = br.ReadString();
                dataspawnplayer.offsetlist           = br.ReadString();
                dataspawnplayer.RelativePositionList = br.ReadString();
                if (_datas.ContainsKey(dataspawnplayer.id))
                {
#if UNITY_EDITOR
                    UnityEditor.EditorApplication.isPaused = true;
#endif
                    throw new ArgumentException("数据有误,主键重复:" + dataspawnplayer.id);
                }
                _datas.Add(dataspawnplayer.id, dataspawnplayer);
            }
            br.Close();
            ms.Close();
        }
Example #2
0
        public static void LoadFromString(string data)
        {
            string content = data;

            string[] lines = content.Split('\n');


            for (int i = 3; i < lines.Length; i++)
            {
                string line = lines[i];
                line = line.Replace("\r", "");
                if (string.IsNullOrEmpty(line))
                {
                    continue;
                }
                string[] values = line.Split('\t');
                if (values.Length != memberCount)
                {
                    Debug.LogError("spawnplayer严重错误,表头和表数据长度不一样");
#if UNITY_EDITOR
                    UnityEditor.EditorApplication.isPaused = true;
#endif
                    throw new ArgumentException("spawnplayer严重错误,表头和表数据长度不一样");
                }
                spawnplayer dataspawnplayer = new spawnplayer();
                if (!int.TryParse(values[0], out dataspawnplayer.id))
                {
#if UNITY_EDITOR
                    Debug.LogError("数据有误:" + values[0] + " to int");
                    UnityEditor.EditorApplication.isPaused = true;
#endif
                    throw new ArgumentException("数据有误:" + values[0] + " to int" + " 第" + i + "行,第0列");
                }
                if (!int.TryParse(values[1], out dataspawnplayer.mapid))
                {
#if UNITY_EDITOR
                    Debug.LogError("数据有误:" + values[1] + " to int");
                    UnityEditor.EditorApplication.isPaused = true;
#endif
                    throw new ArgumentException("数据有误:" + values[1] + " to int" + " 第" + i + "行,第1列");
                }
                if (!int.TryParse(values[2], out dataspawnplayer.stage))
                {
#if UNITY_EDITOR
                    Debug.LogError("数据有误:" + values[2] + " to int");
                    UnityEditor.EditorApplication.isPaused = true;
#endif
                    throw new ArgumentException("数据有误:" + values[2] + " to int" + " 第" + i + "行,第2列");
                }
                dataspawnplayer.idlist = values[3];
                if (!int.TryParse(values[4], out dataspawnplayer.numberofplayer))
                {
#if UNITY_EDITOR
                    Debug.LogError("数据有误:" + values[4] + " to int");
                    UnityEditor.EditorApplication.isPaused = true;
#endif
                    throw new ArgumentException("数据有误:" + values[4] + " to int" + " 第" + i + "行,第4列");
                }
                if (!int.TryParse(values[5], out dataspawnplayer.condition))
                {
#if UNITY_EDITOR
                    Debug.LogError("数据有误:" + values[5] + " to int");
                    UnityEditor.EditorApplication.isPaused = true;
#endif
                    throw new ArgumentException("数据有误:" + values[5] + " to int" + " 第" + i + "行,第5列");
                }
                dataspawnplayer.spawncenter          = values[6];
                dataspawnplayer.offsetlist           = values[7];
                dataspawnplayer.RelativePositionList = values[8];
                if (datas.ContainsKey(dataspawnplayer.id))
                {
#if UNITY_EDITOR
                    UnityEditor.EditorApplication.isPaused = true;
#endif
                    throw new ArgumentException("数据有误,主键重复:" + dataspawnplayer.id);
                }
                datas.Add(dataspawnplayer.id, dataspawnplayer);
            }
        }