-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathToHouseLevel.cs
57 lines (55 loc) · 1.56 KB
/
ToHouseLevel.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
//This code is written By Kareem Hatem BUE ICS Y2 After prep 2020/2021
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class ToHouseLevel : MonoBehaviour
{
private int currentMission;
public KeyCode Interact;
public KeyCode Leave;
public GameObject dialogBox;
public Text dialogText;
public string dialog;
public bool dialogActive;
// Start is called before the first frame update
void Start()
{
currentMission = 0;
}
private void OnCollisionEnter2D(Collision2D other)
{
if (other.gameObject.tag == "Player")
{
currentMission = other.gameObject.GetComponent<PlayerStats>().currentmission;
dialogActive = true;
}
}
private void OnCollisionExit2D(Collision2D other)
{
if (other.gameObject.tag == "Player")
{
dialogActive = false;
}
}
// Update is called once per frame
void Update()
{
if (Input.GetKey(Interact) && dialogActive)
{
if (dialogBox.activeInHierarchy)
{
dialogBox.SetActive(false);
}
else
{
dialogBox.SetActive(true);
dialogText.text = dialog;
}
}
if (Input.GetKey(Leave) && currentMission >= 3 && dialogActive)
{
UnityEngine.SceneManagement.SceneManager.LoadScene("VillageHouseLevelScene");
}
}
}