From be83f3c0305643770ece5ee43aa5de877bf10425 Mon Sep 17 00:00:00 2001 From: Jens Pitkanen Date: Mon, 20 Apr 2020 19:13:16 +0300 Subject: [PATCH] Add on-the-move ignition, tweak many knobs --- .../Already Burned Stick Burn Quality.asset | 19 + ...ready Burned Stick Burn Quality.asset.meta | 8 + .../Burn Qualities/Stick Burn Quality.asset | 1 + .../Prefabs/Environment/BurningStick.prefab | 150 ++++++- Assets/Prefabs/Environment/stick.prefab | 49 ++- Assets/Prefabs/Player/Player.prefab | 409 +++++++++++++++++- Assets/Scripts/BurnQuality.cs | 1 + Assets/Scripts/Burnable.cs | 1 - Assets/Scripts/Campfire.cs | 12 +- Assets/Scripts/Item.cs | 11 +- Assets/Scripts/ItemGrabber.cs | 81 +++- Assets/Scripts/Torch.cs | 79 +++- 12 files changed, 771 insertions(+), 50 deletions(-) create mode 100644 Assets/Burn Qualities/Already Burned Stick Burn Quality.asset create mode 100644 Assets/Burn Qualities/Already Burned Stick Burn Quality.asset.meta diff --git a/Assets/Burn Qualities/Already Burned Stick Burn Quality.asset b/Assets/Burn Qualities/Already Burned Stick Burn Quality.asset new file mode 100644 index 0000000..77b036f --- /dev/null +++ b/Assets/Burn Qualities/Already Burned Stick Burn Quality.asset @@ -0,0 +1,19 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!114 &11400000 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 0} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 89be129a0b3b303478d411ad4ec84e30, type: 3} + m_Name: Already Burned Stick Burn Quality + m_EditorClassIdentifier: + DisplayName: burnt stick + FuelValue: 1 + FlameEffect: 0.3 + SoundEffect: 0.8 + Ignitable: 1 diff --git a/Assets/Burn Qualities/Already Burned Stick Burn Quality.asset.meta b/Assets/Burn Qualities/Already Burned Stick Burn Quality.asset.meta new file mode 100644 index 0000000..7517189 --- /dev/null +++ b/Assets/Burn Qualities/Already Burned Stick Burn Quality.asset.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: 62d0193d1d08b814d9328f3dd1d117cb +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Burn Qualities/Stick Burn Quality.asset b/Assets/Burn Qualities/Stick Burn Quality.asset index 8a429f1..88296e8 100644 --- a/Assets/Burn Qualities/Stick Burn Quality.asset +++ b/Assets/Burn Qualities/Stick Burn Quality.asset @@ -12,6 +12,7 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: 89be129a0b3b303478d411ad4ec84e30, type: 3} m_Name: Stick Burn Quality m_EditorClassIdentifier: + DisplayName: stick FuelValue: 5 FlameEffect: 0.7 SoundEffect: 1.5 diff --git a/Assets/Prefabs/Environment/BurningStick.prefab b/Assets/Prefabs/Environment/BurningStick.prefab index ae31313..2060b70 100644 --- a/Assets/Prefabs/Environment/BurningStick.prefab +++ b/Assets/Prefabs/Environment/BurningStick.prefab @@ -10,6 +10,8 @@ GameObject: m_Component: - component: {fileID: 1830340994370403595} - component: {fileID: -5925851218717166877} + - component: {fileID: 2081929903982442016} + - component: {fileID: 1226804790312226784} m_Layer: 0 m_Name: BurningStick m_TagString: Untagged @@ -31,6 +33,9 @@ Transform: - {fileID: 1126355678538028640} - {fileID: 7281152459947064446} - {fileID: 1153588192824730054} + - {fileID: 8656022059323805365} + - {fileID: 3832243548091795177} + - {fileID: 7948189956267693667} m_Father: {fileID: 0} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} @@ -46,11 +51,76 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: a42ab79bb3f7ede4badb6d60155c8c48, type: 3} m_Name: m_EditorClassIdentifier: + FirePoint: {fileID: 8656022059323805365} + Particles: {fileID: 2784569998125654179} Light: {fileID: 235010646391593287} NormalColor: {r: 1, g: 0.88479936, b: 0.759434, a: 1} PanicColor: {r: 1, g: 0.65243995, b: 0.4481132, a: 1} - Lifetime: 60 - PanicLifetimeThreshold: 20 + Lifetime: 30 + PanicLifetimeThreshold: 10 + PassTorchAnimationDuration: 0.5 + IgniteDuration: 2 +--- !u!54 &2081929903982442016 +Rigidbody: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2086008818391599545} + 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!114 &1226804790312226784 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2086008818391599545} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: f70b810850590804092bb2c772ea6012, type: 3} + m_Name: + m_EditorClassIdentifier: + Quality: {fileID: 11400000, guid: 62d0193d1d08b814d9328f3dd1d117cb, type: 2} + IgnitePoint: {fileID: 7948189956267693667} + Grabbed: 0 +--- !u!1 &2819347287429737535 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 8656022059323805365} + m_Layer: 0 + m_Name: Fire Point + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &8656022059323805365 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2819347287429737535} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0.0113, y: 0.223, z: -0.009} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 1830340994370403595} + m_RootOrder: 3 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &3363062943258591200 GameObject: m_ObjectHideFlags: 0 @@ -95,7 +165,7 @@ Light: m_Shape: 0 m_Color: {r: 1, g: 0.96851534, b: 0.8820755, a: 1} m_Intensity: 1 - m_Range: 10 + m_Range: 20 m_SpotAngle: 30 m_InnerSpotAngle: 21.80208 m_CookieSize: 10 @@ -143,6 +213,50 @@ Light: m_UseBoundingSphereOverride: 0 m_ShadowRadius: 0 m_ShadowAngle: 0 +--- !u!1 &6712795841363214792 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 3832243548091795177} + - component: {fileID: 7519311620685240342} + m_Layer: 10 + m_Name: Collider + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &3832243548091795177 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 6712795841363214792} + 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: 1830340994370403595} + m_RootOrder: 4 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!65 &7519311620685240342 +BoxCollider: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 6712795841363214792} + m_Material: {fileID: 0} + m_IsTrigger: 0 + m_Enabled: 1 + serializedVersion: 2 + m_Size: {x: 0.05, y: 0.48, z: 0.06} + m_Center: {x: 0, y: 0, z: 0} --- !u!1 &6731946952526266997 GameObject: m_ObjectHideFlags: 0 @@ -4906,6 +5020,36 @@ ParticleSystemRenderer: m_Mesh2: {fileID: 0} m_Mesh3: {fileID: 0} m_MaskInteraction: 0 +--- !u!1 &7981884805349908101 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 7948189956267693667} + m_Layer: 10 + m_Name: Ignite Point + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &7948189956267693667 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7981884805349908101} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0.006, y: 0.218, z: -0.008} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 1830340994370403595} + m_RootOrder: 5 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1001 &2337769920449910628 PrefabInstance: m_ObjectHideFlags: 0 diff --git a/Assets/Prefabs/Environment/stick.prefab b/Assets/Prefabs/Environment/stick.prefab index 37c4917..c5416b1 100644 --- a/Assets/Prefabs/Environment/stick.prefab +++ b/Assets/Prefabs/Environment/stick.prefab @@ -10,10 +10,9 @@ GameObject: m_Component: - component: {fileID: 1830340994370403595} - component: {fileID: 3556743581346332214} - - component: {fileID: 4588890757707193608} - component: {fileID: 1732996613952540235} m_Layer: 10 - m_Name: Stick + m_Name: stick m_TagString: Untagged m_Icon: {fileID: 0} m_NavMeshLayer: 0 @@ -32,6 +31,7 @@ Transform: m_Children: - {fileID: 4295605565537018981} - {fileID: 7722979984909929174} + - {fileID: 8934967594637573488} m_Father: {fileID: 0} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} @@ -47,20 +47,9 @@ MonoBehaviour: m_Script: {fileID: 11500000, guid: f70b810850590804092bb2c772ea6012, type: 3} m_Name: m_EditorClassIdentifier: - Grabbed: 0 ---- !u!114 &4588890757707193608 -MonoBehaviour: - m_ObjectHideFlags: 0 - m_CorrespondingSourceObject: {fileID: 0} - m_PrefabInstance: {fileID: 0} - m_PrefabAsset: {fileID: 0} - m_GameObject: {fileID: 2086008818391599545} - m_Enabled: 1 - m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: b647d1ea5d6785a4d8e6f6b2208e5f1c, type: 3} - m_Name: - m_EditorClassIdentifier: Quality: {fileID: 11400000, guid: 273b9cf97d0c80e449f24a33a2d261d1, type: 2} + IgnitePoint: {fileID: 8934967594637573488} + Grabbed: 0 --- !u!54 &1732996613952540235 Rigidbody: m_ObjectHideFlags: 0 @@ -77,6 +66,36 @@ Rigidbody: m_Interpolate: 0 m_Constraints: 0 m_CollisionDetection: 0 +--- !u!1 &7882310482220326929 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 8934967594637573488} + m_Layer: 10 + m_Name: Ignite Point + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &8934967594637573488 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7882310482220326929} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0.006, y: 0.218, z: -0.008} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 1830340994370403595} + m_RootOrder: 2 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &8445609960004857605 GameObject: m_ObjectHideFlags: 0 diff --git a/Assets/Prefabs/Player/Player.prefab b/Assets/Prefabs/Player/Player.prefab index ea94a8a..336a0f2 100644 --- a/Assets/Prefabs/Player/Player.prefab +++ b/Assets/Prefabs/Player/Player.prefab @@ -1,5 +1,49 @@ %YAML 1.1 %TAG !u! tag:unity3d.com,2011: +--- !u!1 &27676023048832705 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1384451742264440157} + - component: {fileID: 5782206196260616238} + m_Layer: 11 + m_Name: Keep Alive Transfrom (16) + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &1384451742264440157 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 27676023048832705} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: -10, y: 0, z: -10} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 3141763353809520921} + m_RootOrder: 16 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!135 &5782206196260616238 +SphereCollider: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 27676023048832705} + m_Material: {fileID: 0} + m_IsTrigger: 1 + m_Enabled: 0 + serializedVersion: 2 + m_Radius: 0.5 + m_Center: {x: 0, y: 0, z: 0} --- !u!1 &78849986942933072 GameObject: m_ObjectHideFlags: 0 @@ -44,6 +88,50 @@ SphereCollider: serializedVersion: 2 m_Radius: 0.5 m_Center: {x: 0, y: 0, z: 0} +--- !u!1 &713016148336713869 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 4630864132575912130} + - component: {fileID: 661562845330251783} + m_Layer: 11 + m_Name: Keep Alive Transfrom (12) + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &4630864132575912130 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 713016148336713869} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: -20, y: 0, z: 10} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 3141763353809520921} + m_RootOrder: 12 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!135 &661562845330251783 +SphereCollider: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 713016148336713869} + m_Material: {fileID: 0} + m_IsTrigger: 1 + m_Enabled: 0 + serializedVersion: 2 + m_Radius: 0.5 + m_Center: {x: 0, y: 0, z: 0} --- !u!1 &1057583362089800098 GameObject: m_ObjectHideFlags: 0 @@ -88,6 +176,94 @@ SphereCollider: serializedVersion: 2 m_Radius: 0.5 m_Center: {x: 0, y: 0, z: 0} +--- !u!1 &2104873953147320951 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 7277570072337539357} + - component: {fileID: 15732591259595782} + m_Layer: 11 + m_Name: Keep Alive Transfrom (14) + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &7277570072337539357 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2104873953147320951} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: -25, y: 0, z: 15} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 3141763353809520921} + m_RootOrder: 14 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!135 &15732591259595782 +SphereCollider: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2104873953147320951} + m_Material: {fileID: 0} + m_IsTrigger: 1 + m_Enabled: 0 + serializedVersion: 2 + m_Radius: 0.5 + m_Center: {x: 0, y: 0, z: 0} +--- !u!1 &2266679855551352873 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 7819267753509099329} + - component: {fileID: 5383000261075680784} + m_Layer: 11 + m_Name: Keep Alive Transfrom (10) + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &7819267753509099329 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2266679855551352873} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: -10, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 3141763353809520921} + m_RootOrder: 10 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!135 &5383000261075680784 +SphereCollider: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2266679855551352873} + m_Material: {fileID: 0} + m_IsTrigger: 1 + m_Enabled: 0 + serializedVersion: 2 + m_Radius: 0.5 + m_Center: {x: 0, y: 0, z: 0} --- !u!1 &2861789733652061628 GameObject: m_ObjectHideFlags: 0 @@ -124,9 +300,106 @@ Transform: - {fileID: 8888317252785736816} - {fileID: 6686210173505003585} - {fileID: 3434104991777237373} + - {fileID: 5115304573585555494} + - {fileID: 7819267753509099329} + - {fileID: 2091520018235315162} + - {fileID: 4630864132575912130} + - {fileID: 3599220988911936054} + - {fileID: 7277570072337539357} + - {fileID: 6022992509014856325} + - {fileID: 1384451742264440157} + - {fileID: 8804215518123185591} m_Father: {fileID: 6125707630481988396} m_RootOrder: 2 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!1 &3115226987715963232 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 8804215518123185591} + - component: {fileID: 354062204651378279} + m_Layer: 11 + m_Name: Keep Alive Transfrom (17) + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &8804215518123185591 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 3115226987715963232} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: -5} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 3141763353809520921} + m_RootOrder: 17 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!135 &354062204651378279 +SphereCollider: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 3115226987715963232} + m_Material: {fileID: 0} + m_IsTrigger: 1 + m_Enabled: 0 + serializedVersion: 2 + m_Radius: 0.5 + m_Center: {x: 0, y: 0, z: 0} +--- !u!1 &3368295456140203855 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 2091520018235315162} + - component: {fileID: 6186455612215863169} + m_Layer: 11 + m_Name: Keep Alive Transfrom (11) + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &2091520018235315162 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 3368295456140203855} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 20, y: 0, z: 10} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 3141763353809520921} + m_RootOrder: 11 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!135 &6186455612215863169 +SphereCollider: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 3368295456140203855} + m_Material: {fileID: 0} + m_IsTrigger: 1 + m_Enabled: 0 + serializedVersion: 2 + m_Radius: 0.5 + m_Center: {x: 0, y: 0, z: 0} --- !u!1 &4063427199230185944 GameObject: m_ObjectHideFlags: 0 @@ -681,12 +954,12 @@ MonoBehaviour: DroppingRaycastMask: serializedVersion: 2 m_Bits: 3895 - Distance: 2 - ThrowVelocity: 6 + Distance: 3 TorchPrefab: {fileID: 2086008818391599545, guid: dc8417fd4adf1fb41a9ac47d53341a6e, type: 3} GrabbedItems: [] Torch: {fileID: 0} + NextTorch: {fileID: 0} --- !u!114 &462937706053753531 MonoBehaviour: m_ObjectHideFlags: 0 @@ -769,6 +1042,50 @@ MonoBehaviour: m_EditorClassIdentifier: Loraces: [] ChunkKeepAliveTransformsParent: {fileID: 3141763353809520921} +--- !u!1 &6215241420411417389 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 6022992509014856325} + - component: {fileID: 5292593151170945205} + m_Layer: 11 + m_Name: Keep Alive Transfrom (15) + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &6022992509014856325 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 6215241420411417389} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 10, y: 0, z: -10} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 3141763353809520921} + m_RootOrder: 15 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!135 &5292593151170945205 +SphereCollider: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 6215241420411417389} + m_Material: {fileID: 0} + m_IsTrigger: 1 + m_Enabled: 0 + serializedVersion: 2 + m_Radius: 0.5 + m_Center: {x: 0, y: 0, z: 0} --- !u!1 &6687183487362402551 GameObject: m_ObjectHideFlags: 0 @@ -887,6 +1204,50 @@ SphereCollider: serializedVersion: 2 m_Radius: 0.5 m_Center: {x: 0, y: 0, z: 0} +--- !u!1 &7997720268311607166 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 5115304573585555494} + - component: {fileID: 6368551018113135453} + m_Layer: 11 + m_Name: Keep Alive Transfrom (9) + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &5115304573585555494 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7997720268311607166} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 10, y: 0, z: 0} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 3141763353809520921} + m_RootOrder: 9 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!135 &6368551018113135453 +SphereCollider: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 7997720268311607166} + m_Material: {fileID: 0} + m_IsTrigger: 1 + m_Enabled: 0 + serializedVersion: 2 + m_Radius: 0.5 + m_Center: {x: 0, y: 0, z: 0} --- !u!1 &8576716471363164543 GameObject: m_ObjectHideFlags: 0 @@ -975,3 +1336,47 @@ SphereCollider: serializedVersion: 2 m_Radius: 0.5 m_Center: {x: 0, y: 0, z: 0} +--- !u!1 &8730405478810434306 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 3599220988911936054} + - component: {fileID: 4332822548068678923} + m_Layer: 11 + m_Name: Keep Alive Transfrom (13) + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &3599220988911936054 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 8730405478810434306} + m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} + m_LocalPosition: {x: 25, y: 0, z: 15} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 3141763353809520921} + m_RootOrder: 13 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!135 &4332822548068678923 +SphereCollider: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 8730405478810434306} + m_Material: {fileID: 0} + m_IsTrigger: 1 + m_Enabled: 0 + serializedVersion: 2 + m_Radius: 0.5 + m_Center: {x: 0, y: 0, z: 0} diff --git a/Assets/Scripts/BurnQuality.cs b/Assets/Scripts/BurnQuality.cs index 8b74f30..d5586dd 100644 --- a/Assets/Scripts/BurnQuality.cs +++ b/Assets/Scripts/BurnQuality.cs @@ -4,6 +4,7 @@ using UnityEngine; [CreateAssetMenu(fileName = "Unnamed Burn Quality", menuName = "Campfire/Burn Quality")] public class BurnQuality : ScriptableObject { + public string DisplayName; public float FuelValue; public float FlameEffect; public float SoundEffect; diff --git a/Assets/Scripts/Burnable.cs b/Assets/Scripts/Burnable.cs index f422382..f2f07d3 100644 --- a/Assets/Scripts/Burnable.cs +++ b/Assets/Scripts/Burnable.cs @@ -4,5 +4,4 @@ using UnityEngine; [RequireComponent(typeof(Rigidbody))] public class Burnable : MonoBehaviour { - public BurnQuality Quality; } diff --git a/Assets/Scripts/Campfire.cs b/Assets/Scripts/Campfire.cs index 19947d6..10df8f6 100644 --- a/Assets/Scripts/Campfire.cs +++ b/Assets/Scripts/Campfire.cs @@ -30,7 +30,7 @@ public class Campfire : MonoBehaviour { private float NextRandomVariance = 0; private float LastRandomVarianceChange = 0; - private List LogQueue = new List(); + private List LogQueue = new List(); private float LastLogBurned = 0; private void Awake() { @@ -62,13 +62,11 @@ public class Campfire : MonoBehaviour { } } - private bool BurnLog(Burnable burnable) { + private bool BurnLog(Item burnable) { if (Fuel >= GoodFuelAmount * 2) { return false; } else { Fuel += burnable.Quality.FuelValue * Mathf.Max(0.5f, (2 - Fuel / GoodFuelAmount)); - Flame.AddFuelEffect += burnable.Quality.FlameEffect; - Sfx.ActiveBurn += burnable.Quality.SoundEffect; Destroy(burnable.gameObject); return true; } @@ -76,8 +74,10 @@ public class Campfire : MonoBehaviour { private void OnCollisionEnter(Collision c) { if (c.collider.attachedRigidbody != null && c.collider.attachedRigidbody) { - Burnable Burnable = c.collider.attachedRigidbody.GetComponent(); + Item Burnable = c.collider.attachedRigidbody.GetComponent(); if (Burnable != null && !LogQueue.Contains(Burnable)) { + Flame.AddFuelEffect += Burnable.Quality.FlameEffect; + Sfx.ActiveBurn += Burnable.Quality.SoundEffect; LogQueue.Add(Burnable); } } @@ -85,7 +85,7 @@ public class Campfire : MonoBehaviour { private void OnCollisionExit(Collision c) { if (c.collider.attachedRigidbody != null && c.collider.attachedRigidbody) { - Burnable Burnable = c.collider.attachedRigidbody.GetComponent(); + Item Burnable = c.collider.attachedRigidbody.GetComponent(); if (Burnable != null) { LogQueue.Remove(Burnable); } diff --git a/Assets/Scripts/Item.cs b/Assets/Scripts/Item.cs index a00347f..1f7e7fd 100644 --- a/Assets/Scripts/Item.cs +++ b/Assets/Scripts/Item.cs @@ -4,6 +4,9 @@ using UnityEngine; [RequireComponent(typeof(Rigidbody))] public class Item : MonoBehaviour { + public BurnQuality Quality; + public Transform IgnitePoint; + [Header("Runtime values")] public bool Grabbed = false; @@ -12,6 +15,7 @@ public class Item : MonoBehaviour { private bool BeingPlaced = false; private Vector3 TargetPosition; private Vector3 GrabOffset; + private Quaternion GrabRotation; private void Awake() { Body = GetComponent(); @@ -21,6 +25,7 @@ public class Item : MonoBehaviour { private void Update() { if (Grabbed) { transform.localPosition = Vector3.Lerp(transform.localPosition, GrabOffset, 10f * Time.deltaTime); + transform.localRotation = Quaternion.Slerp(transform.localRotation, GrabRotation, 10f * Time.deltaTime); } else if (BeingPlaced) { // Lerp to TargetPosition, then continue simulation Vector3 Delta = TargetPosition - transform.position; @@ -35,9 +40,11 @@ public class Item : MonoBehaviour { } } - public void PickUp(Transform handTransform, Vector3 offset) { + public void PickUp(Transform handTransform) { transform.parent = handTransform; - GrabOffset = offset; + GrabOffset = new Vector3(Random.value - 0.5f, Random.value - 0.5f, Random.value - 0.5f) * 0.15f; + Vector3 DirectionOffset = new Vector3(Random.value - 0.5f, Random.value - 0.5f, 0) * 0.8f; + GrabRotation = Quaternion.LookRotation(Vector3.down, (Vector3.forward + DirectionOffset).normalized); Body.isKinematic = true; Grabbed = true; } diff --git a/Assets/Scripts/ItemGrabber.cs b/Assets/Scripts/ItemGrabber.cs index b94962b..d1d72d1 100644 --- a/Assets/Scripts/ItemGrabber.cs +++ b/Assets/Scripts/ItemGrabber.cs @@ -14,7 +14,6 @@ public class ItemGrabber : MonoBehaviour { public LayerMask ItemLayer; public LayerMask DroppingRaycastMask; public float Distance; - public float ThrowVelocity; [Header("Prefabs")] public GameObject TorchPrefab; @@ -22,6 +21,7 @@ public class ItemGrabber : MonoBehaviour { [Header("Runtime values")] public List GrabbedItems; public Torch Torch; + public GameObject NextTorch; private void Start() { PrimaryIndicator.alpha = 0; @@ -35,13 +35,16 @@ public class ItemGrabber : MonoBehaviour { Vector3 From = CameraTransform.position; Vector3 Direction = CameraTransform.forward; + Item TorchableItem = GetTorchableItem(); + bool CanIgniteTorch = Torch != null && TorchableItem != null; + if (Physics.Raycast(From, Direction, out Hit, Distance, ItemLayer) && Hit.collider.attachedRigidbody != null) { Item = Hit.collider.attachedRigidbody.GetComponent(); } if (Item != null && Input.GetButtonDown("Grab")) { - Item.PickUp(HandTransform, new Vector3(Random.value - 0.5f, Random.value - 0.5f, Random.value - 0.5f) * 0.1f); + Item.PickUp(HandTransform); GrabbedItems.Add(Item); } @@ -49,14 +52,21 @@ public class ItemGrabber : MonoBehaviour { if (Physics.Raycast(From, Direction, out Hit, Distance * 2f, 1 << LayerMask.NameToLayer("Campfire")) && Hit.collider.attachedRigidbody != null) { Campfire = Hit.collider.attachedRigidbody.GetComponent(); + CanIgniteTorch |= Campfire != null && TorchableItem != null; } - if (Campfire != null && Torch == null && Input.GetButtonDown("Ignite")) { - Item GrabbedItem = GrabbedItems[0]; - GrabbedItems.RemoveAt(0); - GameObject TorchObj = Instantiate(TorchPrefab, GrabbedItem.transform.position, GrabbedItem.transform.rotation, TorchHandTransform); - Torch = TorchObj.GetComponent(); - Destroy(GrabbedItem.gameObject); + if (CanIgniteTorch && Input.GetButtonDown("Ignite")) { + if (Torch == null) { + NextTorch = TorchableItem.gameObject; + GrabbedItems.Remove(TorchableItem); + EquipNewTorch(); + } else { + // Starts the pass + NextTorch = TorchableItem.gameObject; + // Passing the torch will cause the current one to extinguish, + // and then the new one will be equipped + Torch.PassTorch(TorchableItem.IgnitePoint); + } } if (Input.GetButtonDown("Grab") && Item == null) { @@ -75,15 +85,60 @@ public class ItemGrabber : MonoBehaviour { } } + if (Torch != null && !Torch.Burning) { + // Move torch back into the right hand + int NextTorchIndex = -1; + for (int I = 0; I < GrabbedItems.Count; I++) { + if (GrabbedItems[I].gameObject == NextTorch) { + NextTorchIndex = I; + continue; + } + } + + // Previous torch's item component + Item TorchItem = Torch.GetComponent(); + TorchItem.PickUp(HandTransform); + if (NextTorchIndex != -1) { + GrabbedItems[NextTorchIndex] = TorchItem; + } else { + GrabbedItems.Add(TorchItem); + } + + // Equip new torch if there is one queued + Torch = null; + if (NextTorch != null) { + EquipNewTorch(); + } + } + PrimaryIndicator.alpha = Mathf.Lerp(PrimaryIndicator.alpha, Item != null || Campfire != null ? 1 : 0, 10f * Time.deltaTime); if (Campfire != null && GrabbedItems.Count > 0) { - PrimaryText.text = $"Burn {GrabbedItems[0].name.ToLower()}"; + PrimaryText.text = $"Burn {GrabbedItems[0].Quality.DisplayName}"; } else if (Item != null) { - PrimaryText.text = $"Take {Item.name.ToLower()}"; + PrimaryText.text = $"Take {Item.Quality.DisplayName}"; } - SecondaryIndicator.alpha = Mathf.Lerp(SecondaryIndicator.alpha, Campfire != null && GrabbedItems.Count > 0 && Torch == null ? 1 : 0, 10f * Time.deltaTime); - if (GrabbedItems.Count > 0) { - SecondaryText.text = $"Ignite {GrabbedItems[0].name.ToLower()}"; + SecondaryIndicator.alpha = Mathf.Lerp(SecondaryIndicator.alpha, CanIgniteTorch ? 1 : 0, 10f * Time.deltaTime); + if (CanIgniteTorch) { + SecondaryText.text = $"Ignite {TorchableItem.Quality.DisplayName}"; } } + + private Item GetTorchableItem() { + Item ChosenItem = null; + foreach (Item I in GrabbedItems) { + Torch CurrentTorch = I.GetComponent(); + if (CurrentTorch == null || CurrentTorch.Burning) { + ChosenItem = I; + continue; + } + } + return ChosenItem; + } + + private void EquipNewTorch() { + GameObject TorchObj = Instantiate(TorchPrefab, NextTorch.transform.position, NextTorch.transform.rotation, TorchHandTransform); + Torch = TorchObj.GetComponent(); + Destroy(NextTorch); + NextTorch = null; + } } diff --git a/Assets/Scripts/Torch.cs b/Assets/Scripts/Torch.cs index b6c5641..24f5d31 100644 --- a/Assets/Scripts/Torch.cs +++ b/Assets/Scripts/Torch.cs @@ -2,20 +2,83 @@ using System.Collections.Generic; using UnityEngine; +[RequireComponent(typeof(Rigidbody))] public class Torch : MonoBehaviour { + public Transform FirePoint; + public ParticleSystem Particles; public Light Light; public Color NormalColor; public Color PanicColor; - public float Lifetime = 3f; + public float Lifetime; public float PanicLifetimeThreshold; + public float PassTorchAnimationDuration; + public float IgniteDuration; - private void Update() { - Lifetime -= Time.deltaTime; - Light.color = Color.Lerp(Light.color, Lifetime <= PanicLifetimeThreshold ? PanicColor : NormalColor, 4f * Time.deltaTime); - transform.localPosition = Vector3.Lerp(transform.localPosition, Vector3.zero, 12f * Time.deltaTime); - transform.localRotation = Quaternion.Slerp(transform.localRotation, Quaternion.LookRotation(Vector3.forward, Vector3.up), 12f * Time.deltaTime); - if (Lifetime <= 0) { - Destroy(gameObject); + public bool Burning { + get { + return Lifetime > 0; } } + + private Rigidbody Body; + + private Quaternion PassRotation = Quaternion.LookRotation(Vector3.forward, (Vector3.right + Vector3.forward).normalized); + private bool PassingTorch = false; + private float TorchPassStarted = 0; + private Transform PassTo; + private Vector3 PassStartPosition; + private Quaternion PassStartRotation; + + private Vector3 BaseScale; + + private void Awake() { + Body = GetComponent(); + BaseScale = transform.localScale; + } + + private void Update() { + if (PassingTorch) { + if (PassTo != null) { + // Move to other, to-be-enflamed torch + transform.position = Vector3.Lerp( + PassStartPosition, + PassTo.position - transform.rotation * FirePoint.localPosition, + (Time.time - TorchPassStarted) / PassTorchAnimationDuration); + transform.localRotation = Quaternion.Slerp( + PassStartRotation, + PassRotation, + (Time.time - TorchPassStarted) / PassTorchAnimationDuration * 2f); + } + if (Time.time - TorchPassStarted >= IgniteDuration) { + Lifetime = 0; + } + } else if (Burning) { + // Move to origin + transform.localPosition = Vector3.Lerp(transform.localPosition, Vector3.zero, 12f * Time.deltaTime); + transform.localRotation = Quaternion.Slerp(transform.localRotation, Quaternion.LookRotation(Vector3.forward, Vector3.up), 12f * Time.deltaTime); + } + + Lifetime -= Time.deltaTime; + Light.color = Color.Lerp(Light.color, Lifetime <= PanicLifetimeThreshold ? PanicColor : NormalColor, 4f * Time.deltaTime); + if (Lifetime <= 0) { + Particles.Stop(); + Light.color = Color.Lerp(Light.color, Color.black, 4f * Time.deltaTime); + if (Light.color == Color.black) { + Light.enabled = false; + } + } + } + + public void PassTorch(Transform target) { + PassingTorch = true; + PassTo = target; + TorchPassStarted = Time.time; + PassStartPosition = transform.position; + PassStartRotation = transform.localRotation; + } + + public void Drop() { + Body.isKinematic = false; + transform.parent = GameObject.FindGameObjectWithTag("World").transform; + } }