rabidus-test/Assets/Scripts/BaseItem.cs

23 lines
456 B
C#

using UnityEngine;
public class BaseItem : MonoBehaviour, IInteractable
{
[SerializeField]
private float _scoreAdd = 0;
protected ScoreController _scoreController;
protected virtual void Awake()
{
_scoreController = FindObjectOfType<ScoreController>();
}
public virtual void Interact()
{
if (_scoreAdd > 0)
_scoreController.AddScore(_scoreAdd, true);
Destroy(gameObject);
}
}