using Microsoft.Xna.Framework;
using System;

namespace Igdc.Drawables
{
    public class HealthBarElement : DrawableBase
    {
        public override Point Size => new Point(17, 20);
        public bool IsAlive { get; private set; } = true;
        public byte X;

        private static readonly Random Random = new Random();

        public HealthBarElement()
        {
            IdleAnimation = new AnimationDefenition
            {
                new AnimationFrame {Frame = new Point(0, 0), Length = 6},
                new AnimationFrame {Frame = new Point(0, 1), Length = 6},
                new AnimationFrame {Frame = new Point(0, 2), Length = 6},
                new AnimationFrame {Frame = new Point(0, 3), Length = 6},
            };
            IdleAnimationEnabled = true;
            for (var i = 0; i < Random.Next(0, 30); i++)
            {
                GetAnimationFrame();
            }
        }

        public void AnimateDeath()
        {
            IsAlive = false;
            SetAnimation(new AnimationDefenition
            {
                new AnimationFrame {Frame = new Point(1, 0), Length = 6},
                new AnimationFrame {Frame = new Point(1, 1), Length = 6},
                new AnimationFrame {Frame = new Point(1, 2), Length = 6},
                new AnimationFrame {Frame = new Point(1, 3), Length = 6},
                new AnimationFrame {Frame = new Point(1, 4), Length = 6},
                new AnimationFrame {Frame = new Point(1, 5), Length = 6},
                new AnimationFrame {Frame = new Point(1, 6), Length = 6},
                new AnimationFrame {Frame = new Point(1, 7), Length = 6},
                new AnimationFrame {Frame = new Point(1, 8), Length = 6},
            });
            IdleAnimationEnabled = false;
        }
    }
}