using System.Collections.Generic;
using UnityEngine;
public class NoteController : BaseNote
{
    private SpriteRenderer m_SpriteRenderer;
    void Awake()
    {
        _transform = gameObject.GetComponent<Transform>();
        _anchorPointTransform = _transform.Find("NoteAnchorPoint").GetComponent<Transform>();
        _rendererTransform = _transform.Find("NoteRenderer").GetComponent<Transform>();
        //获取自身渲染器组件
        m_SpriteRenderer = _anchorPointTransform.GetComponent<SpriteRenderer>();
    }
    void Update()
    {
        UpdateRenderer(_songInformation.SongCurrentTime, _BPMGroup.CurrentNoteSpeed);
        UpdateAnchorPoint(_songInformation.SongCurrentTime, _BPMGroup.CurrentNoteSpeed, _BPMGroup.Beat);
    }
    private Color A0 = new Color(255, 255, 255, 0);
    private Color A255 = new Color(255, 255, 255, 255);
    //用于控制物体颜色的参数t
    private float t = 0;
    /// <summary>
    /// 用于被外部实例化的公开方法
    /// </summary>
    public void Init(Vector3 pos, float noteTime, SongInformationContainer container, BPMGroup timing)
    {
        //重置击中状态
        IsValid = false;
        Vector3 ViewPos = new Vector3(pos.x, pos.y, 0);
        _songInformation = container;
        TargetTime = noteTime;
        _transform.position = ViewPos;
        _rendererTransform.position = pos;
        m_SpriteRenderer.color = A0; t = 0;
        _BPMGroup = timing;
    }

}
