-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTimeShard.cs
33 lines (28 loc) · 963 Bytes
/
TimeShard.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
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace PlanetTaxi
{
public class TimeShard : MonoBehaviour
{
[Header("A GameObject-hez kapcsolt Collider-nek Trigger-nek kell lennie!")]
[Tooltip("Objektum ami bekapcsol felvételkor")]
[SerializeField] private GameObject _objectToTurnOn;
[Tooltip("Hang ami lejátszódik felvételkor. Ne legyen az AudioSource ezen a GameObject-en!")]
[SerializeField] private AudioSource _pickUpSound;
private void Start()
{
if (_objectToTurnOn != null) _objectToTurnOn.SetActive(false);
}
private void OnTriggerEnter(Collider other)
{
if (other.GetComponent<TaxiController>() != null)
{
LevelMaster.Instance.TimeShardCollected();
if (_objectToTurnOn != null) _objectToTurnOn.SetActive(true);
if (_pickUpSound != null) _pickUpSound.Play();
Destroy(gameObject);
}
}
}
}