public void ThreadProc() { while (true) { Application.Current.Dispatcher.Invoke((Action)(() => { missile.Fly(x, y); if (y > player.y && y < player.y + 50 && x > player.x && x < player.x + 50) // collison player with enemy bullet { Debug.WriteLine("Hitted!"); hitted = true; if (player.armor > 0) // Player has armor { Debug.WriteLine("Player has armor!" + player.armor); player.armor -= 10; // Destroy armor Debug.WriteLine("Player loses 10 armor, now: " + player.armor); } else if (player.armor <= 0) // Player has no armor { Debug.WriteLine("Player no armor, life: " + player.life); player.life -= missile.dmg; // Player loses all lifes MainWindow.main.Dispatcher.Invoke(new Action(delegate() { MainWindow.main.LifePoints = player.life.ToString(); })); if (player.life < 0) // GameOver { player.texture.Source = null; MainWindow.main.Dispatcher.Invoke(new Action(delegate() { MainWindow.main.ShowScoreboard(); })); // print GameOver } } } })); y += 10; if (y > 600) { hitted = true; } if (hitted == true) { Application.Current.Dispatcher.Invoke((Action)(() => { missile.dynamicImage.Source = null; })); break; } Thread.Sleep(100); } }