Exemplo n.º 1
0
        /// <summary>
        /// Method which determines whether the card was 'dropped' 
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        public override void DeckViewer_DragDrop(object sender, DragEventArgs e)
        {
            if (e.Data.GetData(typeof(CardBox)) != null && this.isFull() == false)
            {

                CardBox draggedCard = (CardBox)e.Data.GetData(typeof(CardBox));


                // A logic structure which determines which panels to move the card to
                if (draggedCard != null && draggedCard.Parent.GetType() == typeof(DeckViewer))
                {
                    DeckViewer fromPanel = draggedCard.Parent as DeckViewer;
                    BoutViewer toPanel = sender as BoutViewer;

                    if (toPanel != null && fromPanel != null)
                    {
                        if (toPanel != fromPanel)
                        {
                            if(toPanel.canPlaceCard(draggedCard.Card))
                            {
                                fromPanel.RemoveCard(draggedCard.Card);
                                toPanel.AddCard(draggedCard.Card, true);
                            }
                        }
                    }

                }

            }


        }
Exemplo n.º 2
0
        /// <summary>
        /// Starts the next turns logic
        /// </summary>
        public void NextTurn()
        {
            //Check if it's the player's turn or the Ai's turn
            if (isPlayerTurn)
            {
                //Make it the AI player's turn
                isPlayerTurn = false;
                (boutDeckViewer as BoutViewer).AllowDrop = false;

                //Since nothing currently triggers the AiPlayer's turn, recursively call
                //this event handler in order to activate the AiPlayer's turn
                NextTurn();
            }
            else
            {
                //The AI chooses what card to play
                Card cardToPlay = enemyPlayer.ChooseAction(enemyDeckViewer, boutDeckViewer);

                //Confirm the AI actually chose a card, and not the default null card
                if (object.ReferenceEquals(cardToPlay, null))
                {
                    //The AI is unable to play any cards, so he loses the Bout
                    EndBout();
                }
                else
                {
                    //The AI plays a card
                    boutDeckViewer.AddCard((Card)cardToPlay.Clone(), false);
                    enemyDeckViewer.RemoveCard(cardToPlay);
                }

                //Make it the human player's turn
                isPlayerTurn = true;
                (boutDeckViewer as BoutViewer).AllowDrop = true;
            }
        }