-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathRaft.cs
More file actions
41 lines (32 loc) · 977 Bytes
/
Raft.cs
File metadata and controls
41 lines (32 loc) · 977 Bytes
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
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class Raft : MonoBehaviour
{
private int nextLevel;
private int currentSceneIndex;
[Header("Sound FX")]
[SerializeField] private AudioSource raftSound;
private GameObject specColl;
// Start is called before the first frame update
private void Start()
{
specColl = GameObject.Find("SpecialCollectible");
nextLevel = SceneManager.GetActiveScene().buildIndex + 1;
}
private void OnTriggerEnter2D(Collider2D collision)
{
if (collision.tag == "Player")
{
if (specColl == null) {
raftSound.Play();
//SaveLoad.saveManager.Save();
SaveLoad.Save();
SceneManager.LoadScene(nextLevel);
} else {
Debug.Log("Get Special Collectible first!");
}
}
}
}