예제 #1
0
    public void Load(byte[] bytes)
    {
        m_map = new Dictionary <int, BagInfo>();
        BinaryHelper helper = new BinaryHelper(bytes);

        int sceneCount = helper.ReadInt();

        for (int index = 0; index < sceneCount; ++index)
        {
            BagInfo info = new BagInfo();

            info.Load(helper);

            m_map.Add(info.m_id, info);
        }
    }
예제 #2
0
 ///   <summary>
 ///   从路径读取玩家信息
 ///   </summary>
 ///   <param name="path">已存在的文件的路径</param>
 public void LoadFromFile(string path, string key = "", bool dencrypt = false)
 {
     if (File.Exists(path + "/PlayerInfoData.zetan"))
     {
         if (dencrypt && key.Length == 32)
         {
             CopyInfo(JsonConvert.DeserializeObject <PlayerInfo>(Encryption.Dencrypt(File.ReadAllText(path + "/PlayerInfoData.zetan"), key)) ?? this);
         }
         else
         {
             CopyInfo(JsonConvert.DeserializeObject <PlayerInfo>(File.ReadAllText(path + "/PlayerInfoData.zetan")) ?? this);
         }
         bag.Load(path, key, dencrypt);
         warehouseInfo.Load(path, key, dencrypt);
     }
     else
     {
         throw new System.Exception("存档不存在");
     }
 }