public static Player loadPlayer(int id, Texture2D foto) { Player player; Stream stream ; BinaryFormatter bFormatter; try { stream = File.Open(id.ToString() + ".player", FileMode.Open); bFormatter = new BinaryFormatter(); player = (Player)bFormatter.Deserialize(stream); stream.Close(); } // si el jugador no existe crea su ficha de nuevo jugador catch (System.IO.FileNotFoundException e) { e.GetType(); player = new Player(id, foto); player.save(); } finally { } return player; }
public static Player loadPlayer(int id, Texture2D foto) { Player player; Stream stream; BinaryFormatter bFormatter; try { stream = File.Open(id.ToString() + ".player", FileMode.Open); bFormatter = new BinaryFormatter(); player = (Player)bFormatter.Deserialize(stream); stream.Close(); } // si el jugador no existe crea su ficha de nuevo jugador catch (System.IO.FileNotFoundException e) { e.GetType(); player = new Player(id, foto); player.save(); } finally { } return(player); }