Commit 8503d4e3 authored by Mitchie Maluschnig's avatar Mitchie Maluschnig
Browse files

organised scripts folder

parent ba831b43
fileFormatVersion: 2
guid: 41d050973d7f949069907590e2c66c75
MonoImporter:
guid: a04f238eb4e39ae4dbe75786919ec611
folderAsset: yes
DefaultImporter:
externalObjects: {}
serializedVersion: 2
defaultReferences: []
executionOrder: 0
icon: {instanceID: 0}
userData:
assetBundleName:
assetBundleVariant:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Key : MonoBehaviour {
public float speed = 1f;
public int points = 10;
public GameObject explosion;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
transform.Translate(Vector3.down * speed * Time.deltaTime, Space.World);
if(!isVisible()){
MimeMime.MissHit(GetComponent<Key>());
Instantiate(explosion, transform.position, transform.rotation);
Destroy(gameObject);
}
}
bool isVisible(){
Plane[] planes = GeometryUtility.CalculateFrustumPlanes(Camera.main);
return GeometryUtility.TestPlanesAABB(planes, GetComponent<Renderer>().bounds);
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Key : MonoBehaviour {
public float speed = 1f;
public int points = 10;
public GameObject explosion;
// Use this for initialization
void Start () {
}
// Update is called once per frame
void Update () {
transform.Translate(Vector3.down * speed * Time.deltaTime, Space.World);
if(!isVisible()){
MimeMime.MissHit(GetComponent<Key>());
Instantiate(explosion, transform.position, transform.rotation);
Destroy(gameObject);
}
}
}
bool isVisible(){
Plane[] planes = GeometryUtility.CalculateFrustumPlanes(Camera.main);
return GeometryUtility.TestPlanesAABB(planes, GetComponent<Renderer>().bounds);
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MimeMime : MonoBehaviour {
private static float playerScore;
private static int combo;
private static float comboMultiplyer;
private static int totalNotes;
private static int perfectHits;
private static int goodHits;
private static int badHits;
private static int misses;
private static int badCount;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class MimeMime : MonoBehaviour {
private static float playerScore;
private static int combo;
private static float comboMultiplyer;
private static int totalNotes;
private static int perfectHits;
private static int goodHits;
private static int badHits;
private static int misses;
private static int badCount;
public static void PerfectHit(Key key)
{
addPlayerScore(key.points);
perfectHits++;
updateMultiplyer();
Combo += 1;
}
public static void GoodHit(Key key)
{
addPlayerScore(key.points * 0.8f);
goodHits++;
updateMultiplyer();
}
public static void BadHit(Key key)
{
addPlayerScore(key.points * 0.4f);
badHits++;
badCount++;
updateMultiplyer();
Combo -= badCount;
}
public static void MissHit(Key key) {
addPlayerScore(key.points * 0.2f);
misses++;
badCount++;
updateMultiplyer();
Combo -= badCount;
}
public static int Combo {
set {
if(value < 0) {
combo = value;
} else {
if(value > 80) {
badCount = 1;
}else if(value > 40) {
badCount = 1;
}else if(value > 20) {
badCount = 1;
}else if(value > 10) {
badCount = 1;
}
combo = value;
}
if (combo < 0) combo = 0;
}
get { return combo; }
}
public static float PlayerScore {
set {
playerScore = value;
}
get { return playerScore; }
}
private static void addPlayerScore(float points) {
PlayerScore += (points * comboMultiplyer);
}
private static void updateMultiplyer() {
totalNotes++;
comboMultiplyer = (float)combo/totalNotes + 1;
print("Multi: " + comboMultiplyer);
}
}
{
addPlayerScore(key.points);
perfectHits++;
updateMultiplyer();
Combo += 1;
}
public static void GoodHit(Key key)
{
addPlayerScore(key.points * 0.8f);
goodHits++;
updateMultiplyer();
}
public static void BadHit(Key key)
{
addPlayerScore(key.points * 0.4f);
badHits++;
badCount++;
updateMultiplyer();
Combo -= badCount;
}
public static void MissHit(Key key) {
addPlayerScore(key.points * 0.2f);
misses++;
badCount++;
updateMultiplyer();
Combo -= badCount;
}
public static int Combo {
set {
if(value < 0) {
combo = value;
} else {
if(value > 80) {
badCount = 1;
}else if(value > 40) {
badCount = 1;
}else if(value > 20) {
badCount = 1;
}else if(value > 10) {
badCount = 1;
}
combo = value;
}
if (combo < 0) combo = 0;
}
get { return combo; }
}
public static float PlayerScore {
set {
playerScore = value;
}
get { return playerScore; }
}
private static void addPlayerScore(float points) {
PlayerScore += (points * comboMultiplyer);
}
private static void updateMultiplyer() {
totalNotes++;
comboMultiplyer = (float)combo/totalNotes + 1;
print("Multi: " + comboMultiplyer);
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class SpawnKeys : MonoBehaviour {
public bool ComputerCheck = false;
public TextAsset songFile;
public GameObject arrowPrefab;
public float skip;
public float volumeFade;
private string song = "default";
private float startTime;
private bool endSong = false;
private AudioSource music;
Queue<string[]> songKeys = new Queue<string[]>();
string[] nextKey;
int pointer = 0;
float songWaitTime;
private LevelManager levelManager;
// Use this for initialization
void Start () {
levelManager = GetComponent<LevelManager>();
startTime = Time.time;
int count = 0;
//Same as above but uses queues, will have to parse
//string of timings into a float later on.
print("Queue version!");
foreach (string line in songFile.text.Split('\n'))
{
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class SpawnKeys : MonoBehaviour {
public bool ComputerCheck = false;
public TextAsset songFile;
public GameObject arrowPrefab;
public float skip;
public float volumeFade;
private string song = "default";
private float startTime;
private bool endSong = false;
private AudioSource music;
Queue<string[]> songKeys = new Queue<string[]>();
string[] nextKey;
int pointer = 0;
float songWaitTime;
private LevelManager levelManager;
// Use this for initialization
void Start () {
levelManager = GetComponent<LevelManager>();
startTime = Time.time;
int count = 0;
//Same as above but uses queues, will have to parse
//string of timings into a float later on.
print("Queue version!");
foreach (string line in songFile.text.Split('\n'))
{
if (count != 0)
{
songKeys.Enqueue(line.Split(' '));
}else{
song = line.Split(' ')[0];
songWaitTime = float.Parse(line.Split(' ')[1]);
}
count++;
}
nextKey = songKeys.Dequeue();
//print out queue
//while (songKeys.Count > 0)
//{
// string[] x = songKeys.Dequeue();
// print(x[0] + " " + x[1]);
//}
AudioClip songAudio = Resources.Load<AudioClip>(song);
songWaitTime = songWaitTime / arrowPrefab.GetComponent<Key>().speed;
StartCoroutine(playSong(songAudio, songWaitTime));
}
//plays the song after the first arrow reaches a barrier.
private IEnumerator playSong(AudioClip musicClip, float waitTime){
yield return new WaitForSeconds(waitTime);
songKeys.Enqueue(line.Split(' '));
}else{
song = line.Split(' ')[0];
songWaitTime = float.Parse(line.Split(' ')[1]);
}
count++;
}
nextKey = songKeys.Dequeue();
//print out queue
//while (songKeys.Count > 0)
//{
// string[] x = songKeys.Dequeue();
// print(x[0] + " " + x[1]);
//}
AudioClip songAudio = Resources.Load<AudioClip>(song);
songWaitTime = songWaitTime / arrowPrefab.GetComponent<Key>().speed;
StartCoroutine(playSong(songAudio, songWaitTime));
}
//plays the song after the first arrow reaches a barrier.
private IEnumerator playSong(AudioClip musicClip, float waitTime){
yield return new WaitForSeconds(waitTime);
music = transform.GetComponent<AudioSource>();
music.clip = musicClip;
music.Play();
music.time = skip;
}
music.Play();
music.time = skip;
}
// Update is called once per frame
private IEnumerator testNote(string arrow){
yield return new WaitForSeconds(songWaitTime);
TriggerManager tester = GameObject.FindWithTag("TriggerManager").GetComponent<TriggerManager>();
tester.test(arrow);
private IEnumerator testNote(string arrow){
yield return new WaitForSeconds(songWaitTime);
TriggerManager tester = GameObject.FindWithTag("TriggerManager").GetComponent<TriggerManager>();
tester.test(arrow);
}
private IEnumerator silasDance(string arrow)
{
yield return new WaitForSeconds(songWaitTime);
TriggerManager tester = GameObject.FindWithTag("TriggerManager").GetComponent<TriggerManager>();
tester.SilasDance(arrow);
private IEnumerator silasDance(string arrow)
{
yield return new WaitForSeconds(songWaitTime);
TriggerManager tester = GameObject.FindWithTag("TriggerManager").GetComponent<TriggerManager>();
tester.SilasDance(arrow);
}
void Update () {
if(endSong == true){
music.volume -= (volumeFade * Time.deltaTime);
}
while (nextKey != null && Time.time > startTime + float.Parse(nextKey[1]) - skip)
{
void Update () {
if(endSong == true){
music.volume -= (volumeFade * Time.deltaTime);
}
while (nextKey != null && Time.time > startTime + float.Parse(nextKey[1]) - skip)
{
if (float.Parse(nextKey[1]) >= skip)
{
switch (nextKey[0])
......@@ -96,57 +96,57 @@ public class SpawnKeys : MonoBehaviour {
case "left":
//print("left");
Instantiate(arrowPrefab, new Vector3(4.85f, 4f, 1f), Quaternion.identity);
if(ComputerCheck == true){
StartCoroutine(testNote("Left"));
}
StartCoroutine(silasDance("Left"));
Instantiate(arrowPrefab, new Vector3(4.85f, 4f, 1f), Quaternion.identity);
if(ComputerCheck == true){
StartCoroutine(testNote("Left"));
}
StartCoroutine(silasDance("Left"));
break;
case "right":
//print("right");
Instantiate(arrowPrefab, new Vector3(8.82f, 4f, 1f), Quaternion.Euler(new Vector3(0, 0, 180)));
if (ComputerCheck == true)
{
StartCoroutine(testNote("Right"));
if (ComputerCheck == true)
{
StartCoroutine(testNote("Right"));
}
StartCoroutine(silasDance("Right"));
break;
case "up":
//print("up");
Instantiate(arrowPrefab, new Vector3(6.18f, 4f, 1f), Quaternion.Euler(new Vector3(0, 0, 270)));
if (ComputerCheck == true)
{
StartCoroutine(testNote("Up"));
if (ComputerCheck == true)
{
StartCoroutine(testNote("Up"));
}
StartCoroutine(silasDance("Up"));
break;
case "down":
//print("DOWN");
Instantiate(arrowPrefab, new Vector3(7.51f, 4f, 1f), Quaternion.Euler(new Vector3(0, 0, 90)));
if (ComputerCheck == true)
{
StartCoroutine(testNote("Down"));
if (ComputerCheck == true)
{
StartCoroutine(testNote("Down"));
}
StartCoroutine(silasDance("Down"));
break;
default:
break;
}
}
if (songKeys.Count > 0)
{
nextKey = songKeys.Dequeue();
}
else
{
if(!endSong){
levelManager.SongFinished();
}
//no more keys
nextKey = null;
endSong = true;
}
}
}
}
}
}
if (songKeys.Count > 0)
{
nextKey = songKeys.Dequeue();
}
else
{
if(!endSong){
levelManager.SongFinished();
}
//no more keys
nextKey = null;
endSong = true;
}
}
}
}
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class TriggerManager : MonoBehaviour
{
public Collider2D perfectCollider;
public Collider2D goodCollider;
public Collider2D badCollider;
private Transform player;
private Transform mime;
public GameObject perfectHit;
public GameObject goodHit;
public GameObject badHit;
//the distance between the centre of each trigger area.
public float sepparation = 1f;
public ContactFilter2D filter = new ContactFilter2D();
enum keys { left = 0, right = 3, up = 1, down = 2 }
// Use this for initialization
void Start()
{
filter.SetLayerMask(LayerMask.GetMask("Key"));
player = GameObject.FindWithTag("Player").transform;
mime = GameObject.FindWithTag("Silas").transform;
}
// Update is called once per frame
void Update()
{
//Check which key the player presses
if (Input.GetKeyDown(KeyCode.LeftArrow))
{
moveColliders((int)keys.left);
player.transform.rotation = Quaternion.Euler(new Vector3(0f, 0f, 90f));