From 5a93de7fdc0d09d70d3241d585989eb74a947c72 Mon Sep 17 00:00:00 2001 From: Jordan Orelli Date: Wed, 20 May 2020 15:55:20 -0500 Subject: [PATCH] crumble brick --- Assets/Materials/CrumbleActive.mat | 77 ++++++++++++++ Assets/Materials/CrumbleActive.mat.meta | 8 ++ Assets/Materials/CrumbleInactive.mat | 78 ++++++++++++++ Assets/Materials/CrumbleInactive.mat.meta | 8 ++ Assets/Prefabs/Crumble Brick.prefab | 123 ++++++++++++++++++++++ Assets/Prefabs/Crumble Brick.prefab.meta | 7 ++ Assets/Scripts/Crumble.cs | 27 ++++- Assets/Scripts/MoveController.cs | 4 + 8 files changed, 328 insertions(+), 4 deletions(-) create mode 100644 Assets/Materials/CrumbleActive.mat create mode 100644 Assets/Materials/CrumbleActive.mat.meta create mode 100644 Assets/Materials/CrumbleInactive.mat create mode 100644 Assets/Materials/CrumbleInactive.mat.meta create mode 100644 Assets/Prefabs/Crumble Brick.prefab create mode 100644 Assets/Prefabs/Crumble Brick.prefab.meta diff --git a/Assets/Materials/CrumbleActive.mat b/Assets/Materials/CrumbleActive.mat new file mode 100644 index 0000000..e35f638 --- /dev/null +++ b/Assets/Materials/CrumbleActive.mat @@ -0,0 +1,77 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!21 &2100000 +Material: + serializedVersion: 6 + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: CrumbleActive + m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0} + m_ShaderKeywords: + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: -1 + stringTagMap: {} + disabledShaderPasses: [] + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _BumpMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailAlbedoMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailMask: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailNormalMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _EmissionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MainTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MetallicGlossMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _OcclusionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _ParallaxMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Floats: + - _BumpScale: 1 + - _Cutoff: 0.5 + - _DetailNormalMapScale: 1 + - _DstBlend: 0 + - _GlossMapScale: 1 + - _Glossiness: 0.5 + - _GlossyReflections: 1 + - _Metallic: 0 + - _Mode: 0 + - _OcclusionStrength: 1 + - _Parallax: 0.02 + - _SmoothnessTextureChannel: 0 + - _SpecularHighlights: 1 + - _SrcBlend: 1 + - _UVSec: 0 + - _ZWrite: 1 + m_Colors: + - _Color: {r: 1, g: 0.16509432, b: 0.9205906, a: 1} + - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} diff --git a/Assets/Materials/CrumbleActive.mat.meta b/Assets/Materials/CrumbleActive.mat.meta new file mode 100644 index 0000000..977fd26 --- /dev/null +++ b/Assets/Materials/CrumbleActive.mat.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: b117c31d14879504eaec23a544cba234 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Materials/CrumbleInactive.mat b/Assets/Materials/CrumbleInactive.mat new file mode 100644 index 0000000..bdc47b8 --- /dev/null +++ b/Assets/Materials/CrumbleInactive.mat @@ -0,0 +1,78 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!21 &2100000 +Material: + serializedVersion: 6 + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_Name: CrumbleInactive + m_Shader: {fileID: 46, guid: 0000000000000000f000000000000000, type: 0} + m_ShaderKeywords: _ALPHAPREMULTIPLY_ON + m_LightmapFlags: 4 + m_EnableInstancingVariants: 0 + m_DoubleSidedGI: 0 + m_CustomRenderQueue: 3000 + stringTagMap: + RenderType: Transparent + disabledShaderPasses: [] + m_SavedProperties: + serializedVersion: 3 + m_TexEnvs: + - _BumpMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailAlbedoMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailMask: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _DetailNormalMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _EmissionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MainTex: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _MetallicGlossMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _OcclusionMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + - _ParallaxMap: + m_Texture: {fileID: 0} + m_Scale: {x: 1, y: 1} + m_Offset: {x: 0, y: 0} + m_Floats: + - _BumpScale: 1 + - _Cutoff: 0.5 + - _DetailNormalMapScale: 1 + - _DstBlend: 10 + - _GlossMapScale: 1 + - _Glossiness: 0.5 + - _GlossyReflections: 1 + - _Metallic: 0 + - _Mode: 3 + - _OcclusionStrength: 1 + - _Parallax: 0.02 + - _SmoothnessTextureChannel: 0 + - _SpecularHighlights: 1 + - _SrcBlend: 1 + - _UVSec: 0 + - _ZWrite: 0 + m_Colors: + - _Color: {r: 0.7169812, g: 0.7169812, b: 0.7169812, a: 0.29803923} + - _EmissionColor: {r: 0, g: 0, b: 0, a: 1} diff --git a/Assets/Materials/CrumbleInactive.mat.meta b/Assets/Materials/CrumbleInactive.mat.meta new file mode 100644 index 0000000..ac84284 --- /dev/null +++ b/Assets/Materials/CrumbleInactive.mat.meta @@ -0,0 +1,8 @@ +fileFormatVersion: 2 +guid: b2508fa039104394280a90534c861268 +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 0 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Prefabs/Crumble Brick.prefab b/Assets/Prefabs/Crumble Brick.prefab new file mode 100644 index 0000000..352318a --- /dev/null +++ b/Assets/Prefabs/Crumble Brick.prefab @@ -0,0 +1,123 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1 &2340729374737727045 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 2340729374737727041} + - component: {fileID: 2340729374737727042} + - component: {fileID: 2340729374737727043} + - component: {fileID: 2340729374737727044} + - component: {fileID: 2340729374737727040} + m_Layer: 10 + m_Name: Crumble Brick + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &2340729374737727041 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2340729374737727045} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 5, y: 1, 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!33 &2340729374737727042 +MeshFilter: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2340729374737727045} + m_Mesh: {fileID: 10210, guid: 0000000000000000e000000000000000, type: 0} +--- !u!23 &2340729374737727043 +MeshRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2340729374737727045} + m_Enabled: 1 + m_CastShadows: 1 + m_ReceiveShadows: 1 + m_DynamicOccludee: 1 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_RayTracingMode: 2 + m_RenderingLayerMask: 1 + m_RendererPriority: 0 + m_Materials: + - {fileID: 2100000, guid: b117c31d14879504eaec23a544cba234, 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 +--- !u!61 &2340729374737727044 +BoxCollider2D: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2340729374737727045} + m_Enabled: 1 + m_Density: 1 + m_Material: {fileID: 0} + m_IsTrigger: 0 + m_UsedByEffector: 0 + m_UsedByComposite: 0 + m_Offset: {x: 0, y: 0} + m_SpriteTilingProperty: + border: {x: 0, y: 0, z: 0, w: 0} + pivot: {x: 0, y: 0} + oldSize: {x: 0, y: 0} + newSize: {x: 0, y: 0} + adaptiveTilingThreshold: 0 + drawMode: 0 + adaptiveTiling: 0 + m_AutoTiling: 0 + serializedVersion: 2 + m_Size: {x: 1, y: 1} + m_EdgeRadius: 0 +--- !u!114 &2340729374737727040 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 2340729374737727045} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 39b95ffbce3c7d947a201729e7b4a749, type: 3} + m_Name: + m_EditorClassIdentifier: + activeMaterial: {fileID: 2100000, guid: b117c31d14879504eaec23a544cba234, type: 2} + inactiveMaterial: {fileID: 2100000, guid: b2508fa039104394280a90534c861268, type: 2} diff --git a/Assets/Prefabs/Crumble Brick.prefab.meta b/Assets/Prefabs/Crumble Brick.prefab.meta new file mode 100644 index 0000000..0407223 --- /dev/null +++ b/Assets/Prefabs/Crumble Brick.prefab.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: a3a39052a553b184e920dfe1af3df53b +PrefabImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Crumble.cs b/Assets/Scripts/Crumble.cs index f407070..e10f68b 100644 --- a/Assets/Scripts/Crumble.cs +++ b/Assets/Scripts/Crumble.cs @@ -4,17 +4,36 @@ using UnityEngine; public class Crumble : MonoBehaviour { + public Material activeMaterial; + public Material inactiveMaterial; + bool isCrumbled; + + private MeshRenderer mesh; + // Start is called before the first frame update void Start() { - + isCrumbled = false; + mesh = GetComponent(); } // Update is called once per frame void Update() { - + if (isCrumbled) { + mesh.material = inactiveMaterial; + GetComponent().enabled = false; + } else { + mesh.material = activeMaterial; + GetComponent().enabled = true; + } + } + + public void Hit() { + isCrumbled = true; + StartCoroutine("Regenerate"); } - void OnCollisionEnter(Collision collision) { - Debug.Log("Collision enter for crumble"); + public IEnumerator Regenerate() { + yield return new WaitForSeconds(3f); + isCrumbled = false; } } diff --git a/Assets/Scripts/MoveController.cs b/Assets/Scripts/MoveController.cs index f5d689b..e2bc902 100644 --- a/Assets/Scripts/MoveController.cs +++ b/Assets/Scripts/MoveController.cs @@ -56,6 +56,10 @@ public class MoveController : MonoBehaviour collisions.above = true; } else { collisions.below = true; + Crumble crumble = hit.collider.gameObject.GetComponent(); + if (crumble) { + crumble.Hit(); + } } velocity.y = (hit.distance - skinWidth) * directionY; rayLength = hit.distance;