2020-01-07 21:52:52 -05:00
|
|
|
using System.Collections;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using UnityEngine;
|
2020-01-11 14:04:14 -05:00
|
|
|
using UnityEngine.SceneManagement;
|
2020-01-07 21:52:52 -05:00
|
|
|
|
|
|
|
|
[System.Serializable]
|
|
|
|
|
|
2020-01-11 14:10:44 -05:00
|
|
|
public class FloorLevel : MonoBehaviour
|
2020-01-07 21:52:52 -05:00
|
|
|
{
|
|
|
|
|
|
2020-01-11 15:55:01 -05:00
|
|
|
public int escalation = 1;
|
2020-01-10 00:26:44 -05:00
|
|
|
public GameObject player;
|
|
|
|
|
public PlayerController script;
|
2020-01-07 21:52:52 -05:00
|
|
|
public GameObject[] obstacleList;
|
|
|
|
|
|
|
|
|
|
private int selection = 0;
|
|
|
|
|
|
2020-01-11 15:55:01 -05:00
|
|
|
void Awake()
|
|
|
|
|
{
|
|
|
|
|
script.respawnTime = Time.time;
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-07 21:52:52 -05:00
|
|
|
// Start is called before the first frame update
|
|
|
|
|
void Start()
|
|
|
|
|
{
|
2020-01-10 00:26:44 -05:00
|
|
|
|
|
|
|
|
script = player.GetComponent<PlayerController>();
|
|
|
|
|
escalation = 1;
|
2020-01-11 14:04:14 -05:00
|
|
|
script.lives = 3;
|
2020-01-10 00:26:44 -05:00
|
|
|
script.finished = false;
|
2020-01-11 14:04:14 -05:00
|
|
|
respawn();
|
2020-01-11 00:46:40 -05:00
|
|
|
script.pivot.transform.Rotate(0.0f, 225.0f, 0.0f, Space.Self);
|
2020-01-10 00:26:44 -05:00
|
|
|
levelBuild();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Update()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
if(script.finished == true)
|
|
|
|
|
{
|
|
|
|
|
|
2020-01-11 00:46:40 -05:00
|
|
|
escalation++;
|
2020-01-11 14:04:14 -05:00
|
|
|
respawn();
|
|
|
|
|
levelBuild();
|
2020-01-10 00:26:44 -05:00
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
2020-01-11 14:04:14 -05:00
|
|
|
if(script.respawn == true)
|
2020-01-11 13:35:50 -05:00
|
|
|
{
|
2020-01-11 14:04:14 -05:00
|
|
|
respawn();
|
|
|
|
|
script.lives--;
|
|
|
|
|
script.respawn = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(script.lives == 0)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
script.lives = -1;
|
|
|
|
|
SceneManager.LoadScene("Hub World", LoadSceneMode.Single);
|
|
|
|
|
|
2020-01-11 13:35:50 -05:00
|
|
|
}
|
|
|
|
|
|
2020-01-10 00:26:44 -05:00
|
|
|
}
|
|
|
|
|
|
2020-01-11 13:35:50 -05:00
|
|
|
void respawn()
|
2020-01-10 00:26:44 -05:00
|
|
|
{
|
|
|
|
|
|
2020-01-11 14:04:14 -05:00
|
|
|
script.transform.position = new Vector3((50*escalation)+100, 2, (50*escalation)+100);
|
2020-01-11 00:46:40 -05:00
|
|
|
script.transform.Rotate(0.0f, 0.0f, 0.0f, Space.Self);
|
2020-01-11 13:35:50 -05:00
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void levelBuild()
|
|
|
|
|
{
|
2020-01-11 00:46:40 -05:00
|
|
|
|
2020-01-10 00:26:44 -05:00
|
|
|
GameObject[] oldObjects = GameObject.FindGameObjectsWithTag("Environment");
|
|
|
|
|
foreach (GameObject target in oldObjects) {
|
|
|
|
|
GameObject.Destroy(target);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Destroy(GameObject.FindWithTag("Finish"));
|
|
|
|
|
|
2020-01-07 21:52:52 -05:00
|
|
|
for(int i = 1; i <= escalation; i++){
|
|
|
|
|
for(int j = 1; j <= escalation; j++){
|
2020-01-10 00:26:44 -05:00
|
|
|
selection = Random.Range(2, obstacleList.Length);
|
2020-01-07 21:52:52 -05:00
|
|
|
Instantiate(obstacleList[selection], new Vector3(50*i, 2, 50*j), Quaternion.identity);
|
|
|
|
|
|
2020-01-10 00:26:44 -05:00
|
|
|
selection = Random.Range(2, obstacleList.Length);
|
2020-01-11 15:55:01 -05:00
|
|
|
Instantiate(obstacleList[selection], new Vector3(-50*i, 2, -50*j), Quaternion.identity);
|
2020-01-07 21:52:52 -05:00
|
|
|
|
2020-01-10 00:26:44 -05:00
|
|
|
selection = Random.Range(2, obstacleList.Length);
|
2020-01-11 15:55:01 -05:00
|
|
|
Instantiate(obstacleList[selection], new Vector3(-50*i, 2, 50*j), Quaternion.identity);
|
2020-01-07 21:52:52 -05:00
|
|
|
|
2020-01-10 00:26:44 -05:00
|
|
|
selection = Random.Range(2, obstacleList.Length);
|
2020-01-11 15:55:01 -05:00
|
|
|
Instantiate(obstacleList[selection], new Vector3(50*i, 2, -50*j), Quaternion.identity);
|
2020-01-11 00:46:40 -05:00
|
|
|
|
|
|
|
|
script.transform.position = new Vector3((50*escalation)+100, 2, (50*escalation)+100);
|
|
|
|
|
script.transform.Rotate(0.0f, 0.0f, 0.0f, Space.Self);
|
2020-01-07 21:52:52 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Instantiate(obstacleList[0], new Vector3((50*escalation)+100, 0, (50*escalation)+100), Quaternion.identity);
|
2020-01-10 00:26:44 -05:00
|
|
|
Instantiate(obstacleList[1], new Vector3(-((50*escalation)+100), 0, -((50*escalation)+100)), Quaternion.identity);
|
|
|
|
|
|
2020-01-11 00:46:40 -05:00
|
|
|
script.finished = false;
|
2020-01-07 21:52:52 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|