-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathAreaBlocked.cs
110 lines (97 loc) · 2.93 KB
/
AreaBlocked.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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class AreaBlocked : MonoBehaviour
{
public bool blockIsActive;
public int questID;
private QuestManager questManager;
private Quest quest;
public string dialogueText;
public bool needsQuestStarted;
public bool needsQuestCompleted;
private ItemsManager itemsManager;
public bool needsItem;
public QuestItem item;
// Start is called before the first frame update
void Start()
{
itemsManager = FindObjectOfType<ItemsManager>();
questManager = FindObjectOfType<QuestManager>();
quest = questManager.QuestWithID(questID);
if (!blockIsActive && !needsItem)
{
this.gameObject.SetActive(false);
}
}
private void OnCollisionEnter2D(Collision2D collision)
{
if (needsItem)
{
if (itemsManager.HasTheQuestItem(item))
{
SFXManager.SharedInstance.PlaySFX(SFXType.SoundType.LOCK_DOOR);
this.gameObject.SetActive(false);
blockIsActive = false;
}
else
{
if (collision.gameObject.tag.Equals("Player"))
{
questManager.ShowQuestText(dialogueText);
}
}
return;
}
if (blockIsActive)
{
//Si el area esta bloqueada
if (needsQuestStarted)
{
//Si necesita solo que la quest este iniciada
if (!quest.questCompleted)
{
if (!quest.questStarted)
{
if (collision.gameObject.tag.Equals("Player"))
{
questManager.ShowQuestText(dialogueText);
}
}
else
{
this.gameObject.SetActive(false);
blockIsActive = false;
}
}
else
{
this.gameObject.SetActive(false);
blockIsActive = false;
}
}
if (needsQuestCompleted)
{
//Si necesita que la quest este terminada
if (!quest.questCompleted)
{
if (collision.gameObject.tag.Equals("Player"))
{
questManager.ShowQuestText(dialogueText);
}
}
else
{
this.gameObject.SetActive(false);
blockIsActive = false;
}
}
}
//Si el area NO esta bloqueada
else
{
this.gameObject.SetActive(false);
blockIsActive = false;
}
}
}