7579175d24
- Removed obsolete scripts: Chest, BreakableWall, Door, DoorInteract, and UiManager. - Moved Chest and BreakableWall scripts to EnvironmentObjects folder. - Introduced HammerThrower class to manage hammer throwing mechanics. - Updated PlayerController to utilize new InputManager and HammerThrower. - Refactored PlayerState to manage player state and item collection. - Enhanced UI management in UiManager to reflect player item collection. - Updated EnemyAI to remove unused movement logic. - Adjusted KeyChest to interact with PlayerState instead of Player. - Cleaned up code and improved event handling for item collection.
26 lines
543 B
C#
26 lines
543 B
C#
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 playerState = collider.GetComponent<PlayerState>();
|
|
if (playerState!=null)
|
|
{
|
|
if (playerState.HasKey)
|
|
{
|
|
_door.OpenDoor();
|
|
}
|
|
}
|
|
}
|
|
}
|