public void combatFinished(GameEntity winner) { soundManager.Stop(); soundManager.GameMusic(); if (winner.getClass() != Klasse.Klassen.Virus) { MessageBox.Show(winner.getName() + " won the fight"); grid[enemy[currentfighter].getx(), enemy[currentfighter].gety()] = 0; enemy[currentfighter] = null; progressBarEnemy.Value = 0; if (!enemiesleft()) { startNextStage(); } else { fight = null; combatPanel.Hide(); drawMap(); } } else { fight = null; currentStage = 0; currentStory = 1; listBox1.Items.Clear(); score.addScore(highscore, player.getName()); player = new GameEntity(Klasse.Klassen.Normalbürger, "Test"); combatPanel.Hide(); panelGame.Hide(); panelMain.Show(); panel1.Hide(); MessageBox.Show("You lose"); } }
private void movePlayer(int xMove, int yMove) { Graphics g = panelMap.CreateGraphics(); if ((int)distance(xMove, yMove, player.getx(), player.gety()) == 1) //Check if Spieler in ein valides Feld geclickt hat (Distanzcheck) { if (grid[xMove, yMove] == 0) //Check if Spieler ein valides Feld geclickt hat (Hindernischeck) { grid[player.getx(), player.gety()] = 0; grid[xMove, yMove] = 1; refreshField(player.getx(), player.gety()); drawEntity(g, spriteHelper.getCombatSprite(player.getClass(), player.getClass()), xMove, yMove); player.setcoords(xMove, yMove); } } moveEnemy(); for (int i = 0; i < 5; i++) { if (enemy[i] != null) { if ((int)distance(player.getx(), player.gety(), enemy[i].getx(), enemy[i].gety()) == 1) { if (fight == null) { fight = new Combat(); } currentfighter = i; soundManager.Stop(); soundManager.CombatMusic(); fight.begin(enemy[i], player, combatPanel, subject, progressBarPlayer, progressBarEnemy, itemArray); break; } } } g.Dispose(); }