Commit 86bb2878 by Juliper

not fix yet

parent dc75a488
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -8,7 +8,6 @@ public class BackgroundChanger : MonoBehaviour { ...@@ -8,7 +8,6 @@ public class BackgroundChanger : MonoBehaviour {
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 GameObject obstacle;
private string[] colors = {"Blue", "Green" }; private string[] colors = {"Blue", "Green" };
public void Start() public void Start()
...@@ -20,21 +19,20 @@ public class BackgroundChanger : MonoBehaviour { ...@@ -20,21 +19,20 @@ public class BackgroundChanger : MonoBehaviour {
private void CollectBackgrounds() private void CollectBackgrounds()
{ {
foreach(string color in colors) background = GameObject.FindWithTag("Background");
{
background = GameObject.FindWithTag(color + "Background");
backgroundGroup.Add(background);
}
} }
private void CollectObstacles() private void CollectObstacles()
{ {
foreach(string color in colors) foreach(string color in colors)
{ {
obstacle = GameObject.FindWithTag(color + "Obstacle"); gameObjectGroup = GameObject.FindGameObjectsWithTag(color + "Obstacle");
foreach(GameObject obstacle in gameObjectGroup)
{
obstacleGroup.Add(obstacle); obstacleGroup.Add(obstacle);
} }
} }
}
public void Update() public void Update()
{ {
...@@ -49,15 +47,12 @@ public class BackgroundChanger : MonoBehaviour { ...@@ -49,15 +47,12 @@ public class BackgroundChanger : MonoBehaviour {
public void UpdateBackgroud(string tagColor) public void UpdateBackgroud(string tagColor)
{ {
foreach(GameObject background in backgroundGroup) if(tagColor == "Green")
{
if (background.tag == tagColor + "Background")
{ {
background.SetActive(true); background.GetComponent<SpriteRenderer>().color = new Color32(46, 204, 113, 255);
} else } else if (tagColor == "Blue")
{ {
background.SetActive(false); background.GetComponent<SpriteRenderer>().color = new Color32(65, 131, 215, 255);
}
} }
UpdateObstacle(tagColor); UpdateObstacle(tagColor);
...@@ -67,7 +62,7 @@ public class BackgroundChanger : MonoBehaviour { ...@@ -67,7 +62,7 @@ public class BackgroundChanger : MonoBehaviour {
{ {
foreach (GameObject obstacle in obstacleGroup) foreach (GameObject obstacle in obstacleGroup)
{ {
if(obstacle.tag == tagColor + "Obstacle") if (obstacle.tag == tagColor + "Obstacle")
{ {
obstacle.SetActive(false); obstacle.SetActive(false);
} else } else
......
...@@ -8,6 +8,7 @@ TagManager: ...@@ -8,6 +8,7 @@ TagManager:
- GreenBackground - GreenBackground
- BlueObstacle - BlueObstacle
- GreenObstacle - GreenObstacle
- Background
layers: layers:
- Default - Default
- TransparentFX - TransparentFX
......
<Properties StartupItem="Assembly-CSharp.csproj"> <Properties StartupItem="Assembly-CSharp.csproj">
<MonoDevelop.Ide.Workspace ActiveConfiguration="Debug" PreferredExecutionTarget="Unity.Instance.Unity Editor" /> <MonoDevelop.Ide.Workspace ActiveConfiguration="Debug" PreferredExecutionTarget="Unity.Instance.Unity Editor" />
<MonoDevelop.Ide.Workbench ActiveDocument="Assets\Scripts\PlayerController.cs"> <MonoDevelop.Ide.Workbench ActiveDocument="Assets\Scripts\BackgroundChanger.cs">
<Files> <Files>
<File FileName="Assets\Scripts\BackgroundChanger.cs" Line="32" Column="2" /> <File FileName="Assets\Scripts\BackgroundChanger.cs" Line="22" Column="1" />
<File FileName="Assets\Scripts\PlayerController.cs" Line="14" Column="3" /> <File FileName="Assets\Scripts\PlayerController.cs" Line="1" Column="1" />
<File FileName="Assets\Scripts\PhysicObject.cs" Line="1" Column="1" /> <File FileName="Assets\Scripts\PhysicObject.cs" Line="1" Column="1" />
<File FileName="Assets\Scripts\SceneLoader.cs" Line="1" Column="1" /> <File FileName="Assets\Scripts\SceneLoader.cs" Line="1" Column="1" />
</Files> </Files>
......
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