WIP
This commit is contained in:
@@ -0,0 +1,15 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class DoorController : MonoBehaviour
|
||||
{
|
||||
private void OnTriggerEnter2D(Collider2D collision)
|
||||
{
|
||||
if (collision.tag == "Player")
|
||||
{
|
||||
//if player have key, door will open
|
||||
//else player can't pass
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b3ead8e41e973dd43b93a8638ea30a36
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -0,0 +1,8 @@
|
||||
namespace Assets.Scripts
|
||||
{
|
||||
public interface IDoor
|
||||
{
|
||||
void OpenDoor();
|
||||
void ToggleDoor();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 62a1e4daba023c94f9fe4c576570cbf4
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -17,6 +17,7 @@ public class PlayerController : MonoBehaviour
|
||||
private BoxCollider2D _boxCollider;
|
||||
private bool _isFall;
|
||||
private bool _facingRight = true;
|
||||
private bool _haveKey = false;
|
||||
|
||||
|
||||
void Start()
|
||||
@@ -106,4 +107,13 @@ public class PlayerController : MonoBehaviour
|
||||
|
||||
_facingRight = !_facingRight;
|
||||
}
|
||||
|
||||
private void OnTriggerEnter2D(Collider2D collision)
|
||||
{
|
||||
var door = collision.GetComponent<DoorController>();
|
||||
if (door != null)
|
||||
{
|
||||
door.OpenDoor();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user