示例#1
0
        /// <summary>
        /// Handles when a cardbox has been clicked
        /// </summary>
        /// <param name="sender"></param>
        public void CardBoxClicked(object sender)
        {
            Turn curTurn  = m_Rounds[m_Rounds.Count - 1].GetCurrentTurn();
            Turn prevTurn = (Turn)curTurn.Clone();

            prevTurn--;
            CardBox     box          = (CardBox)sender;
            PlayingCard selectedCard = (PlayingCard)(box).Card.Clone();//make a copy
            StackPanel  sp           = (StackPanel)box.Parent;
            Grid        g            = (Grid)sp.Parent;
            PlayerUI    pui          = (PlayerUI)g.Parent;

            pui.DeleteCard(box);
            //Validate input params...
            if (curTurn.isDefending())
            {
                m_Gg.m_BattleArea.AddDefenseCard(new CardBox(selectedCard, Orientation.Vertical, curTurn.GetHashCode()));
                curTurn.Defend(selectedCard);
                WriteToLog("Player " + prevTurn.GetPlayer().ID.ToString() + " " + ((!(PlayerType.human == prevTurn.GetPlayer().GetMode())) ? "computer" : "human")
                           + " defended using " + selectedCard.ToString());
            }
            else
            {
                m_Gg.m_BattleArea.AddAttackCard(new CardBox(selectedCard, Orientation.Vertical, curTurn.GetHashCode()));
                curTurn.Attack(selectedCard);
                WriteToLog("Player " + prevTurn.GetPlayer().ID.ToString() + " " + ((!(PlayerType.human == prevTurn.GetPlayer().GetMode())) ? "computer" : "human")
                           + " attacked using " + selectedCard.ToString());
            }
            curTurn.GetPlayer().m_Hand -= selectedCard;
            m_Rounds[m_Rounds.Count - 1].updateBoldedStatus(curTurn, ref m_Gg);
            btnDoneGuard = false;
        }
 public void AddDefenseCard(CardBox defenseCard)
 {
     defenseCard.Margin = new Thickness(3);
     spDefend.Children.Add(defenseCard);
     BuildBoard();
 }
 public void AddAttackCard(CardBox attackCard)
 {
     attackCard.Margin = new Thickness(3);
     spAttack.Children.Add(attackCard);
     BuildBoard();
 }
 public void DeleteCard(CardBox card)
 {
     spPlayerHand.Children.Remove(card);
     RealignCards(spPlayerHand);
 }
 public void AddCard(CardBox card)
 {
     spPlayerHand.Children.Add(card);
     RealignCards(spPlayerHand);
 }