Implement campfire
This commit is contained in:
parent
1a70bcc3d5
commit
27502d0940
@ -12,5 +12,6 @@ MonoBehaviour:
|
||||
m_Script: {fileID: 11500000, guid: 89be129a0b3b303478d411ad4ec84e30, type: 3}
|
||||
m_Name: Stick Burn Quality
|
||||
m_EditorClassIdentifier:
|
||||
FuelValue: 10
|
||||
FuelValue: 5
|
||||
FlameEffect: 1
|
||||
BurningSound: {fileID: 0}
|
||||
|
@ -9,6 +9,9 @@ GameObject:
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 8265150240760341263}
|
||||
- component: {fileID: 1683130550026608685}
|
||||
- component: {fileID: 986826787110512831}
|
||||
- component: {fileID: 7293540718676611162}
|
||||
m_Layer: 0
|
||||
m_Name: Campfire
|
||||
m_TagString: Untagged
|
||||
@ -29,9 +32,202 @@ Transform:
|
||||
m_Children:
|
||||
- {fileID: 3464217916028558321}
|
||||
- {fileID: 5299650773545078260}
|
||||
- {fileID: 8703236790229133739}
|
||||
- {fileID: 8279143985661205166}
|
||||
- {fileID: 664587661892241191}
|
||||
m_Father: {fileID: 0}
|
||||
m_RootOrder: 0
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!114 &1683130550026608685
|
||||
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: 5f97cfece62896c43a1ecf4354b5e229, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
Aliveness: 1
|
||||
System: {fileID: 2943469733383700679}
|
||||
AddFuelEffect: 0
|
||||
--- !u!114 &986826787110512831
|
||||
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: d53e1b3547ca29043b4a527f784da518, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
GameState: {fileID: 0}
|
||||
DynamicLight: {fileID: 6245881137502637047}
|
||||
Flame: {fileID: 1683130550026608685}
|
||||
BurnEffectSource: {fileID: 964052589141395917}
|
||||
GoodFuelAmount: 20
|
||||
TooLowFuelColor: {r: 1, g: 0.791215, b: 0.6273585, a: 0}
|
||||
RandomVarianceDuration: 0.2
|
||||
RandomVarianceMagnitude: 0.25
|
||||
LogBurningCooldown: 1
|
||||
Fuel: 30
|
||||
--- !u!54 &7293540718676611162
|
||||
Rigidbody:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 1791762180592942439}
|
||||
serializedVersion: 2
|
||||
m_Mass: 1
|
||||
m_Drag: 0
|
||||
m_AngularDrag: 0.05
|
||||
m_UseGravity: 1
|
||||
m_IsKinematic: 1
|
||||
m_Interpolate: 0
|
||||
m_Constraints: 0
|
||||
m_CollisionDetection: 0
|
||||
--- !u!1 &4030757379513544979
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 664587661892241191}
|
||||
- component: {fileID: 3740775333387538961}
|
||||
m_Layer: 0
|
||||
m_Name: Collider
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!4 &664587661892241191
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 4030757379513544979}
|
||||
m_LocalRotation: {x: -0.7069834, y: 0, z: 0, w: 0.7072302}
|
||||
m_LocalPosition: {x: 0, y: 0, z: 0}
|
||||
m_LocalScale: {x: 100, y: 100, z: 100}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 8265150240760341263}
|
||||
m_RootOrder: 4
|
||||
m_LocalEulerAnglesHint: {x: -89.98, y: 0, z: 0}
|
||||
--- !u!64 &3740775333387538961
|
||||
MeshCollider:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 4030757379513544979}
|
||||
m_Material: {fileID: 0}
|
||||
m_IsTrigger: 0
|
||||
m_Enabled: 1
|
||||
serializedVersion: 4
|
||||
m_Convex: 1
|
||||
m_CookingOptions: 14
|
||||
m_Mesh: {fileID: -4095829847968280453, guid: 4facd75878c39c7499d4291e717cda98, type: 3}
|
||||
--- !u!1 &4797807552203538256
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 8703236790229133739}
|
||||
- component: {fileID: 6245881137502637047}
|
||||
m_Layer: 0
|
||||
m_Name: Campfire Light
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!4 &8703236790229133739
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 4797807552203538256}
|
||||
m_LocalRotation: {x: -0.7010575, y: 0.092295825, z: -0.0922958, w: -0.7010574}
|
||||
m_LocalPosition: {x: 0, y: 1, z: 0}
|
||||
m_LocalScale: {x: 1, y: 1, z: 1}
|
||||
m_Children: []
|
||||
m_Father: {fileID: 8265150240760341263}
|
||||
m_RootOrder: 2
|
||||
m_LocalEulerAnglesHint: {x: -270, y: 0, z: 15.000001}
|
||||
--- !u!108 &6245881137502637047
|
||||
Light:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 4797807552203538256}
|
||||
m_Enabled: 1
|
||||
serializedVersion: 10
|
||||
m_Type: 2
|
||||
m_Shape: 0
|
||||
m_Color: {r: 1, g: 0.84329563, b: 0.6556604, a: 1}
|
||||
m_Intensity: 1.5
|
||||
m_Range: 9.458514
|
||||
m_SpotAngle: 30
|
||||
m_InnerSpotAngle: 21.80208
|
||||
m_CookieSize: 10
|
||||
m_Shadows:
|
||||
m_Type: 2
|
||||
m_Resolution: -1
|
||||
m_CustomResolution: -1
|
||||
m_Strength: 0.763
|
||||
m_Bias: 0.05
|
||||
m_NormalBias: 0.4
|
||||
m_NearPlane: 0.2
|
||||
m_CullingMatrixOverride:
|
||||
e00: 1
|
||||
e01: 0
|
||||
e02: 0
|
||||
e03: 0
|
||||
e10: 0
|
||||
e11: 1
|
||||
e12: 0
|
||||
e13: 0
|
||||
e20: 0
|
||||
e21: 0
|
||||
e22: 1
|
||||
e23: 0
|
||||
e30: 0
|
||||
e31: 0
|
||||
e32: 0
|
||||
e33: 1
|
||||
m_UseCullingMatrixOverride: 0
|
||||
m_Cookie: {fileID: 0}
|
||||
m_DrawHalo: 0
|
||||
m_Flare: {fileID: 0}
|
||||
m_RenderMode: 1
|
||||
m_CullingMask:
|
||||
serializedVersion: 2
|
||||
m_Bits: 4294967295
|
||||
m_RenderingLayerMask: 1
|
||||
m_Lightmapping: 4
|
||||
m_LightShadowCasterMode: 0
|
||||
m_AreaSize: {x: 7, y: 7}
|
||||
m_BounceIntensity: 1
|
||||
m_ColorTemperature: 6570
|
||||
m_UseColorTemperature: 0
|
||||
m_BoundingSphereOverride: {x: 0, y: NaN, z: -1, w: 1e-45}
|
||||
m_UseBoundingSphereOverride: 0
|
||||
m_ShadowRadius: 0
|
||||
m_ShadowAngle: 0
|
||||
--- !u!1 &5974196502008569916
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
@ -43,7 +239,6 @@ GameObject:
|
||||
- component: {fileID: 5299650773545078260}
|
||||
- component: {fileID: 2943469733383700679}
|
||||
- component: {fileID: 3600058222818994886}
|
||||
- component: {fileID: 6154584365662919414}
|
||||
m_Layer: 0
|
||||
m_Name: Particle System
|
||||
m_TagString: Untagged
|
||||
@ -898,7 +1093,7 @@ ParticleSystem:
|
||||
rateOverTime:
|
||||
serializedVersion: 2
|
||||
minMaxState: 0
|
||||
scalar: 232.9613
|
||||
scalar: 100
|
||||
minScalar: 10
|
||||
maxCurve:
|
||||
serializedVersion: 2
|
||||
@ -2007,7 +2202,7 @@ ParticleSystem:
|
||||
radial:
|
||||
serializedVersion: 2
|
||||
minMaxState: 0
|
||||
scalar: 1.8634114
|
||||
scalar: 0.7
|
||||
minScalar: 0.1
|
||||
maxCurve:
|
||||
serializedVersion: 2
|
||||
@ -4796,22 +4991,134 @@ ParticleSystemRenderer:
|
||||
m_Mesh2: {fileID: 0}
|
||||
m_Mesh3: {fileID: 0}
|
||||
m_MaskInteraction: 0
|
||||
--- !u!114 &6154584365662919414
|
||||
MonoBehaviour:
|
||||
--- !u!1 &8502149746935864804
|
||||
GameObject:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 5974196502008569916}
|
||||
serializedVersion: 6
|
||||
m_Component:
|
||||
- component: {fileID: 8279143985661205166}
|
||||
- component: {fileID: 964052589141395917}
|
||||
m_Layer: 0
|
||||
m_Name: Burning Effect Audio Source
|
||||
m_TagString: Untagged
|
||||
m_Icon: {fileID: 0}
|
||||
m_NavMeshLayer: 0
|
||||
m_StaticEditorFlags: 0
|
||||
m_IsActive: 1
|
||||
--- !u!4 &8279143985661205166
|
||||
Transform:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
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_Children: []
|
||||
m_Father: {fileID: 8265150240760341263}
|
||||
m_RootOrder: 3
|
||||
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
|
||||
--- !u!82 &964052589141395917
|
||||
AudioSource:
|
||||
m_ObjectHideFlags: 0
|
||||
m_CorrespondingSourceObject: {fileID: 0}
|
||||
m_PrefabInstance: {fileID: 0}
|
||||
m_PrefabAsset: {fileID: 0}
|
||||
m_GameObject: {fileID: 8502149746935864804}
|
||||
m_Enabled: 1
|
||||
m_EditorHideFlags: 0
|
||||
m_Script: {fileID: 11500000, guid: 5f97cfece62896c43a1ecf4354b5e229, type: 3}
|
||||
m_Name:
|
||||
m_EditorClassIdentifier:
|
||||
Aliveness: 1
|
||||
System: {fileID: 2943469733383700679}
|
||||
LogEffect: 0
|
||||
SecretBoost: 1.6620164
|
||||
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
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -5,5 +5,6 @@ using UnityEngine;
|
||||
[CreateAssetMenu(fileName = "Unnamed Burn Quality", menuName = "Campfire/Burn Quality")]
|
||||
public class BurnQuality : ScriptableObject {
|
||||
public float FuelValue;
|
||||
public float FlameEffect;
|
||||
public AudioClip BurningSound;
|
||||
}
|
||||
|
@ -5,6 +5,7 @@ using UnityEngine;
|
||||
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 float GoodFuelAmount;
|
||||
@ -36,9 +37,10 @@ public class Campfire : MonoBehaviour {
|
||||
private void Update() {
|
||||
if (LogQueue.Count > 0 && Time.time - LastLogBurned > LogBurningCooldown) {
|
||||
LastLogBurned = Time.time;
|
||||
BurnLog(LogQueue[0]);
|
||||
if (BurnLog(LogQueue[0])) {
|
||||
LogQueue.RemoveAt(0);
|
||||
}
|
||||
}
|
||||
|
||||
if (Time.time - LastRandomVarianceChange > RandomVarianceDuration) {
|
||||
NextRandomVariance = (Random.value - 0.5f) * 2f * RandomVarianceMagnitude;
|
||||
@ -49,19 +51,23 @@ public class Campfire : MonoBehaviour {
|
||||
Fuel -= Time.deltaTime;
|
||||
DynamicLight.range = Mathf.Log(Fuel + 1f, 10) / 2f * FullRange + RandomVariance;
|
||||
DynamicLight.color = Color.Lerp(DynamicLight.color, Fuel < GoodFuelAmount ? TooLowFuelColor : EnoughFuelColor, 10f * Time.deltaTime);
|
||||
Flame.Aliveness = Mathf.Log(Fuel + 1f, 10) / 2f;
|
||||
|
||||
if (Fuel <= 0) {
|
||||
GameState.Current = State.GameOver;
|
||||
}
|
||||
}
|
||||
|
||||
private void BurnLog(Burnable burnable) {
|
||||
Fuel += burnable.Quality.FuelValue;
|
||||
if (Fuel < GoodFuelAmount) {
|
||||
Fuel += 2;
|
||||
}
|
||||
private bool BurnLog(Burnable burnable) {
|
||||
if (Fuel >= GoodFuelAmount * 2) {
|
||||
return false;
|
||||
} else {
|
||||
Fuel += burnable.Quality.FuelValue * Mathf.Max(0, (2 - Fuel / GoodFuelAmount));
|
||||
Flame.AddFuelEffect += burnable.Quality.FlameEffect;
|
||||
BurnEffectSource.PlayOneShot(burnable.Quality.BurningSound);
|
||||
Destroy(burnable.gameObject);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
private void OnCollisionEnter(Collision c) {
|
||||
|
Loading…
Reference in New Issue
Block a user