using Microsoft.Xna.Framework;
using System.Collections.Generic;
using System.Linq;
using System;

namespace Igdc.Drawables
{
    public class BattlePlayer : DrawableBase
    {
        public override Point Size { get; } = new Point(49, 58);
        public int Health
        {
            get { return _health; }
            set
            {
                _health = value;
                // Show
                foreach (var element in HealthBar.Where(e => e.X < _health))
                {
                    //element.SetAnimation
                }
                // Hide
                foreach (var element in HealthBar.Where(e => e.X >= _health && e.IsAlive))
                {
                    element.AnimateDeath();
                }
            }
        }
        private int _health = 3;

        public List<HealthBarElement> HealthBar = new List<HealthBarElement>
        {
            new HealthBarElement { X = 0 },
            new HealthBarElement { X = 1 },
            new HealthBarElement { X = 2 }
        };

        public byte X = 1;

        private readonly AnimationDefenition DefaultAnimation = new AnimationDefenition
        {
            new AnimationFrame { Frame = new Point(0, 0), Length = 3 },
            new AnimationFrame { Frame = new Point(0, 0), Length = 3 },
            
        };

        public void AnimateAttack()
        {
            SetAnimation(new AnimationDefenition
            {
                new AnimationFrame {Frame = new Point(0, 1), Length = 4},
                new AnimationFrame {Frame = new Point(0, 2), Length = 4},
                new AnimationFrame {Frame = new Point(0, 0), Length = 0},
            });
        }

        //private readonly AnimationDefenition HideAnimation = new AnimationDefenition
        //{
        //    new AnimationFrame { Frame = new Point(0, 0), Length = 3 },
        //    new AnimationFrame { Frame = new Point(0, 0), Length = 3 }
        //};
    }
}