diff --git a/Assets/Scripts/Character.cs b/Assets/Scripts/Character.cs index 9660a36..4504764 100644 --- a/Assets/Scripts/Character.cs +++ b/Assets/Scripts/Character.cs @@ -16,13 +16,16 @@ public abstract class Character : MonoBehaviour [SerializeField] private LayerMask _mapLayer; + + protected SpriteRenderer _spriteRenderer; private Rigidbody2D _body; private CapsuleCollider2D _capsuleCollider; protected bool _isOnBridge; private bool _isOnLadder = false; + protected bool _isFalling; protected bool _facingRight = true; @@ -37,7 +40,7 @@ public abstract class Character : MonoBehaviour { _body = GetComponent(); _capsuleCollider = GetComponent(); - + _spriteRenderer = GetComponentInChildren(); _cellSize = new Vector2(0.6f, 1f); Spawn(); } diff --git a/Assets/Scripts/EnemyAI.cs b/Assets/Scripts/EnemyAI.cs index a818486..6317230 100644 --- a/Assets/Scripts/EnemyAI.cs +++ b/Assets/Scripts/EnemyAI.cs @@ -9,7 +9,8 @@ public class EnemyAI : Character protected override void OnDeath() { _needRespawn = true; -} + _spriteRenderer.enabled =false; + } protected override void SetClimbingAnimation(bool isClimbing) { @@ -28,6 +29,7 @@ public class EnemyAI : Character { _respawnElementTimer = _respawnTimeout; _needRespawn = false; + _spriteRenderer.enabled =true; Spawn(); } return; diff --git a/Assets/Scripts/Player.cs b/Assets/Scripts/Player.cs index 1a08b5c..1ba96e4 100644 --- a/Assets/Scripts/Player.cs +++ b/Assets/Scripts/Player.cs @@ -30,7 +30,7 @@ public class Player : Character private GameObject _hammer; private bool _isHoldingHammer = true; - private SpriteRenderer _spriteRenderer; + public event EventHandler OnPlayerTakeItem; @@ -46,7 +46,7 @@ public class Player : Character Instance = this; DontDestroyOnLoad(gameObject); - _spriteRenderer = GetComponentInChildren(); + } public void AddCoin()