/// <summary> /// Function that provides bridge between menu and the game. /// Disables menu's functionality by assifning empty function to it. /// Switches input (KeyDown) to game mode by turning gameOn. /// Initializes Map and calls function that makes the game start. /// </summary> /// <param name="loadMap"></param> private void MakeItHappen(LoadMap loadMap) { Menu(() => { }); // Lambda expression - calls empty action <=> Does nothing Level = 0; gameOn = true; Map = loadMap.Map; PlayGame(false); }
/// <summary> /// Loads predefined original map and calls MakeItHappen to procced to gameplay. /// </summary> private void OrgGame_Click(object sender, EventArgs e) { LoadMap loadMap = new LoadMap("../OriginalMap.txt"); if (loadMap.Map != null) { MakeItHappen(loadMap); } }
/// <summary> /// Opens file dialog after clinking on Select Map in menu. /// Tries to open and load selected map from the file afterwards. /// Calls procedure MakeItHappen in case of success. /// </summary> private void selectMap_Click(object sender, EventArgs e) { if (openFileDialog1.ShowDialog() == DialogResult.OK) { menuLayer = mn.submenu; Menu(Menu_SelectMap); string path = openFileDialog1.FileName; LoadMap loadMap; if (symbols.Count == 0) { loadMap = new LoadMap(path); } else { loadMap = new LoadMap(path, symbols.ToArray()); symbols = new List <char>(); } if (loadMap.Map != null) { MakeItHappen(loadMap); } } }