Commit 408f312a by Juliper

fix-2

parents 5e5ec16c 52ac555a
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -4,26 +4,24 @@ using UnityEngine; ...@@ -4,26 +4,24 @@ using UnityEngine;
public class BackgroundChanger : MonoBehaviour { public class BackgroundChanger : MonoBehaviour {
private List<GameObject> backgroundGroup = new List<GameObject>(); private List<GameObject> backgroundGroup = new List<GameObject>();
private List<GameObject> obstacleGroup = new List<GameObject>(); private List<GameObject> obstacleGroup = new List<GameObject>();
private GameObject[] gameObjectGroup; private GameObject[] gameObjectGroup;
private GameObject background; private GameObject background;
private string[] colors = {"Blue", "Green", "Yellow" }; private string[] colors = {"Blue", "Green", "Yellow" };
public void Start() public void Start()
{ {
CollectBackgrounds(); CollectBackgrounds();
CollectObstacles(); CollectObstacles();
UpdateBackgroud(colors[0]); UpdateBackgroud(colors[0]);
} }
private void CollectBackgrounds() private void CollectBackgrounds()
{ {
background = GameObject.FindWithTag("Background"); background = GameObject.FindWithTag("Background");
} }
private void CollectObstacles() private void CollectObstacles()
{ {
foreach(string color in colors) foreach(string color in colors)
...@@ -35,38 +33,37 @@ public class BackgroundChanger : MonoBehaviour { ...@@ -35,38 +33,37 @@ public class BackgroundChanger : MonoBehaviour {
} }
} }
} }
public void Update()
{
if (Input.GetKey(KeyCode.X))
{
UpdateBackgroud("Blue");
} else if (Input.GetKey(KeyCode.Z))
{
UpdateBackgroud("Green");
} else if (Input.GetKey(KeyCode.C))
{
UpdateBackgroud("Yellow");
}
}
public void Update() public void UpdateBackgroud(string tagColor)
{ {
if (Input.GetKey(KeyCode.X)) if(tagColor == "Green")
{ {
UpdateBackgroud("Blue"); background.GetComponent<SpriteRenderer>().color = new Color32(46, 204, 113, 255);
} else if (Input.GetKey(KeyCode.Z)) } else if (tagColor == "Blue")
{ {
UpdateBackgroud("Green"); background.GetComponent<SpriteRenderer>().color = new Color32(65, 131, 215, 255);
} else if (Input.GetKey(KeyCode.C)) } else if (tagColor == "Yellow")
{ {
UpdateBackgroud("Yellow"); background.GetComponent<SpriteRenderer>().color = new Color32(255, 193, 7, 255);
} }
}
public void UpdateBackgroud(string tagColor)
{
if(tagColor == "Green")
{
background.GetComponent<SpriteRenderer>().color = new Color32(46, 204, 113, 255);
} else if (tagColor == "Blue")
{
background.GetComponent<SpriteRenderer>().color = new Color32(65, 131, 215, 255);
} else if (tagColor == "Yellow")
{
background.GetComponent<SpriteRenderer>().color = new Color32(255, 193, 7, 255);
}
UpdateObstacle(tagColor);
}
UpdateObstacle(tagColor);
}
private void UpdateObstacle(string tagColor) private void UpdateObstacle(string tagColor)
{ {
......
...@@ -3,16 +3,7 @@ ...@@ -3,16 +3,7 @@
--- !u!78 &1 --- !u!78 &1
TagManager: TagManager:
serializedVersion: 2 serializedVersion: 2
tags: tags: []
- BlueObstacle
- GreenObstacle
- Background
- BlueBackground
- GreenBackground
- WhiteObstacle
- YellowObstacle
- GreyObstacle
- Water
layers: layers:
- Default - Default
- TransparentFX - TransparentFX
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment