diff --git a/Assets/JustSign/Scenes/Game.unity b/Assets/JustSign/Scenes/Game.unity
index 5d87084..606f596 100644
--- a/Assets/JustSign/Scenes/Game.unity
+++ b/Assets/JustSign/Scenes/Game.unity
@@ -4140,6 +4140,7 @@ GameObject:
- component: {fileID: 1768150805}
- component: {fileID: 1768150804}
- component: {fileID: 1768150803}
+ - component: {fileID: 1768150807}
m_Layer: 5
m_Name: Canvas
m_TagString: Untagged
@@ -4229,6 +4230,19 @@ RectTransform:
m_AnchoredPosition: {x: 0, y: 0}
m_SizeDelta: {x: 0, y: 0}
m_Pivot: {x: 0, y: 0}
+--- !u!114 &1768150807
+MonoBehaviour:
+ m_ObjectHideFlags: 0
+ m_CorrespondingSourceObject: {fileID: 0}
+ m_PrefabInstance: {fileID: 0}
+ m_PrefabAsset: {fileID: 0}
+ m_GameObject: {fileID: 1768150802}
+ m_Enabled: 1
+ m_EditorHideFlags: 0
+ m_Script: {fileID: 11500000, guid: 9ede962218eda88668cd8032b921aada, type: 3}
+ m_Name:
+ m_EditorClassIdentifier:
+ canvas: {fileID: 1768150805}
--- !u!1 &1898716846
GameObject:
m_ObjectHideFlags: 0
diff --git a/Assets/JustSign/Scripts/JustSignController.cs b/Assets/JustSign/Scripts/JustSignController.cs
index c1548b4..3571056 100644
--- a/Assets/JustSign/Scripts/JustSignController.cs
+++ b/Assets/JustSign/Scripts/JustSignController.cs
@@ -1,9 +1,18 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
+using UnityEngine.UI;
+///
+/// Contains all game logic for the JustSign game
+///
public class JustSignController : MonoBehaviour
{
+ ///
+ /// The canvas containing all components
+ ///
+ public Canvas canvas;
+
///
/// All of the words that can be used in this session
///
@@ -19,23 +28,79 @@ public class JustSignController : MonoBehaviour
///
private Theme currentTheme;
+ ///
+ /// List of strings representing all words on the track
+ ///
+ private List activeWords = new List();
+
+ ///
+ /// List of objects representing all symbols on the track
+ ///
+ private List activeSymbols = new List();
+
+ ///
+ /// Width and height of the symbols
+ ///
+ private int symbolSize = 280;
+
+ ///
+ /// Controls movement speed of symbols (higher -> faster)
+ ///
+ private int moveSpeed = 200;
+
+ ///
+ /// Starting X-coordinate of a symbol = (-1920 - symbolsize) / 2
+ ///
+ private int trackX = -1100;
+
+ ///
+ /// Starting Y-coordinate of a symbol
+ ///
+ private int trackY = -200;
+
+ ///
+ /// Time at which the last symbol was spawned
+ ///
+ private float lastSpawn;
+
// Start is called before the first frame update
void Start()
{
themeList = ThemeLoader.LoadJson();
currentTheme = FindThemeByName(PlayerPrefs.GetString("themeName"));
words = currentTheme.words;
- /*
- RectTransform rectTransform = newImage.GetComponent();
- rectTransform.localPosition = new Vector3(xPosition, yPosition, 0);
- rectTransform.sizeDelta = new Vector2(width, height);
- */
+ lastSpawn = Time.time;
+
+ SpawnNewSymbol();
}
// Update is called once per frame
void Update()
- {
-
+ {
+ float currentTime = Time.time;
+ if (currentTime - lastSpawn > 1) {
+ lastSpawn = currentTime;
+ SpawnNewSymbol();
+ }
+
+ if (activeSymbols[0].GetComponent().localPosition.x > -trackX) {
+ Debug.Log("LENGTH BEFORE:");
+ Debug.Log(activeWords.Count);
+ activeWords.RemoveAt(0);
+ Debug.Log("LENGTH AFTER:");
+ Debug.Log(activeWords.Count);
+ GameObject symbol = activeSymbols[0];
+ activeSymbols.RemoveAt(0);
+ Destroy(symbol);
+ }
+
+ //Debug.Log(activeWords.Count);
+ Debug.Log(activeWords.Count);
+
+ foreach (GameObject symbol in activeSymbols) {
+ RectTransform rectTransform = symbol.GetComponent();
+ rectTransform.localPosition = new Vector3(rectTransform.localPosition.x + Time.deltaTime * moveSpeed, trackY, 0);
+ }
}
///
@@ -60,4 +125,26 @@ public class JustSignController : MonoBehaviour
Debug.Log("Requested theme not found");
return null;
}
+
+ ///
+ /// Create a new symbol at the start of the track
+ ///
+ void SpawnNewSymbol() {
+ string nextSymbol = words[UnityEngine.Random.Range(0, words.Length)];
+
+ GameObject newSymbolObject = new GameObject("Symbol");
+ Image newImage = newSymbolObject.AddComponent();
+ RectTransform rectTransform = newSymbolObject.GetComponent();
+ rectTransform.SetParent(canvas.transform, false); // Set the parent to the Canvas
+ rectTransform.localPosition = new Vector3(trackX, trackY, 0);
+ rectTransform.sizeDelta = new Vector2(symbolSize, symbolSize);
+
+ Sprite sprite = Resources.Load("Common/Images/" + nextSymbol);
+
+ // Set the new sprite as the Image component's source image
+ newImage.sprite = sprite;
+
+ activeWords.Add(nextSymbol);
+ activeSymbols.Add(newSymbolObject);
+ }
}
diff --git a/Assets/SpellingBee/Scripts/GameController.cs b/Assets/SpellingBee/Scripts/GameController.cs
index a108ad7..7333266 100644
--- a/Assets/SpellingBee/Scripts/GameController.cs
+++ b/Assets/SpellingBee/Scripts/GameController.cs
@@ -6,6 +6,9 @@ using TMPro;
using UnityEngine;
using UnityEngine.UI;
+///
+/// Contains all game logic for the SpellingBee game
+///
public class GameController : MonoBehaviour
{
///