36 lines
856 B
C#
36 lines
856 B
C#
|
|
using UnityEngine;
|
|
|
|
public class BonusPickup : MonoBehaviour
|
|
{
|
|
public BonusEffect bonusEffect;
|
|
public float rotationSpeed = 100f;
|
|
|
|
private GameObject _originalPrefab;
|
|
|
|
public void Init(GameObject prefab)
|
|
{
|
|
_originalPrefab = prefab;
|
|
}
|
|
|
|
void Update()
|
|
{
|
|
transform.Rotate(Vector3.up, rotationSpeed * Time.deltaTime);
|
|
}
|
|
|
|
private void OnTriggerEnter(Collider other)
|
|
{
|
|
if (other.CompareTag("Player"))
|
|
{
|
|
if (BonusManager.Instance != null && bonusEffect != null)
|
|
{
|
|
BonusManager.Instance.ActivateBonus(bonusEffect);
|
|
Debug.Log("бонус подобран");
|
|
}
|
|
|
|
if (_originalPrefab != null)
|
|
SimpleObjectPool.Instance.ReturnToPool(_originalPrefab, gameObject);
|
|
}
|
|
}
|
|
}
|