diff options
author | Mikkel Bybjerg <mikkel.bybjerg@hotmail.com> | 2019-04-27 18:08:57 +0200 |
---|---|---|
committer | Mikkel Bybjerg <mikkel.bybjerg@hotmail.com> | 2019-04-27 18:08:57 +0200 |
commit | 0f510216cac75c8a5e69e86f9009eaf4f338b889 (patch) | |
tree | 83c64ef455f6acce8fdaa3e3ae95a85049b0dba4 | |
parent | 27dcfd09f51191196f44da030ce68338ac09e6b3 (diff) | |
parent | 53a8d342ee667d1b28c1dc1e173ad73338a930b9 (diff) |
merge
-rw-r--r-- | nGJ2019/Assets/Scenes/Marcin_sandbox.unity | 298 | ||||
-rw-r--r-- | nGJ2019/Assets/Scripts/EventTimeline.cs | 28 | ||||
-rw-r--r-- | nGJ2019/Assets/Scripts/Messenger.cs | 33 | ||||
-rw-r--r-- | nGJ2019/Assets/Scripts/ObstacleSpawner.cs | 6 |
4 files changed, 360 insertions, 5 deletions
diff --git a/nGJ2019/Assets/Scenes/Marcin_sandbox.unity b/nGJ2019/Assets/Scenes/Marcin_sandbox.unity index a066ed9..2babc03 100644 --- a/nGJ2019/Assets/Scenes/Marcin_sandbox.unity +++ b/nGJ2019/Assets/Scenes/Marcin_sandbox.unity @@ -168,7 +168,7 @@ Transform: - {fileID: 1342555977} - {fileID: 1576648787} m_Father: {fileID: 0} - m_RootOrder: 3 + m_RootOrder: 5 m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!4 &572685425 stripped Transform: @@ -176,6 +176,51 @@ Transform: type: 3} m_PrefabInstance: {fileID: 963179641} m_PrefabAsset: {fileID: 0} +--- !u!1 &762447638 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 762447640} + - component: {fileID: 762447639} + m_Layer: 0 + m_Name: Messenger + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &762447639 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 762447638} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 11500000, guid: 90b9adb2719954b53b69b9dc121082f2, type: 3} + m_Name: + m_EditorClassIdentifier: + MainText: {fileID: 1427683653} + Spawner: {fileID: 1576648788} +--- !u!4 &762447640 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 762447638} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: -11} + m_LocalScale: {x: 1, y: 1, z: 1} + m_Children: [] + m_Father: {fileID: 0} + m_RootOrder: 1 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1001 &963179641 PrefabInstance: m_ObjectHideFlags: 0 @@ -226,7 +271,7 @@ PrefabInstance: - target: {fileID: 1998900778231223133, guid: 1955f0f25a1504ef6978634b4e8986ca, type: 3} propertyPath: m_RootOrder - value: 1 + value: 3 objectReference: {fileID: 0} - target: {fileID: 1998900778231223133, guid: 1955f0f25a1504ef6978634b4e8986ca, type: 3} @@ -245,6 +290,72 @@ PrefabInstance: objectReference: {fileID: 0} m_RemovedComponents: [] m_SourcePrefab: {fileID: 100100000, guid: 1955f0f25a1504ef6978634b4e8986ca, type: 3} +--- !u!1 &1196247045 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1196247048} + - component: {fileID: 1196247047} + - component: {fileID: 1196247046} + m_Layer: 0 + m_Name: EventSystem + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &1196247046 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1196247045} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 1077351063, guid: f70555f144d8491a825f0804e09c671c, type: 3} + m_Name: + m_EditorClassIdentifier: + m_HorizontalAxis: Horizontal + m_VerticalAxis: Vertical + m_SubmitButton: Submit + m_CancelButton: Cancel + m_InputActionsPerSecond: 10 + m_RepeatDelay: 0.5 + m_ForceModuleActive: 0 +--- !u!114 &1196247047 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1196247045} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: -619905303, guid: f70555f144d8491a825f0804e09c671c, type: 3} + m_Name: + m_EditorClassIdentifier: + m_FirstSelected: {fileID: 0} + m_sendNavigationEvents: 1 + m_DragThreshold: 10 +--- !u!4 &1196247048 +Transform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1196247045} + 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: [] + m_Father: {fileID: 0} + m_RootOrder: 7 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} --- !u!1 &1342555976 GameObject: m_ObjectHideFlags: 0 @@ -324,6 +435,85 @@ SpriteRenderer: m_WasSpriteAssigned: 1 m_MaskInteraction: 0 m_SpriteSortPoint: 0 +--- !u!1 &1427683651 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1427683652} + - component: {fileID: 1427683654} + - component: {fileID: 1427683653} + m_Layer: 5 + m_Name: Text + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!224 &1427683652 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1427683651} + 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: [] + m_Father: {fileID: 1695765869} + m_RootOrder: 0 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0.5, y: 0.5} + m_AnchorMax: {x: 0.5, y: 0.5} + m_AnchoredPosition: {x: 0, y: 87.8} + m_SizeDelta: {x: 298.1, y: 54} + m_Pivot: {x: 0.5, y: 0.5} +--- !u!114 &1427683653 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1427683651} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 708705254, guid: f70555f144d8491a825f0804e09c671c, type: 3} + m_Name: + m_EditorClassIdentifier: + m_Material: {fileID: 0} + m_Color: {r: 0.19607843, g: 0.19607843, b: 0.19607843, a: 1} + m_RaycastTarget: 1 + m_OnCullStateChanged: + m_PersistentCalls: + m_Calls: [] + m_TypeName: UnityEngine.UI.MaskableGraphic+CullStateChangedEvent, UnityEngine.UI, + Version=1.0.0.0, Culture=neutral, PublicKeyToken=null + m_FontData: + m_Font: {fileID: 10102, guid: 0000000000000000e000000000000000, type: 0} + m_FontSize: 40 + m_FontStyle: 0 + m_BestFit: 0 + m_MinSize: 1 + m_MaxSize: 40 + m_Alignment: 0 + m_AlignByGeometry: 0 + m_RichText: 1 + m_HorizontalOverflow: 0 + m_VerticalOverflow: 0 + m_LineSpacing: 1 + m_Text: +--- !u!222 &1427683654 +CanvasRenderer: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1427683651} + m_CullTransparentMesh: 0 --- !u!1 &1508541068 GameObject: m_ObjectHideFlags: 0 @@ -413,7 +603,7 @@ Transform: m_LocalScale: {x: 1, y: 1, z: 1} m_Children: [] m_Father: {fileID: 0} - m_RootOrder: 4 + m_RootOrder: 6 m_LocalEulerAnglesHint: {x: 50, y: -30, z: 0} --- !u!1 &1576648786 GameObject: @@ -469,7 +659,107 @@ MonoBehaviour: rockJawsPrefab: {fileID: 1998900778231223134, guid: a2b1bab6b90944171a71ff986bce4ebf, type: 3} scrolling: {fileID: 202725831} + messenger: {fileID: 0} spawnLine: 13.5 +--- !u!1 &1695765865 +GameObject: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + serializedVersion: 6 + m_Component: + - component: {fileID: 1695765869} + - component: {fileID: 1695765868} + - component: {fileID: 1695765867} + - component: {fileID: 1695765866} + m_Layer: 5 + m_Name: Canvas + m_TagString: Untagged + m_Icon: {fileID: 0} + m_NavMeshLayer: 0 + m_StaticEditorFlags: 0 + m_IsActive: 1 +--- !u!114 &1695765866 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1695765865} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 1301386320, guid: f70555f144d8491a825f0804e09c671c, type: 3} + m_Name: + m_EditorClassIdentifier: + m_IgnoreReversedGraphics: 1 + m_BlockingObjects: 0 + m_BlockingMask: + serializedVersion: 2 + m_Bits: 4294967295 +--- !u!114 &1695765867 +MonoBehaviour: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1695765865} + m_Enabled: 1 + m_EditorHideFlags: 0 + m_Script: {fileID: 1980459831, guid: f70555f144d8491a825f0804e09c671c, type: 3} + m_Name: + m_EditorClassIdentifier: + m_UiScaleMode: 0 + m_ReferencePixelsPerUnit: 100 + m_ScaleFactor: 1 + m_ReferenceResolution: {x: 800, y: 600} + m_ScreenMatchMode: 0 + m_MatchWidthOrHeight: 0 + m_PhysicalUnit: 3 + m_FallbackScreenDPI: 96 + m_DefaultSpriteDPI: 96 + m_DynamicPixelsPerUnit: 1 +--- !u!223 &1695765868 +Canvas: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1695765865} + m_Enabled: 1 + serializedVersion: 3 + m_RenderMode: 1 + m_Camera: {fileID: 1928510846} + m_PlaneDistance: 100 + m_PixelPerfect: 0 + m_ReceivesEvents: 1 + m_OverrideSorting: 0 + m_OverridePixelPerfect: 0 + m_SortingBucketNormalizedSize: 0 + m_AdditionalShaderChannelsFlag: 0 + m_SortingLayerID: 0 + m_SortingOrder: 3 + m_TargetDisplay: 0 +--- !u!224 &1695765869 +RectTransform: + m_ObjectHideFlags: 0 + m_CorrespondingSourceObject: {fileID: 0} + m_PrefabInstance: {fileID: 0} + m_PrefabAsset: {fileID: 0} + m_GameObject: {fileID: 1695765865} + m_LocalRotation: {x: 0, y: 0, z: 0, w: 1} + m_LocalPosition: {x: 0, y: 0, z: 0} + m_LocalScale: {x: 0, y: 0, z: 0} + m_Children: + - {fileID: 1427683652} + m_Father: {fileID: 0} + m_RootOrder: 2 + m_LocalEulerAnglesHint: {x: 0, y: 0, z: 0} + m_AnchorMin: {x: 0, y: 0} + m_AnchorMax: {x: 0, y: 0} + m_AnchoredPosition: {x: 0, y: 0} + m_SizeDelta: {x: 0, y: 0} + m_Pivot: {x: 0, y: 0} --- !u!1001 &1920748800 PrefabInstance: m_ObjectHideFlags: 0 @@ -520,7 +810,7 @@ PrefabInstance: - target: {fileID: 1998900778231223133, guid: 1955f0f25a1504ef6978634b4e8986ca, type: 3} propertyPath: m_RootOrder - value: 2 + value: 4 objectReference: {fileID: 0} - target: {fileID: 1998900778231223133, guid: 1955f0f25a1504ef6978634b4e8986ca, type: 3} diff --git a/nGJ2019/Assets/Scripts/EventTimeline.cs b/nGJ2019/Assets/Scripts/EventTimeline.cs index 21b0bdb..b864ae7 100644 --- a/nGJ2019/Assets/Scripts/EventTimeline.cs +++ b/nGJ2019/Assets/Scripts/EventTimeline.cs @@ -17,15 +17,30 @@ public class EventTimeline this.type = type; } } + + public class MessageEvent + { + public float time; + public String message; + + public MessageEvent(float time, String message) + { + this.time = time; + this.message = message; + } + } public event Action<SpawnEvent> OnSpawnEvent; + public event Action<MessageEvent> OnMessageEvent; private List<SpawnEvent> futureEvents; + private List<MessageEvent> futureMessages; private float currentTime; public EventTimeline() { futureEvents = new List<SpawnEvent>(); + futureMessages = new List<MessageEvent>(); currentTime = 0; } @@ -34,17 +49,28 @@ public class EventTimeline futureEvents.Add(new SpawnEvent(time, height, type)); futureEvents.Sort((x,y) => x.time.CompareTo(y.time)); } + + public void Add(float time, String message) + { + futureMessages.Add(new MessageEvent(time, message)); + futureMessages.Sort((x,y) => x.time.CompareTo(y.time)); + } public void timeTick(float deltaTime) { currentTime += deltaTime; - while(futureEvents.Count > 0 && currentTime > futureEvents[0].time) + while(futureEvents.Count > 0 && currentTime > futureEvents[0].time && futureMessages.Count > 0 && currentTime > futureMessages[0].time) { SpawnEvent e = futureEvents[0]; futureEvents.RemoveAt(0); if(OnSpawnEvent != null) OnSpawnEvent(e); + + MessageEvent m = futureMessages[0]; + futureMessages.RemoveAt(0); + if(OnMessageEvent != null) + OnMessageEvent(m); } } } diff --git a/nGJ2019/Assets/Scripts/Messenger.cs b/nGJ2019/Assets/Scripts/Messenger.cs new file mode 100644 index 0000000..ca2ffe1 --- /dev/null +++ b/nGJ2019/Assets/Scripts/Messenger.cs @@ -0,0 +1,33 @@ +using System;
+using System.Collections;
+using System.Collections.Generic;
+using UnityEngine;
+using UnityEngine.UI;
+
+public class Messenger : MonoBehaviour
+{
+ public Text MainText;
+ public ObstacleSpawner Spawner;
+ private EventTimeline timeline;
+
+ // Start is called before the first frame update
+ void Start()
+ {
+ timeline = Spawner.GetEventTimeline();
+
+ timeline.Add(1, "Test");
+
+ timeline.OnMessageEvent += MessageOnEvent;
+ }
+
+ // Update is called once per frame
+ void Update()
+ {
+
+ }
+
+ void MessageOnEvent(EventTimeline.MessageEvent e)
+ {
+ MainText.text = e.message;
+ }
+}
diff --git a/nGJ2019/Assets/Scripts/ObstacleSpawner.cs b/nGJ2019/Assets/Scripts/ObstacleSpawner.cs index c285352..f438e85 100644 --- a/nGJ2019/Assets/Scripts/ObstacleSpawner.cs +++ b/nGJ2019/Assets/Scripts/ObstacleSpawner.cs @@ -8,6 +8,7 @@ public class ObstacleSpawner : MonoBehaviour public GameObject caveWallsPrefab, rockTopPrefab, rockBottomPrefab, narrowPassagePrefab, rockJawsPrefab; public LevelScrolling scrolling; + public Messenger messenger; public float spawnLine; @@ -63,4 +64,9 @@ public class ObstacleSpawner : MonoBehaviour Gizmos.color = Color.green; Gizmos.DrawLine(new Vector3(spawnLine, -10, 0), new Vector3(spawnLine, 10, 0)); } + + public EventTimeline GetEventTimeline() + { + return timeline; + } } |