Added final game mode - infinity runner

This commit is contained in:
Gregory Campbell
2020-01-29 22:59:06 -05:00
parent a18a380505
commit 4da18fe82b
10 changed files with 2788 additions and 4 deletions
+1 -1
View File
@@ -14,7 +14,7 @@ GameObject:
- component: {fileID: 7744844281032758491} - component: {fileID: 7744844281032758491}
m_Layer: 0 m_Layer: 0
m_Name: Wall Cross m_Name: Wall Cross
m_TagString: Wall m_TagString: Environment
m_Icon: {fileID: 0} m_Icon: {fileID: 0}
m_NavMeshLayer: 0 m_NavMeshLayer: 0
m_StaticEditorFlags: 0 m_StaticEditorFlags: 0
+1 -1
View File
@@ -14,7 +14,7 @@ GameObject:
- component: {fileID: 7394667320821091783} - component: {fileID: 7394667320821091783}
m_Layer: 0 m_Layer: 0
m_Name: Wall One Line m_Name: Wall One Line
m_TagString: Wall m_TagString: Environment
m_Icon: {fileID: 0} m_Icon: {fileID: 0}
m_NavMeshLayer: 0 m_NavMeshLayer: 0
m_StaticEditorFlags: 0 m_StaticEditorFlags: 0
+1 -1
View File
@@ -200,7 +200,7 @@ GameObject:
- component: {fileID: 92413188735621731} - component: {fileID: 92413188735621731}
m_Layer: 0 m_Layer: 0
m_Name: Wall Three Line m_Name: Wall Three Line
m_TagString: Wall m_TagString: Environment
m_Icon: {fileID: 0} m_Icon: {fileID: 0}
m_NavMeshLayer: 0 m_NavMeshLayer: 0
m_StaticEditorFlags: 0 m_StaticEditorFlags: 0
+1 -1
View File
@@ -107,7 +107,7 @@ GameObject:
- component: {fileID: 4958842341639916667} - component: {fileID: 4958842341639916667}
m_Layer: 0 m_Layer: 0
m_Name: Wall Two Line m_Name: Wall Two Line
m_TagString: Wall m_TagString: Environment
m_Icon: {fileID: 0} m_Icon: {fileID: 0}
m_NavMeshLayer: 0 m_NavMeshLayer: 0
m_StaticEditorFlags: 0 m_StaticEditorFlags: 0
File diff suppressed because it is too large Load Diff
+7
View File
@@ -0,0 +1,7 @@
fileFormatVersion: 2
guid: b20f4caac2446934da2e0ad194ea7ee1
DefaultImporter:
externalObjects: {}
userData:
assetBundleName:
assetBundleVariant:
+158
View File
@@ -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;
}
}
+11
View File
@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: af278bae524228a41b70f1e4870c0474
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
+17
View File
@@ -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(Input.GetButtonDown("Pause"))
{ {
if(GameIsPaused) if(GameIsPaused)
@@ -113,6 +119,12 @@ public class PauseMenu : MonoBehaviour
TimeText.text = "TIME: " + Mathf.Round(WaypointRace.fullTime); 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() public void LoadHubWorld()
@@ -150,6 +162,11 @@ public class PauseMenu : MonoBehaviour
SceneManager.LoadScene("Waypoint Race", LoadSceneMode.Single); SceneManager.LoadScene("Waypoint Race", LoadSceneMode.Single);
} }
if(InfinityRunner.gameOver == true)
{
SceneManager.LoadScene("Infinity Runner", LoadSceneMode.Single);
}
} }
public void Quit() public void Quit()
+6
View File
@@ -107,6 +107,12 @@ public class PlayerController : MonoBehaviour
SceneManager.LoadScene("Waypoint Race", LoadSceneMode.Single); SceneManager.LoadScene("Waypoint Race", LoadSceneMode.Single);
respawnTime = Time.time; respawnTime = Time.time;
} }
if(hit.gameObject.tag == "Infinite Portal")
{
SceneManager.LoadScene("Infinity Runner", LoadSceneMode.Single);
respawnTime = Time.time;
}
} }