コード例 #1
0
        private Animation CreateGradientAnimation(CardState cardState)
        {
            double start;
            double end;

            if (cardState == CardState.Expanded)
            {
                _gradientTransitionY = CardBackground.CanvasSize.Height;
                start = _gradientTransitionY;
                end   = -_gradientHeight;
            }
            else
            {
                _gradientTransitionY = -_gradientHeight;
                start = _gradientTransitionY;
                end   = CardBackground.CanvasSize.Height;
            }

            var gradientAnimation = new Animation(
                callback: v =>
            {
                _gradientTransitionY = (float)v;
                CardBackground.InvalidateSurface();
            },
                start: start,
                end: end,
                easing: Easing.Linear,
                finished: () =>
            {
            }
                );

            return(gradientAnimation);
        }
コード例 #2
0
        private Animation GradientAnimation(CardState cardstate)
        {
            double start;
            double end;

            if (cardstate == CardState.Expended)
            {
                _gradientTransitionY = CardBackground.CanvasSize.Height;
                start = _gradientHeight;
                end   = -_gradientTransitionY;
            }
            else
            {
                _gradientTransitionY = -_gradientHeight;
                start = _gradientTransitionY;
                end   = CardBackground.CanvasSize.Height;
            }

            var gradientAnime = new Animation(v =>
            {
                _gradientTransitionY = (float)v;
                CardBackground.InvalidateSurface();
            }, start, end, Easing.Linear);

            return(gradientAnime);
        }
コード例 #3
0
        protected override void OnBindingContextChanged()
        {
            base.OnBindingContextChanged();

            if (this.BindingContext == null)
            {
                return;
            }
            _viewModel = this.BindingContext as ProductsCardsModels;

            // because we can't bind skia drawing using the binding engine
            // we cache the paint objects when the bound character changes

            //initialisont la position du top de la carte
            _cardTopAnimPosition = _cardTopMargin;
            _ProductColor        = Color.FromHex(_viewModel.ProductColor).ToSKColor();
            _ProductPaint        = new SKPaint()
            {
                Color = _ProductColor
            };
            _gradientTransitionY = float.MaxValue; // cette grande valeur permet que le gradient soit en bas de l'ecran avant que l'initialisation de la variable ne debute dans l'animation
            //_ProductAnimeOffsetY = 520f * _density;

            _ProductNamePaint = new SKPaint()
            {
                Typeface    = _typeface,
                IsAntialias = true,
                Color       = SKColors.White,
                TextSize    = 30 * _density
            };
            CardBackground.InvalidateSurface();
        }
コード例 #4
0
        private void Element_DataChanged(object sender, ElementControlEventArgs e)
        {
            var el = new CardElement();

            switch (e.Type)
            {
            case 0:
                var cb = new CardBackground();
                cb.layer  = e.Layer;
                cb.x      = (int)e.Locate.X;
                cb.y      = (int)e.Locate.Y;
                cb.bgPath = e.Path;
                card.Set(e.Layer, cb);
                break;

            case 1:
                var cf = new CardFram();
                cf.layer  = e.Layer;
                cf.x      = (int)e.Locate.X;
                cf.y      = (int)e.Locate.Y;
                cf.bgPath = e.Path;
                card.Set(e.Layer, cf);
                break;

            case 2:
                var ci = new CardImage();
                ci.layer  = e.Layer;
                ci.x      = (int)e.Locate.X;
                ci.y      = (int)e.Locate.Y;
                ci.bgPath = e.Path;
                ci.Width  = elements[e.Layer].pictureWidth.Value;
                ci.Height = elements[e.Layer].pictureHeight.Value;
                card.Set(e.Layer, ci);
                break;

            case 3:
                var cn = new CardImgNum();
                cn.layer  = e.Layer;
                cn.x      = (int)e.Locate.X;
                cn.y      = (int)e.Locate.Y;
                cn.bgPath = e.Path;
                cn.num    = e.Num;
                card.Set(e.Layer, cn);

                break;

            case 4:
                var ct = new CardText();
                ct.layer  = e.Layer;
                ct.x      = (int)e.Locate.X;
                ct.y      = (int)e.Locate.Y;
                ct.bgPath = e.Path;
                ct.Text   = e.Text;
                card.Set(e.Layer, ct);
                break;
            }

            Render();
        }
