Exemplo n.º 1
0
        /// <summary>
        /// Ermittelt nach Mausklick auf die Dartscheibe das getroffene Feld und die Punktzahl des Wurfs.
        /// Aktualisiert anschließend das GUI
        /// </summary>
        private void pictureBox_Dart_MouseUp(object sender, MouseEventArgs e)
        {
            int posX = (e.X - (pictureBox_Dart.Width / 2));
            int posY = ((pictureBox_Dart.Height / 2) - e.Y);

            int angle = getAngle(posX, posY);
            int zone  = GetZone(angle);
            int Score = GetScore(angle, posX, posY);

            if (GetRing(posX, posY) == enumRingType.DoubleBull)
            {
                cg.HandleThrow(Score, 25, 5);
            }
            else if (GetRing(posX, posY) == enumRingType.SingleBull)
            {
                cg.HandleThrow(Score, 25, 4);
            }
            else if (GetRing(posX, posY) == enumRingType.Triple)
            {
                cg.HandleThrow(Score, zone, 3);
            }
            else if (GetRing(posX, posY) == enumRingType.Double)
            {
                cg.HandleThrow(Score, zone, 2);
            }
            else if (GetRing(posX, posY) == enumRingType.Single)
            {
                cg.HandleThrow(Score, zone, 1);
            }
            else
            {
                cg.HandleThrow(Score, 0, 0);
            }

            win = cg.CheckForWin();
            if (win)
            {
                winner = cg.players.FindIndex(x => x.Name == cg.Winner);
            }
            UpdateScreen(win);
            if (cg.players[cg.ActivePlayer].ThrowsLeft == 0)
            {
                cg.NextPlayer();
            }
            UpdateScreen(false);
        }
Exemplo n.º 2
0
 public Cricket(int player, int startPoints, string player1, string player2, Form1 f1)
 {
     InitializeComponent();
     panel_Player2.Visible  = true;
     label_Player1Name.Text = player1;
     label_Player2Name.Text = player2;
     this.f1 = f1;
     string[] names = new string[2] {
         player1, player2
     };
     cg = new CricketGame(player, startPoints, names);
     for (int i = 0; i < player; i++)
     {
         UpdateScreen(false);
         cg.NextPlayer();
     }
     UpdateScreen(false);
 }