// detects whenever checker eaten other checker
        public static CheckerPB FindEetenChecker(CheckerPB checker, Point newCheckerPosition)
        {
            int       moveAngel     = CalculateMoveAngel(checker.checker.oldPositionOnBord, newCheckerPosition);
            CheckerPB eatenChecker  = null;
            Point     moveDirection = new Point(Math.Sign((float)(Math.Cos(ToRadians(moveAngel)))), Math.Sign((float)Math.Sin(ToRadians(moveAngel))));

            Point possiblePosition;

            if (checker.checker.checkerType == Constants.blackChecker)
            {
                if (moveDirection.X > 0)
                {
                    possiblePosition = new Point((newCheckerPosition.X - 1), (newCheckerPosition.Y - 1));
                }
                else
                {
                    possiblePosition = new Point((newCheckerPosition.X - 1), (newCheckerPosition.Y + 1));
                }

                foreach (KeyValuePair <string, CheckerPB> pair in checkers)
                {
                    if ((pair.Value.checker.oldPositionOnBord == possiblePosition) && (pair.Value.checker.checkerType != checker.checker.checkerType))
                    {
                        CheckerPB ch = pair.Value;
                        return(ch);
                    }
                }
            }
            else
            {
                if (moveDirection.X > 0)
                {
                    possiblePosition = new Point((newCheckerPosition.X + 1), (newCheckerPosition.Y - 1));
                }
                else
                {
                    possiblePosition = new Point((newCheckerPosition.X + 1), (newCheckerPosition.Y + 1));
                }

                foreach (KeyValuePair <string, CheckerPB> pair in checkers)
                {
                    if ((pair.Value.checker.oldPositionOnBord == possiblePosition) && (pair.Value.checker.checkerType != checker.checker.checkerType))
                    {
                        CheckerPB   ch = pair.Value;
                        DTO_Checker c  = ch.checker;
                        return(ch);
                    }
                }
            }

            return(eatenChecker);
        }
예제 #2
0
        // updates server on checker move (the server updates the opponent player with this player moves)
        public static void UpdateServerWithCheckerMove(DTO_Checker checker, string eatenCheckerID)
        {
            if (GameController.gameType != Constants.GAME_TYPE_PLAY_ONLINE)
            {
                return;
            }

            Thread thread = new Thread(delegate()
            {
                duplexServiceClient.UpdateServerWithCheckerMove(GameController.currentPlayingGameID, GameController.loggedInAccountPlayerPlaying, checker, eatenCheckerID);
            });

            thread.Start();
        }
예제 #3
0
    public void UpdateServerWithCheckerMove(int gameID, DTO_Player player, DTO_Checker checker, string eatenCheckerID)
    {
        //get game for this player
        var query = from gp in db.GamePlays
                    where gp.GAME_ID == gameID
                    select gp;

        GamePlay gpFromDB = null;

        foreach (GamePlay gamePlay in query)
        {
            gpFromDB = gamePlay;
        }

        games[gpFromDB.GAME_ID].updateClientOnCheckerMove(player, checker, eatenCheckerID);
    }
예제 #4
0
        public CheckerPB(String ID, int type, Size size, Point position, Size gameBoardCellSize)
        {
            checker = new DTO_Checker {
                ID = ID, checkerType = type
            };

            if (type == Constants.blackChecker)
            {
                this.Image = (Image)(new Bitmap(Properties.Resources.checker_black, size));
            }
            else
            {
                this.Image = (Image)(new Bitmap(Properties.Resources.checker_white, size));
            }


            this.Width             = size.Width;
            this.Height            = size.Height;
            this.Location          = position;
            this.BackColor         = Color.Transparent;
            this.gameBoardCellSize = gameBoardCellSize;
        }
예제 #5
0
 public void UpdateClientWithCheckerMove(DTO_Checker ch)
 {
     GameController.UpdateCheckerPosition(GameController.checkers[ch.ID], ch.oldPositionOnBord);
     GameController.updateCurrentOpponentVisibility(GameController.loggedInAccountPlayerPlaying);
     GameController.isThisPlayerTurn = true;
 }