コード例 #1
0
        // onClick for card elements
        public void CardClicked(CardBox card)
        {
            GameState Game = card.CardReferenced.Game;

            if (card.CardReferenced is HeroCard || card.CardReferenced.Game.CurrentPower == card.CardReferenced || !card.CardReferenced.Game.IsP1Turn)
            {
                return;
            }
            // Get the game from the top-level gamebox by traversing up until we find the gamebox
            Control GameB = this;

            while (!(GameB is GameBox))
            {
                GameB = GameB.Parent;
            }
            GameBox GameUI = GameB as GameBox;

            GameUI.HideNotif();

            if (GameUI.SelectedCard == null && (!card.CardPlayableIndicator.Visible || card.CardPlayableIndicator.BackColor == card.RED_IND || card.CardReferenced.Owner == Game.PlayerTwo))
            {
                return;
            }

            // If nothing is selected yet, we set the selected card
            if (GameUI.SelectedCard == null)
            {
                GameUI.SelectedCard = CardReferenced;
                BackgroundImage     = Properties.Resources.SelectedCardBody;
                return;
            }
            // Otherwise the move is completed and processe
            Move NextMove = new Move(GameUI.SelectedCard.Id, CardReferenced.Id);

            if (GameUI.SelectedCard.IsPlayable(NextMove))
            {
                GameUI.Game.ProcessMove(NextMove);
                GameUI.Net.Send(NextMove);
            }
            GameUI.SelectedCard = null;
            GameUI.RenderState(GameUI.Game);
        }