Level Two
This page will go over how the game transfers the player from Level 1 to Level 2.
How does it happen?
After the player defeats the Boss KoolAid, they are teleported to level two, which is an arena where you must fight multiple Fleas, the bassist from hit dad rock band The Red Hot Chili Peppers.
The if statement below is a case within both attack buttons in FrmBattle, which checks if the player killed the boss. When they do they are sent to Level 2, the battle screen closes as it does normally, and then Level 1 is hidden and has its objects suspended to prevent any bugs.
if (enemy.Health <= 0 && enemy.Name == "enemyBossKoolAid") {
player.Score += 10;
NextLevel();
}
private void NextLevel() {
FrmLevel2 level2 = new FrmLevel2();
//exits application when level2 form closes
level2.FormClosed += GameExit;
//passes player picture
level2.picPlayer.BackgroundImage = picPlayer.BackgroundImage;
level2.Show();
// pauses everything on level1, since it is still running in the background
level.HaltAll();
level.Hide();
}
private void GameExit(object sender, FormClosedEventArgs e) {
Application.Exit();
}
Here in Level 1, the HaltAll() function stops the currently playing music, nulls out all enemy objects and walls, and stops moving the player.
internal void HaltAll() {
StopAndDispose();
HaltMove = true;
bossKoolaid = null;
enemyPoisonPacket = null;
enemyCheeto = null;
enemyFlea = null;
fleaFlag = false;
walls = null;
}
Last updated