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(); }
public void HideBoardGame() { GameBoardUserControl gameBoard = (GameBoardUserControl)RootCanvas.Children.Cast <FrameworkElement>().FirstOrDefault(o => o.Name == "GameBoard"); gameBoard.Visibility = Visibility.Hidden; IsGameBoardVisible = false; }
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); }
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); }