/// <summary>
        /// Places the ball on game field.
        /// </summary>
        /// <param name="windowId">The window identifier.</param>
        /// <param name="position">The position.</param>
        public void PlaceBallOnGameField(long windowId, Point position)
        {
            GameManager.Current.LogMessage(
                string.Format(
                    "Placed ball in window with id {0} on position {1}",
                    windowId,
                    position),
                Tracer.Debug);
            var eventArgs = new BallPlacedOnGameFieldEventArgs(windowId, position);

            this.BallPlacedOnGameField(this, eventArgs);
        }
示例#2
0
        /// <summary>
        /// Places the ball on game field based on an event callback.
        /// </summary>
        /// <param name="sender">The sender.</param>
        /// <param name="args">The <see cref="BallPlacedOnGameFieldEventArgs"/> instance containing the event data.</param>
        private void PlaceBallOnGameField(object sender, BallPlacedOnGameFieldEventArgs args)
        {
            var viewModel = this.gameWindowViewModels.FirstOrDefault(x => x.Window.Id == args.WindowId);

            if (viewModel != null)
            {
                var position = GameHelpers.GetBallPositionFromGridCoordinates(args.Position);
                this.CurrentGame.CurrentBallPosition = position;
                this.CurrentGame.CurrentWindow       = viewModel.Window;
                this.CurrentGame.CurrentPlayer.CurrentPlayerState = Player.PlayerState.BallPlaced;
                viewModel.PlaceBall(position, this.CurrentGame.CurrentPlayer.PlayerColor);
            }
        }
 /// <summary>
 /// Called when the server sends the callback to set the start point.
 /// </summary>
 /// <param name="sender">The sender.</param>
 /// <param name="args">The <see cref="BallPlacedOnGameFieldEventArgs"/> instance containing the event data.</param>
 public void OnBallPlacedOnGameField(object sender, BallPlacedOnGameFieldEventArgs args)
 {
     this.BallPlacedOnGameField(this, args);
 }
示例#4
0
        /// <summary>
        /// Sets the start point.
        /// </summary>
        /// <param name="windowId">The windows identifier.</param>
        /// <param name="pointX">The point x.</param>
        /// <param name="pointY">The point y.</param>
        public void SetStartPoint(long windowId, double pointX, double pointY)
        {
            var args = new BallPlacedOnGameFieldEventArgs(windowId, new Point(pointX, pointY));

            ThreadContext.InvokeOnUiThread(() => this.OnStartPointSet(args));
        }
示例#5
0
 /// <summary>
 /// Raises the <see cref="E:StartPointSet" /> event.
 /// </summary>
 /// <param name="args">The <see cref="BallPlacedOnGameFieldEventArgs"/> instance containing the event data.</param>
 private void OnStartPointSet(BallPlacedOnGameFieldEventArgs args)
 {
     this.StartPointSet(this, args);
 }