2024-04-16 03:23:44 -07:00
|
|
|
using DG.Tweening;
|
2024-04-15 04:10:00 -07:00
|
|
|
using GadGame.Manager;
|
|
|
|
using Pools.Runtime;
|
|
|
|
using UnityEngine;
|
|
|
|
|
|
|
|
namespace GadGame.MiniGame
|
|
|
|
{
|
2024-04-16 01:47:19 -07:00
|
|
|
public class Bomb : MonoBehaviour, ICollect, IPoolable
|
2024-04-15 04:10:00 -07:00
|
|
|
{
|
|
|
|
[SerializeField] private int _reduceScore;
|
2024-04-15 20:57:02 -07:00
|
|
|
[SerializeField] private Rigidbody2D _rb;
|
2024-04-16 01:47:19 -07:00
|
|
|
|
|
|
|
private bool _inUsed;
|
2024-04-15 20:57:02 -07:00
|
|
|
|
|
|
|
public void Init(float gravityScale = 1)
|
|
|
|
{
|
|
|
|
_rb.gravityScale = gravityScale;
|
2024-04-16 03:23:44 -07:00
|
|
|
transform.DORotate(new Vector3(0, 0, 1),0.1f).SetLoops(-1, LoopType.Incremental);
|
2024-04-15 20:57:02 -07:00
|
|
|
}
|
|
|
|
|
2024-04-16 03:23:44 -07:00
|
|
|
private void LateUpdate()
|
2024-04-15 20:57:02 -07:00
|
|
|
{
|
2024-04-16 01:47:19 -07:00
|
|
|
if (_inUsed && _rb.position.y <= -10)
|
2024-04-15 20:57:02 -07:00
|
|
|
{
|
|
|
|
this.Release();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2024-04-15 04:10:00 -07:00
|
|
|
public void Collect()
|
|
|
|
{
|
|
|
|
GameManager.Instance.UpdateScore(-_reduceScore);
|
|
|
|
this.Release();
|
|
|
|
}
|
2024-04-16 01:47:19 -07:00
|
|
|
|
|
|
|
public void OnGet()
|
|
|
|
{
|
|
|
|
_inUsed = true;
|
|
|
|
}
|
|
|
|
|
|
|
|
public void OnRelease()
|
|
|
|
{
|
|
|
|
_inUsed = false;
|
|
|
|
}
|
2024-04-15 04:10:00 -07:00
|
|
|
}
|
|
|
|
}
|