示例#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);
        }
示例#2
0
        public PlayerBox(BaseCard card) : base(card)
        {
            Height = Width;
            Controls.Clear();
            Click += (_s, _e) =>
            {
                GameBox Box = (Parent as GameBox);
                if (Box.SelectedCard == null)
                {
                    return;
                }
                Move NextMove = new Move(Box.SelectedCard.Id, card.Game.PlayerTwo.PlayerCard.Id);
                if (Box.SelectedCard.IsPlayable(NextMove))
                {
                    Box.Game.ProcessMove(NextMove);
                    Box.Net.Send(NextMove);
                }
                Box.SelectedCard = null;
                Box.RenderState(Box.Game);
            };

            HealthLabel = new Label();
            Controls.Add(HealthLabel);
        }