Added final game mode - infinity runner
This commit is contained in:
@@ -0,0 +1,158 @@
|
||||
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;
|
||||
|
||||
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;
|
||||
|
||||
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;
|
||||
}
|
||||
|
||||
} 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;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
spawn.transform.localScale = new Vector3(spawn.transform.localScale.x*(0.25f*(escalation)), 1, spawn.transform.localScale.z*(0.25f*escalation));
|
||||
|
||||
lastSpawn = spawn.transform;
|
||||
|
||||
spawnTime = Time.time;
|
||||
|
||||
Destroy(GameObject.FindWithTag("Environment"));
|
||||
|
||||
}
|
||||
|
||||
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()
|
||||
{
|
||||
|
||||
GameObject start = Instantiate(obstacleList[0], new Vector3(0, 0, 0), Quaternion.identity) as GameObject;
|
||||
GameObject startOne = Instantiate(obstacleList[0], new Vector3(0, 0, 25), Quaternion.identity) as GameObject;
|
||||
GameObject startTwo = Instantiate(obstacleList[0], new Vector3(0, 0, 50), Quaternion.identity) as GameObject;
|
||||
|
||||
start.transform.localScale = new Vector3(25, 1, 25);
|
||||
startOne.transform.localScale = new Vector3(25, 1, 25);
|
||||
startTwo.transform.localScale = new Vector3(25, 1, 25);
|
||||
|
||||
lastSpawn = startTwo.transform;
|
||||
|
||||
script.finished = false;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,11 @@
|
||||
fileFormatVersion: 2
|
||||
guid: af278bae524228a41b70f1e4870c0474
|
||||
MonoImporter:
|
||||
externalObjects: {}
|
||||
serializedVersion: 2
|
||||
defaultReferences: []
|
||||
executionOrder: 0
|
||||
icon: {instanceID: 0}
|
||||
userData:
|
||||
assetBundleName:
|
||||
assetBundleVariant:
|
||||
@@ -41,6 +41,12 @@ public class PauseMenu : MonoBehaviour
|
||||
|
||||
}
|
||||
|
||||
if(SceneManager.GetActiveScene().name == "Infinity Runner")
|
||||
{
|
||||
ScoreText.text = "LEVEL: " + InfinityRunner.escalation + "-" + InfinityRunner.level;
|
||||
LivesText.text = "LIVES: " + PlayerController.shownLives;
|
||||
}
|
||||
|
||||
if(Input.GetButtonDown("Pause"))
|
||||
{
|
||||
if(GameIsPaused)
|
||||
@@ -113,6 +119,12 @@ public class PauseMenu : MonoBehaviour
|
||||
TimeText.text = "TIME: " + Mathf.Round(WaypointRace.fullTime);
|
||||
}
|
||||
|
||||
if(InfinityRunner.gameOver == true)
|
||||
{
|
||||
ScoreText.text = "LEVEL: " + InfinityRunner.escalation + "-" + InfinityRunner.level;
|
||||
TimeText.text = "TIME: " + Mathf.Round(InfinityRunner.fullTime);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void LoadHubWorld()
|
||||
@@ -150,6 +162,11 @@ public class PauseMenu : MonoBehaviour
|
||||
SceneManager.LoadScene("Waypoint Race", LoadSceneMode.Single);
|
||||
}
|
||||
|
||||
if(InfinityRunner.gameOver == true)
|
||||
{
|
||||
SceneManager.LoadScene("Infinity Runner", LoadSceneMode.Single);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void Quit()
|
||||
|
||||
@@ -107,6 +107,12 @@ public class PlayerController : MonoBehaviour
|
||||
SceneManager.LoadScene("Waypoint Race", LoadSceneMode.Single);
|
||||
respawnTime = Time.time;
|
||||
}
|
||||
|
||||
if(hit.gameObject.tag == "Infinite Portal")
|
||||
{
|
||||
SceneManager.LoadScene("Infinity Runner", LoadSceneMode.Single);
|
||||
respawnTime = Time.time;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user