示例#1
0
        public GamePageData(BoardPlacementData boardPlacementData, int currTimeSec, int currTimeMin, int currTimeHour, int turnCount, Board playerBoard, Board aiBoard, Ai ai)
        {
            if (boardPlacementData == null)
            {
                throw new ArgumentException("boardPlacementData cannot be null");
            }
            else if (currTimeSec < 0 || currTimeMin < 0 || currTimeHour < 0)
            {
                throw new ArgumentException("Один из счетчиков времени отрицательный, все они должны быть положительными");
            }
            else if (turnCount < 0)
            {
                throw new ArgumentException("число оборотов не может быть отрицательным");
            }
            else if (playerBoard == null || aiBoard == null)
            {
                throw new ArgumentException("Обе платы не");
            }
            else if (ai == null)
            {
                throw new ArgumentException("the ai cannot be null");
            }

            this.boardPlacementData = boardPlacementData;
            this.currTimeHour       = currTimeHour;
            this.currTimeMin        = currTimeMin;
            this.currTimeSec        = currTimeSec;
            this.turnCount          = turnCount;
            this.playerBoard        = playerBoard;
            this.aiBoard            = aiBoard;
            this.ai = ai;
        }
示例#2
0
        public GamePageData(BoardPlacementData boardPlacementData, int currTimeSec, int currTimeMin, int currTimeHour, int turnCount, Board playerBoard, Board aiBoard, Ai ai)
        {
            /* Verify nullity and negativity of parameters */
            if (boardPlacementData == null)
            {
                throw new ArgumentException("boardPlacementData cannot be null");
            }
            else if (currTimeSec < 0 || currTimeMin < 0 || currTimeHour < 0)
            {
                throw new ArgumentException("One of the time counter is negative, they should all be positive");
            }
            else if (turnCount < 0)
            {
                throw new ArgumentException("the number of turns cannot be negative");
            }
            else if (playerBoard == null || aiBoard == null)
            {
                throw new ArgumentException("Both boards should not be null");
            }
            else if (ai == null)
            {
                throw new ArgumentException("the ai cannot be null");
            }

            this.boardPlacementData = boardPlacementData;
            this.currTimeHour       = currTimeHour;
            this.currTimeMin        = currTimeMin;
            this.currTimeSec        = currTimeSec;
            this.turnCount          = turnCount;
            this.playerBoard        = playerBoard;
            this.aiBoard            = aiBoard;
            this.ai = ai;
        }
示例#3
0
        public Game(BoardPlacementData boardPlacementData)
        {
            InitializeComponent();
            Narrator.startplaying(NarratorTxt, null);

            for (int i = 0; i < 10; i++)
            {
                for (int j = 0; j < 10; j++)
                {
                    Button inGrid = new Button();
                    inGrid.Click += Button_Click;

                    battleGrid.Children.Add(inGrid);
                    Grid.SetRow(inGrid, i);
                    Grid.SetColumn(inGrid, j);
                }
            }

            for (int i = 0; i < 10; i++)
            {
                for (int j = 0; j < 10; j++)
                {
                    Button inGrid = new Button();

                    battleGrid_Copy.Children.Add(inGrid);
                    Grid.SetRow(inGrid, i);
                    Grid.SetColumn(inGrid, j);
                }
            }

            Ai ai;

            level = boardPlacementData.getLevel().ToString();

            switch (boardPlacementData.getLevel())
            {
            case AiLevel.EASY:
                ai = new Easy();
                break;

            case AiLevel.MEDIUM:
                ai = new Medium();
                break;

            case AiLevel.HARD:
                ai = new Hard();
                break;

            default:
                throw new NotSupportedException("ai unknown");
            }

            Board aiBoard = new Board(battleGrid_Copy);

            battleGrid_Copy.IsEnabled = false;
            for (int i = 0; i < boardPlacementData.getAiShip().Length; i++)
            {
                aiBoard.placeShip(new Ship(boardPlacementData.getAiShip()[i].position));
            }

            Board playerBoard = new Board(battleGrid);

            for (int i = 0; i < boardPlacementData.getPlayerShip().Length; i++)
            {
                playerBoard.placeShip(new Ship(boardPlacementData.getPlayerShip()[i].position));
            }

            this.gamePageData = new GamePageData(boardPlacementData, 0, 0, 0, 0, playerBoard, aiBoard, ai);

            initPlayerTicker(this.gamePageData.boardPlacementData.getIdleTime());

            startMainTimer(this.gamePageData.getTimeSec(), this.gamePageData.getTimeMin(), this.gamePageData.getTimeHour());

            idleTimeDispatcher.Start();
        }
示例#4
0
 public void goToGame(BoardPlacementData boardPlacement)
 {
     mainFrame.NavigationService.Navigate(new Game(boardPlacement));
 }
示例#5
0
        public void goToGame(BoardPlacementData boardPlacementData)

        {
            this.NavigationService.Navigate(new Game(boardPlacementData));
        }