Music implementation, cloud art, and bug fixes
Implemented music Added cloud tiles Made players be able to stand on each others' heads Synced the music and day/night cycle Added a transition in to the gameplay scene Fixed blocking while dying bug
This commit is contained in:
14
Assets/Scripts/EventSystemizer.cs
Normal file
14
Assets/Scripts/EventSystemizer.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.EventSystems;
|
||||
|
||||
public class EventSystemizer : MonoBehaviour
|
||||
{
|
||||
private void Update()
|
||||
{
|
||||
foreach (EventSystem system in FindObjectsByType<EventSystem>(FindObjectsSortMode.None))
|
||||
{
|
||||
if (system == GetComponent<EventSystem>()) continue;
|
||||
Destroy(system.gameObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/EventSystemizer.cs.meta
Normal file
2
Assets/Scripts/EventSystemizer.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 305a0eb0ddc9f88438e978efa8dd6f69
|
||||
@@ -17,7 +17,7 @@ public class FallPlatform : MonoBehaviour
|
||||
}
|
||||
private void OnTriggerEnter2D(Collider2D collision)
|
||||
{
|
||||
if (!falling/* && collision.gameObject.CompareTag("Player")*/)
|
||||
if (!falling && (collision.gameObject.CompareTag("Player") || collision.transform.GetChild(0).TryGetComponent(out FallPlatform _)))
|
||||
{
|
||||
StartCoroutine(FallAfterDelay());
|
||||
}
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Events;
|
||||
using UnityEngine.InputSystem;
|
||||
|
||||
public class GameManager : MonoBehaviour
|
||||
@@ -14,6 +15,8 @@ public class GameManager : MonoBehaviour
|
||||
public static List<Color> playerColors = new List<Color>();
|
||||
public float offset = 1f;
|
||||
|
||||
public static bool music = true;
|
||||
|
||||
public bool gameOver = false;
|
||||
|
||||
private void Awake()
|
||||
@@ -30,6 +33,7 @@ public class GameManager : MonoBehaviour
|
||||
|
||||
private void Start()
|
||||
{
|
||||
MusicManager.Instance.StartPlaylist();
|
||||
StartGame();
|
||||
}
|
||||
|
||||
|
||||
22
Assets/Scripts/InfiniteScroll.cs
Normal file
22
Assets/Scripts/InfiniteScroll.cs
Normal file
@@ -0,0 +1,22 @@
|
||||
using UnityEngine;
|
||||
|
||||
public class InfiniteScroll : MonoBehaviour
|
||||
{
|
||||
public float speed;
|
||||
public float start;
|
||||
public float end;
|
||||
|
||||
private void Update()
|
||||
{
|
||||
if (transform.position.x > end)
|
||||
{
|
||||
transform.position = new Vector3(start, transform.position.y, transform.position.z);
|
||||
}
|
||||
else if (transform.position.x < start)
|
||||
{
|
||||
transform.position = new Vector3(end, transform.position.y, transform.position.z);
|
||||
}
|
||||
|
||||
transform.position += speed * Time.deltaTime * Vector3.right;
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/InfiniteScroll.cs.meta
Normal file
2
Assets/Scripts/InfiniteScroll.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: c0e4599228c7142f9a5d65ab96f9fdc3
|
||||
41
Assets/Scripts/LifeDisplayManager.cs
Normal file
41
Assets/Scripts/LifeDisplayManager.cs
Normal file
@@ -0,0 +1,41 @@
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class LifeDisplayManager : MonoBehaviour
|
||||
{
|
||||
public GameObject players;
|
||||
public GameObject playerPrefab;
|
||||
public GameObject lifePrefab;
|
||||
|
||||
public Dictionary<Damageable, List<GameObject>> lifeDisplays = new Dictionary<Damageable, List<GameObject>>();
|
||||
|
||||
private void Start()
|
||||
{
|
||||
foreach (GameObject player in GameManager.players)
|
||||
{
|
||||
Transform parent = Instantiate(playerPrefab, players.transform).transform;
|
||||
|
||||
List<GameObject> lives = new List<GameObject>();
|
||||
for (int i = 0; i < player.GetComponent<Damageable>().lives; i++)
|
||||
{
|
||||
GameObject life = Instantiate(lifePrefab, parent);
|
||||
life.GetComponentInChildren<Image>().color = GameManager.playerColors[GameManager.players.IndexOf(player)];
|
||||
lives.Add(life);
|
||||
}
|
||||
|
||||
lifeDisplays.Add(player.GetComponent<Damageable>(), lives);
|
||||
}
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
foreach (Damageable damageable in lifeDisplays.Keys)
|
||||
{
|
||||
foreach (GameObject life in lifeDisplays[damageable])
|
||||
{
|
||||
life.SetActive(lifeDisplays[damageable].IndexOf(life) < damageable.lives);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/LifeDisplayManager.cs.meta
Normal file
2
Assets/Scripts/LifeDisplayManager.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 3e87378682ef9471d82043136357cc02
|
||||
18
Assets/Scripts/MapSelect.cs
Normal file
18
Assets/Scripts/MapSelect.cs
Normal file
@@ -0,0 +1,18 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class MapSelect : MonoBehaviour
|
||||
{
|
||||
private ToggleGroup maps;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
maps = GetComponent<ToggleGroup>();
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
Toggle toggle = maps.GetFirstActiveToggle();
|
||||
GameManager.map = toggle.name;
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/MapSelect.cs.meta
Normal file
2
Assets/Scripts/MapSelect.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 200b7ae572458463f97cb3b2fb349152
|
||||
29
Assets/Scripts/ModeSelect.cs
Normal file
29
Assets/Scripts/ModeSelect.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
|
||||
public class ModeSelect : MonoBehaviour
|
||||
{
|
||||
private ToggleGroup maps;
|
||||
|
||||
private void Start()
|
||||
{
|
||||
maps = GetComponent<ToggleGroup>();
|
||||
}
|
||||
|
||||
void Update()
|
||||
{
|
||||
Toggle toggle = maps.GetFirstActiveToggle();
|
||||
if (toggle.name == "Free-For-All")
|
||||
{
|
||||
GameManager.gameMode = GameManager.GameMode.freeForAll;
|
||||
}
|
||||
else if (toggle.name == "Keep-Away")
|
||||
{
|
||||
GameManager.gameMode = GameManager.GameMode.keepAway;
|
||||
}
|
||||
else if (toggle.name == "Obstacle Course")
|
||||
{
|
||||
GameManager.gameMode = GameManager.GameMode.obstacleCourse;
|
||||
}
|
||||
}
|
||||
}
|
||||
2
Assets/Scripts/ModeSelect.cs.meta
Normal file
2
Assets/Scripts/ModeSelect.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 234cf5c6ddbad406d9c687f76819ad6a
|
||||
8
Assets/Scripts/Music.meta
Normal file
8
Assets/Scripts/Music.meta
Normal file
@@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: e5d30ab9d20fa416dbd26b382141fe1d
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
BIN
Assets/Scripts/Music/._MusicManager.cs
Normal file
BIN
Assets/Scripts/Music/._MusicManager.cs
Normal file
Binary file not shown.
BIN
Assets/Scripts/Music/._MusicManager.cs.meta
Normal file
BIN
Assets/Scripts/Music/._MusicManager.cs.meta
Normal file
Binary file not shown.
BIN
Assets/Scripts/Music/._MusicTrack.cs
Normal file
BIN
Assets/Scripts/Music/._MusicTrack.cs
Normal file
Binary file not shown.
BIN
Assets/Scripts/Music/._MusicTrack.cs.meta
Normal file
BIN
Assets/Scripts/Music/._MusicTrack.cs.meta
Normal file
Binary file not shown.
BIN
Assets/Scripts/Music/._TrackLayer.cs
Normal file
BIN
Assets/Scripts/Music/._TrackLayer.cs
Normal file
Binary file not shown.
BIN
Assets/Scripts/Music/._TrackLayer.cs.meta
Normal file
BIN
Assets/Scripts/Music/._TrackLayer.cs.meta
Normal file
Binary file not shown.
BIN
Assets/Scripts/Music/._TrackManager.cs
Normal file
BIN
Assets/Scripts/Music/._TrackManager.cs
Normal file
Binary file not shown.
BIN
Assets/Scripts/Music/._TrackManager.cs.meta
Normal file
BIN
Assets/Scripts/Music/._TrackManager.cs.meta
Normal file
Binary file not shown.
107
Assets/Scripts/Music/MusicManager.cs
Normal file
107
Assets/Scripts/Music/MusicManager.cs
Normal file
@@ -0,0 +1,107 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Assertions.Must;
|
||||
using UnityEngine.Playables;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
public class MusicManager : MonoBehaviour
|
||||
{
|
||||
public static MusicManager Instance;
|
||||
public List<Playlist> playlists;
|
||||
private Dictionary<string, Playlist> sceneToPlaylist = new Dictionary<string, Playlist>();
|
||||
public GameObject songPrefab;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
if (Instance == null)
|
||||
{
|
||||
Instance = this;
|
||||
}
|
||||
else
|
||||
{
|
||||
Destroy(this.gameObject);
|
||||
}
|
||||
|
||||
foreach (Playlist playlist in playlists)
|
||||
{
|
||||
foreach (string scene in playlist.trackScenes)
|
||||
{
|
||||
sceneToPlaylist.Add(scene, playlist);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void StartPlaylist()
|
||||
{
|
||||
if (GetActiveSceneNotTitleScreen() == "Player Select") return;
|
||||
StopAllCoroutines();
|
||||
foreach (Transform child in transform)
|
||||
{
|
||||
Destroy(child.gameObject);
|
||||
}
|
||||
StartCoroutine(PlayPlaylist(sceneToPlaylist[GetActiveSceneNotTitleScreen()]));
|
||||
}
|
||||
|
||||
public void StartPlaylist(string scene)
|
||||
{
|
||||
if (GetActiveSceneNotTitleScreen() == "Player Select") return;
|
||||
StopAllCoroutines();
|
||||
foreach (Transform child in transform)
|
||||
{
|
||||
Destroy(child.gameObject);
|
||||
}
|
||||
StartCoroutine(PlayPlaylist(sceneToPlaylist[scene]));
|
||||
}
|
||||
|
||||
private IEnumerator PlayPlaylist(Playlist playlist)
|
||||
{
|
||||
while (true)
|
||||
{
|
||||
List<AudioClip> randomized = new List<AudioClip>(playlist.songs);
|
||||
for (int i = 0; i < randomized.Count; i++)
|
||||
{
|
||||
AudioClip temp = randomized[i];
|
||||
int randomIndex = Random.Range(i, randomized.Count);
|
||||
randomized[i] = randomized[randomIndex];
|
||||
randomized[randomIndex] = temp;
|
||||
}
|
||||
|
||||
foreach (AudioClip song in randomized)
|
||||
{
|
||||
AudioSource songInstance = Instantiate(songPrefab, transform).GetComponent<AudioSource>();
|
||||
songInstance.clip = song;
|
||||
songInstance.volume = playlist.volume;
|
||||
songInstance.Play();
|
||||
if (playlist.shuffleTime > 0f)
|
||||
{
|
||||
yield return new WaitForSeconds(playlist.shuffleTime);
|
||||
float time = 0f;
|
||||
while (time < 5f)
|
||||
{
|
||||
songInstance.volume = playlist.volume * (1 - time / 5f);
|
||||
time += Time.deltaTime;
|
||||
yield return null;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
yield return new WaitForSeconds(song.length);
|
||||
}
|
||||
Destroy(songInstance.gameObject);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static string GetActiveSceneNotTitleScreen()
|
||||
{
|
||||
for (int sceneIndex = 0; sceneIndex < SceneManager.sceneCount; sceneIndex++)
|
||||
{
|
||||
if (SceneManager.GetSceneAt(sceneIndex).name != "Title Screen")
|
||||
{
|
||||
return SceneManager.GetSceneAt(sceneIndex).name;
|
||||
}
|
||||
}
|
||||
return "Title Screen";
|
||||
}
|
||||
}
|
||||
11
Assets/Scripts/Music/MusicManager.cs.meta
Normal file
11
Assets/Scripts/Music/MusicManager.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f701561e8549d464b9530bb56c6bfeb9
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: -50
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
14
Assets/Scripts/Music/Playlist.cs
Normal file
14
Assets/Scripts/Music/Playlist.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Audio;
|
||||
|
||||
[System.Serializable]
|
||||
public class Playlist
|
||||
{
|
||||
public string trackName;
|
||||
public List<string> trackScenes;
|
||||
public List<AudioClip> songs;
|
||||
public float shuffleTime;
|
||||
public float volume;
|
||||
}
|
||||
11
Assets/Scripts/Music/Playlist.cs.meta
Normal file
11
Assets/Scripts/Music/Playlist.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7217d9ffc9dfd0c42bd093ee6d9c5db1
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
16
Assets/Scripts/Music/TrackLayer.cs
Normal file
16
Assets/Scripts/Music/TrackLayer.cs
Normal file
@@ -0,0 +1,16 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.Audio;
|
||||
|
||||
[System.Serializable]
|
||||
public class TrackLayer
|
||||
{
|
||||
public string layerName;
|
||||
public AudioClip layerTrack;
|
||||
public enum EnableTrigger { Scene, Magnetism, Goal, Button, Toggle, Movement, ConstantForce, EndOfLevel, ElectromagneticPulse, Collectible };
|
||||
public EnableTrigger enableTrigger = EnableTrigger.Scene;
|
||||
|
||||
public List<string> layerScenes;
|
||||
public string triggerName;
|
||||
}
|
||||
11
Assets/Scripts/Music/TrackLayer.cs.meta
Normal file
11
Assets/Scripts/Music/TrackLayer.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8a0b53b66b1b30143a043e7df151c454
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
366
Assets/Scripts/Music/TrackManager.cs
Normal file
366
Assets/Scripts/Music/TrackManager.cs
Normal file
@@ -0,0 +1,366 @@
|
||||
#if NO
|
||||
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using System.Data.Common;
|
||||
using System.Runtime.CompilerServices;
|
||||
using Unity.VisualScripting;
|
||||
using UnityEngine;
|
||||
using UnityEngine.SceneManagement;
|
||||
|
||||
public class TrackManager : MonoBehaviour
|
||||
{
|
||||
public Playlist musicTrack;
|
||||
public GameObject layerPrefab;
|
||||
|
||||
private List<TrackLayer> persistentLayers = new List<TrackLayer>();
|
||||
|
||||
private Scene currentScene;
|
||||
|
||||
private void Awake()
|
||||
{
|
||||
if (!GameManager.music)
|
||||
{
|
||||
Destroy(gameObject);
|
||||
}
|
||||
}
|
||||
|
||||
private void Start()
|
||||
{
|
||||
foreach (var layer in musicTrack.trackLayers)
|
||||
{
|
||||
if (layer.enableTrigger != TrackLayer.EnableTrigger.Scene)
|
||||
{
|
||||
persistentLayers.Add(layer);
|
||||
}
|
||||
}
|
||||
|
||||
currentScene = GetActiveSceneNotStatistics();
|
||||
InitializeLayers();
|
||||
UpdateLayers(musicTrack.trackLayers);
|
||||
}
|
||||
|
||||
private void Update()
|
||||
{
|
||||
CheckForRestartability();
|
||||
|
||||
if (currentScene != GetActiveSceneNotStatistics())
|
||||
{
|
||||
currentScene = GetActiveSceneNotStatistics();
|
||||
UpdateLayers(musicTrack.trackLayers);
|
||||
}
|
||||
|
||||
if (persistentLayers.Count != 0) UpdateLayers(persistentLayers);
|
||||
}
|
||||
|
||||
private void InitializeLayers()
|
||||
{
|
||||
foreach (TrackLayer layer in musicTrack.trackLayers)
|
||||
{
|
||||
AudioSource layerSource = Instantiate(layerPrefab, transform).GetComponent<AudioSource>();
|
||||
layerSource.gameObject.name = layer.layerName;
|
||||
layerSource.clip = layer.layerTrack;
|
||||
layerSource.volume = 0;
|
||||
|
||||
try
|
||||
{
|
||||
layerSource.outputAudioMixerGroup = musicTrack.defaultMixer.FindMatchingGroups("Master/" + layer.layerName)[0];
|
||||
}
|
||||
catch
|
||||
{
|
||||
layerSource.outputAudioMixerGroup = musicTrack.defaultMixer.FindMatchingGroups("Master")[0];
|
||||
}
|
||||
|
||||
layerSource.Play();
|
||||
}
|
||||
}
|
||||
|
||||
private void UpdateLayers(List<TrackLayer> layers)
|
||||
{
|
||||
if (StatisticsManager.PlayerPrefs.GetInt("settingMusic") == 1)
|
||||
{
|
||||
foreach (TrackLayer layer in layers)
|
||||
{
|
||||
DisableLayer(layer);
|
||||
|
||||
if (layer.enableTrigger == TrackLayer.EnableTrigger.Magnetism)
|
||||
{
|
||||
GameObject player = GameObject.Find(layer.triggerName);
|
||||
try
|
||||
{
|
||||
if (player != null && (player.GetComponent<PlayerMovement>().magnetized/* || FindFirstObjectByType<LevelEnd>().ending*/))
|
||||
{
|
||||
if (layer.layerScenes.Count == 0)
|
||||
{
|
||||
EnableLayer(layer);
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (string scene in layer.layerScenes)
|
||||
{
|
||||
if (scene == currentScene.name)
|
||||
{
|
||||
EnableLayer(layer);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
print(e.ToString());
|
||||
}
|
||||
}
|
||||
else if (layer.enableTrigger == TrackLayer.EnableTrigger.Movement)
|
||||
{
|
||||
GameObject player = GameObject.Find(layer.triggerName);
|
||||
try
|
||||
{
|
||||
if (player != null && player.GetComponent<Rigidbody2D>().linearVelocity.magnitude >= 0.1f)
|
||||
{
|
||||
if (layer.layerScenes.Count == 0)
|
||||
{
|
||||
EnableLayer(layer);
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (string scene in layer.layerScenes)
|
||||
{
|
||||
if (scene == currentScene.name)
|
||||
{
|
||||
EnableLayer(layer);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
print(e.ToString());
|
||||
}
|
||||
}
|
||||
else if (layer.enableTrigger == TrackLayer.EnableTrigger.ConstantForce)
|
||||
{
|
||||
GameObject player = GameObject.Find(layer.triggerName);
|
||||
try
|
||||
{
|
||||
if (player != null && player.GetComponent<ConstantForce2D>().force.magnitude >= 0.1f)
|
||||
{
|
||||
if (layer.layerScenes.Count == 0)
|
||||
{
|
||||
EnableLayer(layer);
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (string scene in layer.layerScenes)
|
||||
{
|
||||
if (scene == currentScene.name)
|
||||
{
|
||||
EnableLayer(layer);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
print(e.ToString());
|
||||
}
|
||||
}
|
||||
else if (layer.enableTrigger == TrackLayer.EnableTrigger.Toggle)
|
||||
{
|
||||
GameObject toggle = GameObject.Find(layer.triggerName);
|
||||
try
|
||||
{
|
||||
if (toggle != null && toggle.GetComponent<ToggleBehavior>().state == ToggleBehavior.ToggleState.active)
|
||||
{
|
||||
if (layer.layerScenes.Count == 0)
|
||||
{
|
||||
EnableLayer(layer);
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (string scene in layer.layerScenes)
|
||||
{
|
||||
if (scene == currentScene.name)
|
||||
{
|
||||
EnableLayer(layer);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
print(e.ToString());
|
||||
}
|
||||
|
||||
}
|
||||
else if (layer.enableTrigger == TrackLayer.EnableTrigger.Button)
|
||||
{
|
||||
GameObject button = GameObject.Find(layer.triggerName);
|
||||
try
|
||||
{
|
||||
if (button != null && button.GetComponent<ButtonBehavior>().state == ButtonBehavior.ButtonState.pressed)
|
||||
{
|
||||
if (layer.layerScenes.Count == 0)
|
||||
{
|
||||
EnableLayer(layer);
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (string scene in layer.layerScenes)
|
||||
{
|
||||
if (scene == currentScene.name)
|
||||
{
|
||||
EnableLayer(layer);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
print(e.ToString());
|
||||
}
|
||||
|
||||
}
|
||||
else if (layer.enableTrigger == TrackLayer.EnableTrigger.Goal)
|
||||
{
|
||||
GameObject goal = GameObject.Find(layer.triggerName);
|
||||
try
|
||||
{
|
||||
if (goal != null && goal.GetComponent<Goal>().isActivated)
|
||||
{
|
||||
if (layer.layerScenes.Count == 0)
|
||||
{
|
||||
EnableLayer(layer);
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (string scene in layer.layerScenes)
|
||||
{
|
||||
if (scene == currentScene.name)
|
||||
{
|
||||
EnableLayer(layer);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (System.Exception e)
|
||||
{
|
||||
print(e.ToString());
|
||||
}
|
||||
|
||||
}
|
||||
else if (layer.enableTrigger == TrackLayer.EnableTrigger.EndOfLevel)
|
||||
{
|
||||
if (FindFirstObjectByType<LevelEnd>().ending)
|
||||
{
|
||||
EnableLayer(layer);
|
||||
}
|
||||
}
|
||||
else if (layer.enableTrigger == TrackLayer.EnableTrigger.ElectromagneticPulse)
|
||||
{
|
||||
if (Camera.main.GetComponent<CameraFollow>().playTheTrack)
|
||||
{
|
||||
EnableLayer(layer);
|
||||
}
|
||||
}
|
||||
else if (layer.enableTrigger == TrackLayer.EnableTrigger.Collectible)
|
||||
{
|
||||
if (FindFirstObjectByType<Collectible>().playTheTrack)
|
||||
{
|
||||
EnableLayer(layer, "collectibleEnabled");
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
foreach (string scene in layer.layerScenes)
|
||||
{
|
||||
if (scene == currentScene.name)
|
||||
{
|
||||
EnableLayer(layer);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void CheckForRestartability()
|
||||
{
|
||||
bool restart = false;
|
||||
|
||||
for (int i = 0; i < transform.childCount; i++)
|
||||
{
|
||||
AudioSource child = transform.GetChild(i).GetComponent<AudioSource>();
|
||||
if (child != null)
|
||||
{
|
||||
if (!child.isPlaying)
|
||||
{
|
||||
restart = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (!restart) return;
|
||||
|
||||
for (int i = 0; i < transform.childCount; i++)
|
||||
{
|
||||
AudioSource child = transform.GetChild(i).GetComponent<AudioSource>();
|
||||
|
||||
if (child != null)
|
||||
{
|
||||
child.Stop();
|
||||
child.Play();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void EnableLayer(TrackLayer layer, string parameter = "enabled")
|
||||
{
|
||||
transform.Find(layer.layerName).GetComponent<Animator>().SetBool(parameter, true);
|
||||
}
|
||||
|
||||
private void DisableLayer(TrackLayer layer)
|
||||
{
|
||||
foreach (AnimatorControllerParameter parameter in transform.Find(layer.layerName).GetComponent<Animator>().parameters)
|
||||
{
|
||||
transform.Find(layer.layerName).GetComponent<Animator>().SetBool(parameter.name, false);
|
||||
}
|
||||
}
|
||||
|
||||
public static Scene GetActiveSceneNotStatistics()
|
||||
{
|
||||
for (int sceneIndex = 0; sceneIndex < SceneManager.sceneCount; sceneIndex++)
|
||||
{
|
||||
if (SceneManager.GetSceneAt(sceneIndex).name != "Statistics Manager Scene")
|
||||
{
|
||||
return SceneManager.GetSceneAt(sceneIndex);
|
||||
}
|
||||
}
|
||||
return SceneManager.GetSceneByBuildIndex(0);
|
||||
}
|
||||
|
||||
public void Stop()
|
||||
{
|
||||
StartCoroutine(DestroyTrack());
|
||||
}
|
||||
|
||||
public IEnumerator DestroyTrack()
|
||||
{
|
||||
yield return new WaitForSeconds(0.5f);
|
||||
Destroy(gameObject);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
11
Assets/Scripts/Music/TrackManager.cs.meta
Normal file
11
Assets/Scripts/Music/TrackManager.cs.meta
Normal file
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 8f4092644348346419647bf86cb02003
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -1,3 +1,4 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
using UnityEngine.InputSystem;
|
||||
|
||||
7
Assets/Scripts/SmoothToTarget.cs
Normal file
7
Assets/Scripts/SmoothToTarget.cs
Normal file
@@ -0,0 +1,7 @@
|
||||
using System.Collections;
|
||||
using UnityEngine;
|
||||
|
||||
public class SmoothToTarget : MonoBehaviour
|
||||
{
|
||||
|
||||
}
|
||||
2
Assets/Scripts/SmoothToTarget.cs.meta
Normal file
2
Assets/Scripts/SmoothToTarget.cs.meta
Normal file
@@ -0,0 +1,2 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 617fdbd52246c4352be58c24aef4fd55
|
||||
Reference in New Issue
Block a user