-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRoom.cs
61 lines (56 loc) · 1.5 KB
/
Room.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
using UnityEngine;
public class Room : MonoBehaviour
{
[SerializeField] GameObject topDoor;
[SerializeField] GameObject bottomDoor;
[SerializeField] GameObject leftDoor;
[SerializeField] GameObject rightDoor;
private bool isTopDoorOpen = false;
private bool isBottomDoorOpen = false;
private bool isLeftDoorOpen = false;
private bool isRightDoorOpen = false;
public Vector2Int RoomIndex { get; set; }
public void OpenDoor(Vector2Int direction)
{
if (direction == Vector2Int.up)
{
topDoor.SetActive(true);
isTopDoorOpen = true;
}
if (direction == Vector2Int.down)
{
bottomDoor.SetActive(true);
isBottomDoorOpen = true;
}
if (direction == Vector2Int.left)
{
leftDoor.SetActive(true);
isLeftDoorOpen = true;
}
if (direction == Vector2Int.right)
{
rightDoor.SetActive(true);
isRightDoorOpen = true;
}
}
internal bool IsDoorOpen(Vector2Int direction)
{
if (direction == Vector2Int.up)
{
return isTopDoorOpen;
}
else if (direction == Vector2Int.down)
{
return isBottomDoorOpen;
}
else if (direction == Vector2Int.left)
{
return isLeftDoorOpen;
}
else if (direction == Vector2Int.right)
{
return isRightDoorOpen;
}
return false;
}
}