From 927a1b9dd7f6a929829908911bd99621c6a956dc Mon Sep 17 00:00:00 2001 From: Cat Flynn Date: Mon, 22 Mar 2021 16:45:42 +0000 Subject: [PATCH] create killbox prefab --- game/Assets/Prefabs/Traps/ArrowWall.prefab | 88 +++++++++++++ game/Assets/Prefabs/Traps/Killbox.prefab | 116 ++++++++++++++++++ game/Assets/Prefabs/Traps/Killbox.prefab.meta | 7 ++ game/Assets/Scenes/BoostPuzzles.unity | 46 +++---- game/Assets/Scripts/Traps/ArrowWall.cs | 25 ++-- game/Assets/Scripts/Traps/Killbox.cs | 57 +++++++++ game/Assets/Scripts/Traps/Killbox.cs.meta | 11 ++ 7 files changed, 304 insertions(+), 46 deletions(-) create mode 100644 game/Assets/Prefabs/Traps/Killbox.prefab create mode 100644 game/Assets/Prefabs/Traps/Killbox.prefab.meta create mode 100644 game/Assets/Scripts/Traps/Killbox.cs create mode 100644 game/Assets/Scripts/Traps/Killbox.cs.meta diff --git a/game/Assets/Prefabs/Traps/ArrowWall.prefab b/game/Assets/Prefabs/Traps/ArrowWall.prefab index add3a40..72d1041 100644 --- a/game/Assets/Prefabs/Traps/ArrowWall.prefab +++ b/game/Assets/Prefabs/Traps/ArrowWall.prefab @@ -4834,6 +4834,7 @@ Transform: m_LocalScale: {x: 1, y: 1, z: 1} m_Children: - {fileID: 719150114373324430} + - {fileID: 5240851486570782915} m_Father: {fileID: 0} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} @@ -4851,6 +4852,7 @@ MonoBehaviour: m_EditorClassIdentifier: _settings: {fileID: 11400000, guid: 36275776eda5c8249bf45e01721afe36, type: 2} _particles: {fileID: 2019849038189154255} + _killbox: {fileID: 0} --- !u!65 &3586933165554218147 BoxCollider: m_ObjectHideFlags: 0 @@ -4864,3 +4866,89 @@ BoxCollider: serializedVersion: 2 m_Size: {x: 2, y: 2, z: 2} m_Center: {x: 0, y: 1, z: 0} +--- !u!1001 &7614645943771473734 +PrefabInstance: + m_ObjectHideFlags: 0 + serializedVersion: 2 + m_Modification: + m_TransformParent: {fileID: 8768409224895496785} + m_Modifications: + - target: {fileID: 1235410945164343452, guid: 356b55083085cda4c9f881946368d5bc, type: 3} + propertyPath: m_Name + value: Killbox + objectReference: {fileID: 0} + - target: {fileID: 2384540058465011589, guid: 356b55083085cda4c9f881946368d5bc, type: 3} + propertyPath: m_RootOrder + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 2384540058465011589, guid: 356b55083085cda4c9f881946368d5bc, type: 3} + propertyPath: m_LocalScale.x + value: 2 + objectReference: {fileID: 0} + - target: {fileID: 2384540058465011589, guid: 356b55083085cda4c9f881946368d5bc, type: 3} + propertyPath: m_LocalScale.y + value: 2 + objectReference: {fileID: 0} + - target: {fileID: 2384540058465011589, guid: 356b55083085cda4c9f881946368d5bc, type: 3} + propertyPath: m_LocalScale.z + value: 2 + objectReference: {fileID: 0} + - target: {fileID: 2384540058465011589, guid: 356b55083085cda4c9f881946368d5bc, type: 3} + propertyPath: m_LocalPosition.y + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 2384540058465011589, guid: 356b55083085cda4c9f881946368d5bc, type: 3} + propertyPath: m_LocalPosition.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 2384540058465011589, guid: 356b55083085cda4c9f881946368d5bc, type: 3} + propertyPath: m_LocalEulerAnglesHint.x + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 2384540058465011589, guid: 356b55083085cda4c9f881946368d5bc, type: 3} + propertyPath: m_LocalEulerAnglesHint.y + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 2384540058465011589, guid: 356b55083085cda4c9f881946368d5bc, type: 3} + propertyPath: m_LocalEulerAnglesHint.z + value: 0 + objectReference: {fileID: 0} + - target: {fileID: 4394339977511682008, guid: 356b55083085cda4c9f881946368d5bc, type: 3} + propertyPath: _playerEnter.m_PersistentCalls.m_Calls.Array.size + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 4394339977511682008, guid: 356b55083085cda4c9f881946368d5bc, type: 3} + propertyPath: _playerEnter.m_PersistentCalls.m_Calls.Array.data[0].m_Mode + value: 1 + objectReference: {fileID: 0} + - target: {fileID: 4394339977511682008, guid: 356b55083085cda4c9f881946368d5bc, type: 3} + propertyPath: _playerEnter.m_PersistentCalls.m_Calls.Array.data[0].m_Target + value: + objectReference: {fileID: 3252345525856873970} + - target: {fileID: 4394339977511682008, guid: 356b55083085cda4c9f881946368d5bc, type: 3} + propertyPath: _playerEnter.m_PersistentCalls.m_Calls.Array.data[0].m_CallState + value: 2 + objectReference: {fileID: 0} + - target: {fileID: 4394339977511682008, guid: 356b55083085cda4c9f881946368d5bc, type: 3} + propertyPath: _playerEnter.m_PersistentCalls.m_Calls.Array.data[0].m_MethodName + value: Trigger + objectReference: {fileID: 0} + - target: {fileID: 4394339977511682008, guid: 356b55083085cda4c9f881946368d5bc, type: 3} + propertyPath: _playerEnter.m_PersistentCalls.m_Calls.Array.data[0].m_TargetAssemblyTypeName + value: ArrowWall, Assembly-CSharp + objectReference: {fileID: 0} + - target: {fileID: 4394339977511682008, guid: 356b55083085cda4c9f881946368d5bc, type: 3} + propertyPath: _playerEnter.m_PersistentCalls.m_Calls.Array.data[0].m_Arguments.m_ObjectArgumentAssemblyTypeName + value: UnityEngine.Object, UnityEngine + objectReference: {fileID: 0} + - target: {fileID: 7503837629980950041, guid: 356b55083085cda4c9f881946368d5bc, type: 3} + propertyPath: m_Enabled + value: 1 + objectReference: {fileID: 0} + m_RemovedComponents: [] + m_SourcePrefab: {fileID: 100100000, guid: 356b55083085cda4c9f881946368d5bc, type: 3} +--- !u!4 &5240851486570782915 stripped +Transform: + m_CorrespondingSourceObject: {fileID: 2384540058465011589, guid: 356b55083085cda4c9f881946368d5bc, type: 3} + m_PrefabInstance: {fileID: 7614645943771473734} + m_PrefabAsset: {fileID: 0} diff --git a/game/Assets/Prefabs/Traps/Killbox.prefab b/game/Assets/Prefabs/Traps/Killbox.prefab new file mode 100644 index 0000000..796d477 --- /dev/null +++ b/game/Assets/Prefabs/Traps/Killbox.prefab @@ -0,0 +1,116 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1 &1235410945164343452 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 2384540058465011589} + - component: {fileID: 1774115580962772399} + - component: {fileID: 4394339977511682008} + - component: {fileID: 7503837629980950041} + - component: {fileID: 7948491899482973705} + m_Layer: 0 + m_Name: Killbox + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &2384540058465011589 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1235410945164343452} + 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: 0} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} +--- !u!65 &1774115580962772399 +BoxCollider: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1235410945164343452} + m_Material: {fileID: 0} + m_IsTrigger: 1 + m_Enabled: 1 + serializedVersion: 2 + m_Size: {x: 1, y: 1, z: 1} + m_Center: {x: 0, y: 0, z: 0} +--- !u!114 &4394339977511682008 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1235410945164343452} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 057a6d45d8ae84046ba8843eb3ba4260, type: 3} + m_Name: + m_EditorClassIdentifier: + _playerEnter: + m_PersistentCalls: + m_Calls: [] + _playerExit: + m_PersistentCalls: + m_Calls: [] +--- !u!23 &7503837629980950041 +MeshRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1235410945164343452} + m_Enabled: 0 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_DynamicOccludee: 1 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_RayTracingMode: 2 + m_RayTraceProcedural: 0 + m_RenderingLayerMask: 1 + m_RendererPriority: 0 + m_Materials: + - {fileID: 2100000, guid: a93d8dde940391d42b8e52a58c1e842d, type: 2} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_ReceiveGI: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 1 + m_SelectedEditorRenderState: 3 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 + m_AdditionalVertexStreams: {fileID: 0} +--- !u!33 &7948491899482973705 +MeshFilter: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1235410945164343452} + m_Mesh: {fileID: 10202, guid: 0000000000000000e000000000000000, type: 0} diff --git a/game/Assets/Prefabs/Traps/Killbox.prefab.meta b/game/Assets/Prefabs/Traps/Killbox.prefab.meta new file mode 100644 index 0000000..794668f --- /dev/null +++ b/game/Assets/Prefabs/Traps/Killbox.prefab.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 356b55083085cda4c9f881946368d5bc +PrefabImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/game/Assets/Scenes/BoostPuzzles.unity b/game/Assets/Scenes/BoostPuzzles.unity index 421f07a..2a1f6c4 100644 --- a/game/Assets/Scenes/BoostPuzzles.unity +++ b/game/Assets/Scenes/BoostPuzzles.unity @@ -150,8 +150,8 @@ Transform: m_PrefabAsset: {fileID: 0} m_GameObject: {fileID: 30295874} m_LocalRotation: {x: -0, y: -0, z: -0, w: 1} - m_LocalPosition: {x: 7.99, y: 8.375, z: 14.805} - m_LocalScale: {x: 2.04556, y: 0.5122717, z: 2.4846175} + m_LocalPosition: {x: 4.27, y: 8.375, z: 14.805} + m_LocalScale: {x: 10.060267, y: 0.5122717, z: 2.4846175} m_Children: [] m_Father: {fileID: 1728400713} m_RootOrder: 7 @@ -941,7 +941,7 @@ GameObject: m_Icon: {fileID: 0} m_NavMeshLayer: 0 m_StaticEditorFlags: 0 - m_IsActive: 0 + m_IsActive: 1 --- !u!4 &1728400713 Transform: m_ObjectHideFlags: 0 @@ -1166,6 +1166,18 @@ PrefabInstance: m_Modification: m_TransformParent: {fileID: 0} m_Modifications: + - target: {fileID: 5240851486570782915, guid: 55fadb9f11c9ea74fb586631ce45bd14, type: 3} + propertyPath: m_LocalPosition.x + value: 4.5 + objectReference: {fileID: 0} + - target: {fileID: 5240851486570782915, guid: 55fadb9f11c9ea74fb586631ce45bd14, type: 3} + propertyPath: m_LocalPosition.y + value: 9.25 + objectReference: {fileID: 0} + - target: {fileID: 5240851486570782915, guid: 55fadb9f11c9ea74fb586631ce45bd14, type: 3} + propertyPath: m_LocalPosition.z + value: 15 + objectReference: {fileID: 0} - target: {fileID: 8768409224895496784, guid: 55fadb9f11c9ea74fb586631ce45bd14, type: 3} propertyPath: m_Name value: ArrowWall @@ -1174,34 +1186,6 @@ PrefabInstance: propertyPath: m_RootOrder value: 5 objectReference: {fileID: 0} - - target: {fileID: 8768409224895496785, guid: 55fadb9f11c9ea74fb586631ce45bd14, type: 3} - propertyPath: m_LocalPosition.x - value: -26.51 - objectReference: {fileID: 0} - - target: {fileID: 8768409224895496785, guid: 55fadb9f11c9ea74fb586631ce45bd14, type: 3} - propertyPath: m_LocalPosition.y - value: 1.0225053 - objectReference: {fileID: 0} - - target: {fileID: 8768409224895496785, guid: 55fadb9f11c9ea74fb586631ce45bd14, type: 3} - propertyPath: m_LocalPosition.z - value: 41.31 - objectReference: {fileID: 0} - - target: {fileID: 8768409224895496785, guid: 55fadb9f11c9ea74fb586631ce45bd14, type: 3} - propertyPath: m_LocalRotation.w - value: 1 - objectReference: {fileID: 0} - - target: {fileID: 8768409224895496785, guid: 55fadb9f11c9ea74fb586631ce45bd14, type: 3} - propertyPath: m_LocalRotation.x - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 8768409224895496785, guid: 55fadb9f11c9ea74fb586631ce45bd14, type: 3} - propertyPath: m_LocalRotation.y - value: 0 - objectReference: {fileID: 0} - - target: {fileID: 8768409224895496785, guid: 55fadb9f11c9ea74fb586631ce45bd14, type: 3} - propertyPath: m_LocalRotation.z - value: 0 - objectReference: {fileID: 0} - target: {fileID: 8768409224895496785, guid: 55fadb9f11c9ea74fb586631ce45bd14, type: 3} propertyPath: m_LocalEulerAnglesHint.x value: 0 diff --git a/game/Assets/Scripts/Traps/ArrowWall.cs b/game/Assets/Scripts/Traps/ArrowWall.cs index 9501762..667f887 100644 --- a/game/Assets/Scripts/Traps/ArrowWall.cs +++ b/game/Assets/Scripts/Traps/ArrowWall.cs @@ -4,31 +4,28 @@ using System.Collections.Generic; using UnityEngine; [RequireComponent(typeof(BoxCollider))] -public class ArrowWall : MonoBehaviour +public partial class ArrowWall : MonoBehaviour { [SerializeField] private TrapSettings _settings; [SerializeField] private ParticleSystem _particles; + [SerializeField] private Killbox _killbox; private float _killTimer = -1; - - private void OnTriggerEnter(Collider other) + + public void Trigger() { - if (!other.TryGetComponent(out PlayerDeath _)) return; - // TODO: pressure plate 'click' sound // set kill timer to zero, start counting _killTimer = 0; } - private void OnTriggerStay(Collider other) + private void Update() { - // bail if the other thing cant die - if (!other.TryGetComponent(out PlayerDeath playerDeath)) return; - + if (_killTimer < 0) return; + // TODO: implications for time freeze _killTimer += Time.deltaTime; - if (_killTimer > _settings.ArrowWall.delay) { // TODO: arrow whoosh noises @@ -37,16 +34,14 @@ public class ArrowWall : MonoBehaviour _particles.Play(); // kill player - playerDeath.Respawn(); + _killbox.KillPlayer(); _killTimer = -1; } } - private void OnTriggerExit(Collider other) + public void Reset() { - if (!other.TryGetComponent(out PlayerDeath _)) return; - _killTimer = -1; } -} +} \ No newline at end of file diff --git a/game/Assets/Scripts/Traps/Killbox.cs b/game/Assets/Scripts/Traps/Killbox.cs new file mode 100644 index 0000000..a9d1dd8 --- /dev/null +++ b/game/Assets/Scripts/Traps/Killbox.cs @@ -0,0 +1,57 @@ +using System; +using System.Collections; +using System.Collections.Generic; +using UnityEngine; +using UnityEngine.Events; + +[RequireComponent(typeof(BoxCollider))] +public class Killbox : MonoBehaviour +{ + private BoxCollider _box; + private PlayerDeath _player; + + [SerializeField] private UnityEvent _playerEnter; + [SerializeField] private UnityEvent _playerExit; + + private void OnEnable() + { + _box = GetComponent(); + _box.isTrigger = true; + } + + private void OnTriggerEnter(Collider other) + { + if (other.TryGetComponent(out PlayerDeath pd) && !_player) + { + _player = pd; + _playerEnter.Invoke(); + } + } + + private void OnTriggerExit(Collider other) + { + if (other.TryGetComponent(out PlayerDeath pd) && _player) + { + if (pd == _player) + { + _player = null; + _playerExit.Invoke(); + } + else + { + Debug.LogError($":thonk:", this); + } + } + } + + public void KillPlayer() + { + if (!_player) + { + Debug.LogError("killbox tried to contain out of bounds player", this); + return; + } + + _player.Respawn(); + } +} diff --git a/game/Assets/Scripts/Traps/Killbox.cs.meta b/game/Assets/Scripts/Traps/Killbox.cs.meta new file mode 100644 index 0000000..94bae94 --- /dev/null +++ b/game/Assets/Scripts/Traps/Killbox.cs.meta @@ -0,0 +1,11 @@ +fileFormatVersion: 2 +guid: 057a6d45d8ae84046ba8843eb3ba4260 +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: