rabidus-test/Assets/Scripts/EnergyItem.cs

23 lines
458 B
C#

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class EnergyItem : MonoBehaviour, IInteractable
{
[SerializeField]
private float _energy = 1;
private EnergyController _energyController;
private void Awake()
{
_energyController = FindObjectOfType<EnergyController>();
}
public void Interact()
{
_energyController.Energy += _energy;
Destroy(gameObject);
}
}