Commit 68674c4b authored by mmaluschnig's avatar mmaluschnig
Browse files

changed the way that the triggerMaster works, Fixes #1. added arrow keys to show direction

parent 92967f4a
......@@ -79,6 +79,7 @@ MonoBehaviour:
m_Name:
m_EditorClassIdentifier:
speed: 1
points: 10
--- !u!212 &212894587835513782
SpriteRenderer:
m_ObjectHideFlags: 1
......
......@@ -240,6 +240,7 @@ GameObject:
m_Component:
- component: {fileID: 285270822}
- component: {fileID: 285270821}
- component: {fileID: 285270823}
m_Layer: 0
m_Name: TriggerManager
m_TagString: Untagged
......@@ -290,6 +291,68 @@ Transform:
m_Father: {fileID: 0}
m_RootOrder: 5
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!114 &285270823
MonoBehaviour:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 285270820}
m_Enabled: 0
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: ae4d8813173274796beae00096b04f90, 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!1 &300922560
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 300922561}
m_Layer: 0
m_Name: KeyImages
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &300922561
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 300922560}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 5, y: -4, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 1066211165}
- {fileID: 1404625502}
- {fileID: 1026491903}
- {fileID: 1124755066}
m_Father: {fileID: 0}
m_RootOrder: 6
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &375935313
GameObject:
m_ObjectHideFlags: 0
......@@ -789,6 +852,231 @@ SpriteRenderer:
m_WasSpriteAssigned: 1
m_MaskInteraction: 0
m_SpriteSortPoint: 0
--- !u!1 &1026491902
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1026491903}
- component: {fileID: 1026491904}
m_Layer: 0
m_Name: down
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &1026491903
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1026491902}
m_LocalRotation: {x: 0, y: 0, z: 1, w: 0}
m_LocalPosition: {x: 2, y: 0, z: 0}
m_LocalScale: {x: 0.29999998, y: 0.29999998, z: 1}
m_Children: []
m_Father: {fileID: 300922561}
m_RootOrder: 2
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 180}
--- !u!212 &1026491904
SpriteRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1026491902}
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: 9731ee7c67f86481aab7cece5317c667, type: 3}
m_Color: {r: 0, g: 0, b: 0, a: 1}
m_FlipX: 0
m_FlipY: 0
m_DrawMode: 0
m_Size: {x: 5.12, y: 5.12}
m_AdaptiveModeThreshold: 0.5
m_SpriteTileMode: 0
m_WasSpriteAssigned: 1
m_MaskInteraction: 0
m_SpriteSortPoint: 0
--- !u!1 &1066211164
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1066211165}
- component: {fileID: 1066211166}
m_Layer: 0
m_Name: left
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &1066211165
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1066211164}
m_LocalRotation: {x: 0, y: 0, z: 0.7071068, w: 0.7071068}
m_LocalPosition: {x: 0, y: 0, z: 0}
m_LocalScale: {x: 0.3, y: 0.3, z: 1}
m_Children: []
m_Father: {fileID: 300922561}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 90}
--- !u!212 &1066211166
SpriteRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1066211164}
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: 9731ee7c67f86481aab7cece5317c667, type: 3}
m_Color: {r: 0, g: 0, b: 0, a: 1}
m_FlipX: 0
m_FlipY: 0
m_DrawMode: 0
m_Size: {x: 5.12, y: 5.12}
m_AdaptiveModeThreshold: 0.5
m_SpriteTileMode: 0
m_WasSpriteAssigned: 1
m_MaskInteraction: 0
m_SpriteSortPoint: 0
--- !u!1 &1124755065
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1124755066}
- component: {fileID: 1124755067}
m_Layer: 0
m_Name: right
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &1124755066
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1124755065}
m_LocalRotation: {x: 0, y: -0, z: 0.7071068, w: -0.7071068}
m_LocalPosition: {x: 3, y: 0, z: 0}
m_LocalScale: {x: 0.29999998, y: 0.29999998, z: 1}
m_Children: []
m_Father: {fileID: 300922561}
m_RootOrder: 3
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 270}
--- !u!212 &1124755067
SpriteRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1124755065}
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: 9731ee7c67f86481aab7cece5317c667, type: 3}
m_Color: {r: 0, g: 0, b: 0, a: 1}
m_FlipX: 0
m_FlipY: 0
m_DrawMode: 0
m_Size: {x: 5.12, y: 5.12}
m_AdaptiveModeThreshold: 0.5
m_SpriteTileMode: 0
m_WasSpriteAssigned: 1
m_MaskInteraction: 0
m_SpriteSortPoint: 0
--- !u!1 &1309197447
GameObject:
m_ObjectHideFlags: 0
......@@ -877,7 +1165,7 @@ Prefab:
objectReference: {fileID: 0}
- target: {fileID: 4145066122545122, guid: 72656df34da634e679741c24832b3f36, type: 2}
propertyPath: m_LocalPosition.y
value: 4
value: -3.994
objectReference: {fileID: 0}
- target: {fileID: 4145066122545122, guid: 72656df34da634e679741c24832b3f36, type: 2}
propertyPath: m_LocalPosition.z
......@@ -906,6 +1194,81 @@ Prefab:
m_RemovedComponents: []
m_SourcePrefab: {fileID: 100100000, guid: 72656df34da634e679741c24832b3f36, type: 2}
m_IsPrefabAsset: 0
--- !u!1 &1404625501
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 1404625502}
- component: {fileID: 1404625503}
m_Layer: 0
m_Name: up
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &1404625502
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1404625501}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: 1, y: 0, z: 0}
m_LocalScale: {x: 0.29999998, y: 0.29999998, z: 1}
m_Children: []
m_Father: {fileID: 300922561}
m_RootOrder: 1
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!212 &1404625503
SpriteRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1404625501}
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: 9731ee7c67f86481aab7cece5317c667, type: 3}
m_Color: {r: 0, g: 0, b: 0, a: 1}
m_FlipX: 0
m_FlipY: 0
m_DrawMode: 0
m_Size: {x: 5.12, y: 5.12}
m_AdaptiveModeThreshold: 0.5
m_SpriteTileMode: 0
m_WasSpriteAssigned: 1
m_MaskInteraction: 0
m_SpriteSortPoint: 0
--- !u!1 &1436390536
GameObject:
m_ObjectHideFlags: 0
......@@ -1183,7 +1546,7 @@ BoxCollider2D:
adaptiveTiling: 0
m_AutoTiling: 0
serializedVersion: 2
m_Size: {x: 0.9, y: 0.4}
m_Size: {x: 0.9, y: 0.6}
m_EdgeRadius: 0
--- !u!1 &1795598300
GameObject:
......
......@@ -5,6 +5,7 @@ using UnityEngine;
public class Key : MonoBehaviour {
public float speed = 1f;
public int points = 10;
// Use this for initialization
void Start () {
......@@ -14,5 +15,14 @@ public class Key : MonoBehaviour {
// Update is called once per frame
void Update () {
transform.Translate(Vector3.down * speed * Time.deltaTime);
if(!isVisible()){
Destroy(gameObject);
}
}
bool isVisible(){
Plane[] planes = GeometryUtility.CalculateFrustumPlanes(Camera.main);
return GeometryUtility.TestPlanesAABB(planes, GetComponent<Renderer>().bounds);
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MimeMime : MonoBehaviour {
public static float playerScore;
public static void PerfectHit(Key key)
{
playerScore += key.points;
}
public static void GoodHit(Key key)
{
playerScore += key.points * 0.8f;
}
public static void BadHit(Key key)
{
playerScore += key.points * 0.5f;
}
}
fileFormatVersion: 2
guid: f97b2260046fd4ce0b2c794deecbd1ca
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class TestTrigger : MonoBehaviour
{
/* TODO:
* currently trigger will test perfect->good->bad hit boxes for any keys
* inside them and then choose the lowest of them i.e. perfect will always
* be picked even if its not the lowest key.
* Later:
* when the player presses a key, find the lowest of all the keys in that
* line and then test perfect-->good-->bad for that key alone.
* i.e. always calculate value of lowst key in the line the player presses.
*/
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 }
// Use this for initialization
void Start()
{
filter.SetLayerMask(LayerMask.GetMask("Key"));
}
// Update is called once per frame
void Update()
{
//Check which key the player presses
if (Input.GetKeyDown(KeyCode.LeftArrow))
{
moveColliders((int)keys.left);
checkAllColliders();
}
if (Input.GetKeyDown(KeyCode.RightArrow))
{
moveColliders((int)keys.right);
checkAllColliders();
}
if (Input.GetKeyDown(KeyCode.UpArrow))
{
moveColliders((int)keys.up);
checkAllColliders();
}
if (Input.GetKeyDown(KeyCode.DownArrow))
{
moveColliders((int)keys.down);
checkAllColliders();
}
}
bool checkCollider(Collider2D c)
{
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;
}
}
void moveColliders(int key)
{
perfectCollider.offset = new Vector2(key * sepparation, perfectCollider.offset.y);
goodCollider.offset = new Vector2(key * sepparation, goodCollider.offset.y);
badCollider.offset = new Vector2(key * sepparation, badCollider.offset.y);
}
void checkAllColliders()
{
if (checkCollider(perfectCollider))