示例#1
0
 private void Load()
 {
     if (File.Exists(saveDataPath))
     {
         var data = File.ReadAllBytes(saveDataPath);
         this.dataHash = MyMsgPacker.Unpack(data) as Hashtable;
     }
     hasChanged = false;
     Debug.Log("loaded");
 }
示例#2
0
        private void LoadFromData(byte[] data)
        {
//            try
//            {
            dataHash = MyMsgPacker.Unpack(data) as Hashtable;
            PlayerManager.Instance.SetPlayerData(dataHash[KEY_PLAYER_DATA] as Hashtable);
//            }
//            catch (Exception e)
//            {
//                Debug.LogError("load error " + e.Message);
//            }
        }
        public void LoadFromData(byte[] data)
        {
            var result = MyMsgPacker.Unpack(data);
            var hash   = result as Hashtable;

            if (hash == null)
            {
                Debug.LogError("map data error!");
            }
            foreach (var key in hash.Keys)
            {
                var tarr   = key.ToString().Split(',');
                var x      = int.Parse(tarr[0]);
                var y      = int.Parse(tarr[1]);
                var points = hash[key] as object[];
                if (points == null)
                {
                    Debug.LogError("map data error: " + x + "," + y);
                    continue;
                }
                var     mapkey = new Vector2(x, y);
                int[][] mapdata;
                if (MapDataDic.ContainsKey(mapkey))
                {
                    mapdata = MapDataDic[mapkey];
                }
                else
                {
                    mapdata = new int[FieldMap.Map_Size][];
                    MapDataDic.Add(mapkey, mapdata);
                }
                foreach (var pstr in points)
                {
                    var parr = pstr.ToString().Split(',');
                    var px   = int.Parse(parr[0]);
                    var py   = int.Parse(parr[1]);
                    var pv   = int.Parse(parr[2]);
                    if (mapdata[px] == null)
                    {
                        mapdata[px] = new int[FieldMap.Map_Size];
                    }
                    mapdata[px][py] = pv;
                }
            }
        }
示例#4
0
        private void Test()
        {
            var ttt = new int[100];

            for (int i = 0; i < 100; i++)
            {
                ttt[i] = i;
            }
            var ttt2 = MyMsgPacker.Pack(ttt);
            var ttt3 = MyMsgPacker.Unpack(ttt2);

            Debug.Log(ttt3.GetType() + " ");
//            var aa = new Hashtable();
//            aa.Add("a1", 1);
//            aa.Add("b1", "bb");
//            aa.Add("c1", 3);
//            var a = MyMsgPacker.Pack(aa);
//            var b = MyMsgPacker.Unpack(a);
//            Debug.Log(b + " " + b.GetType());
//            var h = (Hashtable) b;
//            Debug.Log(h["a1"] + " " + h["b1"] + " " + h["c1"]);
        }