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

namespace Project.Sound
{
    public class SoundRingEffect : CoreBehaviour
    {
        public float scale = 5f;
        public float time = 0.5f;
        private new SpriteRenderer renderer;
        private UnityTimer lifeTimer;

        // Use this for initialization
        protected override void InnerAwake()
        {
            this.renderer = GetComponent<SpriteRenderer>();
            this.lifeTimer = new UnityTimer(this.time, false);
        }

        // Update is called once per frame
        protected override void InnerUpdate()
        {
            this.lifeTimer.Advance();
            float phase = this.lifeTimer.GetCurrent() / this.lifeTimer.GetEnd();
            this.transform.localScale = Vector3.one + (Vector3.one * phase * this.scale);
            this.renderer.color = new Color(this.renderer.color.r, this.renderer.color.g, this.renderer.color.b, 1 - phase);
            if (this.lifeTimer.IsComplete())
            {
                Destroy(this.gameObject);
            }
        }
    }
}