diff options
-rw-r--r-- | nGJ2019/Assets/Prefabs/CaveWalls.prefab | 4 | ||||
-rw-r--r-- | nGJ2019/Assets/Prefabs/NarrowPassage.prefab | 4 | ||||
-rw-r--r-- | nGJ2019/Assets/Prefabs/ObstacleRockBottom.prefab | 2 | ||||
-rw-r--r-- | nGJ2019/Assets/Prefabs/ObstacleRockTop.prefab | 2 | ||||
-rw-r--r-- | nGJ2019/Assets/Prefabs/RockJaws.prefab | 14 | ||||
-rw-r--r-- | nGJ2019/Assets/Scenes/Marcin_sandbox.unity | 31 | ||||
-rw-r--r-- | nGJ2019/Assets/Scripts/EventTimeline.cs | 7 | ||||
-rw-r--r-- | nGJ2019/Assets/Scripts/LevelScrolling.cs | 104 | ||||
-rw-r--r-- | nGJ2019/Assets/Scripts/Messenger.cs | 1 | ||||
-rw-r--r-- | nGJ2019/Assets/Scripts/ObstacleSpawner.cs | 5 |
10 files changed, 93 insertions, 81 deletions
diff --git a/nGJ2019/Assets/Prefabs/CaveWalls.prefab b/nGJ2019/Assets/Prefabs/CaveWalls.prefab index 1ce1868..c57f273 100644 --- a/nGJ2019/Assets/Prefabs/CaveWalls.prefab +++ b/nGJ2019/Assets/Prefabs/CaveWalls.prefab @@ -56,7 +56,7 @@ MonoBehaviour: m_GameObject: {fileID: 7538015035249639830} m_Enabled: 1 m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 59a101027e69992449080dd35f887c3b, type: 3} + m_Script: {fileID: 11500000, guid: 992985330ae614733ac43350c8ea0ab0, type: 3} m_Name: m_EditorClassIdentifier: type: 0 @@ -82,7 +82,7 @@ MonoBehaviour: m_GameObject: {fileID: 7538015035695901050} m_Enabled: 1 m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 59a101027e69992449080dd35f887c3b, type: 3} + m_Script: {fileID: 11500000, guid: 992985330ae614733ac43350c8ea0ab0, type: 3} m_Name: m_EditorClassIdentifier: type: 0 diff --git a/nGJ2019/Assets/Prefabs/NarrowPassage.prefab b/nGJ2019/Assets/Prefabs/NarrowPassage.prefab index e084c31..dd3b6a0 100644 --- a/nGJ2019/Assets/Prefabs/NarrowPassage.prefab +++ b/nGJ2019/Assets/Prefabs/NarrowPassage.prefab @@ -56,7 +56,7 @@ MonoBehaviour: m_GameObject: {fileID: 7538015035249639830} m_Enabled: 1 m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 59a101027e69992449080dd35f887c3b, type: 3} + m_Script: {fileID: 11500000, guid: 992985330ae614733ac43350c8ea0ab0, type: 3} m_Name: m_EditorClassIdentifier: type: 3 @@ -82,7 +82,7 @@ MonoBehaviour: m_GameObject: {fileID: 7538015035695901050} m_Enabled: 1 m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 59a101027e69992449080dd35f887c3b, type: 3} + m_Script: {fileID: 11500000, guid: 992985330ae614733ac43350c8ea0ab0, type: 3} m_Name: m_EditorClassIdentifier: type: 3 diff --git a/nGJ2019/Assets/Prefabs/ObstacleRockBottom.prefab b/nGJ2019/Assets/Prefabs/ObstacleRockBottom.prefab index e2ff2f0..3e92b76 100644 --- a/nGJ2019/Assets/Prefabs/ObstacleRockBottom.prefab +++ b/nGJ2019/Assets/Prefabs/ObstacleRockBottom.prefab @@ -58,7 +58,7 @@ MonoBehaviour: m_GameObject: {fileID: 264553704504758048} m_Enabled: 1 m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 59a101027e69992449080dd35f887c3b, type: 3} + m_Script: {fileID: 11500000, guid: 992985330ae614733ac43350c8ea0ab0, type: 3} m_Name: m_EditorClassIdentifier: type: 2 diff --git a/nGJ2019/Assets/Prefabs/ObstacleRockTop.prefab b/nGJ2019/Assets/Prefabs/ObstacleRockTop.prefab index 06a8c5c..b42f9ed 100644 --- a/nGJ2019/Assets/Prefabs/ObstacleRockTop.prefab +++ b/nGJ2019/Assets/Prefabs/ObstacleRockTop.prefab @@ -60,7 +60,7 @@ MonoBehaviour: m_GameObject: {fileID: 2825962919672506772} m_Enabled: 1 m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 59a101027e69992449080dd35f887c3b, type: 3} + m_Script: {fileID: 11500000, guid: 992985330ae614733ac43350c8ea0ab0, type: 3} m_Name: m_EditorClassIdentifier: type: 1 diff --git a/nGJ2019/Assets/Prefabs/RockJaws.prefab b/nGJ2019/Assets/Prefabs/RockJaws.prefab index d7cb896..81143fd 100644 --- a/nGJ2019/Assets/Prefabs/RockJaws.prefab +++ b/nGJ2019/Assets/Prefabs/RockJaws.prefab @@ -9,7 +9,7 @@ GameObject: serializedVersion: 6 m_Component: - component: {fileID: 1998900778231223133} - - component: {fileID: 7713002535168256047} + - component: {fileID: 1464312581659586306} m_Layer: 0 m_Name: RockJaws m_TagString: Untagged @@ -33,7 +33,7 @@ Transform: m_Father: {fileID: 0} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!114 &7713002535168256047 +--- !u!114 &1464312581659586306 MonoBehaviour: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} @@ -42,7 +42,7 @@ MonoBehaviour: m_GameObject: {fileID: 1998900778231223134} m_Enabled: 1 m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: d508cc86bb112da41aab7f9073311fe5, type: 3} + m_Script: {fileID: 11500000, guid: b69da2d4b545440ed86bcb8e72e0a7eb, type: 3} m_Name: m_EditorClassIdentifier: TopJaw: {fileID: 6829481666799721321} @@ -61,7 +61,7 @@ BoxCollider: serializedVersion: 2 m_Size: {x: 9.5, y: 5.46, z: 2.82} m_Center: {x: 1.06, y: -3.84, z: -1.14} ---- !u!114 &8957168230144321536 +--- !u!114 &4943350886894711678 MonoBehaviour: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} @@ -70,7 +70,7 @@ MonoBehaviour: m_GameObject: {fileID: 7538015035249639830} m_Enabled: 1 m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 59a101027e69992449080dd35f887c3b, type: 3} + m_Script: {fileID: 11500000, guid: 992985330ae614733ac43350c8ea0ab0, type: 3} m_Name: m_EditorClassIdentifier: type: 4 @@ -87,7 +87,7 @@ BoxCollider: serializedVersion: 2 m_Size: {x: 7, y: 4.32, z: 2.28} m_Center: {x: 0, y: 0.96, z: -1.2} ---- !u!114 &3978623340426940721 +--- !u!114 &4015049844703851200 MonoBehaviour: m_ObjectHideFlags: 0 m_CorrespondingSourceObject: {fileID: 0} @@ -96,7 +96,7 @@ MonoBehaviour: m_GameObject: {fileID: 7538015035695901050} m_Enabled: 1 m_EditorHideFlags: 0 - m_Script: {fileID: 11500000, guid: 59a101027e69992449080dd35f887c3b, type: 3} + m_Script: {fileID: 11500000, guid: 992985330ae614733ac43350c8ea0ab0, type: 3} m_Name: m_EditorClassIdentifier: type: 4 diff --git a/nGJ2019/Assets/Scenes/Marcin_sandbox.unity b/nGJ2019/Assets/Scenes/Marcin_sandbox.unity index 2babc03..42a9843 100644 --- a/nGJ2019/Assets/Scenes/Marcin_sandbox.unity +++ b/nGJ2019/Assets/Scenes/Marcin_sandbox.unity @@ -151,8 +151,8 @@ MonoBehaviour: m_EditorClassIdentifier: UpdateRate: -5 Obstacles: - - {fileID: 572685425} - - {fileID: 1961649641} + - {fileID: 1359531025} + - {fileID: 1133548864} Background: {fileID: 1342555977} --- !u!4 &202725832 Transform: @@ -170,12 +170,6 @@ Transform: m_Father: {fileID: 0} m_RootOrder: 5 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!4 &572685425 stripped -Transform: - m_CorrespondingSourceObject: {fileID: 1998900778231223133, guid: 1955f0f25a1504ef6978634b4e8986ca, - type: 3} - m_PrefabInstance: {fileID: 963179641} - m_PrefabAsset: {fileID: 0} --- !u!1 &762447638 GameObject: m_ObjectHideFlags: 0 @@ -290,6 +284,12 @@ PrefabInstance: objectReference: {fileID: 0} m_RemovedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: 1955f0f25a1504ef6978634b4e8986ca, type: 3} +--- !u!1 &1133548864 stripped +GameObject: + m_CorrespondingSourceObject: {fileID: 1998900778231223134, guid: 1955f0f25a1504ef6978634b4e8986ca, + type: 3} + m_PrefabInstance: {fileID: 1920748800} + m_PrefabAsset: {fileID: 0} --- !u!1 &1196247045 GameObject: m_ObjectHideFlags: 0 @@ -424,7 +424,7 @@ SpriteRenderer: m_SortingLayerID: 0 m_SortingLayer: 0 m_SortingOrder: -1 - m_Sprite: {fileID: 21300000, guid: f961209db19f64f58a67ad7f0554c561, type: 3} + m_Sprite: {fileID: 21300000, guid: 420921107e115344ea4e97eeb2bca416, type: 3} m_Color: {r: 1, g: 1, b: 1, a: 1} m_FlipX: 0 m_FlipY: 0 @@ -435,6 +435,12 @@ SpriteRenderer: m_WasSpriteAssigned: 1 m_MaskInteraction: 0 m_SpriteSortPoint: 0 +--- !u!1 &1359531025 stripped +GameObject: + m_CorrespondingSourceObject: {fileID: 1998900778231223134, guid: 1955f0f25a1504ef6978634b4e8986ca, + type: 3} + m_PrefabInstance: {fileID: 963179641} + m_PrefabAsset: {fileID: 0} --- !u!1 &1427683651 GameObject: m_ObjectHideFlags: 0 @@ -659,7 +665,6 @@ MonoBehaviour: rockJawsPrefab: {fileID: 1998900778231223134, guid: a2b1bab6b90944171a71ff986bce4ebf, type: 3} scrolling: {fileID: 202725831} - messenger: {fileID: 0} spawnLine: 13.5 --- !u!1 &1695765865 GameObject: @@ -912,9 +917,3 @@ Transform: m_Father: {fileID: 0} m_RootOrder: 0 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} ---- !u!4 &1961649641 stripped -Transform: - m_CorrespondingSourceObject: {fileID: 1998900778231223133, guid: 1955f0f25a1504ef6978634b4e8986ca, - type: 3} - m_PrefabInstance: {fileID: 1920748800} - m_PrefabAsset: {fileID: 0} diff --git a/nGJ2019/Assets/Scripts/EventTimeline.cs b/nGJ2019/Assets/Scripts/EventTimeline.cs index b864ae7..18b87cc 100644 --- a/nGJ2019/Assets/Scripts/EventTimeline.cs +++ b/nGJ2019/Assets/Scripts/EventTimeline.cs @@ -60,17 +60,20 @@ public class EventTimeline { currentTime += deltaTime; - while(futureEvents.Count > 0 && currentTime > futureEvents[0].time && futureMessages.Count > 0 && currentTime > futureMessages[0].time) + while(futureEvents.Count > 0 && currentTime > futureEvents[0].time) { SpawnEvent e = futureEvents[0]; futureEvents.RemoveAt(0); if(OnSpawnEvent != null) OnSpawnEvent(e); + } + while(futureMessages.Count > 0 && currentTime > futureMessages[0].time) + { MessageEvent m = futureMessages[0]; futureMessages.RemoveAt(0); if(OnMessageEvent != null) OnMessageEvent(m); - } + } } } diff --git a/nGJ2019/Assets/Scripts/LevelScrolling.cs b/nGJ2019/Assets/Scripts/LevelScrolling.cs index 0122a69..fac0a13 100644 --- a/nGJ2019/Assets/Scripts/LevelScrolling.cs +++ b/nGJ2019/Assets/Scripts/LevelScrolling.cs @@ -4,66 +4,76 @@ using UnityEngine; public class LevelScrolling : MonoBehaviour
{
- public int UpdateRate = -5;
- public List<Transform> Obstacles;
- public Transform Background;
+ public int UpdateRate = -5;
+ public List<GameObject> Obstacles;
+ public Transform Background;
- private Vector3 initialBgPos;
- private float[] backgroundSize;
+ private Vector3 initialBgPos;
+ private float[] backgroundSize;
- // Start is called before the first frame update
- void Start()
- {
- ResizeBackground();
- }
+ // Start is called before the first frame update
+ void Start()
+ {
+ ResizeBackground();
+ }
+
+ // Update is called once per frame
+ void Update()
+ {
- // Update is called once per frame
- void Update()
- {
+ }
+
+ void FixedUpdate()
+ {
+ MoveBackground();
+ MoveObstacles();
+ DestroyObstacles();
+ }
- }
+ void ResizeBackground()
+ {
+ var sr = Background.GetComponent<SpriteRenderer>();
+ if (sr == null) return;
- void FixedUpdate()
- {
- MoveBackground();
- MoveObstacles();
- }
+ Background.localScale = new Vector3(1, 1, 1);
- private void ResizeBackground()
- {
- var sr = Background.GetComponent<SpriteRenderer>();
- if (sr == null) return;
+ var width = sr.sprite.bounds.size.x;
+ var height = sr.sprite.bounds.size.y;
- Background.localScale = new Vector3(1, 1, 1);
+ var worldScreenHeight = Camera.main.orthographicSize * 2.0;
+ var worldScreenWidth = worldScreenHeight / Screen.height * Screen.width;
- var width = sr.sprite.bounds.size.x;
- var height = sr.sprite.bounds.size.y;
+ var finalHeight = (float)(worldScreenHeight / height);
+ var finalWidth = (float)(worldScreenWidth / width);
- var worldScreenHeight = Camera.main.orthographicSize * 2.0;
- var worldScreenWidth = worldScreenHeight / Screen.height * Screen.width;
+ Background.localScale = new Vector3(finalHeight, finalHeight, 1);
- var finalHeight = (float)(worldScreenHeight / height);
- var finalWidth = (float)(worldScreenWidth / width);
+ var viewportX = Camera.main.ViewportToWorldPoint(new Vector3(0, 1, 0)).x;
+ Background.position = new Vector3(viewportX * -1, 0, 0);
+ initialBgPos = Background.position;
+ }
- Background.localScale = new Vector3(finalHeight, finalHeight, 1);
+ void MoveObstacles()
+ {
+ for (int i = 0; i < Obstacles.Count; i++)
+ {
+ Obstacles[i].transform.Translate(0.01f * UpdateRate, 0, 0);
+ }
+ }
- var viewportX = Camera.main.ViewportToWorldPoint(new Vector3(0, 1, 0)).x;
- Background.position = new Vector3(viewportX * -1, 0, 0);
- initialBgPos = Background.position;
- }
+ void DestroyObstacles()
+ {
+ if (Obstacles[0].transform.position.x < -30)
+ {
+ Destroy(Obstacles[0]);
+ Obstacles.RemoveAt(0);
+ }
+ }
- private void MoveObstacles()
- {
- foreach (var o in Obstacles)
+ void MoveBackground()
{
- o.Translate(0.01f * UpdateRate, 0, 0);
+ if (Background.position.x > -initialBgPos.x)
+ Background.Translate(0.01f * UpdateRate, 0, 0);
+ else Background.position = initialBgPos;
}
- }
-
- private void MoveBackground()
- {
- if (Background.position.x > -initialBgPos.x)
- Background.Translate(0.01f * UpdateRate, 0, 0);
- else Background.position = initialBgPos;
- }
}
diff --git a/nGJ2019/Assets/Scripts/Messenger.cs b/nGJ2019/Assets/Scripts/Messenger.cs index ca2ffe1..21d2f8d 100644 --- a/nGJ2019/Assets/Scripts/Messenger.cs +++ b/nGJ2019/Assets/Scripts/Messenger.cs @@ -16,6 +16,7 @@ public class Messenger : MonoBehaviour timeline = Spawner.GetEventTimeline();
timeline.Add(1, "Test");
+ timeline.Add(3, "");
timeline.OnMessageEvent += MessageOnEvent;
}
diff --git a/nGJ2019/Assets/Scripts/ObstacleSpawner.cs b/nGJ2019/Assets/Scripts/ObstacleSpawner.cs index f438e85..0e6b3ac 100644 --- a/nGJ2019/Assets/Scripts/ObstacleSpawner.cs +++ b/nGJ2019/Assets/Scripts/ObstacleSpawner.cs @@ -8,7 +8,6 @@ public class ObstacleSpawner : MonoBehaviour public GameObject caveWallsPrefab, rockTopPrefab, rockBottomPrefab, narrowPassagePrefab, rockJawsPrefab; public LevelScrolling scrolling; - public Messenger messenger; public float spawnLine; @@ -35,8 +34,8 @@ public class ObstacleSpawner : MonoBehaviour break; } - var transformT = ((GameObject)Instantiate(prefab, new Vector3(spawnLine, e.height, 0), Quaternion.identity)).transform; - scrolling.Obstacles.Add(transformT); + var o = Instantiate(prefab, new Vector3(spawnLine, e.height, 0), Quaternion.identity); + scrolling.Obstacles.Add(o); } void Start() |