Add campfire sfx
This commit is contained in:
parent
ad7411212e
commit
6e35630bd4
@ -85,7 +85,7 @@ AudioMixerGroupController:
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_Name: Effects
|
||||
m_Name: Fire
|
||||
m_AudioMixer: {fileID: 24100000}
|
||||
m_GroupID: 1bdb8c14a13a7064e887fd8c05bd43e7
|
||||
m_Children: []
|
||||
@ -126,7 +126,7 @@ AudioMixerController:
|
||||
- 01ed36fd4259f874d8e152aa9f5cbdb4
|
||||
name: View
|
||||
m_CurrentViewIndex: 0
|
||||
m_TargetSnapshot: {fileID: -3105936107480203619}
|
||||
m_TargetSnapshot: {fileID: 24500006}
|
||||
--- !u!243 &24300002
|
||||
AudioMixerGroupController:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -170,7 +170,12 @@ AudioMixerSnapshotController:
|
||||
m_Name: Snapshot
|
||||
m_AudioMixer: {fileID: 24100000}
|
||||
m_SnapshotID: ff8dc610a6ec0d14cb32ecaf12b55eb7
|
||||
m_FloatValues: {}
|
||||
m_FloatValues:
|
||||
8f482920c408fd34e9c8792cf526bf12: 115
|
||||
b58fd3f8e205ca64aa5718e8bc864bc6: 0
|
||||
6ca751ba6a985aa4eb7f21b4ec43b475: -6898
|
||||
2889b28bff25e764f9db668c9c682f67: -7135
|
||||
fd01f6bdeaa870c4688fa6fcad7c3e41: 0
|
||||
m_TransitionOverrides: {}
|
||||
--- !u!243 &586271417499195193
|
||||
AudioMixerGroupController:
|
||||
|
@ -13,5 +13,5 @@ MonoBehaviour:
|
||||
m_Name: Stick Burn Quality
|
||||
m_EditorClassIdentifier:
|
||||
FuelValue: 5
|
||||
FlameEffect: 1
|
||||
BurningSound: {fileID: 0}
|
||||
FlameEffect: 0.7
|
||||
SoundEffect: 1.5
|
||||
|
@ -10,6 +10,7 @@ GameObject:
|
||||
m_Component:
|
||||
- component: {fileID: 8265150240760341263}
|
||||
- component: {fileID: 1683130550026608685}
|
||||
- component: {fileID: 8651001597528790401}
|
||||
- component: {fileID: 986826787110512831}
|
||||
- component: {fileID: 7293540718676611162}
|
||||
m_Layer: 9
|
||||
@ -33,9 +34,11 @@ Transform:
|
||||
- {fileID: 3464217916028558321}
|
||||
- {fileID: 5299650773545078260}
|
||||
- {fileID: 8703236790229133739}
|
||||
- {fileID: 8279143985661205166}
|
||||
- {fileID: 664587661892241191}
|
||||
- {fileID: 4407621139176341806}
|
||||
- {fileID: 8279143985661205166}
|
||||
- {fileID: 7662489421148146333}
|
||||
- {fileID: 2738699342724056705}
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
@ -54,6 +57,37 @@ MonoBehaviour:
|
||||
Aliveness: 1
|
||||
System: {fileID: 2943469733383700679}
|
||||
AddFuelEffect: 0
|
||||
--- !u!114 &8651001597528790401
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1791762180592942439}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: d18e85062ab028c4ca9a84353fa8546d, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
ActiveBurnSource: {fileID: 964052589141395917}
|
||||
AmbientSource: {fileID: 6967554575247233918}
|
||||
IntenseAmbientSource: {fileID: 957089656851647374}
|
||||
Campfire: {fileID: 986826787110512831}
|
||||
ActiveBurn: 0
|
||||
EndClip: {fileID: 8300000, guid: b481d5c4bed94f941bae37e955b81fef, type: 3}
|
||||
AmbientClips:
|
||||
- {fileID: 8300000, guid: 280c9d9eb97f5ce4d857fb945bfddb1e, type: 3}
|
||||
- {fileID: 8300000, guid: f33dea627b0de8248a82605c4e0e6e71, type: 3}
|
||||
- {fileID: 8300000, guid: 021edc202d1cd73478de90d9a3ead06e, type: 3}
|
||||
- {fileID: 8300000, guid: 2d22ab70306de704598b89a705777afb, type: 3}
|
||||
IntenseAmbientClips:
|
||||
- {fileID: 8300000, guid: 64b06e9eaa709314cb30df9602d12c74, type: 3}
|
||||
- {fileID: 8300000, guid: ee4e7bcd1c671924aad990a5b81f9ab8, type: 3}
|
||||
- {fileID: 8300000, guid: 899f7639274b30245bab3419c24f9e17, type: 3}
|
||||
- {fileID: 8300000, guid: 51167812d2a8d2e4e8ab2bcbbb0d2a1a, type: 3}
|
||||
CrackleClips:
|
||||
- {fileID: 8300000, guid: 19153e6dbca2b4644b7ce8ea38cc3b75, type: 3}
|
||||
- {fileID: 8300000, guid: 5da1dbc7c73386f429c072e4d5cd113a, type: 3}
|
||||
--- !u!114 &986826787110512831
|
||||
MonoBehaviour:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -69,7 +103,7 @@ MonoBehaviour:
|
||||
GameState: {fileID: 0}
|
||||
DynamicLight: {fileID: 6245881137502637047}
|
||||
Flame: {fileID: 1683130550026608685}
|
||||
BurnEffectSource: {fileID: 964052589141395917}
|
||||
Sfx: {fileID: 8651001597528790401}
|
||||
GoodFuelAmount: 30
|
||||
TooLowFuelColor: {r: 1, g: 0.791215, b: 0.6273585, a: 0}
|
||||
RandomVarianceDuration: 0.2
|
||||
@ -92,6 +126,134 @@ Rigidbody:
|
||||
m_Interpolate: 0
|
||||
m_Constraints: 0
|
||||
m_CollisionDetection: 0
|
||||
--- !u!1 &3090626986165219207
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 7662489421148146333}
|
||||
- component: {fileID: 6967554575247233918}
|
||||
m_Layer: 9
|
||||
m_Name: Ambient Audio Source
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!4 &7662489421148146333
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 3090626986165219207}
|
||||
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: 8265150240760341263}
|
||||
m_RootOrder: 6
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!82 &6967554575247233918
|
||||
AudioSource:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 3090626986165219207}
|
||||
m_Enabled: 1
|
||||
serializedVersion: 4
|
||||
OutputAudioMixerGroup: {fileID: -267709887311468707, guid: 032de345950918c4e89684078c6a7213,
|
||||
type: 2}
|
||||
m_audioClip: {fileID: 0}
|
||||
m_PlayOnAwake: 0
|
||||
m_Volume: 1
|
||||
m_Pitch: 1
|
||||
Loop: 0
|
||||
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: 1
|
||||
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 &4030757379513544979
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -122,7 +284,7 @@ Transform:
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 8265150240760341263}
|
||||
m_RootOrder: 4
|
||||
m_RootOrder: 3
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!65 &3313787702854768125
|
||||
BoxCollider:
|
||||
@ -5034,7 +5196,7 @@ Transform:
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 8265150240760341263}
|
||||
m_RootOrder: 5
|
||||
m_RootOrder: 4
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!136 &7258398958978246311
|
||||
CapsuleCollider:
|
||||
@ -5061,7 +5223,7 @@ GameObject:
|
||||
- component: {fileID: 8279143985661205166}
|
||||
- component: {fileID: 964052589141395917}
|
||||
m_Layer: 9
|
||||
m_Name: Burning Effect Audio Source
|
||||
m_Name: Active Burn Audio Source
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
@ -5075,11 +5237,11 @@ Transform:
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 8502149746935864804}
|
||||
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
|
||||
m_LocalPosition: {x: -0.0039999997, y: 0.5292903, z: 0.016000003}
|
||||
m_LocalScale: {x: 1.1047, y: 0.17583999, z: 1.1398}
|
||||
m_LocalPosition: {x: 0, y: 0.5, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 8265150240760341263}
|
||||
m_RootOrder: 3
|
||||
m_RootOrder: 5
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!82 &964052589141395917
|
||||
AudioSource:
|
||||
@ -5178,6 +5340,134 @@ AudioSource:
|
||||
m_PreInfinity: 2
|
||||
m_PostInfinity: 2
|
||||
m_RotationOrder: 4
|
||||
--- !u!1 &9045967002764336402
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 2738699342724056705}
|
||||
- component: {fileID: 957089656851647374}
|
||||
m_Layer: 9
|
||||
m_Name: Intense Ambient Audio Source
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!4 &2738699342724056705
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 9045967002764336402}
|
||||
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
|
||||
m_LocalPosition: {x: 0, y: 0.25, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 8265150240760341263}
|
||||
m_RootOrder: 7
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!82 &957089656851647374
|
||||
AudioSource:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 9045967002764336402}
|
||||
m_Enabled: 1
|
||||
serializedVersion: 4
|
||||
OutputAudioMixerGroup: {fileID: -267709887311468707, guid: 032de345950918c4e89684078c6a7213,
|
||||
type: 2}
|
||||
m_audioClip: {fileID: 0}
|
||||
m_PlayOnAwake: 0
|
||||
m_Volume: 1
|
||||
m_Pitch: 1
|
||||
Loop: 0
|
||||
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: 1
|
||||
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!1001 &8460551870366396651
|
||||
PrefabInstance:
|
||||
m_ObjectHideFlags: 0
|
||||
|
@ -6,5 +6,5 @@ using UnityEngine;
|
||||
public class BurnQuality : ScriptableObject {
|
||||
public float FuelValue;
|
||||
public float FlameEffect;
|
||||
public AudioClip BurningSound;
|
||||
public float SoundEffect;
|
||||
}
|
||||
|
@ -6,8 +6,7 @@ public class Campfire : MonoBehaviour {
|
||||
public GameState GameState;
|
||||
public Light DynamicLight;
|
||||
public Flame Flame;
|
||||
[Tooltip("This audiosource will play the clips to indicate that an object has been thrown in the fire.")]
|
||||
public AudioSource BurnEffectSource;
|
||||
public CampfireSfx Sfx;
|
||||
public float GoodFuelAmount;
|
||||
[Tooltip("The light turns this color when Fuel < GoodFuelAmount. Otherwise it'll be as it is in the editor.")]
|
||||
public Color TooLowFuelColor;
|
||||
@ -18,6 +17,11 @@ public class Campfire : MonoBehaviour {
|
||||
|
||||
[Header("Runtime values")]
|
||||
public float Fuel;
|
||||
public float TimeToEnd {
|
||||
get {
|
||||
return Fuel - 0.7f;
|
||||
}
|
||||
}
|
||||
|
||||
private Color EnoughFuelColor;
|
||||
private float FullRange;
|
||||
@ -51,7 +55,7 @@ public class Campfire : MonoBehaviour {
|
||||
Fuel = Mathf.Max(0, Fuel - Time.deltaTime);
|
||||
DynamicLight.range = Fuel / GoodFuelAmount / 2f * FullRange + RandomVariance;
|
||||
DynamicLight.color = Color.Lerp(DynamicLight.color, Fuel < GoodFuelAmount ? TooLowFuelColor : EnoughFuelColor, 10f * Time.deltaTime);
|
||||
Flame.Aliveness = Mathf.Log(Mathf.Max(0.01f, Fuel - 0.7f), 10) / 2f;
|
||||
Flame.Aliveness = Mathf.Log(Mathf.Max(0.01f, TimeToEnd), 10) / 2f;
|
||||
|
||||
if (Fuel <= 0) {
|
||||
GameState.Current = State.GameOver;
|
||||
@ -64,7 +68,7 @@ public class Campfire : MonoBehaviour {
|
||||
} else {
|
||||
Fuel += burnable.Quality.FuelValue * Mathf.Max(0, (2 - Fuel / GoodFuelAmount));
|
||||
Flame.AddFuelEffect += burnable.Quality.FlameEffect;
|
||||
BurnEffectSource.PlayOneShot(burnable.Quality.BurningSound);
|
||||
Sfx.ActiveBurn += burnable.Quality.SoundEffect;
|
||||
Destroy(burnable.gameObject);
|
||||
return true;
|
||||
}
|
||||
|
70
Assets/Scripts/CampfireSfx.cs
Normal file
70
Assets/Scripts/CampfireSfx.cs
Normal file
@ -0,0 +1,70 @@
|
||||
using System.Collections;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class CampfireSfx : MonoBehaviour {
|
||||
public AudioSource ActiveBurnSource;
|
||||
public AudioSource AmbientSource;
|
||||
public AudioSource IntenseAmbientSource;
|
||||
public Campfire Campfire;
|
||||
public float ActiveBurn = 0f;
|
||||
|
||||
[Header("Clips")]
|
||||
public AudioClip EndClip;
|
||||
public AudioClip[] AmbientClips;
|
||||
public AudioClip[] IntenseAmbientClips;
|
||||
public AudioClip[] CrackleClips;
|
||||
|
||||
private void Update() {
|
||||
ActiveBurn = Mathf.Max(0, ActiveBurn - Time.deltaTime);
|
||||
|
||||
ActiveBurnSource.pitch = Time.timeScale;
|
||||
AmbientSource.pitch = Time.timeScale;
|
||||
IntenseAmbientSource.pitch = Time.timeScale;
|
||||
|
||||
if (Campfire.TimeToEnd <= 0) {
|
||||
IntenseAmbientSource.volume = Mathf.Lerp(IntenseAmbientSource.volume, 0, 10f * Time.deltaTime);
|
||||
ActiveBurnSource.volume = Mathf.Lerp(ActiveBurnSource.volume, 0, 10f * Time.deltaTime);
|
||||
AmbientSource.volume = Mathf.Lerp(AmbientSource.volume, 0, 10f * Time.deltaTime);
|
||||
return;
|
||||
} else {
|
||||
IntenseAmbientSource.volume = Mathf.Max(ActiveBurn, Mathf.Clamp((Campfire.Fuel - Campfire.GoodFuelAmount) / Campfire.GoodFuelAmount, 0, 1));
|
||||
ActiveBurnSource.volume = Mathf.Pow(ActiveBurn, 0.3f);
|
||||
AmbientSource.volume = Mathf.Lerp(AmbientSource.volume, 1, 10f * Time.deltaTime);
|
||||
}
|
||||
|
||||
|
||||
bool StartEndClip = Campfire.TimeToEnd <= EndClip.length && AmbientSource.clip != EndClip;
|
||||
bool StopEndClip = Campfire.TimeToEnd > EndClip.length && AmbientSource.clip == EndClip;
|
||||
if (StartEndClip) {
|
||||
AmbientSource.clip = EndClip;
|
||||
AmbientSource.Play();
|
||||
AmbientSource.time = EndClip.length - Campfire.TimeToEnd;
|
||||
} else if (StopEndClip || NeedsRefresh(AmbientSource)) {
|
||||
AmbientSource.clip = RandomClip(AmbientClips);
|
||||
AmbientSource.Play();
|
||||
}
|
||||
|
||||
if (NeedsRefresh(IntenseAmbientSource)) {
|
||||
IntenseAmbientSource.clip = RandomClip(IntenseAmbientClips);
|
||||
IntenseAmbientSource.Play();
|
||||
}
|
||||
|
||||
if (ActiveBurn > 0 && NeedsRefresh(ActiveBurnSource)) {
|
||||
ActiveBurnSource.clip = RandomClip(CrackleClips);
|
||||
ActiveBurnSource.Play();
|
||||
}
|
||||
}
|
||||
|
||||
private bool NeedsRefresh(AudioSource source) {
|
||||
return !source.isPlaying || source.clip == null || (source.clip.length - source.time) <= Time.deltaTime;
|
||||
}
|
||||
|
||||
private AudioClip RandomClip(AudioClip[] clips) {
|
||||
if (clips.Length > 0) {
|
||||
return clips[Random.Range(0, clips.Length)];
|
||||
} else {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
}
|
11
Assets/Scripts/CampfireSfx.cs.meta
Normal file
11
Assets/Scripts/CampfireSfx.cs.meta
Normal file
@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: d18e85062ab028c4ca9a84353fa8546d
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
8
Assets/Sounds.meta
Normal file
8
Assets/Sounds.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 44d7cc8239c4d454bac21997a6b7a2ed
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
8
Assets/Sounds/Fire.meta
Normal file
8
Assets/Sounds/Fire.meta
Normal file
@ -0,0 +1,8 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 7919c2585987ec3439a911f0cde543ed
|
||||
folderAsset: yes
|
||||
DefaultImporter:
|
||||
externalObjects: {}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
BIN
Assets/Sounds/Fire/Fire01.ogg
Normal file
BIN
Assets/Sounds/Fire/Fire01.ogg
Normal file
Binary file not shown.
22
Assets/Sounds/Fire/Fire01.ogg.meta
Normal file
22
Assets/Sounds/Fire/Fire01.ogg.meta
Normal file
@ -0,0 +1,22 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 280c9d9eb97f5ce4d857fb945bfddb1e
|
||||
AudioImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 6
|
||||
defaultSettings:
|
||||
loadType: 0
|
||||
sampleRateSetting: 0
|
||||
sampleRateOverride: 44100
|
||||
compressionFormat: 1
|
||||
quality: 1
|
||||
conversionMode: 0
|
||||
platformSettingOverrides: {}
|
||||
forceToMono: 0
|
||||
normalize: 1
|
||||
preloadAudioData: 1
|
||||
loadInBackground: 0
|
||||
ambisonic: 0
|
||||
3D: 1
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
BIN
Assets/Sounds/Fire/Fire02.ogg
Normal file
BIN
Assets/Sounds/Fire/Fire02.ogg
Normal file
Binary file not shown.
22
Assets/Sounds/Fire/Fire02.ogg.meta
Normal file
22
Assets/Sounds/Fire/Fire02.ogg.meta
Normal file
@ -0,0 +1,22 @@
|
||||
fileFormatVersion: 2
|
||||
guid: f33dea627b0de8248a82605c4e0e6e71
|
||||
AudioImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 6
|
||||
defaultSettings:
|
||||
loadType: 0
|
||||
sampleRateSetting: 0
|
||||
sampleRateOverride: 44100
|
||||
compressionFormat: 1
|
||||
quality: 1
|
||||
conversionMode: 0
|
||||
platformSettingOverrides: {}
|
||||
forceToMono: 0
|
||||
normalize: 1
|
||||
preloadAudioData: 1
|
||||
loadInBackground: 0
|
||||
ambisonic: 0
|
||||
3D: 1
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
BIN
Assets/Sounds/Fire/Fire03.ogg
Normal file
BIN
Assets/Sounds/Fire/Fire03.ogg
Normal file
Binary file not shown.
22
Assets/Sounds/Fire/Fire03.ogg.meta
Normal file
22
Assets/Sounds/Fire/Fire03.ogg.meta
Normal file
@ -0,0 +1,22 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 021edc202d1cd73478de90d9a3ead06e
|
||||
AudioImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 6
|
||||
defaultSettings:
|
||||
loadType: 0
|
||||
sampleRateSetting: 0
|
||||
sampleRateOverride: 44100
|
||||
compressionFormat: 1
|
||||
quality: 1
|
||||
conversionMode: 0
|
||||
platformSettingOverrides: {}
|
||||
forceToMono: 0
|
||||
normalize: 1
|
||||
preloadAudioData: 1
|
||||
loadInBackground: 0
|
||||
ambisonic: 0
|
||||
3D: 1
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
BIN
Assets/Sounds/Fire/Fire04.ogg
Normal file
BIN
Assets/Sounds/Fire/Fire04.ogg
Normal file
Binary file not shown.
22
Assets/Sounds/Fire/Fire04.ogg.meta
Normal file
22
Assets/Sounds/Fire/Fire04.ogg.meta
Normal file
@ -0,0 +1,22 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 2d22ab70306de704598b89a705777afb
|
||||
AudioImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 6
|
||||
defaultSettings:
|
||||
loadType: 0
|
||||
sampleRateSetting: 0
|
||||
sampleRateOverride: 44100
|
||||
compressionFormat: 1
|
||||
quality: 1
|
||||
conversionMode: 0
|
||||
platformSettingOverrides: {}
|
||||
forceToMono: 0
|
||||
normalize: 1
|
||||
preloadAudioData: 1
|
||||
loadInBackground: 0
|
||||
ambisonic: 0
|
||||
3D: 1
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
BIN
Assets/Sounds/Fire/FireCrackly01.ogg
Normal file
BIN
Assets/Sounds/Fire/FireCrackly01.ogg
Normal file
Binary file not shown.
22
Assets/Sounds/Fire/FireCrackly01.ogg.meta
Normal file
22
Assets/Sounds/Fire/FireCrackly01.ogg.meta
Normal file
@ -0,0 +1,22 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 19153e6dbca2b4644b7ce8ea38cc3b75
|
||||
AudioImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 6
|
||||
defaultSettings:
|
||||
loadType: 0
|
||||
sampleRateSetting: 0
|
||||
sampleRateOverride: 44100
|
||||
compressionFormat: 1
|
||||
quality: 1
|
||||
conversionMode: 0
|
||||
platformSettingOverrides: {}
|
||||
forceToMono: 0
|
||||
normalize: 1
|
||||
preloadAudioData: 1
|
||||
loadInBackground: 0
|
||||
ambisonic: 0
|
||||
3D: 1
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
BIN
Assets/Sounds/Fire/FireCrackly02.ogg
Normal file
BIN
Assets/Sounds/Fire/FireCrackly02.ogg
Normal file
Binary file not shown.
22
Assets/Sounds/Fire/FireCrackly02.ogg.meta
Normal file
22
Assets/Sounds/Fire/FireCrackly02.ogg.meta
Normal file
@ -0,0 +1,22 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 5da1dbc7c73386f429c072e4d5cd113a
|
||||
AudioImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 6
|
||||
defaultSettings:
|
||||
loadType: 0
|
||||
sampleRateSetting: 0
|
||||
sampleRateOverride: 44100
|
||||
compressionFormat: 1
|
||||
quality: 1
|
||||
conversionMode: 0
|
||||
platformSettingOverrides: {}
|
||||
forceToMono: 0
|
||||
normalize: 1
|
||||
preloadAudioData: 1
|
||||
loadInBackground: 0
|
||||
ambisonic: 0
|
||||
3D: 1
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
BIN
Assets/Sounds/Fire/FireEnd.ogg
Normal file
BIN
Assets/Sounds/Fire/FireEnd.ogg
Normal file
Binary file not shown.
22
Assets/Sounds/Fire/FireEnd.ogg.meta
Normal file
22
Assets/Sounds/Fire/FireEnd.ogg.meta
Normal file
@ -0,0 +1,22 @@
|
||||
fileFormatVersion: 2
|
||||
guid: b481d5c4bed94f941bae37e955b81fef
|
||||
AudioImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 6
|
||||
defaultSettings:
|
||||
loadType: 0
|
||||
sampleRateSetting: 0
|
||||
sampleRateOverride: 44100
|
||||
compressionFormat: 1
|
||||
quality: 1
|
||||
conversionMode: 0
|
||||
platformSettingOverrides: {}
|
||||
forceToMono: 0
|
||||
normalize: 1
|
||||
preloadAudioData: 1
|
||||
loadInBackground: 0
|
||||
ambisonic: 0
|
||||
3D: 1
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
BIN
Assets/Sounds/Fire/FireIntense01.ogg
Normal file
BIN
Assets/Sounds/Fire/FireIntense01.ogg
Normal file
Binary file not shown.
22
Assets/Sounds/Fire/FireIntense01.ogg.meta
Normal file
22
Assets/Sounds/Fire/FireIntense01.ogg.meta
Normal file
@ -0,0 +1,22 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 64b06e9eaa709314cb30df9602d12c74
|
||||
AudioImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 6
|
||||
defaultSettings:
|
||||
loadType: 0
|
||||
sampleRateSetting: 0
|
||||
sampleRateOverride: 44100
|
||||
compressionFormat: 1
|
||||
quality: 1
|
||||
conversionMode: 0
|
||||
platformSettingOverrides: {}
|
||||
forceToMono: 0
|
||||
normalize: 1
|
||||
preloadAudioData: 1
|
||||
loadInBackground: 0
|
||||
ambisonic: 0
|
||||
3D: 1
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
BIN
Assets/Sounds/Fire/FireIntense02.ogg
Normal file
BIN
Assets/Sounds/Fire/FireIntense02.ogg
Normal file
Binary file not shown.
22
Assets/Sounds/Fire/FireIntense02.ogg.meta
Normal file
22
Assets/Sounds/Fire/FireIntense02.ogg.meta
Normal file
@ -0,0 +1,22 @@
|
||||
fileFormatVersion: 2
|
||||
guid: ee4e7bcd1c671924aad990a5b81f9ab8
|
||||
AudioImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 6
|
||||
defaultSettings:
|
||||
loadType: 0
|
||||
sampleRateSetting: 0
|
||||
sampleRateOverride: 44100
|
||||
compressionFormat: 1
|
||||
quality: 1
|
||||
conversionMode: 0
|
||||
platformSettingOverrides: {}
|
||||
forceToMono: 0
|
||||
normalize: 1
|
||||
preloadAudioData: 1
|
||||
loadInBackground: 0
|
||||
ambisonic: 0
|
||||
3D: 1
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
BIN
Assets/Sounds/Fire/FireIntense03.ogg
Normal file
BIN
Assets/Sounds/Fire/FireIntense03.ogg
Normal file
Binary file not shown.
22
Assets/Sounds/Fire/FireIntense03.ogg.meta
Normal file
22
Assets/Sounds/Fire/FireIntense03.ogg.meta
Normal file
@ -0,0 +1,22 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 899f7639274b30245bab3419c24f9e17
|
||||
AudioImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 6
|
||||
defaultSettings:
|
||||
loadType: 0
|
||||
sampleRateSetting: 0
|
||||
sampleRateOverride: 44100
|
||||
compressionFormat: 1
|
||||
quality: 1
|
||||
conversionMode: 0
|
||||
platformSettingOverrides: {}
|
||||
forceToMono: 0
|
||||
normalize: 1
|
||||
preloadAudioData: 1
|
||||
loadInBackground: 0
|
||||
ambisonic: 0
|
||||
3D: 1
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
BIN
Assets/Sounds/Fire/FireIntense04.ogg
Normal file
BIN
Assets/Sounds/Fire/FireIntense04.ogg
Normal file
Binary file not shown.
22
Assets/Sounds/Fire/FireIntense04.ogg.meta
Normal file
22
Assets/Sounds/Fire/FireIntense04.ogg.meta
Normal file
@ -0,0 +1,22 @@
|
||||
fileFormatVersion: 2
|
||||
guid: 51167812d2a8d2e4e8ab2bcbbb0d2a1a
|
||||
AudioImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 6
|
||||
defaultSettings:
|
||||
loadType: 0
|
||||
sampleRateSetting: 0
|
||||
sampleRateOverride: 44100
|
||||
compressionFormat: 1
|
||||
quality: 1
|
||||
conversionMode: 0
|
||||
platformSettingOverrides: {}
|
||||
forceToMono: 0
|
||||
normalize: 1
|
||||
preloadAudioData: 1
|
||||
loadInBackground: 0
|
||||
ambisonic: 0
|
||||
3D: 1
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
Loading…
Reference in New Issue
Block a user