diff options
Diffstat (limited to 'nGJ2019/Assets/Scripts')
-rw-r--r-- | nGJ2019/Assets/Scripts/LevelScrolling.cs | 6 | ||||
-rw-r--r-- | nGJ2019/Assets/Scripts/ObstacleSpawner.cs | 1 | ||||
-rw-r--r-- | nGJ2019/Assets/Scripts/RockJaws.cs | 37 |
3 files changed, 41 insertions, 3 deletions
diff --git a/nGJ2019/Assets/Scripts/LevelScrolling.cs b/nGJ2019/Assets/Scripts/LevelScrolling.cs index 025bf40..0122a69 100644 --- a/nGJ2019/Assets/Scripts/LevelScrolling.cs +++ b/nGJ2019/Assets/Scripts/LevelScrolling.cs @@ -4,7 +4,7 @@ using UnityEngine; public class LevelScrolling : MonoBehaviour
{
- public int UpdateRate = 1;
+ public int UpdateRate = -5;
public List<Transform> Obstacles;
public Transform Background;
@@ -56,14 +56,14 @@ public class LevelScrolling : MonoBehaviour {
foreach (var o in Obstacles)
{
- o.Translate(new Vector2(0.01f * UpdateRate, 0));
+ o.Translate(0.01f * UpdateRate, 0, 0);
}
}
private void MoveBackground()
{
if (Background.position.x > -initialBgPos.x)
- Background.Translate(new Vector2(0.01f * UpdateRate, 0));
+ Background.Translate(0.01f * UpdateRate, 0, 0);
else Background.position = initialBgPos;
}
}
diff --git a/nGJ2019/Assets/Scripts/ObstacleSpawner.cs b/nGJ2019/Assets/Scripts/ObstacleSpawner.cs index a9d1078..c285352 100644 --- a/nGJ2019/Assets/Scripts/ObstacleSpawner.cs +++ b/nGJ2019/Assets/Scripts/ObstacleSpawner.cs @@ -47,6 +47,7 @@ public class ObstacleSpawner : MonoBehaviour timeline.Add(2, 2.75f, ObstacleType.rockTop); timeline.Add(8, -2, ObstacleType.rockBottom); timeline.Add(20, 0, ObstacleType.narrowPassage); + timeline.Add(30, 0, ObstacleType.rockJaws); timeline.OnSpawnEvent += spawnOnEvent; } diff --git a/nGJ2019/Assets/Scripts/RockJaws.cs b/nGJ2019/Assets/Scripts/RockJaws.cs new file mode 100644 index 0000000..a161dfe --- /dev/null +++ b/nGJ2019/Assets/Scripts/RockJaws.cs @@ -0,0 +1,37 @@ +using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+
+public class RockJaws : MonoBehaviour
+{
+ public Transform TopJaw;
+ public Transform BottomJaw;
+ public int Speed = 10;
+ private bool reverse = false;
+ private float initialTopJawY;
+ // Start is called before the first frame update
+ void Start()
+ {
+ initialTopJawY = TopJaw.localPosition.y;
+ }
+
+ // Update is called once per frame
+ void Update()
+ {
+
+ }
+
+ void FixedUpdate()
+ {
+ if (TopJaw.localPosition.y < BottomJaw.localPosition.y) reverse = true;
+ else if(TopJaw.localPosition.y > initialTopJawY) reverse = false;
+
+ if (!reverse) {
+ TopJaw.Translate(0, -0.01f * Speed, 0);
+ BottomJaw.Translate(0, 0.01f * Speed, 0);
+ } else {
+ TopJaw.Translate(0, 0.01f * Speed, 0);
+ BottomJaw.Translate(0, -0.01f * Speed, 0);
+ }
+ }
+}
|