Commit bfb9119a authored by mmaluschnig's avatar mmaluschnig
Browse files

trigger script now opperates on the lowest falling key if there are multiple in a collider

parent 087d884b
......@@ -36,7 +36,7 @@ Transform:
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1765769401102260}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 5, y: 4, z: -5}
m_LocalPosition: {x: 5, y: 4, z: 0}
m_LocalScale: {x: 1.6, y: 1.6, z: 1}
m_Children: []
m_Father: {fileID: 0}
......
......@@ -136,7 +136,7 @@ Transform:
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 61287469}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: -5.01, y: 0, z: 0}
m_LocalPosition: {x: -2.48, y: 0, z: 0}
m_LocalScale: {x: 1.0000005, y: 1.0000005, z: 1}
m_Children: []
m_Father: {fileID: 855676381}
......@@ -197,7 +197,6 @@ GameObject:
m_Component:
- component: {fileID: 89139955}
- component: {fileID: 89139956}
- component: {fileID: 89139957}
m_Layer: 0
m_Name: LevelMaster
m_TagString: Untagged
......@@ -232,17 +231,65 @@ MonoBehaviour:
songFile: {fileID: 4900000, guid: d66310f56c0f0487b8df20890b29e5f6, type: 3}
arrowPrefab: {fileID: 1765769401102260, guid: 72656df34da634e679741c24832b3f36,
type: 2}
--- !u!114 &89139957
--- !u!1 &285270820
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 285270822}
- component: {fileID: 285270821}
m_Layer: 0
m_Name: TriggerManager
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!114 &285270821
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 89139954}
m_GameObject: {fileID: 285270820}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: 41d050973d7f949069907590e2c66c75, type: 3}
m_Script: {fileID: 11500000, guid: 82a4931dfb6f441169be246ab4d239ed, type: 3}
m_Name:
m_EditorClassIdentifier:
perfectCollider: {fileID: 421586391}
goodCollider: {fileID: 1746446293}
badCollider: {fileID: 1795598302}
perfectRope: {fileID: 1309197447}
sepparation: 1
filter:
useTriggers: 0
useLayerMask: 0
useDepth: 0
useOutsideDepth: 0
useNormalAngle: 0
useOutsideNormalAngle: 0
layerMask:
serializedVersion: 2
m_Bits: 0
minDepth: 0
maxDepth: 0
minNormalAngle: 0
maxNormalAngle: 0
--- !u!4 &285270822
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 285270820}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 5, y: -4, z: -0.033203125}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 5
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &375935313
GameObject:
m_ObjectHideFlags: 0
......@@ -266,7 +313,7 @@ Transform:
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 375935313}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: -0, y: -1, z: 0}
m_LocalPosition: {x: 2.51, y: -1, z: 0}
m_LocalScale: {x: 1.0000005, y: 1.0000005, z: 1}
m_Children: []
m_Father: {fileID: 855676381}
......@@ -318,60 +365,6 @@ SpriteRenderer:
m_WasSpriteAssigned: 1
m_MaskInteraction: 0
m_SpriteSortPoint: 0
--- !u!1 &405112373
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 405112374}
- component: {fileID: 405112375}
m_Layer: 0
m_Name: Left trigger (1)
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &405112374
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 405112373}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 1, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 2015949860}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!61 &405112375
BoxCollider2D:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 405112373}
m_Enabled: 1
m_Density: 1
m_Material: {fileID: 0}
m_IsTrigger: 1
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!1 &421586389
GameObject:
m_ObjectHideFlags: 0
......@@ -382,7 +375,7 @@ GameObject:
- component: {fileID: 421586390}
- component: {fileID: 421586391}
m_Layer: 0
m_Name: Left perfect trigger
m_Name: perfect trigger
m_TagString: Perfect
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
......@@ -398,7 +391,7 @@ Transform:
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 1537712232}
m_Father: {fileID: 883848910}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!61 &421586391
......@@ -424,7 +417,7 @@ BoxCollider2D:
adaptiveTiling: 0
m_AutoTiling: 0
serializedVersion: 2
m_Size: {x: 1, y: 0.1}
m_Size: {x: 0.9, y: 0.15}
m_EdgeRadius: 0
--- !u!1 &519420028
GameObject:
......@@ -526,7 +519,7 @@ Transform:
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 730121062}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: -5.01, y: -2.0000002, z: 0}
m_LocalPosition: {x: -2.48, y: -2, z: 0}
m_LocalScale: {x: 1.0000005, y: 1.0000005, z: 1}
m_Children: []
m_Father: {fileID: 855676381}
......@@ -601,7 +594,7 @@ Transform:
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 747950581}
m_LocalRotation: {x: 0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalPosition: {x: 2.51, y: -0, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 855676381}
......@@ -675,7 +668,7 @@ Transform:
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 855676380}
m_LocalRotation: {x: -0, y: -0, z: 0.7071068, w: 0.7071068}
m_LocalPosition: {x: 5, y: 2.52, z: 1}
m_LocalPosition: {x: 5, y: 0, z: 10}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 747950582}
......@@ -686,9 +679,41 @@ Transform:
- {fileID: 884924692}
- {fileID: 730121063}
- {fileID: 1490052202}
- {fileID: 1309197448}
m_Father: {fileID: 0}
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &883848909
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 883848910}
m_Layer: 0
m_Name: Triggers
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &883848910
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 883848909}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 5, y: -4, z: -0.033203125}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 421586390}
- {fileID: 1746446292}
- {fileID: 1795598301}
m_Father: {fileID: 0}
m_RootOrder: 4
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &884924691
GameObject:
m_ObjectHideFlags: 0
......@@ -712,7 +737,7 @@ Transform:
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 884924691}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: -5.01, y: -1.0000001, z: 0}
m_LocalPosition: {x: -2.48, y: -1, z: 0}
m_LocalScale: {x: 1.0000005, y: 1.0000005, z: 1}
m_Children: []
m_Father: {fileID: 855676381}
......@@ -764,6 +789,81 @@ SpriteRenderer:
m_WasSpriteAssigned: 1
m_MaskInteraction: 0
m_SpriteSortPoint: 0
--- !u!1 &1309197447
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1309197448}
- component: {fileID: 1309197449}
m_Layer: 0
m_Name: perfect rope
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &1309197448
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1309197447}
m_LocalRotation: {x: 0, y: 0, z: 0.7071068, w: 0.7071068}
m_LocalPosition: {x: -4.05, y: -1.64, z: 0}
m_LocalScale: {x: 1.0000005, y: 1.0000005, z: 1}
m_Children: []
m_Father: {fileID: 855676381}
m_RootOrder: 8
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 90}
--- !u!212 &1309197449
SpriteRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1309197447}
m_Enabled: 1
m_CastShadows: 0
m_ReceiveShadows: 0
m_DynamicOccludee: 1
m_MotionVectors: 1
m_LightProbeUsage: 1
m_ReflectionProbeUsage: 1
m_RenderingLayerMask: 4294967295
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: 21300000, guid: abc7c8627cab5494da8e4bd5f24a5796, type: 3}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_FlipX: 0
m_FlipY: 0
m_DrawMode: 0
m_Size: {x: 5, y: 0.86}
m_AdaptiveModeThreshold: 0.5
m_SpriteTileMode: 0
m_WasSpriteAssigned: 1
m_MaskInteraction: 0
m_SpriteSortPoint: 0
--- !u!1001 &1337961999
Prefab:
m_ObjectHideFlags: 0
......@@ -803,11 +903,6 @@ Prefab:
propertyPath: m_RootOrder
value: 2
objectReference: {fileID: 0}
- target: {fileID: 61597912326454196, guid: 72656df34da634e679741c24832b3f36,
type: 2}
propertyPath: m_Size.y
value: 0.02
objectReference: {fileID: 0}
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 72656df34da634e679741c24832b3f36, type: 2}
m_IsPrefabAsset: 0
......@@ -834,7 +929,7 @@ Transform:
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1436390536}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: -0.00000011920929, y: -2, z: 0}
m_LocalPosition: {x: 2.51, y: -2, z: 0}
m_LocalScale: {x: 1.0000005, y: 1.0000005, z: 1}
m_Children: []
m_Father: {fileID: 855676381}
......@@ -909,7 +1004,7 @@ Transform:
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1477440284}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: -0.00000011920929, y: -3, z: 0}
m_LocalPosition: {x: 2.51, y: -3, z: 0}
m_LocalScale: {x: 1.0000005, y: 1.0000005, z: 1}
m_Children: []
m_Father: {fileID: 855676381}
......@@ -984,7 +1079,7 @@ Transform:
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1490052201}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: -5.01, y: -3.0000005, z: 0}
m_LocalPosition: {x: -2.48, y: -3, z: 0}
m_LocalScale: {x: 1.0000005, y: 1.0000005, z: 1}
m_Children: []
m_Father: {fileID: 855676381}
......@@ -1036,62 +1131,111 @@ SpriteRenderer:
m_WasSpriteAssigned: 1
m_MaskInteraction: 0
m_SpriteSortPoint: 0
--- !u!1 &1537712231
--- !u!1 &1746446291
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1537712232}
- component: {fileID: 1746446292}
- component: {fileID: 1746446293}
m_Layer: 0
m_Name: Perfect Triggers
m_TagString: Untagged
m_Name: Good Trigger
m_TagString: Perfect
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &1537712232
--- !u!4 &1746446292
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1537712231}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_GameObject: {fileID: 1746446291}
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:
- {fileID: 421586390}
m_Father: {fileID: 2015949860}
m_Children: []
m_Father: {fileID: 883848910}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &2015949859
--- !u!61 &1746446293
BoxCollider2D:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1746446291}
m_Enabled: 1
m_Density: 1
m_Material: {fileID: 0}
m_IsTrigger: 1
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: 0.9, y: 0.4}
m_EdgeRadius: 0
--- !u!1 &1795598300
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 2015949860}
- component: {fileID: 1795598301}
- component: {fileID: 1795598302}
m_Layer: 0
m_Name: Triggers
m_TagString: Untagged
m_Name: Bad Trigger
m_TagString: Perfect
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &2015949860
--- !u!4 &1795598301
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 2015949859}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 5, y: -4, z: -0.033203125}
m_GameObject: {fileID: 1795598300}
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:
- {fileID: 405112374}
- {fileID: 1537712232}
m_Father: {fileID: 0}
m_RootOrder: 4
m_Children: []
m_Father: {fileID: 883848910}
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!61 &1795598302
BoxCollider2D:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1795598300}
m_Enabled: 1
m_Density: 1
m_Material: {fileID: 0}
m_IsTrigger: 1
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: 0.9, y: 8}
m_EdgeRadius: 0
......@@ -2,18 +2,21 @@
using System.Collections.Generic;
using UnityEngine;
public class TriggerManager : MonoBehaviour {
public class TriggerManager : MonoBehaviour
{
public Collider2D perfectCollider;
public Collider2D goodCollider;
public Collider2D badCollider;
public GameObject perfectRope;
//the distance between the centre of each trigger area.
public float sepparation = 1f;
public ContactFilter2D filter = new ContactFilter2D();
enum keys {left = 0, right = 3, up = 1, down = 2}
enum keys { left = 0, right = 3, up = 1, down = 2 }
// Use this for initialization
void Start()
......@@ -52,34 +55,68 @@ public class TriggerManager : MonoBehaviour {
bool checkCollider(Collider2D c)
{
var results = new Collider2D[10];
if(c.OverlapCollider(filter,results) != 0){
Collider2D[] results = new Collider2D[10];
int numColliders = c.OverlapCollider(filter, results);
//print("Num: " + numColliders);
if (numColliders <= 0)
{
return false;
}
else if (numColliders == 1)
{
//("YES");
Destroy(results[0].gameObject);
return true;
}
else
{
//find the gameobject with the lowest y value.
//another (less opperation heavy option could be to hold an
//ordered list of the falling keys but thats too much admin.
int lowestIndex = 0;
float lowestValue = results[0].GetComponentInParent<Transform>().position.y;
for (int i = 0; i < numColliders; i++)
{
float thisValue = results[i].GetComponentInParent<Transform>().position.y;
if (thisValue < lowestValue)
{
lowestIndex = i;
lowestValue = thisValue;
}
}
Destroy(results[lowestIndex].gameObject);
return true;
}
return false;
}