c# project

Upload: kenneth-sy

Post on 02-Mar-2016

24 views

Category:

Documents


0 download

DESCRIPTION

C# Project

TRANSCRIPT

Polytechnic University of the PhilippinesSanta Rosa, Laguna

s

C#- Text Twist

Alcabasa, AnclarizeAlignay, AnabelleAlpante, Mary AnnBegonia, Mark LesterSamarita, Jenny AnnSy, Kenneth Jodan

OCTOBER 2013frmMainusing System;using System.Drawing;using System.Windows.Forms;

namespace Text_Twist{/// /// Description of Form1./// public partial class frmMain : Form{public frmMain(){//// The InitializeComponent() call is required for Windows Forms designer support.//InitializeComponent();//// TODO: Add constructor code after the InitializeComponent() call.//}

void TimedBtnClick(object sender, EventArgs e){frmTimed timedForm = new frmTimed();timedForm.Show();this.Hide();}void UntimedBtnClick(object sender, EventArgs e){frmUntimed untimedForm = new frmUntimed();untimedForm.Show();this.Hide();}void QuitBtnClick(object sender, EventArgs e){Form quit=new frmQuit();quit.ShowDialog();}void HighBtnClick(object sender, EventArgs e){Form Highscore = new frmHighscore(1);Highscore.ShowDialog();}void CreditsBtnClick(object sender, EventArgs e){Form credits = new frmCredits();credits.ShowDialog();}

private void frmMain_Load(object sender, EventArgs e) {

}}}

frmTimed

using System;using System.Collections.Generic;using System.Drawing;using System.Windows.Forms;

namespace Text_Twist{/// /// Description of frmTimed./// public partial class frmTimed : Form{public frmTimed(){//// The InitializeComponent() call is required for Windows Forms designer support.//InitializeComponent();//// TODO: Add constructor code after the InitializeComponent() call.//}#region "Declarations"string ChoosenWord;List Dic7L = new List();List DicAll = new List();string textLine ="";List PossibleWords = new List();int gameTime;long totalscore;int allwords;List TName = new List();List TScore = new List(); #endregion#region "Startup Events"public void Startup(){System.IO.StreamReader MyReaderDic7L ;System.IO.StreamReader MyReaderDicAll;string fldrDic7L ="\\Dic\\Dic7L.txt";string fldrDicAll ="\\Dic\\DicAll.txt";

fldrDic7L = Application.StartupPath + fldrDic7L; MyReaderDic7L = new System.IO.StreamReader(fldrDic7L); fldrDicAll = Application.StartupPath + fldrDicAll; MyReaderDicAll = new System.IO.StreamReader(fldrDicAll); while (MyReaderDic7L.Peek() != -1){ textLine = MyReaderDic7L.ReadLine(); Dic7L.Add(textLine.ToString());} while (MyReaderDicAll.Peek() != -1){ textLine = MyReaderDicAll.ReadLine(); DicAll.Add(textLine.ToString());} MyReaderDicAll.Close(); MyReaderDic7L.Close();}void FrmTimedLoad(object sender, EventArgs e){NewGame();}void TimerTick(object sender, EventArgs e){gameTime -= 1;int ss = gameTime;int hh = ss / 3600;int mm = (ss - (hh * 3600)) / 60;ss = ss - (hh * 3600 + mm * 60);lblTime.Text = String.Format("{0:D1}:{1:D2}", mm, ss);if (gameTime == 0) {if (nextBtn.Visible == true) {timer.Enabled=false;lbl.Text = "You only got "+listBox.Items.Count+" words";showResult();Form next=new frmNextRound();next.ShowDialog();if(next.DialogResult == DialogResult.OK){NewGame();continueScore();} }else {timer.Enabled = false;lbl.Text = "You only got "+listBox.Items.Count+" words";showResult();chckHigh();}}}#endregion#region "Functions"void chckHigh(){System.IO.StreamReader MyReaderTName;System.IO.StreamReader MyReaderTScore;string fldrTName ="\\Hscore\\TName.txt";string fldrTScore ="\\Hscore\\TScore.txt";

fldrTName = Application.StartupPath + fldrTName; MyReaderTName = new System.IO.StreamReader(fldrTName); fldrTScore = Application.StartupPath + fldrTScore; MyReaderTScore = new System.IO.StreamReader(fldrTScore); int i =0; while (MyReaderTName.Peek() != -1){ textLine = MyReaderTName.ReadLine(); TName.Add(textLine.ToString()); i++;} i =0; while (MyReaderTScore.Peek() != -1){ textLine = MyReaderTScore.ReadLine(); TScore.Add(Convert.ToInt64(textLine)); i++;} MyReaderTName.Close(); MyReaderTScore.Close(); if(totalscore >= TScore[9]){ Form newhigh = new frmNewHighScore();newhigh.ShowDialog();if(newhigh.DialogResult == DialogResult.OK){Form addhgh=new frmAddHighscore(totalscore,1);addhgh.ShowDialog();if(addhgh.DialogResult == DialogResult.OK){Form Highscore = new frmHighscore(1);Highscore.ShowDialog();if(Highscore.DialogResult == DialogResult.OK){this.Close();Form menu=new frmMain();menu.Show();}}} } else{ Form gameover=new frmGameOver();gameover.ShowDialog();if(gameover.DialogResult == DialogResult.OK){this.Close();}if(gameover.DialogResult == DialogResult.Retry){NewGame();} }}public void continueScore(){score.Text = String.Format("{0:N0}",totalscore);}public void showResult(){listBox.Items.Clear();listBox.Items.Add(ChoosenWord);for(int i=0;i