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;
public class BackgroundChanger : MonoBehaviour {
private List<GameObject> backgroundGroup = new List<GameObject>();
private List<GameObject> obstacleGroup = new List<GameObject>();
private GameObject[] gameObjectGroup;
private GameObject background;
private string[] colors = {"Blue", "Green", "Yellow" };
public void Start()
{
CollectBackgrounds();
CollectObstacles();
UpdateBackgroud(colors[0]);
}
public void Start()
{
CollectBackgrounds();
CollectObstacles();
UpdateBackgroud(colors[0]);
}
private void CollectBackgrounds()
{
background = GameObject.FindWithTag("Background");
}
private void CollectObstacles()
{
foreach(string color in colors)
......@@ -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()
{
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 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);
}
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)
{
......
......@@ -3,16 +3,7 @@
--- !u!78 &1
TagManager:
serializedVersion: 2
tags:
- BlueObstacle
- GreenObstacle
- Background
- BlueBackground
- GreenBackground
- WhiteObstacle
- YellowObstacle
- GreyObstacle
- Water
tags: []
layers:
- Default
- 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