rabidus-test/Assets/Scripts/EnergyItem.cs

23 lines
456 B
C#
Raw Normal View History

2023-07-28 11:48:57 +03:00
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class EnergyItem : MonoBehaviour, ICollectable
{
[SerializeField]
private float _energy = 1;
private EnergyController _energyController;
private void Awake()
{
_energyController = FindObjectOfType<EnergyController>();
}
public void Collect()
{
_energyController.Energy += _energy;
Destroy(gameObject);
}
}