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

public class Bonus : MonoBehaviour {
    NPC npcTracking;

    void Awake()
    {
        Observer.bonusTouchedHandler += OnBonusTouched;
    }

    void FixedUpdate()
    {
        if (npcTracking != null) this.transform.position = npcTracking.transform.position;
        else this.gameObject.SetActive(false);
    }

    void OnBonusTouched(NPC npc)
    {
        this.npcTracking = npc;
        this.transform.position = npcTracking.transform.position;
        this.gameObject.SetActive(true);
    }
}
