private void Collider2D_Tick(object sender, EventArgs e)
 {
     //Bricks collider
     if (GameData.gameInitiated)
     {
         int xAxis = 10;
         int yAxis = 4;
         for (int j = yAxis - 1; j >= 0; j--)
         {
             for (int i = 0; i < xAxis; i++)
             {
                 if (bricksMatrix[i, j] != null)
                 {
                     if (mario.Bounds.IntersectsWith(bricksMatrix[i, j].Bounds))
                     {
                         bricksMatrix[i, j].hits--;
                         if (bricksMatrix[i, j].hits == 1)
                         {
                             bricksMatrix[i, j].BackgroundImage = Image.FromFile("../../Resources/Bricks/brokenBrick.png");
                             player.score = Convert.ToString($"Score: {Convert.ToInt32(player.score.Substring(6)) + 100}");
                         }
                         else
                         {
                             Controls.Remove(bricksMatrix[i, j]);
                             bricksMatrix[i, j] = null;
                             player.score       = Convert.ToString($"Score: {Convert.ToInt32(player.score.Substring(6)) + 100}");
                             number_of_bricks--;
                             if (number_of_bricks == 0)
                             {
                                 StaticAttributes.finished = true;
                                 var NewScore = (Convert.ToInt32(player.time.Substring(5)) + Convert.ToInt32(player.score.Substring(6))) * (Convert.ToInt32(player.lives.Substring(1)) + 1);
                                 if (!StaticAttributes.nicknameRepeated)
                                 {
                                     ControllerPlayer.AddNickname(player.nickname);
                                 }
                                 ControllerPlayer.AddScore(player.nickname, NewScore);
                                 Congratulations congratulations = new Congratulations(player);
                                 congratulations.Show();
                                 Hide();
                             }
                         }
                         GameData.dirY *= -1;
                         return;
                     }
                 }
             }
         }
     }
 }
예제 #2
0
        public MainWindowVM()
        {
            game = new Game3(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 0, 24);
            //game = Game.FromCsv("C:/Users/Админ/Desktop/Puzzle15IITLab/Taken15/FieldFile.csv");
            GameBlockClickCommand = new RelayCommand(x =>
            {
                game.GameBlockClick((int)x);
                if (!game.IsOver)
                {
                    return;
                }

                var congratulations = new Congratulations();
                congratulations.Show();
            });
            GameBackCommand    = new RelayCommand(x => game.Back());
            GameForwardCommand = new RelayCommand(x => game.Forward());
        }