Files
real-shooter/Assets/Scripts/Pickups/AmmoPickUp.cs
2022-05-04 23:50:07 +07:00

24 lines
617 B
C#
Executable File

using UnityEngine;
[RequireComponent(typeof(BoxCollider))]
public class AmmoPickUp : MonoBehaviour, IPickable
{
public PickUpType type => PickUpType.Ammunition;
public void OnTriggerEnter(Collider other)
{
PickObject(other.gameObject);
}
private void OnDestroy()
{
Debug.LogWarning("Pooled object was destroyed");
}
public void PickObject(GameObject obj)
{
obj.GetComponent<ICharacter>()?.GetCharacter.Condition.TakeAmmo(SettingsReader.Instance.GetSettings.AmmunitionPickupAmount);
gameObject.SetActive(false);
}
}