2020-01-29 22:59:06 -05:00
|
|
|
using System.Collections;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
using UnityEngine.SceneManagement;
|
|
|
|
|
|
|
|
|
|
[System.Serializable]
|
|
|
|
|
|
|
|
|
|
public class InfinityRunner : MonoBehaviour
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
public static bool gameOver = false;
|
|
|
|
|
public static int escalation = 1;
|
|
|
|
|
public static int level = 1;
|
|
|
|
|
public static float fullTime;
|
|
|
|
|
public GameObject player;
|
|
|
|
|
public PlayerController script;
|
|
|
|
|
public GameObject[] obstacleList;
|
|
|
|
|
public GameObject[] easyObstacleList;
|
|
|
|
|
public GameObject[] medObstaclelIst;
|
2020-02-01 17:56:51 -05:00
|
|
|
public GameObject boundaries;
|
2020-01-29 22:59:06 -05:00
|
|
|
|
|
|
|
|
private int selection;
|
|
|
|
|
private float countdownTime = 5.0f;
|
|
|
|
|
private float spawnTime = 0.0f;
|
|
|
|
|
|
|
|
|
|
private Transform lastSpawn;
|
|
|
|
|
|
|
|
|
|
void Awake()
|
|
|
|
|
{
|
|
|
|
|
script.respawnTime = Time.time;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Start is called before the first frame update
|
|
|
|
|
void Start()
|
|
|
|
|
{
|
|
|
|
|
fullTime = Time.time;
|
|
|
|
|
spawnTime = Time.time;
|
|
|
|
|
gameOver = false;
|
|
|
|
|
script = player.GetComponent<PlayerController>();
|
|
|
|
|
level = 1;
|
|
|
|
|
escalation = 1;
|
|
|
|
|
script.lives = 3;
|
|
|
|
|
script.finished = false;
|
|
|
|
|
script.transform.position = new Vector3(0, 2, 0);
|
|
|
|
|
script.transform.Rotate(0.0f, 0.0f, 0.0f, Space.Self);
|
|
|
|
|
script.pivot.transform.Rotate(0.0f, 0.0f, 0.0f, Space.Self);
|
|
|
|
|
levelBuild();
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void Update()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
if(spawnTime + countdownTime < Time.time)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
level++;
|
|
|
|
|
if(level > 3)
|
|
|
|
|
{
|
|
|
|
|
escalation++;
|
|
|
|
|
level = 1;
|
|
|
|
|
|
|
|
|
|
if(countdownTime > 3.0f)
|
|
|
|
|
{
|
|
|
|
|
countdownTime -= 0.5f;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
GameObject spawn;
|
2020-02-01 17:56:51 -05:00
|
|
|
GameObject wallOne;
|
|
|
|
|
GameObject wallTwo;
|
2020-01-29 22:59:06 -05:00
|
|
|
|
|
|
|
|
if(level == 1)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
if(escalation > 2 && escalation < 5)
|
|
|
|
|
{
|
|
|
|
|
selection = Random.Range(0, medObstaclelIst.Length);
|
|
|
|
|
spawn = Instantiate(medObstaclelIst[selection], new Vector3(0, 0, lastSpawn.transform.position.z+(25*escalation)-12.5f), Quaternion.identity) as GameObject;
|
|
|
|
|
} else if(escalation >= 5) {
|
|
|
|
|
selection = Random.Range(0, obstacleList.Length);
|
|
|
|
|
spawn = Instantiate(obstacleList[selection], new Vector3(0, 0, lastSpawn.transform.position.z+(25*escalation)-12.5f), Quaternion.identity) as GameObject;
|
|
|
|
|
} else {
|
|
|
|
|
selection = Random.Range(0, easyObstacleList.Length);
|
|
|
|
|
spawn = Instantiate(easyObstacleList[selection], new Vector3(0, 0, lastSpawn.transform.position.z+(25*escalation)-12.5f), Quaternion.identity) as GameObject;
|
2020-02-01 17:56:51 -05:00
|
|
|
|
2020-01-29 22:59:06 -05:00
|
|
|
}
|
|
|
|
|
|
2020-02-01 17:56:51 -05:00
|
|
|
wallOne = Instantiate(boundaries, new Vector3(((25f*(escalation)))/2, 0, lastSpawn.transform.position.z+(25*escalation)-12.5f), Quaternion.identity) as GameObject;
|
|
|
|
|
wallTwo = Instantiate(boundaries, new Vector3(((25f*(escalation)))/-2, 0, lastSpawn.transform.position.z+(25*escalation)-12.5f), Quaternion.identity) as GameObject;
|
|
|
|
|
|
2020-01-29 22:59:06 -05:00
|
|
|
} else {
|
|
|
|
|
|
|
|
|
|
if(escalation > 2 && escalation < 5)
|
|
|
|
|
{
|
|
|
|
|
selection = Random.Range(0, medObstaclelIst.Length);
|
|
|
|
|
spawn = Instantiate(medObstaclelIst[selection], new Vector3(0, 0, lastSpawn.transform.position.z+(25*escalation)), Quaternion.identity) as GameObject;
|
|
|
|
|
} else if(escalation >= 5) {
|
|
|
|
|
selection = Random.Range(0, obstacleList.Length);
|
|
|
|
|
spawn = Instantiate(obstacleList[selection], new Vector3(0, 0, lastSpawn.transform.position.z+(25*escalation)), Quaternion.identity) as GameObject;
|
|
|
|
|
} else {
|
|
|
|
|
selection = Random.Range(0, easyObstacleList.Length);
|
|
|
|
|
spawn = Instantiate(easyObstacleList[selection], new Vector3(0, 0, lastSpawn.transform.position.z+(25*escalation)), Quaternion.identity) as GameObject;
|
|
|
|
|
}
|
|
|
|
|
|
2020-02-01 17:56:51 -05:00
|
|
|
wallOne = Instantiate(boundaries, new Vector3(((25f*(escalation)))/2, 0, lastSpawn.transform.position.z+(25*escalation)), Quaternion.identity) as GameObject;
|
|
|
|
|
wallTwo = Instantiate(boundaries, new Vector3(((25f*(escalation)))/-2, 0, lastSpawn.transform.position.z+(25*escalation)), Quaternion.identity) as GameObject;
|
|
|
|
|
|
2020-01-29 22:59:06 -05:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
spawn.transform.localScale = new Vector3(spawn.transform.localScale.x*(0.25f*(escalation)), 1, spawn.transform.localScale.z*(0.25f*escalation));
|
2020-02-01 17:56:51 -05:00
|
|
|
wallOne.transform.localScale = new Vector3(wallOne.transform.localScale.x*(0.25f*(escalation)), 1, wallOne.transform.localScale.z*(0.25f*escalation));
|
|
|
|
|
wallTwo.transform.localScale = new Vector3(wallTwo.transform.localScale.x*(0.25f*(escalation)), 1, wallTwo.transform.localScale.z*(0.25f*escalation));
|
2020-01-29 22:59:06 -05:00
|
|
|
|
|
|
|
|
lastSpawn = spawn.transform;
|
|
|
|
|
|
|
|
|
|
spawnTime = Time.time;
|
|
|
|
|
|
2020-02-01 17:56:51 -05:00
|
|
|
GameObject[] oldObjects = GameObject.FindGameObjectsWithTag("Environment");
|
|
|
|
|
for(int i = 0; i < 3; i++) {
|
|
|
|
|
GameObject.Destroy(oldObjects[i]);
|
|
|
|
|
}
|
2020-01-29 22:59:06 -05:00
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(script.respawn == true)
|
|
|
|
|
{
|
|
|
|
|
respawn();
|
|
|
|
|
script.lives--;
|
|
|
|
|
script.respawn = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if(script.lives == 0)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
script.lives = -1;
|
|
|
|
|
fullTime = Time.time - fullTime;
|
|
|
|
|
gameOver = true;
|
|
|
|
|
Cursor.visible = true;
|
|
|
|
|
Cursor.lockState = CursorLockMode.None;
|
|
|
|
|
PauseMenu.GameIsOver = true;
|
|
|
|
|
SceneManager.LoadScene("Hub World", LoadSceneMode.Single);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void respawn()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
script.transform.position = new Vector3(0, 10, lastSpawn.transform.position.z);
|
|
|
|
|
script.transform.Rotate(0.0f, 0.0f, 0.0f, Space.Self);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void levelBuild()
|
|
|
|
|
{
|
|
|
|
|
|
2020-02-01 17:56:51 -05:00
|
|
|
GameObject walls;
|
2020-01-29 22:59:06 -05:00
|
|
|
|
2020-02-01 17:56:51 -05:00
|
|
|
GameObject start = Instantiate(obstacleList[0], new Vector3(0, 0, 0), Quaternion.identity) as GameObject;
|
2020-01-29 22:59:06 -05:00
|
|
|
start.transform.localScale = new Vector3(25, 1, 25);
|
2020-02-01 17:56:51 -05:00
|
|
|
|
|
|
|
|
walls = Instantiate(boundaries, new Vector3(12.5f, 0, 0), Quaternion.identity) as GameObject;
|
|
|
|
|
walls.transform.localScale = new Vector3(0.25f, 1, 0.25f);
|
|
|
|
|
walls = Instantiate(boundaries, new Vector3(-12.5f, 0, 0), Quaternion.identity) as GameObject;
|
|
|
|
|
walls.transform.localScale = new Vector3(0.25f, 1, 0.25f);
|
|
|
|
|
|
|
|
|
|
GameObject startOne = Instantiate(obstacleList[0], new Vector3(0, 0, 25), Quaternion.identity) as GameObject;
|
|
|
|
|
startOne.transform.localScale = new Vector3(25, 1, 25);
|
|
|
|
|
|
|
|
|
|
walls = Instantiate(boundaries, new Vector3(12.5f, 0, 25), Quaternion.identity) as GameObject;
|
|
|
|
|
walls.transform.localScale = new Vector3(0.25f, 1, 0.25f);
|
|
|
|
|
walls = Instantiate(boundaries, new Vector3(-12.5f, 0, 25), Quaternion.identity) as GameObject;
|
|
|
|
|
walls.transform.localScale = new Vector3(0.25f, 1, 0.25f);
|
|
|
|
|
|
|
|
|
|
GameObject startTwo = Instantiate(obstacleList[0], new Vector3(0, 0, 50), Quaternion.identity) as GameObject;
|
|
|
|
|
startTwo.transform.localScale = new Vector3(25, 1, 25);
|
|
|
|
|
|
|
|
|
|
walls = Instantiate(boundaries, new Vector3(12.5f, 0, 50), Quaternion.identity) as GameObject;
|
|
|
|
|
walls.transform.localScale = new Vector3(0.25f, 1, 0.25f);
|
|
|
|
|
walls = Instantiate(boundaries, new Vector3(-12.5f, 0, 50), Quaternion.identity) as GameObject;
|
|
|
|
|
walls.transform.localScale = new Vector3(0.25f, 1, 0.25f);
|
2020-01-29 22:59:06 -05:00
|
|
|
|
|
|
|
|
lastSpawn = startTwo.transform;
|
|
|
|
|
|
|
|
|
|
script.finished = false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|