diff --git a/.idea/.idea.Inter-Face-Off/.idea/dictionaries/project.xml b/.idea/.idea.Inter-Face-Off/.idea/dictionaries/project.xml
new file mode 100644
index 0000000..43b4bfd
--- /dev/null
+++ b/.idea/.idea.Inter-Face-Off/.idea/dictionaries/project.xml
@@ -0,0 +1,7 @@
+
+
+
+ gameobject
+
+
+
\ No newline at end of file
diff --git a/Assets/Scenes/SampleScene.unity b/Assets/Scenes/SampleScene.unity
index e346597..dd8472e 100644
--- a/Assets/Scenes/SampleScene.unity
+++ b/Assets/Scenes/SampleScene.unity
@@ -630,7 +630,7 @@ GameObject:
m_Icon: {fileID: 0}
m_NavMeshLayer: 0
m_StaticEditorFlags: 0
- m_IsActive: 1
+ m_IsActive: 0
--- !u!224 &1867692259
RectTransform:
m_ObjectHideFlags: 0
diff --git a/Assets/Scripts/WindowBase.cs b/Assets/Scripts/WindowBase.cs
index 51b60e5..677e344 100644
--- a/Assets/Scripts/WindowBase.cs
+++ b/Assets/Scripts/WindowBase.cs
@@ -7,11 +7,21 @@ namespace InterfaceOff
public WindowInteractions Interactions { get; set; }
public WindowComponents Components { get; set; }
+ public Vector3 Velocity { get; set; }
+
public void InstantiateWindowBase()
{
transform.position = CanvasManager.GetRandomPositionOnCanvas();
+
+ OnWindowInstantiation();
}
-
+
+ public void LateUpdate()
+ {
+ transform.position += Velocity * Time.deltaTime;
+ }
+
+ public virtual void OnWindowInstantiation() { }
public virtual void OnWindowClicked() { }
}
}
diff --git a/Assets/Scripts/WindowSpawner.cs b/Assets/Scripts/WindowSpawner.cs
index 41b83c6..9a57e49 100644
--- a/Assets/Scripts/WindowSpawner.cs
+++ b/Assets/Scripts/WindowSpawner.cs
@@ -1,6 +1,7 @@
using System;
using System.Collections.Generic;
using UnityEngine;
+using Random = UnityEngine.Random;
namespace InterfaceOff
{
@@ -31,29 +32,37 @@ namespace InterfaceOff
}
}
- private void Update()
+ private void SpawnNewRandomWindow()
{
- if (Input.GetKeyDown(KeyCode.Space))
+ /* Creates the gameobject with a random class */
+ GameObject go = Instantiate(SampleChild, GameCanvas.transform);
+ go.SetActive(true);
+
+ Type type = WindowTypes.GetRandom();
+ WindowBase windowBase = go.AddComponent(type) as WindowBase;
+
+ /* Checks it created correctly before instantiating further */
+ if (DebugUtils.IsNull(windowBase))
{
- /* Creates the gameobject with a random class */
- GameObject go = Instantiate(SampleChild, GameCanvas.transform);
- go.SetActive(true);
-
- Type type = WindowTypes.GetRandom();
- WindowBase windowBase = go.AddComponent(type) as WindowBase;
-
- /* Checks it created correctly before instantiating further */
- if (DebugUtils.IsNull(windowBase))
- {
- Debug.LogError("How did this happen");
- return;
- }
+ Debug.LogError("How did this happen");
+ return;
+ }
- windowBase.Interactions = go.GetComponent();
- windowBase.Interactions.SetAttachedTo(windowBase);
+ /* Makes sure the WindowInteractions and WindowComponents are setup before passing to user code */
+ windowBase.Interactions = go.GetComponent();
+ windowBase.Interactions.SetAttachedTo(windowBase);
- windowBase.Components = go.GetComponent();
- windowBase.InstantiateWindowBase();
+ windowBase.Components = go.GetComponent();
+ windowBase.InstantiateWindowBase();
+ }
+
+ private void FixedUpdate()
+ {
+ /* Checks if it should spawn a window */
+ bool shouldSpawn = Random.Range(0, 40) == 0;
+ if (shouldSpawn)
+ {
+ SpawnNewRandomWindow();
}
}
}
diff --git a/Assets/Scripts/Windows.meta b/Assets/Scripts/Windows.meta
new file mode 100644
index 0000000..14daad0
--- /dev/null
+++ b/Assets/Scripts/Windows.meta
@@ -0,0 +1,3 @@
+fileFormatVersion: 2
+guid: 8cc86789c70b427d88ef6a4672547137
+timeCreated: 1768302148
\ No newline at end of file
diff --git a/Assets/Scripts/BasicWindow.cs b/Assets/Scripts/Windows/BasicWindow.cs
similarity index 100%
rename from Assets/Scripts/BasicWindow.cs
rename to Assets/Scripts/Windows/BasicWindow.cs
diff --git a/Assets/Scripts/BasicWindow.cs.meta b/Assets/Scripts/Windows/BasicWindow.cs.meta
similarity index 100%
rename from Assets/Scripts/BasicWindow.cs.meta
rename to Assets/Scripts/Windows/BasicWindow.cs.meta
diff --git a/Assets/Scripts/Windows/MovingWindow.cs b/Assets/Scripts/Windows/MovingWindow.cs
new file mode 100644
index 0000000..58cded1
--- /dev/null
+++ b/Assets/Scripts/Windows/MovingWindow.cs
@@ -0,0 +1,25 @@
+using UnityEngine;
+
+namespace InterfaceOff
+{
+ public class MovingWindow : WindowBase
+ {
+ private int m_Health = 5;
+
+ public override void OnWindowInstantiation()
+ {
+ Components.WindowImage.color = Color.red;
+ Velocity = new Vector3(100, 100, 0);
+ }
+
+ public override void OnWindowClicked()
+ {
+ /* Decreases health and destroys if at 0 */
+ m_Health--;
+ if (m_Health <= 0)
+ {
+ Destroy(gameObject);
+ }
+ }
+ }
+}
\ No newline at end of file
diff --git a/Assets/Scripts/Windows/MovingWindow.cs.meta b/Assets/Scripts/Windows/MovingWindow.cs.meta
new file mode 100644
index 0000000..2fda614
--- /dev/null
+++ b/Assets/Scripts/Windows/MovingWindow.cs.meta
@@ -0,0 +1,3 @@
+fileFormatVersion: 2
+guid: a7ad1aa722804bbba796feea129247f1
+timeCreated: 1768302389
\ No newline at end of file