Commit f4ef43de authored by Benjamin Lane's avatar Benjamin Lane

Merge branch 'master' of https://git.gmu.edu/gadig/Birb into hazard

parents 3bec3cec 9b5b0014
fileFormatVersion: 2
guid: d6cfe212a9e97a048bc05857f0f87591
folderAsset: yes
timeCreated: 1490918387
licenseType: Free
DefaultImporter:
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 2aab0f924f5a7d14a927cf6163be748a
timeCreated: 1490918393
licenseType: Free
NativeFormatImporter:
userData:
assetBundleName:
assetBundleVariant:
fileFormatVersion: 2
guid: 0782f02b063b40842aa8836e9899e8fb
timeCreated: 1490918392
licenseType: Free
NativeFormatImporter:
userData:
assetBundleName:
assetBundleVariant:
......@@ -2,17 +2,20 @@
using System.Collections.Generic;
using UnityEngine.UI;
using UnityEngine;
using UnityEngine.SceneManagement;
public class GameManager : SingletonBehaviour<GameManager>
{
//Manages game state. Pause, death, win, changing levels, and level time.
public float waitTime;
private bool _isPaused;
private float _levelTimer;
public Text timerText;
private GameObject birb;
void Awake()
{
birb = GameObject.Find("Player");
DontDestroyOnLoad(this);
//isPaused = true;
}
......@@ -46,11 +49,16 @@ public class GameManager : SingletonBehaviour<GameManager>
get; set;
}
public void Fail()
public static void Fail()
{
Debug.Log("You have died");
GameManager.instance.Invoke("ReloadScene", GameManager.instance.waitTime);
}
void ReloadScene()
{
SceneManager.LoadScene(SceneManager.GetActiveScene().name);
}
public void Win()
public static void Win()
{
Debug.Log("You won!");
}
......
......@@ -5,6 +5,8 @@ using UnityEngine.SceneManagement;
public class Birb : AbstractBehavior {
public bool isDead { get; private set; }
//Add the name of the animations to be played.
private string idleAnim = "";
private string walkAnim = "";
......@@ -40,8 +42,12 @@ public class Birb : AbstractBehavior {
public void Die()
{
animator.Play (hurtAnim);
GameManager.instance.Fail ();
isDead = true;
animator.SetBool("is dead", true);
body.isKinematic = true;
body.velocity = Vector2.zero;
new WaitForSeconds(5);
GameManager.Fail ();
}
//Determines if the animation state must change.
......
......@@ -8,7 +8,7 @@ public class Hazard : MonoBehaviour {
{
if (other.CompareTag("Player"))
{
other.GetComponent<Birb>().Die ();
other.gameObject.SendMessage("Die", SendMessageOptions.DontRequireReceiver);
}
}
}
......@@ -10,7 +10,7 @@ public class WinTrigger : MonoBehaviour {
if(other.gameObject.name == "Player") //ensuring it's the player
{
//tell manager it has won
GameManager.instance.Win();
GameManager.Win();
//Debug.Log("Victory Achieved");
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment