Refactor treasure scriptable objects; update references and remove unused assets
This commit is contained in:
@@ -12,11 +12,17 @@ public class HammerThrower : MonoBehaviour
|
||||
private bool _hasHammer = true;
|
||||
private bool _facingRight = true;
|
||||
private float _cooldownTimer = 0f;
|
||||
private Collider2D _playerCollider;
|
||||
|
||||
public bool HasHammer => _hasHammer;
|
||||
public bool CanThrow => _hasHammer && _cooldownTimer <= 0f;
|
||||
public float CooldownRemaining => Mathf.Max(0f, _cooldownTimer);
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
_playerCollider = GetComponent<Collider2D>() ?? GetComponentInChildren<Collider2D>();
|
||||
}
|
||||
|
||||
public void SetFacingDirection(bool facingRight)
|
||||
{
|
||||
_facingRight = facingRight;
|
||||
@@ -38,6 +44,15 @@ public class HammerThrower : MonoBehaviour
|
||||
|
||||
_currentHammer = Instantiate(_hammerPrefab, _spawnPoint.position, _spawnPoint.rotation);
|
||||
|
||||
if (_playerCollider != null)
|
||||
{
|
||||
var hammerCollider = _currentHammer.GetComponent<Collider2D>();
|
||||
if (hammerCollider != null)
|
||||
{
|
||||
Physics2D.IgnoreCollision(_playerCollider, hammerCollider);
|
||||
}
|
||||
}
|
||||
|
||||
// Initialize hammer with direction and speed
|
||||
var hammerComponent = _currentHammer.GetComponent<Hammer>();
|
||||
if (hammerComponent != null)
|
||||
|
||||
Reference in New Issue
Block a user