Commit 6336f2dc authored by Mitchie Maluschnig's avatar Mitchie Maluschnig
Browse files

added special trapezes which player can collect, also tracks the number of fliips the player does

parent bbf0b1a0
......@@ -6,5 +6,5 @@ PhysicsMaterial2D:
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_Name: SideWall
friction: 0.4
friction: 0
bounciness: 0.2
......@@ -144,7 +144,7 @@ MonoBehaviour:
m_Script: {fileID: 11500000, guid: f33e79404d5b5fd41b00e377f96d109d, type: 3}
m_Name:
m_EditorClassIdentifier:
lifeTime: 1
lifeTime: 2
--- !u!198 &198279119958671290
ParticleSystem:
m_ObjectHideFlags: 1
......
%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_SourcePrefab: {fileID: 0}
m_RootGameObject: {fileID: 1140605560837190}
m_IsPrefabAsset: 1
--- !u!1 &1140605560837190
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
serializedVersion: 6
m_Component:
- component: {fileID: 4904109785098498}
- component: {fileID: 212916306437539460}
- component: {fileID: 70256452550416304}
- component: {fileID: 114685032441255122}
m_Layer: 8
m_Name: SpecialTrapeze
m_TagString: Pie
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!1 &1649884426353186
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
serializedVersion: 6
m_Component:
- component: {fileID: 4218138701822224}
- component: {fileID: 212903321114658726}
m_Layer: 0
m_Name: creamPie
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!4 &4218138701822224
Transform:
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1649884426353186}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0.45, z: 0}
m_LocalScale: {x: 3, y: 3, z: 1}
m_Children: []
m_Father: {fileID: 4904109785098498}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!4 &4904109785098498
Transform:
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1140605560837190}
m_LocalRotation: {x: -0, y: -0, z: -0, w: 1}
m_LocalPosition: {x: -19.04, y: -55.829998, z: 0}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children:
- {fileID: 4218138701822224}
m_Father: {fileID: 0}
m_RootOrder: 0
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!70 &70256452550416304
CapsuleCollider2D:
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1140605560837190}
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.06}
m_Size: {x: 5, y: 0.6}
m_Direction: 1
--- !u!114 &114685032441255122
MonoBehaviour:
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1140605560837190}
m_Enabled: 1
m_EditorHideFlags: 0
m_Script: {fileID: 11500000, guid: bbf42f3430dfc5b48a94215583091a1d, type: 3}
m_Name:
m_EditorClassIdentifier:
points: 10
specialItem: {fileID: 1649884426353186}
OnCollectParticles: {fileID: 1301897093530838, guid: fe523caf0352a7547a3f1404bd46b43d,
type: 2}
--- !u!212 &212903321114658726
SpriteRenderer:
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1649884426353186}
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: 0b8ef5caf917b91458ec8edc45766835, 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.42, y: 0.28}
m_AdaptiveModeThreshold: 0.5
m_SpriteTileMode: 0
m_WasSpriteAssigned: 1
m_MaskInteraction: 0
m_SpriteSortPoint: 0
--- !u!212 &212916306437539460
SpriteRenderer:
m_ObjectHideFlags: 1
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 100100000}
m_GameObject: {fileID: 1140605560837190}
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
fileFormatVersion: 2
guid: d9eae21df7f7349429f09e42b02d7a23
NativeFormatImporter:
externalObjects: {}
mainObjectFileID: 100100000
userData:
assetBundleName:
assetBundleVariant:
......@@ -23,7 +23,7 @@ GameObject:
- component: {fileID: 70346896267999526}
- component: {fileID: 68677398153341540}
m_Layer: 8
m_Name: rope 1
m_Name: StandardTrapeze
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
......
......@@ -380,6 +380,81 @@ CanvasRenderer:
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 113816536}
m_CullTransparentMesh: 0
--- !u!1 &124138635
GameObject:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
serializedVersion: 6
m_Component:
- component: {fileID: 124138637}
- component: {fileID: 124138636}
m_Layer: 0
m_Name: cole tent (1)
m_TagString: Untagged
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
m_IsActive: 1
--- !u!212 &124138636
SpriteRenderer:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 124138635}
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: -1966733235
m_SortingLayer: 2
m_SortingOrder: 0
m_Sprite: {fileID: 21300000, guid: 9dcfcb216d85dd449816699afb0499e6, type: 3}
m_Color: {r: 1, g: 1, b: 1, a: 1}
m_FlipX: 0
m_FlipY: 0
m_DrawMode: 0
m_Size: {x: 10, y: 5}
m_AdaptiveModeThreshold: 0.5
m_SpriteTileMode: 0
m_WasSpriteAssigned: 1
m_MaskInteraction: 0
m_SpriteSortPoint: 0
--- !u!4 &124138637
Transform:
m_ObjectHideFlags: 0
m_CorrespondingSourceObject: {fileID: 0}
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 124138635}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 10.47, y: 4.16, z: 0}
m_LocalScale: {x: 4, y: 3.7, z: 1}
m_Children: []
m_Father: {fileID: 0}
m_RootOrder: 10
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
--- !u!1 &134449645
GameObject:
m_ObjectHideFlags: 0
......@@ -1175,7 +1250,7 @@ Camera:
far clip plane: 1000
field of view: 60
orthographic: 1
orthographic size: 5
orthographic size: 8
m_Depth: -1
m_CullingMask:
serializedVersion: 2
......@@ -1198,7 +1273,7 @@ Transform:
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 519420028}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 0, y: 0, z: -10}
m_LocalPosition: {x: 0, y: 2.92, z: -10}
m_LocalScale: {x: 1, y: 1, z: 1}
m_Children: []
m_Father: {fileID: 0}
......@@ -1494,7 +1569,7 @@ RectTransform:
m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0}
m_AnchorMin: {x: 0, y: 0}
m_AnchorMax: {x: 1, y: 1}
m_AnchoredPosition: {x: 54.999985, y: -46}
m_AnchoredPosition: {x: 55, y: -46}
m_SizeDelta: {x: -130, y: -108}
m_Pivot: {x: 0.5, y: 0.5}
--- !u!114 &850495251
......@@ -7861,8 +7936,8 @@ SpriteRenderer:
m_AutoUVMaxDistance: 0.5
m_AutoUVMaxAngle: 89
m_LightmapParameters: {fileID: 0}
m_SortingLayerID: -1106870113
m_SortingLayer: 1
m_SortingLayerID: -1966733235
m_SortingLayer: 2
m_SortingOrder: 1
m_Sprite: {fileID: 21300000, guid: 9dcfcb216d85dd449816699afb0499e6, type: 3}
m_Color: {r: 1, g: 1, b: 1, a: 1}
......@@ -7882,7 +7957,7 @@ Transform:
m_PrefabInternal: {fileID: 0}
m_GameObject: {fileID: 1977796532}
m_LocalRotation: {x: 0, y: 0, z: 0, w: 1}
m_LocalPosition: {x: 14.555, y: 1.26, z: 0}
m_LocalPosition: {x: 12.13, y: 1.32, z: 0}
m_LocalScale: {x: 2.5099998, y: 2.15, z: 1}
m_Children: []
m_Father: {fileID: 0}
......
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
//taken from:
//https://forum.unity.com/threads/counting-an-objects-rotations.4170/
public class CountRotations : MonoBehaviour {
private float totalRotation = 0;
public int nrOfRotations {
get {
return ((int)totalRotation) / 360;
}
}
private Vector3 lastPoint;
// Use this for initialization
void Start() {
lastPoint = transform.TransformDirection(Vector3.right);
lastPoint.z = 0;
}
// Update is called once per frame
void Update() {
Vector3 facing = transform.TransformDirection(Vector3.right);
facing.z = 0;
float angle = Vector3.Angle(lastPoint, facing);
if (Vector3.Cross(lastPoint, facing).z < 0)
angle *= -1;
totalRotation += angle;
lastPoint = facing;
}
public void resetCounter() {
totalRotation = 0;
lastPoint = transform.TransformDirection(Vector3.right);
}
}
fileFormatVersion: 2
guid: 297674a11bfe68e42b79507cd3da50f8
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
......@@ -5,6 +5,7 @@ using UnityEngine;
public class GenerateTrapezes : MonoBehaviour {
public GameObject trapeze;
public GameObject specialTrapeze;
public float AvgXSepparation = 10;
public float XDifference = 0.8f;
......@@ -84,10 +85,14 @@ public class GenerateTrapezes : MonoBehaviour {
for (int i = 0; i < currentTrapezeInLevel.Length; i++) {
if (currentTrapezeInLevel[i].position.x <= playerHands.position.x + 2 * AvgXSepparation/*use camera stuff maybe*/) {
GameObject thisTrapeze = trapeze;
if (i == 0) {
//top tier
YScaler += Random.Range(minYProgression, maxYProgression) * progression;
//random chance of spawning a collectable
if(Random.Range(0,1f) < 0.2) {
thisTrapeze = specialTrapeze;
}
} else if (i == 2) {
//middle tier
} else {
......@@ -103,7 +108,7 @@ public class GenerateTrapezes : MonoBehaviour {
newTrapeze.x += XScaler;
newTrapeze.y += YScaler;
//print("X " + XScaler + "Y " + YScaler);
currentTrapezeInLevel[i] = Instantiate(trapeze, newTrapeze, Quaternion.identity).transform;
currentTrapezeInLevel[i] = Instantiate(thisTrapeze, newTrapeze, Quaternion.identity).transform;
numTrapezes++;
}
}
......
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class SpecialTrapeze : MonoBehaviour {
public int points;
private bool collected;
public GameObject specialItem;
public GameObject OnCollectParticles;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
public void setCollected() {
if (!collected) {
collected = true;
TrapezeController.collected += 1;
TrapezeController.score += points;
specialItem.SetActive(false);
Instantiate(OnCollectParticles, transform);
}
}
}
fileFormatVersion: 2
guid: bbf42f3430dfc5b48a94215583091a1d
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class TrapezeController : MonoBehaviour {
public static float score;
public static int collected;
public static float TimeRemaining;
public Text ScoreText;
public Text CollectedText;
public Text TimeRemainingText;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
}
private void FixedUpdate() {
ScoreText.text = score.ToString();
CollectedText.text = collected.ToString();
TimeRemainingText.text = TimeRemaining.ToString();
}
}
fileFormatVersion: 2
guid: ff1761de81c540148b7f1898de9309f5
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
......@@ -13,7 +13,8 @@ public class TrapezePerson : MonoBehaviour {
private HingeJoint2D hinge;
private Rigidbody2D body;
private HandsTrigger handsTrigger;
private HandsTrigger handsTrigger;
private CountRotations rotations;
[HideInInspector]
public Transform currentPivot;
......@@ -23,18 +24,21 @@ public class TrapezePerson : MonoBehaviour {
private float linearVelocity;
// Use this for initialization
void Start () {
currentPivot = midPivot;
hinge = GetComponent<HingeJoint2D>();
body = GetComponent<Rigidbody2D>();
handsTrigger = GetComponentInChildren<HandsTrigger>();
rotations = GetComponent<CountRotations>();
}
// Update is called once per frame
void Update () {
//checkRotations();
print(rotations.nrOfRotations);
if (Input.GetKey(KeyCode.D) || Input.GetKeyDown(KeyCode.RightArrow)) {
if (onTrapeze) {
body.AddTorque(swingForce / 10);
......@@ -68,6 +72,11 @@ public class TrapezePerson : MonoBehaviour {
currentTrapeze = trapeze;
Time.timeScale = 1;
body.freezeRotation = false;
//check if trapeze is a special trapeze
if(trapeze.tag == "Pie") {
trapeze.GetComponent<SpecialTrapeze>().setCollected();
}
}