using Microsoft.Xna.Framework;

namespace Igdc.Drawables
{
    public class MapPlayer : DrawableBase
    {
        public byte X;
        public byte Y;

        public override Point Size => new Point(16);

        public void AnimateUp(bool hasMovement) => AnimateMovement(0, hasMovement);
        public void AnimateRight(bool hasMovement) => AnimateMovement(1, hasMovement);
        public void AnimateDown(bool hasMovement) => AnimateMovement(2, hasMovement);
        public void AnimateLeft(bool hasMovement) => AnimateMovement(3, hasMovement);

        private void AnimateMovement(int x, bool hasMovement)
        {
            if (hasMovement)
            {
                SetAnimation(new AnimationDefenition
                {
                    new AnimationFrame {Frame = new Point(x, 2), Length = 6},
                    new AnimationFrame {Frame = new Point(x, 3), Length = 6},
                });
            }
            IdleAnimation = new AnimationDefenition
            {
                new AnimationFrame {Frame = new Point(x, 0), Length = 6},
                new AnimationFrame {Frame = new Point(x, 1), Length = 6},
            };
            IdleAnimationEnabled = true;
        }
    }
}