Exemple #1
0
        private void Game_Loop_Tick(object sender, EventArgs e)
        {
            string pressed_key = MainSpace.SelfRef.PressedKey;

            if (!_playGame && (pressed_key == "R"))
            {
                Breaking_Text.Text  = "";
                Speed_Info.Visible  = true;
                Instruction.Visible = true;
                Pause_Label.Visible = false;
                _playGame           = true;
                VoiceManager.Change_Voice("Go");
            }

            if (pressed_key == "Escape")
            {
                Game_Loop.Stop();
                Speed_Info.Visible    = false;
                Instruction.Visible   = false;
                Pause_Label.Visible   = true;
                EndGame_Label.Visible = false;
                _playGame             = false;
                SoundManager.Stop_All_Sound();
                MainSpace.SelfRef.Show_Menu();
            }

            if (_playGame)
            {
                _carPlayer.Key_Event(pressed_key);
                _carPlayer.Update();

                _enemyAi.Behavior();
                _carEnemy.Move_Enemy(_carPlayer.Car.CurrentSpeed);
                _carEnemy.Update();

                _propController.Update(Width);

                _road.Remove_Road_Parts();
                _road.Prolong_Road_Parts();
                _road.Move_Road_Parts(_carPlayer.Car.CurrentSpeed);

                _finish.Check_Win(_carPlayer.Car.CoverDistance, _carEnemy.Car.CoverDistance);
                _finish.Move(_carPlayer.Car.CurrentSpeed);


                CollisionManager.Check();

                AnimationManager.Update_Animations();

                Speed_Info.Text = $"Скорость: {_carPlayer.Car.CurrentSpeed} \nНитро: {_carPlayer.Car.CurentBoostCharge}";

                if (!string.IsNullOrEmpty(_finish.Result) && (EndGame_Label.Visible == false))
                {
                    EndGame_Label.Visible = true;
                }
            }
            Repaint();
        }
Exemple #2
0
 public void Show_Garage()
 {
     FormBorderStyle = FormBorderStyle.Sizable;
     Game.Hide();
     MenuGame.Hide();
     Garage.Show();
     Garage.BringToFront();
     MusicManager.Change_Music("Garage");
     VoiceManager.Change_Voice("Garage");
 }
Exemple #3
0
        public void Check_Win(float Player_Distance, float Enemy_Distance)
        {
            if (string.IsNullOrEmpty(Result) && (Player_Distance > _widthScreen * Distance))
            {
                Result          = "Player";
                WinAnim.Visible = true;
                MusicManager.Change_Music("Win");
                VoiceManager.Change_Voice("Winner");
            }

            if (string.IsNullOrEmpty(Result) && (Enemy_Distance > _widthScreen * Distance))
            {
                Result           = "Enemy ";
                LoseAnim.Visible = true;
                MusicManager.Change_Music("GameOver");
                VoiceManager.Change_Voice("GameOver");
            }
        }
Exemple #4
0
        private void Collision_Handler(string Name1, string Name2)
        {
            if ((Name1 == "Player_Car") && (Name2 == "Enemy_Car"))
            {
                _playGame = false;
                SoundManager.Stop_All_Sound();
                CollisionManager.Work    = false;
                Breaking_Text.Text       = "Crash car";
                _finish.LoseAnim.Visible = true;
                _carPlayer.Freeze        = true;
                _carEnemy.Freeze         = true;
                EndGame_Label.Visible    = true;

                MusicManager.Change_Music("GameOver");
                VoiceManager.Change_Voice("GameOver");
                SoundManager.Play_Sound("BrokenCar");

                AnimationManager.Group_Visible(false, _carPlayer.Car.Id);
                AnimationManager.Set_Visible(true, _carPlayer.Car.Id + "Breaking");
                AnimationManager.Group_Visible(false, _carEnemy.Car.Id);
                AnimationManager.Set_Visible(true, _carEnemy.Car.Id + "Breaking");
                AnimationManager.Set_Visible(false, "PropBoostPlayer");
                AnimationManager.Set_Visible(false, "PropBoostEnemy");
            }

            if ((Name1 == "Player_Car") && ((Name2 == "Left_Board") || (Name2 == "Right_Board")))
            {
                _playGame = false;
                SoundManager.Stop_All_Sound();
                CollisionManager.Work    = false;
                Breaking_Text.Text       = "Crash Player on border";
                _finish.LoseAnim.Visible = true;
                _carPlayer.Freeze        = true;
                EndGame_Label.Visible    = true;

                MusicManager.Change_Music("GameOver");
                VoiceManager.Change_Voice("GameOver");
                SoundManager.Play_Sound("BrokenCar");

                AnimationManager.Group_Visible(false, _carPlayer.Car.Id);
                AnimationManager.Set_Visible(true, _carPlayer.Car.Id + "Breaking");
            }

            if ((Name1 == "Enemy_Car") && ((Name2 == "Left_Board") || (Name2 == "Right_Board")))
            {
                _playGame = false;
                SoundManager.Stop_All_Sound();
                CollisionManager.Work   = false;
                Breaking_Text.Text      = "Crash Enemy on border";
                _finish.WinAnim.Visible = true;
                _carEnemy.Freeze        = true;
                EndGame_Label.Visible   = true;

                MusicManager.Change_Music("Win");
                VoiceManager.Change_Voice("Winner");
                SoundManager.Play_Sound("BrokenCar");

                AnimationManager.Group_Visible(false, _carEnemy.Car.Id);
                AnimationManager.Set_Visible(true, _carEnemy.Car.Id + "Breaking");
            }
        }