コード例 #5
0
        private Animation CreateCardAnimation(CardState cardstate)
        {
            var cardAnimStart = cardstate == CardState.Expended ? _cardTopMargin : _cornerRadius;
            var endAnimCard   = cardstate == CardState.Expended ? -_cornerRadius : _cardTopMargin;
            var cardAnim      = new Animation(v => { _cardTopAnimPosition = v; CardBackground.InvalidateSurface(); }, cardAnimStart, endAnimCard, Easing.SinInOut);

            return(cardAnim);
        }
コード例 #6
0
        protected override void OnBindingContextChanged()
        {
            base.OnBindingContextChanged();
            if (this.BindingContext == null)
            {
                return;
            }
            _viewModel = this.BindingContext as Hero;

            // because we can't bind skia drawing using the binding engine
            // we cache the paint objects when the bound character changes
            _heroColor = Color.FromHex(_viewModel.HeroColor).ToSKColor();
            _heroPaint = new SKPaint()
            {
                Color = _heroColor
            };
            _gradientTransitionY = float.MaxValue;

            _heroNamePaint = new SKPaint()
            {
                Typeface    = _typeface,
                IsAntialias = true,
                Color       = SKColors.White,
                TextSize    = 60f * _density
            };
            _heroNamePosY = 450f * _density;
            _heroNamePosX = 40f * _density;

            _realNamePaint = new SKPaint()
            {
                Typeface    = _typeface,
                IsAntialias = true,
                Color       = SKColors.White,
                TextSize    = 25 * _density
            };
            _realNamePosY = 550f * _density;

            // setup initial values
            _cardTopAnimPosition = _cardTopMargin;

            // repaint the surface with the new colors
            CardBackground.InvalidateSurface();
        }
コード例 #7
0
        private Animation CreateCardAnimation(CardState cardState)
        {
            // work out where the top of the card should be
            var cardAnimStart = cardState == CardState.Expanded ? _cardTopMargin : -_cornerRadius;
            var cardAnimEnd   = cardState == CardState.Expanded ? -_cornerRadius : _cardTopMargin;

            var cardAnim = new Animation(
                v =>
            {
                _cardTopAnimPosition = v;
                CardBackground.InvalidateSurface();
            },
                cardAnimStart,
                cardAnimEnd,
                Easing.SinInOut
                );

            return(cardAnim);
        }
コード例 #8
0
        private Animation CreateHeroNameAnimation(CardState cardState)
        {
            // work out where the top of the card should be
            var nameAnimationStart = cardState == CardState.Expanded ? 0 : -50;
            var nameAnimationEnd   = cardState == CardState.Expanded ? -50 : 0;

            var imageAnim = new Animation(
                v =>
            {
                _heroNameOffsetY = (float)v * _density;
                CardBackground.InvalidateSurface();
            },
                nameAnimationStart,
                nameAnimationEnd,
                Easing.SpringOut
                );

            return(imageAnim);
        }
コード例 #9
0
        private Animation CardAnimation(CardState cardState)
        {
            //work out where the top of the card should be
            Debug.WriteLine($"CARD STATE: {cardState.ToString()}");
            var animationStart = cardState == CardState.Expanded ? _cardTopMargin : -_cornerRadius;
            var animationStop  = cardState == CardState.Expanded ? -_cornerRadius : _cardTopMargin;

            var animation = new Animation(
                v =>
            {
                _cardTopPosition = v;
                CardBackground.InvalidateSurface();
            },
                animationStart,
                animationStop,
                Easing.SinInOut
                );

            return(animation);
        }
