using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using SFML.Graphics;
using SFML.Window;
using YourBeatingHeart.Main.Graphics;
using YourBeatingHeart.Main.Entities;

namespace YourBeatingHeart.Main.States.Play.Entities
{
    public class PointDisplayEntity : DrawableEntity
    {
        PlayState playState;
        List<PlayerPointDisplay> pointDisplays;

        public PointDisplayEntity(PlayState playState) : base(null, PlayState.Layers.TopmostText)
        {
            pointDisplays = new List<PlayerPointDisplay>();

            for(int i = 0; i < playState.Players.Count; i++)
                pointDisplays.Add(new PlayerPointDisplay(playState.Game, "Player_" + (i + 1).ToString() + "_strikes.xml",
                    new Vector2f(Constants.SCORE_X_POS[playState.Players.Count - 1, i], 20), "player_" + (i + 1).ToString() + "_name.png"));

            this.playState = playState;
        }

        public override void Update(float elapsedTime)
        {
            foreach (var player in playState.Players)
            {
                pointDisplays[(int) player.Id].Update(player.Score, elapsedTime);
            }
            //for(int i = 0; i < pointDisplays.Count; i++)
            //    pointDisplays[i].Update(state.score[i], elapsedTime);
        }

        public override void Draw(RenderTarget renderTarget)
        {
            foreach(PlayerPointDisplay disp in pointDisplays)
                renderTarget.Draw(disp);
        }
    }
}
