I'm trying to create a falling word typing game like z-type.
I have used the code provided here
I want to create multiple levels in the game, and it seems like I need to make some changes in the code for each level.
For example, in the word display file, I want the active word to be changed to red for level 1 and blue for level 2.
So I created a copy of my level 1 scene, created a duplicate WordDisplay script file, changed the code for active word to blue....
public class WordDisplay : MonoBehaviour {
public Text text;
public float fallSpeed = 1f;
public void SetWord (string word)
{
text.text = word;
}
public void RemoveLetter ()
{
text.text = text.text.Remove(0, 1);
text.color = Color.red;
}
//...
Here's the duplicate script I made:
public class WordDisplay1 : MonoBehaviour {
public Text text;
public float fallSpeed = 1f;
public void SetWord (string word)
{
text.text = word;
}
public void RemoveLetter ()
{
text.text = text.text.Remove(0, 1);
text.color = Color.blue;
}
//...
Then I made a copy of the WordSpawner as well because I was getting an error: I had to change the method's return type to to WordDisplay1 and then got one more error which was in the Word file, leading to more changes...
public class WordSpawner : MonoBehaviour {
public GameObject wordPrefab;
public Transform wordCanvas;
public WordDisplay SpawnWord()
{
//...
public class WordSpawner1 : MonoBehaviour {
public GameObject wordPrefab;
public Transform wordCanvas;
public WordDisplay1 SpawnWord1()
{
//...
Then I created a duplicate of the word prefab and selected the appropriate word spawner file...
All of this seems like too many changes for a simple colour.
Is there a better way to have multiple levels without having to create a duplicate of all these files and the word prefab?