Code refactor, added coins chests, key chest and door
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
using Assets.Scripts;
|
||||
using UnityEngine;
|
||||
|
||||
public class DoorInteract : MonoBehaviour
|
||||
{
|
||||
[SerializeField] private GameObject _doorGameObject;
|
||||
private IDoor _door;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
_door =_doorGameObject.GetComponent<IDoor>();
|
||||
}
|
||||
|
||||
private void OnTriggerEnter2D(Collider2D collider)
|
||||
{
|
||||
var player = collider.GetComponent<Player>();
|
||||
if (player!=null)
|
||||
{
|
||||
if (player.IsHasKey())
|
||||
{
|
||||
_door.OpenDoor();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user