private void EnemyTimer_Tick(object sender, EventArgs e) { Enemy.Location = new Point(Enemy.Location.X - Speed, Enemy.Location.Y); //Beveger den til venstre med 3px if (Enemy.Right <= 0) //Hvis Venstresiden av fienden er helt til venstre på skjermen { MoveEnemyOutOfScreen(); //Flytter x posisjonen til 950, starter om igjen NewRandomSpeed(); } if (Missile.Bounds.IntersectsWith(Enemy.Bounds)) { Count++; // Teller antall gangen kulen har truffet fienden Output.Text = "You score is " + Count.ToString(); MoveEnemyOutOfScreen(); MissileToStartPosition(); NewRandomSpeed(); FireBullet = false; Missile.Visible = true; if (Count >= AmountOfPointsToWin) // Hvis du har nok poeng for å vinne { StopEnemyMoving(); PlayerTimer.Stop(); TimeSpentToWin.Stop(); // Stopper timeren som forteller hvor lang tid du har brukt ShowScore showMyResult = new ShowScore(Count, Time); // Videresender poeng og tid til nytt skjema showMyResult.Show(); // Gjør skjemaet synlig EnemyBlackSheepTimer.Stop(); // Stopper alle svarte sauer } } }
private void TimeSpentToWin_Tick(object sender, EventArgs e) // Kode fra Lasse Bertnzen, stoppeklokke { Console.WriteLine("Tick!!"); Time++; TimeSpent.Text = "You've spent: " + Time.ToString() + " seconds"; if (Time % 10 == 0) { MoveEnemyBlackSheepOutOfScreen(); EnemyBlackSheepTimer.Start(); // #BUG // F } }
private void EnemyBlackSheepTimer_Tick(object sender, EventArgs e) { EnemyBlackSheep.Location = new Point(EnemyBlackSheep.Location.X - 20, EnemyBlackSheep.Location.Y); if (Missile.Bounds.IntersectsWith(EnemyBlackSheep.Bounds)) { MoveEnemyBlackSheepOutOfScreen(); EnemyBlackSheepTimer.Stop(); Count = Count + 2; Output.Text = "You score is " + Count.ToString(); } }