From 7d10afcbf94d0c3f2d34ec538049289db95bec1d Mon Sep 17 00:00:00 2001 From: Kayne Ruse Date: Sat, 21 Apr 2018 15:03:13 +1000 Subject: [PATCH] Wind blows over gaps --- Assets/Prefabs/Block_Water.prefab | 124 +++++++++++++++++++++++++ Assets/Prefabs/Block_Water.prefab.meta | 10 ++ Assets/Scripts/Blocks/BlockGap.cs | 6 ++ Assets/Scripts/Blocks/BlockGap.cs.meta | 13 +++ Assets/Scripts/Blocks/BlockIce.cs | 11 +++ Assets/Scripts/Bomb.cs | 11 +++ Assets/Scripts/Damagers/WindDamager.cs | 2 +- 7 files changed, 176 insertions(+), 1 deletion(-) create mode 100644 Assets/Prefabs/Block_Water.prefab create mode 100644 Assets/Prefabs/Block_Water.prefab.meta create mode 100644 Assets/Scripts/Blocks/BlockGap.cs create mode 100644 Assets/Scripts/Blocks/BlockGap.cs.meta diff --git a/Assets/Prefabs/Block_Water.prefab b/Assets/Prefabs/Block_Water.prefab new file mode 100644 index 0000000..0bed1dc --- /dev/null +++ b/Assets/Prefabs/Block_Water.prefab @@ -0,0 +1,124 @@ +%YAML 1.1 +%TAG !u! tag:unity3d.com,2011: +--- !u!1001 &100100000 +Prefab: + m_ObjectHideFlags: 1 + serializedVersion: 2 + m_Modification: + m_TransformParent: {fileID: 0} + m_Modifications: [] + m_RemovedComponents: [] + m_ParentPrefab: {fileID: 0} + m_RootGameObject: {fileID: 1602245136708268} + m_IsPrefabParent: 1 +--- !u!1 &1602245136708268 +GameObject: + m_ObjectHideFlags: 0 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + serializedVersion: 5 + m_Component: + - component: {fileID: 4727204445767746} + - component: {fileID: 212692672482381216} + - component: {fileID: 61417820969500070} + - component: {fileID: 114653526516097830} + m_Layer: 0 + m_Name: Block_Water + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!4 &4727204445767746 +Transform: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1602245136708268} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0.309, y: 0.434, z: 0.09194599} + 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!61 &61417820969500070 +BoxCollider2D: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1602245136708268} + 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.5, y: 0.5} + oldSize: {x: 0.16, y: 0.16} + newSize: {x: 0.16, y: 0.16} + adaptiveTilingThreshold: 0.5 + drawMode: 0 + adaptiveTiling: 0 + m_AutoTiling: 0 + serializedVersion: 2 + m_Size: {x: 0.16, y: 0.16} + m_EdgeRadius: 0 +--- !u!114 &114653526516097830 +MonoBehaviour: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1602245136708268} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 07e0c3a4814d62f418256b87b1da3ed5, type: 3} + m_Name: + m_EditorClassIdentifier: +--- !u!212 &212692672482381216 +SpriteRenderer: + m_ObjectHideFlags: 1 + m_PrefabParentObject: {fileID: 0} + m_PrefabInternal: {fileID: 100100000} + m_GameObject: {fileID: 1602245136708268} + m_Enabled: 1 + m_CastShadows: 0 + m_ReceiveShadows: 0 + m_DynamicOccludee: 1 + m_MotionVectors: 1 + m_LightProbeUsage: 1 + m_ReflectionProbeUsage: 1 + m_Materials: + - {fileID: 10754, guid: 0000000000000000f000000000000000, type: 0} + m_StaticBatchInfo: + firstSubMesh: 0 + subMeshCount: 0 + m_StaticBatchRoot: {fileID: 0} + m_ProbeAnchor: {fileID: 0} + m_LightProbeVolumeOverride: {fileID: 0} + m_ScaleInLightmap: 1 + m_PreserveUVs: 0 + m_IgnoreNormalsForChartDetection: 0 + m_ImportantGI: 0 + m_StitchLightmapSeams: 0 + m_SelectedEditorRenderState: 0 + m_MinimumChartSize: 4 + m_AutoUVMaxDistance: 0.5 + m_AutoUVMaxAngle: 89 + m_LightmapParameters: {fileID: 0} + m_SortingLayerID: 0 + m_SortingLayer: 0 + m_SortingOrder: 0 + m_Sprite: {fileID: 21300004, guid: f0425e92c7345064ab2dccbd778f3b15, type: 3} + m_Color: {r: 1, g: 1, b: 1, a: 1} + m_FlipX: 0 + m_FlipY: 0 + m_DrawMode: 0 + m_Size: {x: 0.16, y: 0.16} + m_AdaptiveModeThreshold: 0.5 + m_SpriteTileMode: 0 + m_WasSpriteAssigned: 1 + m_MaskInteraction: 0 diff --git a/Assets/Prefabs/Block_Water.prefab.meta b/Assets/Prefabs/Block_Water.prefab.meta new file mode 100644 index 0000000..1222c4a --- /dev/null +++ b/Assets/Prefabs/Block_Water.prefab.meta @@ -0,0 +1,10 @@ +fileFormatVersion: 2 +guid: 05968d49eff9aa04b9087b76d2a70f50 +timeCreated: 1524286841 +licenseType: Free +NativeFormatImporter: + externalObjects: {} + mainObjectFileID: 100100000 + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Blocks/BlockGap.cs b/Assets/Scripts/Blocks/BlockGap.cs new file mode 100644 index 0000000..2843a86 --- /dev/null +++ b/Assets/Scripts/Blocks/BlockGap.cs @@ -0,0 +1,6 @@ +using System.Collections; +using System.Collections.Generic; +using UnityEngine; + +public class BlockGap : MonoBehaviour { +} diff --git a/Assets/Scripts/Blocks/BlockGap.cs.meta b/Assets/Scripts/Blocks/BlockGap.cs.meta new file mode 100644 index 0000000..27497ed --- /dev/null +++ b/Assets/Scripts/Blocks/BlockGap.cs.meta @@ -0,0 +1,13 @@ +fileFormatVersion: 2 +guid: 07e0c3a4814d62f418256b87b1da3ed5 +timeCreated: 1524286791 +licenseType: Free +MonoImporter: + externalObjects: {} + serializedVersion: 2 + defaultReferences: [] + executionOrder: 0 + icon: {instanceID: 0} + userData: + assetBundleName: + assetBundleVariant: diff --git a/Assets/Scripts/Blocks/BlockIce.cs b/Assets/Scripts/Blocks/BlockIce.cs index 6ae6f82..e7d5145 100644 --- a/Assets/Scripts/Blocks/BlockIce.cs +++ b/Assets/Scripts/Blocks/BlockIce.cs @@ -3,10 +3,16 @@ using System.Collections.Generic; using UnityEngine; public class BlockIce : MonoBehaviour { + Rigidbody2D rigidBody; + public float bombTimer = -1; public GameObject bombPrefab; + void Awake() { + rigidBody = GetComponent (); + } + void OnTriggerEnter2D(Collider2D collider) { //TODO: use durability class? FireDamager fire = collider.gameObject.GetComponent (); @@ -18,5 +24,10 @@ public class BlockIce : MonoBehaviour { } Destroy (gameObject); } + + WindDamager wind = collider.gameObject.GetComponent (); + if (wind != null) { + rigidBody.AddForce (collider.gameObject.GetComponent ().velocity * 20, ForceMode2D.Impulse); + } } } diff --git a/Assets/Scripts/Bomb.cs b/Assets/Scripts/Bomb.cs index 69e4572..bf619ec 100644 --- a/Assets/Scripts/Bomb.cs +++ b/Assets/Scripts/Bomb.cs @@ -3,6 +3,8 @@ using System.Collections.Generic; using UnityEngine; public class Bomb : MonoBehaviour { + Rigidbody2D rigidBody; + public float timer; GameObject explosion; @@ -10,6 +12,10 @@ public class Bomb : MonoBehaviour { float birthTime; + void Awake() { + rigidBody = GetComponent (); + } + void Start() { StartCoroutine (ExplodeAfter (timer)); @@ -32,6 +38,11 @@ public class Bomb : MonoBehaviour { iceBlock.GetComponent ().bombTimer = timer - (Time.time - birthTime); Destroy (gameObject); } + + WindDamager wind = collider.gameObject.GetComponent (); + if (wind != null) { + rigidBody.AddForce (collider.gameObject.GetComponent ().velocity / 2, ForceMode2D.Impulse); + } } IEnumerator ExplodeAfter(float delay) { diff --git a/Assets/Scripts/Damagers/WindDamager.cs b/Assets/Scripts/Damagers/WindDamager.cs index e697bc2..7ed0901 100644 --- a/Assets/Scripts/Damagers/WindDamager.cs +++ b/Assets/Scripts/Damagers/WindDamager.cs @@ -5,7 +5,7 @@ using UnityEngine; //shootable public class WindDamager : DamagerBase { void OnTriggerEnter2D(Collider2D collider) { - if (collider.gameObject.GetComponent () == null) { //pass through other instances of self + if (collider.gameObject.GetComponent () == null && collider.gameObject.GetComponent () == null) { Destroy (gameObject); } }