Beispiel #1
0
        private void playBallButton_Click(object sender, EventArgs e)
        {
            BallEventArgs ballEventArgs = new BallEventArgs(
                (int)trajectory.Value, (int)distance.Value);

            ball.OnBallInPlay(ballEventArgs);
        }
Beispiel #2
0
 public void HitTheBall(BallEventArgs e)
 {
     if (hitBallCallback != null)
     {
         hitBallCallback(e);
     }
 }
Beispiel #3
0
 void Ball_BallInPlay(Object sender, BallEventArgs e)
 {
     if (e.Distance < 80 && e.Distance >= 60 && e.Trajectory < 10)
     {
         Console.WriteLine("I Poke it! ~Pitcher");
     }
 }
Beispiel #4
0
 void Ball_BallInPlay(Object sender, BallEventArgs e)
 {
     if (e.Distance >= 80 && e.Trajectory >= 20)
     {
         Console.WriteLine("I Catch the ball! ~Fan");
     }
 }
Beispiel #5
0
 private void playBallButton_Click(object sender, EventArgs e)
 {
     Bat bat = ball.GetNewBat();
     BallEventArgs ballEventArgs = new BallEventArgs(
         (int)trajectory.Value, (int)distance.Value);
     bat.HitTheBall(ballEventArgs);
 }
Beispiel #6
0
 public void HitTheBall(BallEventArgs e)
 {
     if (hitBallCallback != null)
     {
         hitBallCallback(e);
     }
 }
        private void playBallButton_Click(object sender, EventArgs e)
        {
            Bat           bat           = ball.GetNewBat();
            BallEventArgs ballEventArgs = new BallEventArgs(
                (int)trajectory.Value, (int)distance.Value);

            bat.HitTheBall(ballEventArgs);
        }
Beispiel #8
0
 public void OnBallInPlay(BallEventArgs e)
 {
     EventHandler<BallEventArgs> ballInPlay = BallInPlay;
     if (ballInPlay != null)
     {
         ballInPlay(this, e);
     }
 }
Beispiel #9
0
 void Ball_BallInPlay(Object sender, BallEventArgs e)
 {
     Console.WriteLine("Distance: " + e.Distance + " Trajectory: " + e.Trajectory);
     if ((e.Distance < 80 && e.Trajectory >= 10 && e.Trajectory < 20) || e.Distance < 60)
     {
         Console.WriteLine("You're Out! ~Umpire");
     }
 }
Beispiel #10
0
        public void OnBallInPlay(BallEventArgs e)
        {
            EventHandler <BallEventArgs> ballInPlay = BallInPlay;

            if (ballInPlay != null)
            {
                BallInPlay(this, e);
            }
        }
        protected void OnBallInPlay(BallEventArgs e)
        {
            EventHandler <BallEventArgs> ballInPlay = BallInPlay;

            if (ballInPlay != null)
            {
                ballInPlay(this, e);
            }
        }
        public void PlayBall()
        {
            Bat bat = ball.GetNewBat();
            BallEventArgs ballEventArgs = new BallEventArgs(Trajectory, Distance);
            bat.HitTheBall(ballEventArgs);

            // Below is the old implementation, until the event raiser was made protected.
            // In this way, the event can only be accessed by the Callback pattern set up in the bat object.
            // ball.OnBallInPlay(ballEventArgs);
        }
        public void PlayBall()
        {
            Bat           bat           = ball.GetNewBat();
            BallEventArgs ballEventArgs = new BallEventArgs(Trajectory, Distance);

            bat.HitTheBall(ballEventArgs);

            // Below is the old implementation, until the event raiser was made protected.
            // In this way, the event can only be accessed by the Callback pattern set up in the bat object.
            // ball.OnBallInPlay(ballEventArgs);
        }
Beispiel #14
0
        /// <summary>
        /// </summary>
        public void OnBallInPlayTest(BallEventArgs e)
        {
            EventHandler <BallEventArgs> ballInPlay = BallInPlayTest;

            if (ballInPlay != null)
            {
                Console.WriteLine("BallInPlayTest event params:[ angle: {0}; distance: {1} cm] \nEvent listeners: {2}", e.Angle, e.Distance,
                                  ballInPlay.GetInvocationList().Length);
                ballInPlay(this, e);
            }
            else
            {
                Console.WriteLine("Event BallInPlay have not listeners");
            }
        }
 void ball_BallInPlay(object sender, EventArgs e)
 {
     if (e is BallEventArgs)
     {
         BallEventArgs ballEventArgs = e as BallEventArgs;
         if ((ballEventArgs.Distance < 95) && (ballEventArgs.Trajectory < 60))
         {
             CatchBall();
         }
         else
         {
             CoverFirstBase();
         }
     }
 }