コード例 #10
0
        protected override void OnBindingContextChanged()
        {
            base.OnBindingContextChanged();
            if (this.BindingContext == null)
            {
                return;
            }
            _viewModel = this.BindingContext as Hero;

            _heroColor = Color.FromHex(_viewModel.HeroColor).ToSKColor();
            _heroPaint = new SKPaint()
            {
                Color = _heroColor
            };
            _gradientTransitionY = float.MaxValue;
            // setup initial values
            _cardTopAnimPosition = _cardTopMargin;

            CardBackground.InvalidateSurface();
        }
コード例 #11
0
ファイル: Card.cs プロジェクト: lucascmb/ClashOfSpells
    // Use this for initialization
    void Start()
    {
        cardAnimator = GetComponent <Animator>();
        players      = FindObjectOfType <Players>();
        cardBg       = GetComponentInChildren <CardBackground>();

        stage = Stage.preparing;
        index = MenuController.GetIndex();

        mask = 2048;

        transform.localPosition = new Vector3(0f, 0f, 0f);
        transform.rotation      = Quaternion.Euler(0, 0, 90);
        transform.localScale    = new Vector3(0f, 0f, 1f);

        elementsAvailable = new IElements[4];

        mostRight = elementsAvailable.Length - 1;
        mostLeft  = 0;
    }
コード例 #12
0
        private Animation CreateGradientAnimation(CardState cardState)
        {
            float animStart, animEnd;

            Debug.WriteLine($"Canvass height: {CardBackground.CanvasSize.Height}");
            if (cardState == CardState.Expanded)
            {
                _gradientTransitionY = CardBackground.CanvasSize.Height;
                animStart            = _gradientTransitionY;
                animEnd = -_gradientHeight;
            }
            else
            {
                _gradientTransitionY = -_gradientHeight;
                animStart            = -_gradientTransitionY;
                animEnd = CardBackground.CanvasSize.Height;
            }

            var anim = new Animation(
                callback: v =>
            {
                _gradientTransitionY = (float)v;
                CardBackground.InvalidateSurface();
            },
                start: animStart,
                end: animEnd,
                finished: () =>
            {
                var fontColor = cardState == CardState.Expanded ? Color.Black : Color.White;
                HeroNameLabelLine1.TextColor = fontColor;
                HeroNameLabelLine2.TextColor = fontColor;
                RealNameLabel.TextColor      = fontColor;
            }
                );

            return(anim);
        }
コード例 #13
0
        protected override void OnBindingContextChanged()
        {
            base.OnBindingContextChanged();
            if (this.BindingContext == null)
            {
                return;
            }
            _viewModel = this.BindingContext as Hero;

            // because we can't bind skia drawing using the binding engine
            // we cache the paint objects when the bound character changes
            _heroColor = Color.FromHex(_viewModel.HeroColor).ToSKColor();
            _heroPaint = new SKPaint()
            {
                Color = _heroColor
            };
            _gradientTransitionY = float.MaxValue;

            // setup initial values
            _cardTopAnimPosition = _cardTopMargin;

            // repaint the surface with the new colors
            CardBackground.InvalidateSurface();
        }
コード例 #14
0
        //public BoxView CardBackground => PokemonBackground;

        protected override void OnBindingContextChanged()
        {
            base.OnBindingContextChanged();
            if (this.BindingContext == null)
            {
                return;
            }
            _viewModel = this.BindingContext as Pokemon;

            // because we can't bind skia drawing using the binding engine
            // we cache the paint objects when the bound character changes

            _pokeColor = Color.FromHex(_viewModel.PokemonPrimaryColor).ToSKColor();
            _pokePaint = new SKPaint()
            {
                Color = _pokeColor
            };

            //setup initial values
            _cardTopPosition = _cardTopMargin;

            // repaint the surface with the new colors
            CardBackground.InvalidateSurface();
        }
