public static void WriteConfig(Config config) { Stream s = File.Open(filename, FileMode.Create); BinaryFormatter binary = new BinaryFormatter(); binary.Serialize(s, config); s.Close(); try { GC.SuppressFinalize(s); GC.Collect(); } catch { // reported } }
private void OK_Click(object sender, EventArgs e) { accept = true; if (EASY.Checked == true) { kindgame = 1; } else if (MEDIUM.Checked == true) { kindgame = 2; } else kindgame = 3; //Information.PokemonNumber = 16 + (optionplay.kindgame - 1) * 6; Information.CurrentKindGame =Information.defaultPokemonNumber+ (kindgame - 1) * 6; form.KindGame = kindgame; form.Score = 0; form.Level = 1; form.argument.Level = 1; form.timeplay.Reset(); form.lifetime.Life = 10 + (form.KindGame - 1) * 5; form.NewGame(); Config config = OptionPlay.ReadConfig(); int tmp = config.MaxLevel; config = new Config(form.effect, form.wayeffect.BackColor, form.English, form.KindGame,tmp); OptionPlay.WriteConfig(config); this.Close(); }
private void OK_Click(object sender, EventArgs e) { if (checkBox1.Checked == true) form.LockSound = false; else form.LockSound = true; if (checkBox2.Checked == true) form.effect = true; else form.effect = false; if (language == 0) form.English = true; else form.English = false; if (checkBox3.Checked == true) { form.full = false; } else { form.full = true; } form.TurnOnScreen(); if (color == 0) form.wayeffect.BackColor = Color.DarkGreen; else if(color==1) form.wayeffect.BackColor = Color.Blue; else if (color == 2) form.wayeffect.BackColor = Color.Red; else if (color == 3) form.wayeffect.BackColor = Color.Orange; else if (color == 4) form.wayeffect.BackColor = Color.Yellow; /*else if (color == 5) form.wayeffect.BackColor = Color.Blue;*/ if (language == 0) { Information.English(); form.English = true; } else { Information.Vietnamese(); form.English = false; } form.ChoosingLanguage(); this.Close(); Config config = OptionPlay.ReadConfig(); int tmp = config.MaxLevel; config = new Config(form.effect, form.wayeffect.BackColor, form.English, form.KindGame, tmp); OptionPlay.WriteConfig(config); }
public static void WriteNewConfig(Config config) { WriteConfig(config); }
private void NextLevel_Click(Object obj, EventArgs e) { if (Information.LockNextButton == true) return; NextClickCount++; if (NextClickCount == 1) { nextLevelEffect.Clickmore(); } else if(NextClickCount==2) { nextLevelEffect.Hide(); NextLevel.Hide(); lifetime.UpdateLife(true); Level++; Config config = OptionPlay.ReadConfig(); int tmp_config = config.MaxLevel; if (Level - 1 > tmp_config) { config = new Config(effect, wayeffect.BackColor, English, KindGame, Level - 1); OptionPlay.WriteConfig(config); } if (Level < 16) { NewGame(); LockGame = false; } else { time.Stop(); gameLocking(); gameover = true; PScreen.ShowScreenFinish(); } } }
public void SetRecord() { int tmp = 0; if (KindGame==1) { UIT_PokemonHighScore.List_highscore high_score = UIT_PokemonHighScore.HighScoreGame.ReadHighScore(); if (Score > high_score.player_easy.GetMinScore()) { if (Score > high_score.player_easy.GetMaxScore()) tmp = 1; InputName IN = new InputName(this, tmp); IN.ShowDialog(); IN.Dispose(); } } else if (KindGame==2) { UIT_PokemonHighScore.List_highscore high_score = UIT_PokemonHighScore.HighScoreGame.ReadHighScore(); if (Score > high_score.player_mid.GetMinScore()) { if (Score > high_score.player_mid.GetMaxScore()) tmp = 1; InputName IN = new InputName(this, tmp); IN.ShowDialog(); IN.Dispose(); } } else { UIT_PokemonHighScore.List_highscore high_score = UIT_PokemonHighScore.HighScoreGame.ReadHighScore(); if (Score> high_score.player_hard.GetMinScore()) { if (Score > high_score.player_hard.GetMaxScore()) tmp = 1; InputName IN = new InputName(this, tmp); IN.ShowDialog(); IN.Dispose(); } } Config config = OptionPlay.ReadConfig(); int tmp_config = config.MaxLevel; if (Level - 1 > tmp_config) { config = new Config(effect, wayeffect.BackColor, English, KindGame, Level - 1); OptionPlay.WriteConfig(config); } PScreen.HideScreen(); HighScore high = new HighScore(KindGame-1); high.ShowDialog(); high.Dispose(); }