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

public class DamageController : MonoBehaviour {
    public string TagName;
    [SerializeField]
    int MyScore = 100;
    public AudioSource AudioSource;
    public AudioClip HageSE;

    bool headDestroyed = false;

    void OnTriggerEnter(Collider other) {

        Debug.Log("OnTriggerEnter event!");
        
        if(other.tag == TagName && !headDestroyed) {
            Debug.Log("bbb");


            // 頭部を非表示にする
            gameObject.SetActive(false);
            // 
            GameObject.Find("GameSystem").GetComponent<GameSystemManager>().Score += MyScore;
            AudioSource.PlayOneShot(HageSE);


            // 頭部が非表示にされたことを記録
            headDestroyed = true;
        }
    }

}