using System.Collections.Generic;
using GGJ.Models;
using UnityEngine;
using Light = GGJ.Models.Light;

namespace GGJ.Objects
{
    public class LightDestination : MonoBehaviour
    {
        public LightColorType colorType = LightColorType.All;
        public LightMoveType moveType = LightMoveType.Photon;

        public Color expectedColor = Color.white;
        public float colorThreshold = 0.05f;
        public List<SpriteRenderer> fillSprites;

        public bool CheckLight(Light l)
        {
            if (colorType == LightColorType.Single)
            {
                return Utils.IsColorSimilar(l.color, expectedColor, colorThreshold) && l.moveType == moveType;
            }
            return l.moveType == moveType;
        }

        public GGJ.Models.Light HitLight(RaycastHit2D hit)
        {
            var l = new GGJ.Models.Light
            {
                direction = Vector2.zero,
                isComplation = true,
                @from = hit.point
            };
            return l;
        }

        public void FillTo(float f)
        {
            foreach (var sprite in fillSprites)
            {
                var c = sprite.color;
                c.a = f;
                sprite.color = c;
            }
        }
    }
}