-
Notifications
You must be signed in to change notification settings - Fork 0
/
PickUp.cs
57 lines (43 loc) · 1.2 KB
/
PickUp.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
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PickUp : Interactive {
public string[] lines;
public string objName;
public Sprite sprite;
public QuestGiver qg;
public GameObject SwordIcon;
public AudioSource SwordActivateSFX;
void Awake(){
SwordIcon.SetActive (false);
}
void OnTriggerEnter (Collider col){
if (col.name == "Hero") {
//Debug.Log ("You have entered the interactive range.");
Interact ();
}
}
void OnTriggerStay (Collider col){
if (Input.GetKeyDown (KeyCode.E) && !CharacterMovement.isDead && col.name == "Hero"){
SwordBehaviour.EnableSword ();
SwordIcon.SetActive (true);
SwordActivateSFX.Play ();
Destroy (gameObject);
NotInteract ();
}
}
void OnTriggerExit (Collider col){
if (col.name == "Hero") {
//Debug.Log ("You have left the interactive range.");
NotInteract ();
}
}
//If player is within interaction range, then start a dialogue
public override void Interact(){
DialogueManager.Instance.AddNewDialogue(lines, objName, sprite);
}
//If player leaves the interaction range, then disable the dialogue
public override void NotInteract(){
DialogueManager.Instance.CloseDialogue ();
}
}