using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;

public enum NoteHitType
{
    PERFECT,
    PERFECT_OTHER_HAND,
    HIT,
    HIT_OTHER_HAND,
    MISS
}

public abstract class NoteObject : MonoBehaviour
{
    public static Action<NoteHitType> OnNoteHit;
    protected float remainedTime;

    public Vector3 startPoint { get { return endPoint + new Vector3(0, 0, 50); } }
    public Vector3 endPoint;

	public float maxRemainedTime = 1;
	public float perfectZ = 10;

    protected virtual void OnDestroy()
    {
        
    }

    public void Awake()
    {
        remainedTime = maxRemainedTime;
    }

    public virtual void NoteHit(NoteHitType type)
    {
        OnNoteHit?.Invoke(type);
        Instantiate(PlayEngine.inst.hitEffectPrefabs[(int)type], transform.position, Quaternion.identity);
        Destroy(gameObject);
    }

    public virtual void SetPosition(float remainedTime)
    {
        transform.position = endPoint + new Vector3(0, 0, 50) * remainedTime / maxRemainedTime;
    }
}
