예제 #1
0
        //Tworzy nowa gre
        public void NewGame(int playerscore, int opponentscore, int color)
        {
            string col = "red";

            if (color == 0)
            {
                col = "white";
            }
            NewInfoWidnow("Opponent found. Your color: " + col);
            setButton(NewGameButton, true);
            game = new Classes.Game(clientnick, playerscore, opponentnick, opponentscore, color);
            if (color == 0)
            {
                setLabelText(PlayerRedNick, opponentnick);
                setLabelText(PlayerRedScore, opponentscore.ToString());
                setLabelText(PlayerWhiteNick, clientnick);
                setLabelText(PlayerWhiteScore, playerscore.ToString());
            }
            else
            {
                setLabelText(PlayerRedNick, clientnick);
                setLabelText(PlayerRedScore, playerscore.ToString());
                setLabelText(PlayerWhiteNick, opponentnick);
                setLabelText(PlayerWhiteScore, opponentscore.ToString());
            }
        }
예제 #2
0
 public void ResetGameForm()
 {
     game = null;
     setLabelText(PlayerRedNick, "guest");
     setLabelText(PlayerWhiteNick, "guest");
     setLabelText(PlayerRedScore, "0");
     setLabelText(PlayerWhiteScore, "0");
     opponentnick = "guest";
     setButton(NewGameButton, true);
     setButtonVisible(RollDicesButton, false);
     setLabelVisible(OpponentSearchLabel, false);
 }
