private async Task start_gameAsync() { int delay1 = Convert.ToInt32(score * .9); // the amount of time that the blocks disappear for int delay2 = Convert.ToInt32(score * .3); // the amount of time that the blocks shake for int delay_between_stages = 4200; int rand; stage_1(0, -200); await Task.Delay(delay_between_stages); while (score < 9000 && !is_game_over) // in this part, the game do two tasks, it generate a random number after every stage { // the second task is to randomly choose the next stage depending on the player location rand = Random_Number.random_number_between(1, 4); delay_between_stages = 4200; if (player.is_player_TopLeft() == true) { switch (rand) { case 1: stage_20(delay2, delay1); rand = await stages_func(delay_between_stages, rand); break; case 2: stage_13(delay2, delay1); rand = await stages_func(delay_between_stages, rand); break; case 3: stage_7(delay2, delay1); rand = await stages_func(delay_between_stages, rand); break; case 4: stage_0(delay2, delay1); rand = await stages_func(delay_between_stages, rand); break; } } else if (player.is_player_TopMiddle() == true) { switch (rand) { case 1: stage_19(delay2, delay1); rand = await stages_func(delay_between_stages, rand); break; case 2: stage_12(delay2, delay1); rand = await stages_func(delay_between_stages, rand); break; case 3: stage_6(delay2, delay1); rand = await stages_func(delay_between_stages, rand); break; case 4: stage_2(delay2, delay1); rand = await stages_func(delay_between_stages, rand); break; } } else if (player.is_player_TopRight() == true) { switch (rand) { case 1: stage_21(delay2, delay1); rand = await stages_func(delay_between_stages, rand); break; case 2: stage_14(delay2, delay1); rand = await stages_func(delay_between_stages, rand); break; case 3: stage_9(delay2, delay1); rand = await stages_func(delay_between_stages, rand); break; case 4: stage_1(delay2, delay1); rand = await stages_func(delay_between_stages, rand); break; } } else if (player.is_player_BottomLeft() == true) { switch (rand) { case 1: stage_20(delay2, delay1); rand = await stages_func(delay_between_stages, rand); break; case 2: stage_17(delay2, delay1); rand = await stages_func(delay_between_stages, rand); break; case 3: stage_8(delay2, delay1); rand = await stages_func(delay_between_stages, rand); break; case 4: stage_5(delay2, delay1); rand = await stages_func(delay_between_stages, rand); break; } } else if (player.is_player_BottomMiddle() == true) { switch (rand) { case 1: stage_22(delay2, delay1); rand = await stages_func(delay_between_stages, rand); break; case 2: stage_18(delay2, delay1); rand = await stages_func(delay_between_stages, rand); break; case 3: stage_23(delay2, delay1); rand = await stages_func(delay_between_stages, rand); break; case 4: stage_3(delay2, delay1); rand = await stages_func(delay_between_stages, rand); break; } } else if (player.is_player_BottomRight() == true) { switch (rand) { case 1: stage_21(delay2, delay1); rand = await stages_func(delay_between_stages, rand); break; case 2: stage_15(delay2, delay1); rand = await stages_func(delay_between_stages, rand); break; case 3: stage_11(delay2, delay1); rand = await stages_func(delay_between_stages, rand); break; case 4: stage_4(delay2, delay1); rand = await stages_func(delay_between_stages, rand); break; } } else { stage_0(0, score); await Task.Delay(delay_between_stages); } } //break; async Task <int> stages_func(int delay, int num) { await Task.Delay(delay); rand = Random_Number.random_number_between(1, 4); Debug.WriteLine("stages random = " + num); return(rand); } }
private async void gameOver() // a function that is triggerd when the player loses the game // thats 1- show the game over window and 2- show the boss (the enemy) { player_scores.Add(score); is_game_over = true; player_img.Visible = false; death_counter++; game_timer.Stop(); Debug.WriteLine("death counter = " + death_counter); Debug.WriteLine("player score " + player_scores[death_counter - 1]); await Task.Delay(750); show_game_over_screenAsync(); play_again_button.Enabled = false; home_play_again.Enabled = false; Cursor = Cursors.WaitCursor; await Task.Delay(1250); play_again_button.Enabled = true; home_play_again.Enabled = true; Cursor = Cursors.Default; async Task show_game_over_screenAsync() { game_over_panel.Location = new Point(200, 400); game_over_panel.Visible = true; game_over_panel.BringToFront(); boss_img.Location = new Point(200, 100); boss_label.Location = new Point(500, 130); boss_img.Visible = true; boss_label.Visible = true; boss_img.BringToFront(); boss_label.BringToFront(); int boss_random_text = Random_Number.random_number_between(1, 12); Debug.WriteLine("boss random1 = " + boss_random_text); if (boss_random_text == 1) { boss_label.Text = "You got Only " + score + " HAHAHAHA"; } else if (boss_random_text == 2) { boss_label.Text = "DON'T PLAY THIS GAME EVER AGAIN"; } else if (boss_random_text == 3) { boss_label.Text = "I could get better score than yours even if i was BLINDFOLDED"; } else if (boss_random_text == 4) { boss_label.Text = "JUST QUIT THE GAME LOSER"; } else if (boss_random_text == 5) { boss_label.Text = "Did you lose INTENTIONALLY!!!"; } else if (boss_random_text == 6) { boss_label.Text = "YOU NEED THOUSANDS OF YEARS TO BEAT THIS GAME"; } else if (boss_random_text == 7) { boss_label.Text = "even my CAT got a better score than yours !!!"; } else if (boss_random_text == 8) { boss_label.Text = "you know you have to use the keyboard to move????"; } else if (boss_random_text == 9) { boss_label.Text = score + ", is your family proud of you?"; } else if (boss_random_text == 10) { boss_label.Text = score + " ONLY, WHAT ARE YOU DOING?!!!"; } else if (boss_random_text == 11 && death_counter >= 2 && player_scores[death_counter - 1] < player_scores[death_counter - 2]) { boss_label.Text = "You know that your score is getting worst"; } else if (boss_random_text == 12 && death_counter >= 2 && player_scores[death_counter - 1] < player_scores[death_counter - 2]) { boss_label.Text = "YOU ARE BECOMING WORST THE MOER YOU PLAY!!!"; } } }
public async void reset_game() // a fucnction that reset the game or start the game { Focus(); BackColor = Color.FromArgb(255, 153, 0); foreach (Control button in this.Controls) { if (button is Button) { button.Visible = false; } } score_txt.Visible = true; is_game_over = false; score_txt.Text = "Score = 0"; player.playerVel = 5; score = -10; player_img.Visible = true; int player_start_x = Random_Number.random_number_between(1, 7) * 100; int player_start_y = Random_Number.random_number_between(4, 7) * 100; player_img.Location = new Point(player_start_x, player_start_y); reset_blocks(); extra_block.Visible = false; // hide the extra block to be used latter game_timer.Start(); await show_be_ready(); start_gameAsync(); async Task show_be_ready() { be_rady_panel.Visible = true; be_rady_panel.BringToFront(); for (int counter = 3; counter > 0; counter--) { be_rady_counter.Text = "" + counter; await Task.Delay(1000); } be_rady_panel.Visible = false; be_rady_panel.SendToBack(); be_rady_panel.Visible = false; be_rady_panel.SendToBack(); Focus(); //if boss_img.Location = new Point(200, 100); boss_label.Location = new Point(500, 130); boss_img.Visible = true; boss_label.Visible = true; boss_img.BringToFront(); boss_label.BringToFront(); if (death_counter == 0) { for (int aCounter = 3; aCounter > 0; aCounter--) { if (aCounter == 3) { boss_label.Text = "Greeting Cube?!"; } else if (aCounter == 2) { boss_label.Text = "or whatever you are... (ಠ_ಠ)"; } else if (aCounter == 1) { boss_label.Text = "just don't fall loser, HAHAHA"; } await Task.Delay(2400); } } else if (death_counter >= 1) { int boss_random_start_text = Random_Number.random_number_between(1, 10); Debug.WriteLine("boss random3 = " + boss_random_start_text); int time_delay = 3500; if (boss_random_start_text == 1) { boss_label.Text = "keep trying you WILL NOT WIN"; } else if (boss_random_start_text == 2) { boss_label.Text = "So... , What are you? a sqare or a cube, something else?"; } else if (boss_random_start_text == 3) { boss_label.Text = "Still trying to figure out what you are"; } else if (boss_random_start_text == 4) { boss_label.Text = "If you keep playing you may get more intresting responses"; } else if (boss_random_start_text == 5) { boss_label.Text = "Why you keep trying? Do you like the game?"; } else if (boss_random_start_text == 6) { boss_label.Text = "Do you know how many attempts you have done? I lost count"; } else if (boss_random_start_text == 7) { boss_label.Text = "well... if you are going to spend a lot of time here can you at least tell me your name"; time_delay = 4200; } else if (boss_random_start_text == 8) { boss_label.Text = "I think you have lost for " + death_counter + " times btw"; } else if (boss_random_start_text == 9) { boss_label.Text = "believe me you are not going to win"; } else if (boss_random_start_text == 10) { boss_label.Text = "YOU ARE WORTHLESS"; } else if (boss_random_start_text == 11 && death_counter >= 2 && player_scores[death_counter - 1] < player_scores[death_counter - 2]) { boss_label.Text = "WHAT A SHAME!!"; } await Task.Delay(time_delay); } boss_img.Visible = false; boss_label.Visible = false; await Task.Delay(500); } }