private void openFile() { OpenFileDialog openFileDialog = new OpenFileDialog(); openFileDialog.Filter = "Balls doc file (*.bls)|*.bls"; openFileDialog.Title = "Open balls doc file"; if (openFileDialog.ShowDialog() == DialogResult.OK) { FileName = openFileDialog.FileName; try { using (FileStream fileStream = new FileStream(FileName, FileMode.Open)) { IFormatter formater = new BinaryFormatter(); SaveObject saveObject = (SaveObject)formater.Deserialize(fileStream); BallController = saveObject.BallController; Plane = saveObject.Plane; } } catch (Exception ex) { MessageBox.Show("Could not read file: " + FileName); FileName = null; return; } Invalidate(true); } }
private void startNew() { FileName = null; BackgroundImageLayout = ImageLayout.Stretch; BallController = new BallController(0, this.Width, this.Height); Plane = new Plane(BallController); this.BackgroundImage = Plane.getImage(); this.DoubleBuffered = true; Paused = false; this.MouseClick += new MouseEventHandler(this.mouse_click); }
public Plane(BallController ballController) { //At the beginnig the state is straight State = 2; Images = new List <Bitmap>(); Images.Add(Game.Properties.Resources.leftleftplane); Images.Add(Game.Properties.Resources.leftplane); Images.Add(Game.Properties.Resources.plane); Images.Add(Game.Properties.Resources.rightplane); Images.Add(Game.Properties.Resources.rightrightplane); BallController = ballController; }
public void fireBallShoot() { BallController.addFireBall(); }