예제 #3
0
        //Przygotowuje grafike planszy
        public Bitmap CreateGameBoard(Classes.Game game)
        {
            Graphics g = Graphics.FromImage(board);

            g.DrawImage(BoardImage, new Point(0, 0));
            if (game != null)
            {
                //wyswietla pionki i zaznaczone pole
                for (int i = 0; i < 6; i++)
                {
                    for (int j = 0; j < game.board.table[i].pawns; j++)
                    {
                        g.DrawImage(PawnImage[game.board.table[i].color], new Point(727 - i * 55, 30 + pawnsdistance[game.board.table[i].pawns] * j));
                    }

                    if (game.board.selected == i)
                    {
                        g.DrawImage(MarkerImage[0], new Point(750 - i * 55, 10));
                    }

                    if (game.board.possiblemoves[0] == i || game.board.possiblemoves[1] == i)
                    {
                        g.DrawImage(MarkerImage[1], new Point(750 - i * 55, 10));
                    }
                }

                for (int i = 6; i < 12; i++)
                {
                    for (int j = 0; j < game.board.table[i].pawns; j++)
                    {
                        g.DrawImage(PawnImage[game.board.table[i].color], new Point(332 - (i - 6) * 55, 30 + pawnsdistance[game.board.table[i].pawns] * j));
                    }

                    if (game.board.selected == i)
                    {
                        g.DrawImage(MarkerImage[0], new Point(355 - (i - 6) * 55, 10));
                    }

                    if (game.board.possiblemoves[0] == i || game.board.possiblemoves[1] == i)
                    {
                        g.DrawImage(MarkerImage[1], new Point(355 - (i - 6) * 55, 10));
                    }
                }

                for (int i = 12; i < 18; i++)
                {
                    for (int j = 0; j < game.board.table[i].pawns; j++)
                    {
                        g.DrawImage(PawnImage[game.board.table[i].color], new Point(57 + (i - 12) * 55, 780 - pawnsdistance[game.board.table[i].pawns] * j));
                    }

                    if (game.board.selected == i)
                    {
                        g.DrawImage(MarkerImage[0], new Point(80 + (i - 12) * 55, 835));
                    }

                    if (game.board.possiblemoves[0] == i || game.board.possiblemoves[1] == i)
                    {
                        g.DrawImage(MarkerImage[1], new Point(80 + (i - 12) * 55, 835));
                    }
                }

                for (int i = 18; i < 24; i++)
                {
                    for (int j = 0; j < game.board.table[i].pawns; j++)
                    {
                        g.DrawImage(PawnImage[game.board.table[i].color], new Point(457 + (i - 18) * 55, 780 - pawnsdistance[game.board.table[i].pawns] * j));
                    }

                    if (game.board.selected == i)
                    {
                        g.DrawImage(MarkerImage[0], new Point(480 + (i - 18) * 55, 835));
                    }

                    if (game.board.possiblemoves[0] == i || game.board.possiblemoves[1] == i)
                    {
                        g.DrawImage(MarkerImage[1], new Point(480 + (i - 18) * 55, 835));
                    }
                }

                for (int j = 0; j < game.board.table[24].pawns; j++)
                {
                    g.DrawImage(PawnImage[game.board.table[24].color], new Point(395, 200 + pawnsdistance[game.board.table[24].pawns] * j));
                    if (game.board.selected == 24)
                    {
                        g.DrawImage(MarkerImage[0], new Point(415, 10));
                    }
                }

                for (int j = 0; j < game.board.table[25].pawns; j++)
                {
                    g.DrawImage(PawnImage[game.board.table[25].color], new Point(400, 600 - pawnsdistance[game.board.table[25].pawns] * j));
                    if (game.board.selected == 25)
                    {
                        g.DrawImage(MarkerImage[0], new Point(420, 835));
                    }
                }

                for (int j = 0; j < game.board.table[26].pawns; j++)
                {
                    g.DrawImage(PawnImage[game.board.table[26].color], new Point(790, 700 - 10 * j));
                }

                if (game.board.possiblemoves[0] == 26 || game.board.possiblemoves[1] == 26)
                {
                    g.DrawImage(MarkerImage[1], new Point(808, 760));
                }

                for (int j = 0; j < game.board.table[27].pawns; j++)
                {
                    g.DrawImage(PawnImage[game.board.table[27].color], new Point(790, 100 + 10 * j));
                }

                if (game.board.possiblemoves[0] == 27 || game.board.possiblemoves[1] == 27)
                {
                    g.DrawImage(MarkerImage[1], new Point(808, 70));
                }

                //wyswietla kosci
                if (game.turn == 0)
                {
                    Classes.Dice[] dices = null;
                    if (game.playermove != null && !game.playermove.GetEndturn())
                    {
                        if (game.playermove.color == 0)
                        {
                            dices = game.playermove.GetDices();
                        }
                    }

                    if (game.opponentmove != null)
                    {
                        if (game.opponentmove.color == 0)
                        {
                            dices = game.opponentmove.GetDices();
                        }
                    }

                    if (dices != null)
                    {
                        if (dices[0].i > 0)
                        {
                            if (dices[0].used)
                            {
                                g.DrawImage(new Bitmap(DiceImage[0, dices[0].i], new Size(40, 40)), new Point(180, 410));
                            }
                            else
                            {
                                g.DrawImage(DiceImage[0, dices[0].i], new Point(170, 400));
                            }
                        }

                        if (dices[0].i > 0)
                        {
                            if (dices[1].used)
                            {
                                g.DrawImage(new Bitmap(DiceImage[0, dices[1].i], new Size(40, 40)), new Point(260, 410));
                            }
                            else
                            {
                                g.DrawImage(DiceImage[0, dices[1].i], new Point(250, 400));
                            }
                        }
                    }
                }

                if (game.turn == 1)
                {
                    Classes.Dice[] dices = null;
                    if (game.playermove != null)
                    {
                        if (game.playermove.color == 1)
                        {
                            dices = game.playermove.GetDices();
                        }
                    }

                    if (game.opponentmove != null)
                    {
                        if (game.opponentmove.color == 1)
                        {
                            dices = game.opponentmove.GetDices();
                        }
                    }

                    if (dices != null)
                    {
                        if (dices[0].i > 0)
                        {
                            if (dices[0].used)
                            {
                                g.DrawImage(new Bitmap(DiceImage[1, dices[0].i], new Size(40, 40)), new Point(530, 410));
                            }
                            else
                            {
                                g.DrawImage(DiceImage[1, dices[0].i], new Point(520, 400));
                            }
                        }

                        if (dices[1].i > 0)
                        {
                            if (dices[1].used)
                            {
                                g.DrawImage(new Bitmap(DiceImage[1, dices[1].i], new Size(40, 40)), new Point(610, 410));
                            }
                            else
                            {
                                g.DrawImage(DiceImage[1, dices[1].i], new Point(600, 400));
                            }
                        }
                    }
                }

                if (game.turn == 2)
                {
                    if (game.GetStartDices()[game.player.color] > 0)
                    {
                        g.DrawImage(DiceImage[0, game.GetStartDices()[game.player.color]], new Point(250, 400));
                    }
                    if (game.GetStartDices()[1 - game.player.color] > 0)
                    {
                        g.DrawImage(DiceImage[1, game.GetStartDices()[1 - game.player.color]], new Point(550, 400));
                    }
                }
            }
            return(board);
        }