public void LoadGame(zipgame zip) { HideHelpEffect(); ComebackDefault(); KindGame = zip.kindgame; Information.CurrentKindGame = zip.sumfirstpokemon; argument.Matrix = zip.Matrix; Information.PokemonNumber = zip.number_pokemon; Information.CurrentKindGame = Information.defaultPokemonNumber + (KindGame - 1) * 6; Score = zip.score; argument.RemainPokemon = zip.Remainpokemon; limittime.percent = zip.percent; percent = limittime.percent; timeplay.hour = zip.hour; timeplay.minute = zip.minute; timeplay.second = zip.second; Level = zip.level; HelpPokemonClick = zip.helpclick; RandomPokemonClick = zip.randomclick; lifetime.Life = zip.Lifetime; lifetime.Invalidate(); SmartEye = zip.smarteye; templateScreen.Show(); InitialImage(); time.Start(); ListHelp = argument.FindCouple(); Information.Level = Level; limittime.UpdatePercent(); limittime.updateTime(); PieceUpdate(); templateScreen.Hide(); draw = true; argument.Level = Level; this.Invalidate(); }
//savegame private void button2_MouseClick(Object obj, MouseEventArgs e) { if (display.gameover == true) { return; } if (display.LockGame == true) { return; } SaveFileDialog gamesave = new SaveFileDialog(); gamesave.Title = "UIT Pokemon save game"; gamesave.Filter = "Only file (*uitp)|*uitp"; gamesave.InitialDirectory = Information.directories; if (gamesave.ShowDialog() == DialogResult.OK) { zipgame zip = display.SaveGame(); LoadSaveGame.SaveGame(zip, gamesave.FileName + ".uitp"); } try { gamesave.Dispose(); GC.Collect(); } catch { // write report file } }
public static zipgame LoadGame(String filename) { Stream s = File.Open(filename, FileMode.Open); BinaryFormatter binary = new BinaryFormatter(); zipgame zip = (zipgame)binary.Deserialize(s); s.Close(); try { GC.Collect(); } catch { } return(zip); }
//open game private void button1_MouseClick(Object obj, MouseEventArgs e) { OpenFileDialog gameload = new OpenFileDialog(); gameload.Title = "UIT Pokemon load game"; gameload.Filter = "Only file (*uitp)|*uitp"; gameload.InitialDirectory = Information.directories; if (gameload.ShowDialog() == DialogResult.OK) { zipgame zip = LoadSaveGame.LoadGame(gameload.FileName); display.LoadGame(zip); } try { gameload.Dispose(); GC.SuppressFinalize(gameload); GC.Collect(); } catch { } }
public static void SaveGame(zipgame zip, String filename) { Stream s = File.Open(filename, FileMode.Create); BinaryFormatter binary = new BinaryFormatter(); try { binary.Serialize(s, zip); } catch (Exception ex) { MessageBox.Show("Loi 7 :File khong the luu \n " + ex.Message); } s.Close(); try { GC.Collect(); } catch { } }
public zipgame SaveGame() { zipgame zip = new zipgame(KindGame, Information.CurrentKindGame, lifetime.Life, argument.Matrix, Level, Information.PokemonNumber, Score, argument.RemainPokemon, limittime.percent, HelpPokemonClick, RandomPokemonClick, SmartEye, timeplay.hour, timeplay.minute, timeplay.second); return(zip); }
public zipgame SaveGame() { zipgame zip = new zipgame(KindGame,Information.CurrentKindGame,lifetime.Life, argument.Matrix,Level, Information.PokemonNumber, Score,argument.RemainPokemon,limittime.percent,HelpPokemonClick, RandomPokemonClick,SmartEye, timeplay.hour, timeplay.minute, timeplay.second); return zip; }