private void timer2_Tick(object sender, EventArgs e) { try { //if (File.Exists(path + txtNamePlayer1.Text + cbJoinersNames.Text+".xml")) //if (File.Exists(path + txtNamePlayer1.Text + cbJoinersNames.Text + ".xml")) if (File.Exists(path + cbJoinersNames.Text + txtNamePlayer1.Text + ".xml")) { // 10.6.2011- לקרוא לטעינת המשחק מקובץ ה-XML ולשלוף ממנו timer2.Stop(); File.Delete(path + cbJoinersNames.Text + ".rom"); //חיבים לוודא שכל השדות מולאו try { a.Play(RammyCube.Properties.Resources.chimes, Microsoft.VisualBasic.AudioPlayMode.Background); //InitializNamesAttrib(); names.Reverse(0, 2); ucg = new ucGame((int)numOfPlayers.Value, names, kinds, networkGame, mainForm.userName); FormGame fGame; fGame = new FormGame(ucg, mainForm); fGame.MdiParent = mainForm; fGame.WindowState = FormWindowState.Maximized; fGame.Show(); this.Close(); } catch (Exception ex) { if (ex.GetType().Name == "NullReferenceException") { MessageBox.Show("!!חובה למלא את שמות וסוגי השחקנים"); } } MessageBox.Show("Game start", "Rammi", MessageBoxButtons.OK, MessageBoxIcon.Information); //stRead.Close(); ucg.startPlayNetwork(ucg.turn); } //stRead.Close(); } catch (Exception ex) { MessageBox.Show(ex.Message); } }
private void timer1_Tick(object sender, EventArgs e) { try { stRead = File.OpenText(path + txtNamePlayer1.Text + ".rom"); string player = stRead.ReadLine(); if (player == "2") { nameplay2 = stRead.ReadLine(); stRead.Close(); File.Delete(path + txtNamePlayer1.Text + ".rom"); timer1.Stop(); MessageBox.Show("!" + nameplay2 + " join for you", "Rammi", MessageBoxButtons.OK, MessageBoxIcon.Information); //חיבים לוודא שכל השדות מולאו try { a.Play(RammyCube.Properties.Resources.chimes, Microsoft.VisualBasic.AudioPlayMode.Background); InitializNamesAttrib(); ucg = new ucGame((int)numOfPlayers.Value, names, kinds, networkGame, mainForm.userName); FormGame fGame; fGame = new FormGame(ucg, mainForm); fGame.MdiParent = mainForm; fGame.WindowState = FormWindowState.Maximized; fGame.Show(); this.Close(); } catch (Exception ex) { if (ex.GetType().Name == "NullReferenceException") { MessageBox.Show("!!חובה למלא את שמות וסוגי השחקנים"); } } } stRead.Close(); } catch (Exception ex) { } }
public FormSaveGame(Form curForm) { InitializeComponent(); formG = (FormGame)curForm; }
private void btnOkNamesKinds_Click(object sender, EventArgs e) { if (rbNetwork.Checked == true) { if (rbNew.Checked == true) { int drive = Microsoft.VisualBasic.FileIO.FileSystem.Drives.Count; int i; for (i = 0; i < drive; i++) { if (Microsoft.VisualBasic.FileIO.FileSystem.Drives[i].DriveType == DriveType.Removable) { path = Microsoft.VisualBasic.FileIO.FileSystem.Drives[i].Name; break; } } stWrite = File.CreateText(txtNamePlayer1.Text + ".rom"); stWrite.WriteLine("1"); stWrite.WriteLine(txtNamePlayer1.Text); stWrite.Close(); timer1.Start(); MessageBox.Show("wait for joiner", "Rammy", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); progressBar1.Visible = true; } else if (rbJoiner.Checked == true) { if (cbJoinersNames.Text == "") { MessageBox.Show("fill name of player", "Rammi", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); cbJoinersNames.Focus(); } else { InitializNamesAttrib(); //stWrite = File.CreateText(path + txtNamePlayer1.Text + ".rom"); stWrite = File.CreateText(path + cbJoinersNames.Text + ".rom"); stWrite.WriteLine("2"); //stWrite.WriteLine(cbJoinersNames.Text); stWrite.WriteLine(txtNamePlayer1.Text); stWrite.Close(); timer2.Start(); MessageBox.Show("wait for ok that someone join for you", "Rammi", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); progressBar1.Visible = true; } } } else { //חיבים לוודא שכל השדות מולאו try { //@@ TODO: להוציא מהערה כשמעתיקים a.Play(RammyCube.Properties.Resources.chimes, Microsoft.VisualBasic.AudioPlayMode.Background); InitializNamesAttrib(); if (mainForm.isOpenSaveGame) { LoadUcGame(); } else { ucg = new ucGame((int)numOfPlayers.Value, names, kinds, false, mainForm.userName); } FormGame fGame; fGame = new FormGame(ucg, mainForm); fGame.MdiParent = mainForm; fGame.WindowState = FormWindowState.Maximized; fGame.Show(); this.Close(); } catch (Exception ex) { if (ex.GetType().Name == "NullReferenceException") { MessageBox.Show("you must fill the names and the kinds of players"); } } } }