Beispiel #1
0
    public PlayerData Load(int i)
    {
        PlayerData   pl = new PlayerData();
        StreamReader sr = null;

        try
        {
            sr = File.OpenText(Application.persistentDataPath + "//playerData_" + i + ".json");
        }
        catch (Exception e)
        {
            return(null);
        }

        string     jsonStr  = sr.ReadToEnd();
        PlayerData jsonInfo = JsonUtility.FromJson <PlayerData>(jsonStr);

        playerData    = jsonInfo;
        currentPlayer = i;
        roleVo.Update(playerData.roleVo);
        servantModel.Load(playerData.servantsModel);
        equipModel.Load(playerData.equipModel);
        skillModel.Load(playerData.skillModel);
        itemModel.Load(playerData.itemModel);
        mapModel.Load(playerData.mapModel);
        sr.Close();
        sr.Dispose();
        return(playerData);
    }