Exemple #1
0
        private GwentCard CopyCard(GwentCard Source)
        {
            string    XmlCard = XamlWriter.Save(Source);
            GwentCard NewCard = XamlReader.Parse(XmlCard) as GwentCard;

            return(NewCard);
        }
Exemple #2
0
        private void AddNewCardToGrid(GwentCard Card, Grid Grid, BindDelegatesHandler BindDelegates)
        {
            BitmapImage bti = new BitmapImage(new Uri(AppDomain.CurrentDomain.BaseDirectory + Card.ToBattleImgPath, UriKind.Absolute));
            Image       img = new Image()
            {
                Stretch = Stretch.Fill,
                Source  = bti,
            };

            UIElement MyControl;

            if (Card is IPlaceable)
            {
                Card NewCard = new Card();
                NewCard.Tag = Card;
                NewCard.SetImage(img);
                NewCard.SetCardPower((Card as IPlaceable).CardDefaultStrength);
                MyControl = NewCard;
            }
            else
            {
                Card NewCard = new Card();
                NewCard.Tag = Card;
                NewCard.SetImage(img);
                NewCard.HideEllipse();
                MyControl = NewCard;
            }
            MyControl.RenderTransformOrigin = new Point(0.5, 0.5);
            MyControl.RenderTransform       = new ScaleTransform(0.9, 0.9);
            BindDelegates(MyControl);
            AddToGrid(Grid, MyControl);
        }
Exemple #3
0
 private void IncImageTagCount(Grid grid, object tag)
 {
     foreach (UIElement element in grid.Children)
     {
         Image     img  = element as Image;
         GwentCard card = img.Tag as GwentCard;
         if (card.CardID == (tag as GwentCard).CardID)
         {
             card.Count++;
         }
     }
 }
Exemple #4
0
        private bool IsNeedCopy(Image Image, Grid Grid)
        {
            GwentCard card = Image.Tag as GwentCard;

            if ((card.Count > 1) && (!GridHasCard(card, Grid)))
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Exemple #5
0
 private bool GridHasCard(GwentCard UserCard, Grid Grid)
 {
     foreach (UIElement element in Grid.Children)
     {
         Image     img  = element as Image;
         GwentCard card = img.Tag as GwentCard;
         if (card.CardID == UserCard.CardID)
         {
             return(true);
         }
     }
     return(false);
 }
Exemple #6
0
 private void BorderLeftMouse_Up(object sender, EventArgs e)
 {
     if (Battlegrnd.SelectedCardID != -1)
     {
         UIElement element = grdInHandCards.Children[Battlegrnd.SelectedCardID];
         GwentCard Card    = GetGwentCard(element);
         Border    brd     = sender as Border;
         int       Line    = LinesBorder.IndexOf(brd);
         if (((Card.CardLine - 1) == Line) || (Card.CardLine == 0))
         {
             grdPlayGround.IsEnabled = false;
             if (Card is IPlaceable)
             {
                 Battlegrnd.InHandCards.RemoveAt(grdInHandCards.Children.IndexOf(element));
                 AddedToInHandCards();
                 (Card as IPlaceable).PlaceCard(Battlegrnd);
                 Battlegrnd.EndTurn();
                 Battlegrnd.SelectedCardID = -1;
                 Battlegrnd.AffectedCardID = -1;
             }
             else if (Card is Iimpact)
             {
                 int Ind = grdInHandCards.Children.IndexOf(element);
                 if ((Card as Iimpact).Impact(Battlegrnd, Line, Battlegrnd.AffectedCardID))
                 {
                     Battlegrnd.InHandCards.RemoveAt(Ind);
                     AddedToInHandCards();
                     Battlegrnd.EndTurn();
                     Battlegrnd.SelectedCardID = -1;
                     Battlegrnd.AffectedCardID = -1;
                 }
                 else
                 {
                     grdPlayGround.IsEnabled = true;
                 }
             }
             else
             {
                 Battlegrnd.InHandCards.RemoveAt(grdInHandCards.Children.IndexOf(element));
                 AddedToInHandCards();
                 Battlegrnd.AddWeatherCard(Card);
                 Battlegrnd.EndTurn();
                 Battlegrnd.SelectedCardID = -1;
                 Battlegrnd.AffectedCardID = -1;
             }
         }
         lblUserCardsPower.Content  = Battlegrnd.UserCardsPower;
         lblInHandCardCount.Content = Battlegrnd.InHandCards.Count;
     }
 }
Exemple #7
0
        private Image DeepImgCopy(Image Source)
        {
            GwentCard NewCard = CopyCard(Source.Tag as GwentCard);

            NewCard.Count = 1;
            (Source.Tag as GwentCard).Count--;
            Image NewImg = new Image()
            {
                Stretch = Stretch.Fill,
                Source  = Source.Source.CloneCurrentValue(),
                Tag     = NewCard,
                RenderTransformOrigin = new Point(0.5, 0.5),
                RenderTransform       = new ScaleTransform(0.9, 0.9)
            };

            BindDelegates(NewImg);
            return(NewImg);
        }
Exemple #8
0
        private void ApplyWeatherEffect()
        {
            GwentCard ClearSkyCard = null;

            foreach (GwentCard Card in Battlegrnd.CurrWeatherCard)
            {
                if (Card.GetType() == typeof(ClearSkyCard))
                {
                    ClearSkyCard = Card;
                }
            }

            if (ClearSkyCard != null)
            {
                ClearSkyCard.PerformSpecialAbility(Battlegrnd);
            }
            else
            {
                foreach (GwentCard Card in Battlegrnd.CurrWeatherCard)
                {
                    Card.PerformSpecialAbility(Battlegrnd);
                }
            }
        }