Beispiel #16
0
 void ball_BallInPlay(object sender, EventArgs e)
 {
     if (e is BallEventArgs)
     {
         BallEventArgs ballEventArgs = e as BallEventArgs;
         if (ballEventArgs.Distance > 400 && ballEventArgs.Trajectory > 30)
         {
             Console.WriteLine("Fan: Home run! I’m going for the ball!");
         }
         else
         {
             Console.WriteLine("Fan: Woo-hoo! Yeah!");
         }
     }
 }
 private void Ball_BallInPlay(object sender, EventArgs e)
 {
     pitchNumber++;
     if (e is BallEventArgs)
     {
         BallEventArgs ballEventArgs = e as BallEventArgs;
         if ((ballEventArgs.Distance > 400) && (ballEventArgs.Trajectory > 30))
         {
             GrabGloveAndCatchBall();
         }
         else
         {
             ScreamAndYell();
         }
     }
 }
Beispiel #18
0
        /// <summary>
        /// </summary>
        protected void OnBallInPlay(BallEventArgs e)
        {
            EventHandler ballInPlay = BallInPlay;

            if (ballInPlay != null)
            {
                StringBuilder info = new StringBuilder(
                    $"BallInPlay event params:[ angle: { e.Angle}; distance: {e.Distance} cm] \nEvent listeners: {ballInPlay.GetInvocationList().Length}");
                foreach (var element in ballInPlay.GetInvocationList())
                {
                    info.Append($"\n\t {element.Target.GetType().Name}");
                }
                Console.WriteLine(info);

                ballInPlay(this, e);
            }
            else
            {
                Console.WriteLine("Event BallInPlay have not listeners");
            }
        }
Beispiel #19
0
        private void btnPlayball_Click(object sender, EventArgs e)
        {
            totalClick++;
            bool isHitted = false;
            BallEventArgs ballEventArgs = new BallEventArgs()
            {
                Angle = double.Parse(txtAngle.Text),
                Distance = double.Parse(txtDistance.Text)
            };

            int randomNumber = ran.Next(1, 100);
            isHitted = (randomNumber >= 1 && randomNumber <= 100);

            if (totalClick <= 3)
            {
                txtResult.Text += string.Format("現在是第{0}次上場打擊\n", totalClick);
                if (isHitted)
                {
                    txtResult.Text += string.Format("打中了,仰角是{0},距離是{1}\n", ballEventArgs.Angle, ballEventArgs.Distance);
                    ball.OnBallInPlay(ballEventArgs);
                    foreach (var v in Role)
                    {
                        txtResult.Text += v.Name + "\n";
                        txtResult.Text += v.Message;
                    }
                }
                else
                {
                    txtResult.Text += string.Format("沒打中了,你還有{0}次機會\n", 3 - totalClick);
                }
            }
            else
            {
                MessageBox.Show("Gameover");
            }
        }
Beispiel #20
0
 public void OnBallInPlay(BallEventArgs ballEventArgs)
 {
     this.ballEventArgs.Angle = ballEventArgs.Angle;
     this.ballEventArgs.Distance = ballEventArgs.Distance;
     BallInPlay(this, this.ballEventArgs);
 }
Beispiel #21
0
 protected void OnBallInPlay(BallEventArgs e)
 {
     EventHandler<BallEventArgs> ballInPlay = BallInPlay;
     if (ballInPlay != null)
         ballInPlay(this, e);
 }
 private void Ball_BallInPlayTest(object sender, BallEventArgs e)
 {
     this.Said("[BallInPlayTest]");
 }
 public void PlayBall()
 {
     BallEventArgs ballEventArgs = new BallEventArgs(Trajectory, Distance);
     ball.OnBallInPlay(ballEventArgs);
 }
Beispiel #24
0
        public void PlayBall()
        {
            BallEventArgs ballEventArgs = new BallEventArgs(Trajectory, Distance);

            ball.OnBallInPlay(ballEventArgs);
        }
Beispiel #25
0
 private void playBallButton_Click(object sender, EventArgs e)
 {
     BallEventArgs ballEventArgs = new BallEventArgs(
         (int)trajectory.Value, (int)distance.Value);
     ball.OnBallInPlay(ballEventArgs);
 }