コード例 #15
0
        /// <summary>
        /// Draws the animation for the specified card background to a new bitmap image and returns it.
        /// </summary>
        /// <param name="background">The background of the card.</param>
        /// <param name="x">The X position of the card, in pixels.</param>
        /// <param name="y">The Y position of the card, in pixels.</param>
        /// <param name="frame">The frame index.</param>
        /// <param name="drawNextFrame">Whether the animation should draw another frame.</param>
        public Bitmap AnimationToBitmap(CardBackground background, int x, int y, int frame, out bool drawNextFrame)
        {
            Bitmap bitmap = new Bitmap(this.Width, this.Height);
            using (Graphics g = Graphics.FromImage(bitmap))
            {
                drawNextFrame = this.DrawAnimation(g, background, x, y, frame);
            }

            return bitmap;
        }
コード例 #16
0
        private Animation NameAnimation(CardState cardstate)
        {
            var NameAnimStart = cardstate == CardState.Expended ? 0 : _ProductAnimeOffsetY;
            var NameAnimEnd   = cardstate == CardState.Expended ?  _ProductAnimeOffsetY - 200: 0;
            var NameAnim      = new Animation(v => { _ProductAnimeOffsetY = (float)v; CardBackground.InvalidateSurface(); }, NameAnimStart, NameAnimEnd, Easing.SpringOut);

            return(NameAnim);
        }
コード例 #17
0
 public void DrawBack(Graphics g, int x, int y, int width, int height, CardBackground background, Color color)
 {
     this.Draw(g, x, y, width, height, (int)background, CardType.Back, color);
 }
コード例 #18
0
 /// <summary>
 /// Draws the animation for the specified card background to a new bitmap image and returns it.
 /// </summary>
 /// <param name="background">The background of the card.</param>
 /// <param name="x">The X position of the card, in pixels.</param>
 /// <param name="y">The Y position of the card, in pixels.</param>
 /// <param name="frame">The frame index.</param>
 /// <returns>Whether the animation should draw another frame.</returns>
 public Bitmap AnimationToBitmap(CardBackground background, int x, int y, int frame)
 {
     bool dnf;
     return this.AnimationToBitmap(background, x, y, frame, out dnf);
 }
コード例 #19
0
 public void DrawBack(Graphics g, int x, int y, CardBackground background, Color color)
 {
     this.DrawBack(g, x, y, this.Width, this.Height, background, color);
 }
コード例 #20
0
 public void DrawBack(Graphics g, Rectangle rectangle, CardBackground background, Color color)
 {
     this.DrawBack(g, rectangle.X, rectangle.Y, rectangle.Width, rectangle.Height, background, color);
 }
コード例 #21
0
 public void DrawBack(Graphics g, Point point, CardBackground background, Color color)
 {
     this.DrawBack(g, point.X, point.Y, background, color);
 }
コード例 #22
0
        /// <summary>
        /// Draws the animation for the specified card background.
        /// </summary>
        /// <param name="g">The graphics context to draw on.</param>
        /// <param name="background">The background of the card.</param>
        /// <param name="x">The X position of the card, in pixels.</param>
        /// <param name="y">The Y position of the card, in pixels.</param>
        /// <param name="frame">The frame index.</param>
        /// <returns>Whether the animation should draw another frame.</returns>
        public bool DrawAnimation(Graphics g, CardBackground background, int x, int y, int frame)
        {
            IntPtr hdc = g.GetHdc();

            try
            {
                return CardRenderer.cdtAnimate(hdc, (int)background, x, y, frame);
            }
            finally
            {
                g.ReleaseHdc(hdc);
            }
        }
コード例 #23
0
 public Bitmap BackToBitmap(int width, int height, CardBackground background, Color color)
 {
     return this.ToBitmap(width, height, (int)background, CardType.Back, color);
 }
コード例 #24
0
 public Bitmap BackToBitmap(Size size, CardBackground background, Color color)
 {
     return this.BackToBitmap(size.Width, size.Height, background, color);
 }
コード例 #25
0
 public Bitmap BackToBitmap(CardBackground background, Color color)
 {
     return this.BackToBitmap(this.Size, background, color);
 }