示例#1
0
        public static void Init(Canvas rootCanvas)
        {
            if (_gameEngine == null)
            {
                _gameEngine = new GameEngine();
            }

            _gameEngine.InitSprites();

            _gameEngine.RootCanvas = rootCanvas;

            // ajout du UserControl du plateau de jeux
            GameBoardUserControl gameBoard = new GameBoardUserControl();

            gameBoard.Name = "GameBoard";
            gameBoard.HorizontalAlignment = HorizontalAlignment.Stretch;
            gameBoard.VerticalAlignment   = VerticalAlignment.Stretch;
            gameBoard.Width  = _gameEngine.RootCanvas.ActualWidth;
            gameBoard.Height = _gameEngine.RootCanvas.ActualHeight;
            _gameEngine.RootCanvas.Children.Add(gameBoard);
            Canvas.SetLeft(gameBoard, 0);
            Canvas.SetTop(gameBoard, 0);

            _gameEngine.InitMediaPlayer();
        }
示例#2
0
        public void HideBoardGame()
        {
            GameBoardUserControl gameBoard = (GameBoardUserControl)RootCanvas.Children.Cast <FrameworkElement>().FirstOrDefault(o => o.Name == "GameBoard");

            gameBoard.Visibility = Visibility.Hidden;

            IsGameBoardVisible = false;
        }
示例#3
0
        public void ShowBoardGame()
        {
            HideMainMenu();
            GameBoardUserControl gameBoard = (GameBoardUserControl)RootCanvas.Children.Cast <FrameworkElement>().FirstOrDefault(o => o.Name == "GameBoard");

            GameEngine.GetInstance().RenderCurrentRoom();
            gameBoard.Visibility = Visibility.Visible;

            IsGameBoardVisible = true;
        }
        private void Play_OnMouseLeftButtonUp(object sender, MouseButtonEventArgs e)
        {
            // Set up game engine
            HumanPlayer humanPlayerRed   = new HumanPlayer(PlayerOneNamePrompt.Text, GameBoardUserControl.human_move_handler);
            HumanPlayer humanPlayerBlack = new HumanPlayer(PlayerTwoNamePrompt.Text, GameBoardUserControl.human_move_handler);

            Board board = BoardSetup.Random();

            GameBoardUserControl control = new GameBoardUserControl(
                board,
                humanPlayerRed,
                humanPlayerBlack,
                PieceType.Red
                );

            ContentControlActions.setBaseContentControl(control);
        }
        private void StartGame(KulamiPeer peer, Board board, bool goFirst)
        {
            Teardown();

            // Set up game engine
            HumanPlayer   humanPlayer   = new HumanPlayer(Networkmanager.ClientName, GameBoardUserControl.human_move_handler);
            NetworkPlayer networkPlayer = new NetworkPlayer(peer);

            GameBoardUserControl control = new GameBoardUserControl(
                board,
                humanPlayer,
                networkPlayer,
                goFirst ? PieceType.Red : PieceType.Black
                );

            control.SetChat(new ChatboxUserControl(peer));

            ContentControlActions.setBaseContentControl(control);
        }
示例#6
0
        private void startGame()
        {
            ContentControlActions.FadeOut();

            // Set up game engine
            HumanPlayer humanPlayer = new HumanPlayer(GameBoardUserControl.human_move_handler);
            Player      AiPlayer    = gameModeIsHard ? (Player) new HardAiPlayer() : new EasyAiPlayer();

            Board board = BoardSetup.Random();

            GameBoardUserControl control = new GameBoardUserControl(
                board,
                humanPlayer,
                AiPlayer,
                playerGoesFirst ? PieceType.Red : PieceType.Black
                );

            ContentControlActions.setBaseContentControl(control);
        }