Merge pull request #24 from gjcampbell777/obstacle_course_expansion

Reworked the obstacle course script so that floor squares can not app…
This commit is contained in:
Gregory Campbell
2020-01-12 22:49:10 -05:00
committed by GitHub
+34 -16
View File
@@ -9,11 +9,13 @@ public class FloorLevel : MonoBehaviour
{ {
public int escalation = 1; public int escalation = 1;
public int level = 1;
public GameObject player; public GameObject player;
public PlayerController script; public PlayerController script;
public GameObject[] obstacleList; public GameObject[] obstacleList;
private int selection = 0; private int selection = 0;
private int height = 2;
void Awake() void Awake()
{ {
@@ -40,7 +42,8 @@ public class FloorLevel : MonoBehaviour
if(script.finished == true) if(script.finished == true)
{ {
escalation++; level++;
if(level > 3) escalation++;
respawn(); respawn();
levelBuild(); levelBuild();
@@ -66,7 +69,7 @@ public class FloorLevel : MonoBehaviour
void respawn() void respawn()
{ {
script.transform.position = new Vector3((50*escalation)+100, 2, (50*escalation)+100); script.transform.position = new Vector3((100*escalation)+50, 2, (100*escalation)+50);
script.transform.Rotate(0.0f, 0.0f, 0.0f, Space.Self); script.transform.Rotate(0.0f, 0.0f, 0.0f, Space.Self);
} }
@@ -81,28 +84,43 @@ public class FloorLevel : MonoBehaviour
Destroy(GameObject.FindWithTag("Finish")); Destroy(GameObject.FindWithTag("Finish"));
for(int i = 1; i <= escalation; i++){ for(int i = 0; i < escalation; i++){
for(int j = 1; j <= escalation; j++){ for(int j = 0; j < escalation; j++){
selection = Random.Range(2, obstacleList.Length);
Instantiate(obstacleList[selection], new Vector3(50*i, 2, 50*j), Quaternion.identity);
selection = Random.Range(2, obstacleList.Length); if(Random.Range(0, 20) != 0 || (i == (escalation-1) && j == (escalation-1) && i == j))
Instantiate(obstacleList[selection], new Vector3(-50*i, 2, -50*j), Quaternion.identity); {
height = Random.Range(0, 7);
selection = Random.Range(2, obstacleList.Length);
Instantiate(obstacleList[selection], new Vector3(100*i+50, height, 100*j+50), Quaternion.identity);
}
selection = Random.Range(2, obstacleList.Length); if(Random.Range(0, 20) != 0 || (i == (escalation-1) && j == (escalation-1) && i == j))
Instantiate(obstacleList[selection], new Vector3(-50*i, 2, 50*j), Quaternion.identity); {
height = Random.Range(0, 7);
selection = Random.Range(2, obstacleList.Length);
Instantiate(obstacleList[selection], new Vector3(-100*i-50, height, -100*j-50), Quaternion.identity);
}
selection = Random.Range(2, obstacleList.Length); if(Random.Range(0, 10) != 0)
Instantiate(obstacleList[selection], new Vector3(50*i, 2, -50*j), Quaternion.identity); {
height = Random.Range(0, 7);
selection = Random.Range(2, obstacleList.Length);
Instantiate(obstacleList[selection], new Vector3(-100*i-50, height, 100*j+50), Quaternion.identity);
}
if(Random.Range(0, 10) != 0)
{
height = Random.Range(0, 7);
selection = Random.Range(2, obstacleList.Length);
Instantiate(obstacleList[selection], new Vector3(100*i+50, height, -100*j-50), Quaternion.identity);
}
script.transform.position = new Vector3((50*escalation)+100, 2, (50*escalation)+100);
script.transform.Rotate(0.0f, 0.0f, 0.0f, Space.Self);
} }
} }
Instantiate(obstacleList[0], new Vector3((50*escalation)+100, 0, (50*escalation)+100), Quaternion.identity); Instantiate(obstacleList[0], new Vector3((100*escalation)+50, 0, (100*escalation)+50), Quaternion.identity);
Instantiate(obstacleList[1], new Vector3(-((50*escalation)+100), 0, -((50*escalation)+100)), Quaternion.identity); Instantiate(obstacleList[1], new Vector3(-((100*escalation)+50), 0, -((100*escalation)+50)), Quaternion.identity);
script.finished = false; script.finished = false;
} }