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

            ball.OnBallInPlay(ballEventArgs);
        }
Esempio n. 2
0
 public void HitTheBall(BallEventArgs e)
 {
     if (hitBallCallback != null)
     {
         hitBallCallback(e);
     }
 }
Esempio n. 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");
     }
 }
Esempio n. 4
0
 void Ball_BallInPlay(Object sender, BallEventArgs e)
 {
     if (e.Distance >= 80 && e.Trajectory >= 20)
     {
         Console.WriteLine("I Catch the ball! ~Fan");
     }
 }
Esempio n. 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);
 }
Esempio n. 6
0
 public void HitTheBall(BallEventArgs e)
 {
     if (hitBallCallback != null)
     {
         hitBallCallback(e);
     }
 }
Esempio n. 7
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);
        }
Esempio n. 8
0
 public void OnBallInPlay(BallEventArgs e)
 {
     EventHandler<BallEventArgs> ballInPlay = BallInPlay;
     if (ballInPlay != null)
     {
         ballInPlay(this, e);
     }
 }
Esempio n. 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");
     }
 }
Esempio n. 10
0
        public void OnBallInPlay(BallEventArgs e)
        {
            EventHandler <BallEventArgs> ballInPlay = BallInPlay;

            if (ballInPlay != null)
            {
                BallInPlay(this, e);
            }
        }
Esempio n. 11
0
        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);
        }
Esempio n. 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");
            }
        }
Esempio n. 15
0
 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();
         }
     }
 }
Esempio n. 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!");
         }
     }
 }
Esempio n. 17
0
 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();
         }
     }
 }
Esempio n. 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");
            }
        }
Esempio n. 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");
            }
        }
Esempio n. 20
0
 public void OnBallInPlay(BallEventArgs ballEventArgs)
 {
     this.ballEventArgs.Angle = ballEventArgs.Angle;
     this.ballEventArgs.Distance = ballEventArgs.Distance;
     BallInPlay(this, this.ballEventArgs);
 }
Esempio n. 21
0
 protected void OnBallInPlay(BallEventArgs e)
 {
     EventHandler<BallEventArgs> ballInPlay = BallInPlay;
     if (ballInPlay != null)
         ballInPlay(this, e);
 }
Esempio n. 22
0
 private void Ball_BallInPlayTest(object sender, BallEventArgs e)
 {
     this.Said("[BallInPlayTest]");
 }
 public void PlayBall()
 {
     BallEventArgs ballEventArgs = new BallEventArgs(Trajectory, Distance);
     ball.OnBallInPlay(ballEventArgs);
 }
Esempio n. 24
0
        public void PlayBall()
        {
            BallEventArgs ballEventArgs = new BallEventArgs(Trajectory, Distance);

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