mirror of
https://github.com/Steffo99/gravity-fusion.git
synced 2024-11-24 01:04:20 +00:00
Merge branch 'master' of https://github.com/Steffo99/LD45
This commit is contained in:
commit
4d0d70bfea
11 changed files with 204 additions and 23 deletions
4
Assets/Code/AfterStart.cs
Normal file
4
Assets/Code/AfterStart.cs
Normal file
|
@ -0,0 +1,4 @@
|
|||
//From https://answers.unity.com/questions/442342/how-to-make-public-variable-read-only-during-run-t.html
|
||||
using UnityEngine;
|
||||
|
||||
public class AfterStart : PropertyAttribute {}
|
|
@ -1,5 +1,5 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 9903d7c519b2c6849943c4d6b8dab4bf
|
||||
guid: 9fae7738546fcf6408a8a1e986460fda
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
4
Assets/Code/BeforeStart.cs
Normal file
4
Assets/Code/BeforeStart.cs
Normal file
|
@ -0,0 +1,4 @@
|
|||
//From https://answers.unity.com/questions/442342/how-to-make-public-variable-read-only-during-run-t.html
|
||||
using UnityEngine;
|
||||
|
||||
public class BeforeStart : PropertyAttribute {}
|
|
@ -1,5 +1,5 @@
|
|||
fileFormatVersion: 2
|
||||
guid: de6a180c8ef2dbd44ae2fd0f7a040623
|
||||
guid: c80c3920999989b4b920fe2953ade20e
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
|
@ -7,7 +7,13 @@ using UnityEngine;
|
|||
public class MusicManager : MonoBehaviour
|
||||
{
|
||||
public AudioSource baseLayer;
|
||||
public List<AudioSource> layers;
|
||||
public float changeSpeed = 1f;
|
||||
|
||||
[BeforeStart]
|
||||
public AudioSource[] layers;
|
||||
|
||||
protected float baseLayerTargetVolume;
|
||||
protected float[] targetVolume;
|
||||
|
||||
protected bool neverStarted;
|
||||
|
||||
|
@ -16,15 +22,20 @@ public class MusicManager : MonoBehaviour
|
|||
foreach(AudioSource audioSource in layers) {
|
||||
audioSource.volume = 0;
|
||||
}
|
||||
targetVolume = new float[layers.Length];
|
||||
for(int i = 0; i < layers.Length; i++) {
|
||||
targetVolume[i] = 0f;
|
||||
}
|
||||
baseLayerTargetVolume = 1f;
|
||||
neverStarted = true;
|
||||
}
|
||||
|
||||
public void UpdateLayers(int maxTier) {
|
||||
if(maxTier == -1) {
|
||||
baseLayer.volume = 1f;
|
||||
baseLayerTargetVolume = 1f;
|
||||
}
|
||||
else {
|
||||
baseLayer.volume = 0f;
|
||||
baseLayerTargetVolume = 0f;
|
||||
}
|
||||
|
||||
if(neverStarted) {
|
||||
|
@ -34,20 +45,39 @@ public class MusicManager : MonoBehaviour
|
|||
neverStarted = false;
|
||||
}
|
||||
|
||||
if(maxTier >= layers.Count) {
|
||||
foreach(AudioSource layer in layers) {
|
||||
layer.volume = 1f;
|
||||
if(maxTier >= layers.Length) {
|
||||
for(int i = 0; i < layers.Length; i++) {
|
||||
targetVolume[i] = 1f;
|
||||
}
|
||||
}
|
||||
else {
|
||||
for(int i = 0; i < layers.Count; i++) {
|
||||
for(int i = 0; i < layers.Length; i++) {
|
||||
if(maxTier >= i) {
|
||||
layers[i].volume = 1f;
|
||||
targetVolume[i] = 1f;
|
||||
}
|
||||
else {
|
||||
layers[i].volume = 0f;
|
||||
targetVolume[i] = 0f;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
protected void Update() {
|
||||
if(baseLayer.volume > baseLayerTargetVolume) {
|
||||
baseLayer.volume = Mathf.Clamp(baseLayer.volume - Time.deltaTime * changeSpeed, baseLayerTargetVolume, float.PositiveInfinity);
|
||||
}
|
||||
else if(baseLayer.volume < baseLayerTargetVolume) {
|
||||
baseLayer.volume = Mathf.Clamp(baseLayer.volume + Time.deltaTime * changeSpeed, 0f, baseLayerTargetVolume);
|
||||
}
|
||||
|
||||
for(int i = 0; i < layers.Length; i++) {
|
||||
if(layers[i].volume > targetVolume[i]) {
|
||||
layers[i].volume = Mathf.Clamp(layers[i].volume - Time.deltaTime * changeSpeed, targetVolume[i], float.PositiveInfinity);
|
||||
}
|
||||
else if(layers[i].volume < targetVolume[i]) {
|
||||
layers[i].volume = Mathf.Clamp(layers[i].volume + Time.deltaTime * changeSpeed, 0f, targetVolume[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -19,5 +19,3 @@ public class AfterStartAttributeDrawer : PropertyDrawer
|
|||
GUI.enabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
public class AfterStart : PropertyAttribute {}
|
11
Assets/Editor/AfterStartAttributeDrawer.cs.meta
Normal file
11
Assets/Editor/AfterStartAttributeDrawer.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: bb6935448ef8afa40b70179ed82526f3
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -1,4 +1,4 @@
|
|||
//From https://answers.unity.com/questions/442342/how-to-make-public-variable-read-only-during-run-t.html
|
||||
//From https://answers.unity.com/questions/442342/how-to-make-public-variable-read-only-during-run-t.html
|
||||
using UnityEngine;
|
||||
using UnityEditor;
|
||||
|
||||
|
@ -18,6 +18,4 @@ public class BeforeStartAttributeDrawer : PropertyDrawer
|
|||
EditorGUI.PropertyField(position, property, label, true);
|
||||
GUI.enabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
public class BeforeStart : PropertyAttribute {}
|
||||
}
|
11
Assets/Editor/BeforeStartAttributeDrawer.cs.meta
Normal file
11
Assets/Editor/BeforeStartAttributeDrawer.cs.meta
Normal file
|
@ -0,0 +1,11 @@
|
|||
fileFormatVersion: 2
|
||||
guid: 0c5fc3bdbfd0b2c4cb8ffcc597e1d884
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
|
@ -1,5 +1,132 @@
|
|||
%YAML 1.1
|
||||
%TAG !u! tag:unity3d.com,2011:
|
||||
--- !u!1 &1636788349
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 1636788350}
|
||||
- component: {fileID: 1636788351}
|
||||
m_Layer: 0
|
||||
m_Name: Layer 2
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!4 &1636788350
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1636788349}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 1990625892755510357}
|
||||
m_RootOrder: 2
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!82 &1636788351
|
||||
AudioSource:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1636788349}
|
||||
m_Enabled: 1
|
||||
serializedVersion: 4
|
||||
OutputAudioMixerGroup: {fileID: 0}
|
||||
m_audioClip: {fileID: 8300000, guid: 7f5aa2a2cf682734ba7c9842badb7b84, type: 3}
|
||||
m_PlayOnAwake: 0
|
||||
m_Volume: 1
|
||||
m_Pitch: 1
|
||||
Loop: 1
|
||||
Mute: 0
|
||||
Spatialize: 0
|
||||
SpatializePostEffects: 0
|
||||
Priority: 128
|
||||
DopplerLevel: 1
|
||||
MinDistance: 1
|
||||
MaxDistance: 500
|
||||
Pan2D: 0
|
||||
rolloffMode: 0
|
||||
BypassEffects: 0
|
||||
BypassListenerEffects: 0
|
||||
BypassReverbZones: 0
|
||||
rolloffCustomCurve:
|
||||
serializedVersion: 2
|
||||
m_Curve:
|
||||
- serializedVersion: 3
|
||||
time: 0
|
||||
value: 1
|
||||
inSlope: 0
|
||||
outSlope: 0
|
||||
tangentMode: 0
|
||||
weightedMode: 0
|
||||
inWeight: 0.33333334
|
||||
outWeight: 0.33333334
|
||||
- serializedVersion: 3
|
||||
time: 1
|
||||
value: 0
|
||||
inSlope: 0
|
||||
outSlope: 0
|
||||
tangentMode: 0
|
||||
weightedMode: 0
|
||||
inWeight: 0.33333334
|
||||
outWeight: 0.33333334
|
||||
m_PreInfinity: 2
|
||||
m_PostInfinity: 2
|
||||
m_RotationOrder: 4
|
||||
panLevelCustomCurve:
|
||||
serializedVersion: 2
|
||||
m_Curve:
|
||||
- serializedVersion: 3
|
||||
time: 0
|
||||
value: 0
|
||||
inSlope: 0
|
||||
outSlope: 0
|
||||
tangentMode: 0
|
||||
weightedMode: 0
|
||||
inWeight: 0.33333334
|
||||
outWeight: 0.33333334
|
||||
m_PreInfinity: 2
|
||||
m_PostInfinity: 2
|
||||
m_RotationOrder: 4
|
||||
spreadCustomCurve:
|
||||
serializedVersion: 2
|
||||
m_Curve:
|
||||
- serializedVersion: 3
|
||||
time: 0
|
||||
value: 0
|
||||
inSlope: 0
|
||||
outSlope: 0
|
||||
tangentMode: 0
|
||||
weightedMode: 0
|
||||
inWeight: 0.33333334
|
||||
outWeight: 0.33333334
|
||||
m_PreInfinity: 2
|
||||
m_PostInfinity: 2
|
||||
m_RotationOrder: 4
|
||||
reverbZoneMixCustomCurve:
|
||||
serializedVersion: 2
|
||||
m_Curve:
|
||||
- serializedVersion: 3
|
||||
time: 0
|
||||
value: 1
|
||||
inSlope: 0
|
||||
outSlope: 0
|
||||
tangentMode: 0
|
||||
weightedMode: 0
|
||||
inWeight: 0.33333334
|
||||
outWeight: 0.33333334
|
||||
m_PreInfinity: 2
|
||||
m_PostInfinity: 2
|
||||
m_RotationOrder: 4
|
||||
--- !u!1 &2840017336573732720
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
@ -42,7 +169,7 @@ AudioSource:
|
|||
serializedVersion: 4
|
||||
OutputAudioMixerGroup: {fileID: 0}
|
||||
m_audioClip: {fileID: 8300000, guid: 37e30c686763c1e4ca22b20a356252c0, type: 3}
|
||||
m_PlayOnAwake: 1
|
||||
m_PlayOnAwake: 0
|
||||
m_Volume: 1
|
||||
m_Pitch: 1
|
||||
Loop: 1
|
||||
|
@ -392,8 +519,10 @@ MonoBehaviour:
|
|||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
baseLayer: {fileID: 787973444833592173}
|
||||
changeSpeed: 1
|
||||
layers:
|
||||
- {fileID: 4850948939192426854}
|
||||
- {fileID: 1636788351}
|
||||
--- !u!1 &7887871963136015922
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
|
@ -550,6 +679,7 @@ Transform:
|
|||
m_Children:
|
||||
- {fileID: 2826821897386302087}
|
||||
- {fileID: 576137496605705657}
|
||||
- {fileID: 1636788350}
|
||||
m_Father: {fileID: 9012813807232547518}
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
|
|
|
@ -590,11 +590,6 @@ PrefabInstance:
|
|||
propertyPath: m_LocalEulerAnglesHint.z
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
- target: {fileID: 4850948939192426854, guid: bf08d766b6e86cf4a8773489143ab2d5,
|
||||
type: 3}
|
||||
propertyPath: m_PlayOnAwake
|
||||
value: 0
|
||||
objectReference: {fileID: 0}
|
||||
m_RemovedComponents: []
|
||||
m_SourcePrefab: {fileID: 100100000, guid: bf08d766b6e86cf4a8773489143ab2d5, type: 3}
|
||||
--- !u!1001 &9221969453494073200
|
||||
|
|
Loading…
Reference in a new issue