using UnityEngine;
using System.Collections;
using Framework.Entities;
using Framework.Extensions;
using System.Linq;
using System.Collections.Generic;
using Framework.InteractionSystem;
using Framework.Utility;
using UnityEngine.UI;
using Project.Actors;

namespace Project.View
{
    public class WoundsDisplay : CoreBehaviour
    {
        //public Text element;
        public Woundable target;
        //private Image[] woundIcons;
        private Transform woundsPanel;

        // Use this for initialization
        protected override void InnerAwake()
        {
            if (this.target == null)
            {
                this.target = GameObject.Find("Player").GetComponent<Woundable>();
            }
            this.woundsPanel = this.transform.RecursivelyFindChild("WoundsPanel");
        }

        // Update is called once per frame
        protected override void InnerUpdate()
        {
            //this.element.text = "Wounds: " + target.wounds + "/" + target.maxWounds;
            for (int i = 0; i < this.woundsPanel.childCount; i++)
            {
                Image woundIcon = this.woundsPanel.GetChild(i).GetComponent<Image>();
                if (this.target.wounds > i)
                {
                    woundIcon.color = new Color(1f, 1f, 1f, 1f); 
                }
                else
                {
                    woundIcon.color = new Color(1f, 1f, 1f, 0.4f); 
                }
            }
        }
    }
}
