/// <summary> /// Triggered whenever the player clicks on the simulation to interact with the screen /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void canvasBox_Click(object sender, EventArgs e) { if (Game.IsRunning()) { int count = Game.Click(PointToClient(Cursor.Position)); if (count > 0) { Game.IncreaseScore(count); } else //if (Game.Score == 0) { Game.DecreaseLifeCount(); if (Game.IsOver()) { Game.Stop(); if (!Game.CheckScore(Game.Score)) { MessageBox.Show("Better luck next time!"); } else { UserInputTextBox wizard = new UserInputTextBox("Please enter your name!", "You got a high score!"); wizard.ShowDialog(); Game.SaveScore(new HighScore(wizard.Value, Game.Score)); } FireworkToolkit.Gaming.MainMenu menu = new FireworkToolkit.Gaming.MainMenu(Game); menu.ShowDialog(); if (!Game.IsRunning()) { Dispose(); } } } /* * else * Game.DecreaseScore(); */ } }
public Form1() { InitializeComponent(); Setup(); this.Disposed += Form1_Disposed; if (!Game.IsRunning()) { // Tries to load in a previous environment if one exists if (File.Exists(Environment.CurrentDirectory + "\\Environment.xml")) { Console.WriteLine("Found an environment file, trying to load."); XElement doc = XElement.Load(Environment.CurrentDirectory + "\\Environment.xml"); if (doc.HasElements) { if (doc.Name == "FireworkGameConfig" && doc.Attribute("Ver").Value == "1.0.1") { Game.FromElement(doc.Element("FireworkGame")); } } } else { Console.WriteLine("Did not find an environment file, will create one this time."); } FireworkToolkit.Gaming.MainMenu menu = new FireworkToolkit.Gaming.MainMenu(Game); menu.ShowDialog(); if (!Game.IsRunning()) { Dispose(); } } }