Refactor treasure scriptable objects; update references and remove unused assets

This commit is contained in:
2026-06-20 19:59:03 +03:00
parent a510443130
commit 374d75d379
9 changed files with 18 additions and 59 deletions
+15
View File
@@ -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)