コード例 #1
0
ファイル: Player.cs プロジェクト: i2um1/VolleyBall
 public void AI(Ball ball, double leftFence)
 {
     double left = (double)this.GetValue(Canvas.LeftProperty);
     if (ball.Left() - this.Left() > -MOVE)
         Direction = Direction.Right;
     else if (ball.Left() - this.Left() < MOVE)
         Direction = Direction.Left;
     else
     {
         this.IsJump = true;
         Direction = Direction.None;
     }
 }
コード例 #2
0
ファイル: Game.cs プロジェクト: i2um1/VolleyBall
        public Game(Canvas canvas, Fence fence, Ball ball, Player[] players, TextBlock result)
        {
            this.canvas = canvas;
            this.fence = fence;
            this.ball = ball;
            this.players = players;
            this.result = result;

            timer = new DispatcherTimer();
            timer.Interval = new System.TimeSpan(speed);
            timer.Tick += new System.EventHandler(timer_Tick);

            wait = new DispatcherTimer();
            wait.Tick += new System.EventHandler(wait_Tick);
            wait.Interval = new TimeSpan(0, 0, 0, 0, timeWait);

            fence.SetLeft((canvas.RealWidth() - fence.Width) / 2.0);
            fence.SetTop(canvas.RealHeight() - fence.Height);

            Reset();
        }