Initial commit

This commit is contained in:
2021-03-18 11:56:10 -04:00
commit 44f201edd8
1582 changed files with 472891 additions and 0 deletions

View File

@@ -0,0 +1,86 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
using UnityEngine.UI;
public class FinishLevel : MonoBehaviour
{
public GameObject levelMusic;
public AudioSource levelComplete;
public GameObject levelTimer;
public GameObject timeLeft;
public GameObject theScore;
public GameObject totalScore;
public GameObject fadeOut;
public int timeCalc;
public int scoreCalc;
public int totalScored;
void OnTriggerEnter(Collider other)
{
if (other.gameObject.tag != "Player") return;
GetComponent<BoxCollider>().enabled = false;
levelMusic.SetActive(false);
levelTimer.SetActive(false);
levelComplete.Play();
StartCoroutine(CalculateScore());
}
IEnumerator CalculateScore()
{
// Stop the spawning of meteors across the whole level
MeteorZone.spawnMeteors = false;
// Reward the player with extra points for the time left on the clock
timeCalc = GlobalTimer.extendScore * 100;
totalScored = GlobalScore.currentScore + timeCalc;
// SReed33
// Changed high score system slightly to show best score for entire playthroughs
// Store this level score in playerprefs
PlayerPrefs.SetInt("LevelScore", totalScored);
// Store the total for this playthrough in playerprefs
PlayerPrefs.SetInt("RunningTotal", PlayerPrefs.GetInt("RunningTotal") + totalScored);
// Check if we beat the high score with this playthrough
print("RunningTotal: " + PlayerPrefs.GetInt("RunningTotal"));
if (PlayerPrefs.GetInt("BestScore") < PlayerPrefs.GetInt("RunningTotal"))
{
PlayerPrefs.SetInt("BestScore", PlayerPrefs.GetInt("RunningTotal"));
}
// Show the bonus applied for time remaining
timeLeft.SetActive(true);
SetChildText(timeLeft, "Time Left: " + GlobalTimer.extendScore + " x100");
yield return new WaitForSeconds(1);
// Give UnityChan 1 second to settle position, then freeze input
// + Also rotates camera to frontView for victory screen
UnityChan.UnityChanControlScriptWithRgidBody.controlsActive = false;
// Show the score from collectables gathered on this level
theScore.SetActive(true);
SetChildText(theScore, "Score: " + GlobalScore.currentScore);
yield return new WaitForSeconds(1);
// Show the calculated total score
totalScore.SetActive(true);
SetChildText(totalScore, "Total Score: " + totalScored);
yield return new WaitForSeconds(3);
// Activate the fadeOut gameobject to fade to next level
fadeOut.SetActive(true);
yield return new WaitForSeconds(2);
SceneManager.LoadScene(Level.nextLevel);
}
// Helper function to set the text of multiple fields that share a parent
void SetChildText(GameObject parent, string text)
{
foreach (Text t in parent.GetComponentsInChildren<Text>())
{
t.text = text;
}
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 6e40eaafcf0d31d499000837c61c00e2
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,30 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class GemPickup : MonoBehaviour
{
public GameObject scoreBox;
public AudioSource collectSound;
public int gemValue;
public int rotateSpeed = 2;
void Update()
{
// Sreed33
// Had to change this to Space.Self to rotate gems correctly on level2
// + Gems on walls an ceilngs were spinning on wrong axis
transform.Rotate(0, rotateSpeed * Time.timeScale, 0, Space.Self);
}
void OnTriggerEnter(Collider other)
{
// If the object is anything other than a player, do nothing
if (!other.CompareTag("Player")) return;
GlobalScore.currentScore += gemValue;
collectSound.Play();
Destroy(gameObject);
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 7d05f05c2a07a9d4f958718cefbe73e6
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,17 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class GlobalScore : MonoBehaviour
{
public GameObject scoreBox;
public static int currentScore;
public int internalScore;
void Update()
{
internalScore = currentScore;
foreach (Text t in scoreBox.GetComponentsInChildren<Text>()) t.text = "" + internalScore;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: ac157fb9c6c907e4f9858d86b0e2ea58
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,33 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
public class GlobalTimer : MonoBehaviour
{
public GameObject timeDisplay01;
public GameObject timeDisplay02;
public bool isTakingTime = false;
public int theSeconds = 150;
public static int extendScore;
void Update()
{
extendScore = theSeconds;
if (isTakingTime == false)
{
StartCoroutine(SubtractSecond());
}
}
IEnumerator SubtractSecond()
{
isTakingTime = true;
theSeconds -= 1;
timeDisplay01.GetComponent<Text>().text = "" + theSeconds;
timeDisplay02.GetComponent<Text>().text = "" + theSeconds;
yield return new WaitForSeconds(1);
isTakingTime = false;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 5372731df4e356a48965e750d1ac5e6f
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,27 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class LevelDeath : MonoBehaviour
{
public GameObject youFell;
public GameObject levelAudio;
public GameObject fadeOut;
void OnTriggerEnter(Collider other)
{
if (other.gameObject.tag != "Player") return;
StartCoroutine(YouFellOff());
}
IEnumerator YouFellOff()
{
youFell.SetActive(true);
levelAudio.SetActive(false);
yield return new WaitForSeconds(2);
fadeOut.SetActive(true);
yield return new WaitForSeconds(1);
SceneManager.LoadScene(Level.thisLevel);
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: f55c2a8138aad434890eb2397ada7320
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,46 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using UnityEngine.SceneManagement;
public class MainMenuFunction : MonoBehaviour
{
public AudioSource buttonPress;
public GameObject bestScoreDisplay;
public int bestScore;
void Start()
{
Cursor.visible = true;
// Reset the running total used to track score between levels
PlayerPrefs.SetInt("RunningTotal", 0);
// Update the best score shown on the main menu
bestScore = PlayerPrefs.GetInt("BestScore");
bestScoreDisplay.GetComponent<Text>().text = "Best: " + bestScore;
// Set the first level to be started when Play Game button is clicked
Level.nextLevel = "Level1";
}
// Called by button click actions
public void PlayGame()
{
buttonPress.Play();
SceneManager.LoadScene(Level.nextLevel);
}
// Called by button click actions
public void QuitGame()
{
buttonPress.Play();
Application.Quit();
}
// Called by button click actions
public void PlayCreds()
{
buttonPress.Play();
SceneManager.LoadScene("Credits");
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: d6f46a68c4812ae46a393fd76e3e5031
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,81 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.SceneManagement;
public class PauseGame : MonoBehaviour
{
public bool gamePaused = false;
public AudioSource levelMusic;
public GameObject pauseMenu;
public AudioSource pauseJingle;
public AudioSource buttonClickAudio;
public Level levelScript;
void Update()
{
// If we pause the game while fading in, disable fadeIn
if (gamePaused && levelScript.fadeIn.activeSelf)
{
levelScript.fadeIn.SetActive(false);
}
// Toggle pause menu
if (Input.GetButtonDown("Cancel"))
{
if (gamePaused == false)
{
Cursor.visible = true;
pauseJingle.Play();
gamePaused = true;
levelMusic.Pause();
pauseMenu.SetActive(true);
// Stop game movement by setting timeScale = 0
Time.timeScale = 0;
}
else
{
pauseMenu.SetActive(false);
levelMusic.UnPause();
Cursor.visible = false;
gamePaused = false;
// Resume game movement
Time.timeScale = 1;
}
}
}
public void ResumeGame()
{
buttonClickAudio.Play();
pauseMenu.SetActive(false);
levelMusic.UnPause();
Cursor.visible = false;
gamePaused = false;
Time.timeScale = 1;
}
public void RestartLevel()
{
buttonClickAudio.Play();
pauseMenu.SetActive(false);
levelMusic.UnPause();
Cursor.visible = false;
gamePaused = false;
Time.timeScale = 1;
SceneManager.LoadScene(Level.thisLevel);
}
public void QuitToMenu()
{
buttonClickAudio.Play();
pauseMenu.SetActive(false);
levelMusic.UnPause();
Cursor.visible = false;
gamePaused = false;
Time.timeScale = 1;
Level.nextLevel = "MainMenu";
SceneManager.LoadScene(Level.nextLevel);
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: e9af471b77ddfbf47a632495e3a29247
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,32 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class PlatformGripper : MonoBehaviour
{
// void OnCollisionStay(Collision other) {
// print("DA");
// if (other.gameObject.tag != "Player") return;
// if (other.transform.parent != this.transform.parent) {
// other.transform.SetParent(this.transform.parent);
// }
// }
// void OnCollisionExit() {
// GameObject.FindGameObjectWithTag("Player").transform.parent = GameObject.Find("##### PLAYER #####").transform;
// }
void OnTriggerStay(Collider other)
{
if (other.gameObject.tag != "Player") return;
if (other.transform.parent != this.transform.parent)
{
other.transform.SetParent(this.transform.parent);
}
}
void OnTriggerExit()
{
GameObject.FindGameObjectWithTag("Player").transform.parent = GameObject.Find("##### PLAYER #####").transform;
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 5b2d79ec13a4d7b47b641315d40bb2a5
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:

View File

@@ -0,0 +1,14 @@
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class RotateSky : MonoBehaviour
{
public float roateSpeed = 1.2f;
void Update()
{
RenderSettings.skybox.SetFloat("_Rotation", Time.time * roateSpeed);
}
}

View File

@@ -0,0 +1,11 @@
fileFormatVersion: 2
guid: 338aa06d65688f24182d573f6137b16a
MonoImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant: