コード例 #1
0
        private void RefreshTableView()
        {
            for (int i = 0; i < 5; i++)
            {
                for (int j = 0; j < 5; j++)
                {
                    GameTable table = g.Table;
                    int[]     pos   = table.GetTableValueAt(i, j);

                    if (pos[1] == -1)
                    {
                        switch (pos[0])
                        {
                        case 0:
                            this.tableView[i][j].Image = Image.FromFile("IMG/1polje.png");
                            break;

                        case 1:
                            this.tableView[i][j].Image = Image.FromFile("IMG/2polje.png");
                            break;

                        case 2:
                            this.tableView[i][j].Image = Image.FromFile("IMG/3polje.png");
                            break;

                        case 3:
                            this.tableView[i][j].Image = Image.FromFile("IMG/4polje.png");
                            break;

                        case 4:
                            this.tableView[i][j].Image = Image.FromFile("IMG/5polje.png");
                            break;
                        }
                    }
                    else if (pos[1] == 0)
                    {
                        if (selected != null && selected.OnSpot(i, j))
                        {
                            switch (pos[0])
                            {
                            case 0:
                                this.tableView[i][j].Image = Image.FromFile("IMG/crveniPiratNa1PlociS.png");
                                break;

                            case 1:
                                this.tableView[i][j].Image = Image.FromFile("IMG/crveniPiratNa2PloceS.png");
                                break;

                            case 2:
                                this.tableView[i][j].Image = Image.FromFile("IMG/crveniPiratNa3PloceS.png");
                                break;

                            case 3:
                                this.tableView[i][j].Image = Image.FromFile("IMG/crveniPiratNa4PloceS.png");
                                break;
                            }
                        }
                        else
                        {
                            switch (pos[0])
                            {
                            case 0:
                                this.tableView[i][j].Image = Image.FromFile("IMG/crveniPiratNa1Ploci.png");
                                break;

                            case 1:
                                this.tableView[i][j].Image = Image.FromFile("IMG/crveniPiratNa2Ploce.png");
                                break;

                            case 2:
                                this.tableView[i][j].Image = Image.FromFile("IMG/crveniPiratNa3Ploce.png");
                                break;

                            case 3:
                                this.tableView[i][j].Image = Image.FromFile("IMG/crveniPiratNa4Ploce.png");
                                break;
                            }
                        }
                    }
                    else
                    {
                        if (selected != null && selected.OnSpot(i, j))
                        {
                            switch (pos[0])
                            {
                            case 0:
                                this.tableView[i][j].Image = Image.FromFile("IMG/plaviPiratNa1PlociS.png");
                                break;

                            case 1:
                                this.tableView[i][j].Image = Image.FromFile("IMG/plaviPiratNa2PloceS.png");
                                break;

                            case 2:
                                this.tableView[i][j].Image = Image.FromFile("IMG/plaviPiratNa3PloceS.png");
                                break;

                            case 3:
                                this.tableView[i][j].Image = Image.FromFile("IMG/plaviPiratNa4PloceS.png");
                                break;
                            }
                        }
                        else
                        {
                            switch (pos[0])
                            {
                            case 0:
                                this.tableView[i][j].Image = Image.FromFile("IMG/plaviPiratNa1Ploci.png");
                                break;

                            case 1:
                                this.tableView[i][j].Image = Image.FromFile("IMG/plaviPiratNa2Ploce.png");
                                break;

                            case 2:
                                this.tableView[i][j].Image = Image.FromFile("IMG/plaviPiratNa3Ploce.png");
                                break;

                            case 3:
                                this.tableView[i][j].Image = Image.FromFile("IMG/plaviPiratNa4Ploce.png");
                                break;
                            }
                        }
                    }
                }
            }

            if (g.GetPlayer(0).Type != GamePlayer.PlayerType.Human)
            {
                string toAdd;
                if (this.evaluationP1 == int.MaxValue)
                {
                    toAdd = "INT_MAX";
                }
                else if (this.evaluationP1 == int.MinValue)
                {
                    toAdd = "INT_MIN";
                }
                else
                {
                    toAdd = this.evaluationP1.ToString();
                }
                this.lbP1.Text = "Best move MINIMAX value: " + toAdd;
            }

            if (g.GetPlayer(1).Type != GamePlayer.PlayerType.Human)
            {
                string toAdd;
                if (this.evaluationP2 == int.MaxValue)
                {
                    toAdd = "INT_MAX";
                }
                else if (this.evaluationP2 == int.MinValue)
                {
                    toAdd = "INT_MIN";
                }
                else
                {
                    toAdd = this.evaluationP2.ToString();
                }
                this.lbP2.Text = "Best move MINIMAX value: " + toAdd;
            }

            int turn = g.Turn + 1;

            lbPlayersTurn.Text = "Players turn: " + turn.ToString();
            lbGameState.Text   = "Game state: " + g.State.ToString();

            if (g.State == Game.GameState.Finished)
            {
                lbGameState.Text += " - Winner is Player " + g.Winner.ToString();
            }
        }