Пример #1
0
 public void HandleTest()
 {
     XmlParser p = new XmlParser();
     Form1 form = new Form1();
     string level = "level1";
     List<GameObject> objects = new List<GameObject>();
     p.Handle(objects, form, level);
     Assert.IsTrue(objects[0] is Player);
 }
Пример #2
0
        public void Game_Init(string level)
        {
            //Initialize all components (ie. Player, Wall, Enemy,  etc.)
            properties_Gameover = false;
            properties_Pause = false;
            //Is replaced with information from the XML-file to make the enemies (loop)
            /*Right now this is a hardcoded placement*/

            game_objects = new List<GameObject>();
            // makes an XMLparser
            parser = new XmlParser();
            parser.Handle(game_objects, game_Form, level);

            //Add borders to the game
            int game_Width = game_Form.getWidthOfGame();
            int game_Height = game_Form.getHeightOfGame();
            game_objects.Add(new Border(0, 0, game_Width, 0, game_Form)); //Top
            game_objects.Add(new Border(0, game_Height, game_Width, 0, game_Form)); //Bottom
            game_objects.Add(new Border(0, 0, 0, game_Height, game_Form)); //Left
            game_objects.Add(new Border(game_Width, 0, 0, game_Height, game_Form)); //Right

            game_objects.Reverse();
        }
Пример #3
0
 //the button handler for the victory menu
 public void VictoryMenu_ButtonHandler(object sender, EventArgs e)
 {
     if(sender == victoryMenu.Get_Button_Exit_Game())
     {
         Close();
         LevelWon.controls.stop();
     }
     else if (sender == victoryMenu.Get_Button_Submit_Score())
     {
     XmlParser xml_parser = new XmlParser();
     xml_parser.SubmitScore(victoryMenu.Get_Submit_Score_Name().Text, game_loop.Get_score() , currentlevel);
     }
     else if(sender == victoryMenu.Get_Button_Main_Menu())
     {
         game_loop.Shutdown();
         LevelWon.controls.stop();
         victoryMenu.Visible = false;
         victoryMenu.Enabled = false;
         statisticsScreen1.Visible = false;
         Width = 800;
         mainMenuScreen.Visible = true;
         mainMenuScreen.Enabled = true;
     }
     else if(sender == victoryMenu.Get_Button_Next_Level())
     {
         LevelWon.controls.stop();
         game_loop.Shutdown();
         victoryMenu.Visible = false;
         victoryMenu.Enabled = false;
         try
         {
             currentlevel++;
             this.Text = "level" + currentlevel;
             this.Update();
             StartGame("level" + currentlevel);
         }
         catch(FileNotFoundException x)
         {
             currentlevel--;
             this.Text = "level" + currentlevel;
             this.Update();
             StartGame("level" + currentlevel);
         }
     }
     else if (sender == victoryMenu.Get_Button_Restart_Level())
     {
         LevelWon.controls.stop();
         game_loop.Shutdown();
         victoryMenu.Visible = false;
         victoryMenu.Enabled = false;
         StartGame("level" + currentlevel);
     }
 }
Пример #4
0
 public void LevelEditor_ButtonHandler(object sender, EventArgs e)
 {
     if (sender == levelEditor.Get_Button_Cancel()) {
         Width = 800;
         levelEditor.Destruct();
         mainMenuScreen.Visible = true;
         mainMenuScreen.Enabled = true;
     } else if (sender == levelEditor.Get_Button_Save()) {
         Console.WriteLine("PRESSED SAVE");
         // DO SAVE ACTION
         XmlParser writer = new XmlParser();
         string savedname = writer.SaveLevel(levelEditor.GetAddedObjects());
         MessageBox.Show("Saved level as " + savedname);
     }
 }