Browse Source

Added re-spawn timer (3s), object doesnt disappear while dead. Added mute button(F11/F12)

master
Lachlan 9 years ago
parent
commit
d5d0727532
4 changed files with 47 additions and 16 deletions
  1. BIN
      playable/Assets/Lachlan_jump_work.unity
  2. +14
    -7
      playable/Assets/Scripts/Menu.cs
  3. +30
    -9
      playable/Assets/Scripts/playerController.cs
  4. +3
    -0
      playable/Assets/Scripts/stickController.cs

BIN
playable/Assets/Lachlan_jump_work.unity View File


+ 14
- 7
playable/Assets/Scripts/Menu.cs View File

@ -11,13 +11,17 @@ public class Menu : MonoBehaviour {
public GameObject musicEpic; public GameObject musicEpic;
private bool start = false; private bool start = false;
private bool menu = true; private bool menu = true;
private float goreCount = 20; private float goreCount = 20;
private string music = "Traditional"; private string music = "Traditional";
// Use this for initialization // Use this for initialization
void Start () { void Start () {
} }
// Update is called once per frame // Update is called once per frame
@ -38,10 +42,18 @@ public class Menu : MonoBehaviour {
Time.timeScale = 0; Time.timeScale = 0;
else else
Time.timeScale = 1; Time.timeScale = 1;
if (Input.GetKey(KeyCode.F12))
AudioListener.volume = 0.0f;
if (Input.GetKey(KeyCode.F11))
AudioListener.volume = 1.0f;
} }
void OnGUI () void OnGUI ()
{ {
if (start) { if (start) {
// Make a background box // Make a background box
GUI.Box (new Rect (Screen.width / 2 - 100, Screen.height / 2 - 150, 200, 300), "Menu"); GUI.Box (new Rect (Screen.width / 2 - 100, Screen.height / 2 - 150, 200, 300), "Menu");
@ -105,13 +117,8 @@ public class Menu : MonoBehaviour {
musicEpic.SetActive(false); musicEpic.SetActive(false);
musicTrad.SetActive(true); musicTrad.SetActive(true);
} }
else if (music =="Traditional"){
music = "Epic";
musicEpic.SetActive(true);
musicTrad.SetActive(false);
}
} }
GUI.Label(new Rect(Screen.width/2 +5, Screen.height/2 +55, 90, 30), "" +music); GUI.Label(new Rect(Screen.width/2 +5, Screen.height/2 +55, 90, 30), "" +music);
if (GUI.Button (new Rect (Screen.width / 2-90 , Screen.height / 2 +90, 180, 30), "Exit Menu")) { if (GUI.Button (new Rect (Screen.width / 2-90 , Screen.height / 2 +90, 180, 30), "Exit Menu")) {

+ 30
- 9
playable/Assets/Scripts/playerController.cs View File

@ -43,13 +43,18 @@ public class playerController : MonoBehaviour {
private bool canDash = true; private bool canDash = true;
private float lastDash; private float lastDash;
private bool stopDash = false; private bool stopDash = false;
public float deathTimer = 3.0f;
void Start(){ void Start(){
if (transform.rotation.y == 180) if (transform.rotation.y == 180)
curDirection = -1; curDirection = -1;
else else
curDirection = 1; curDirection = 1;
} }
@ -70,6 +75,8 @@ public class playerController : MonoBehaviour {
} }
} }
void FixedUpdate() { void FixedUpdate() {
@ -148,15 +155,28 @@ public class playerController : MonoBehaviour {
}//end displayHealth }//end displayHealth
//respawns player if they die //respawns player if they die
private void death(){
if (health <= 0) {
Instantiate (newCandy, transform.position + Vector3.up, transform.rotation);
private void death()
{
if (health <= 0)
if (deathTimer > 0)
{
deathTimer -=Time.deltaTime;
//gameObject.active = false;
if(deathTimer <=0)
{
//gameObject.active = true;
Vector3 spawnPos = new Vector3 (Random.Range (-20.0f, 20.0f), 15.0f, 0); //picks random position
health = 3; //resets life
transform.position = spawnPos; //changes position
rigidbody2D.velocity = Vector2.zero;
Instantiate (newCandy, transform.position + Vector3.up, transform.rotation);
Vector3 spawnPos = new Vector3 (Random.Range (-20.0f, 20.0f), 15.0f, 0); //picks random position
health = 3; //resets life
transform.position = spawnPos; //changes position
rigidbody2D.velocity = Vector2.zero;
deathTimer = deathTimer + 3.02f;
}
}//end if }//end if
}//end death }//end death
@ -181,6 +201,7 @@ public class playerController : MonoBehaviour {
} }
//spin
IEnumerator spinAttack(Vector3 byAngles, float inTime) { IEnumerator spinAttack(Vector3 byAngles, float inTime) {
isSpinning = true; isSpinning = true;
canSpin = false; canSpin = false;
@ -200,7 +221,7 @@ public class playerController : MonoBehaviour {
isSpinning = false; isSpinning = false;
stick.isAttacking = false; stick.isAttacking = false;
} }
//dash
IEnumerator dashAttack (float dashDistance,float dashTime) { IEnumerator dashAttack (float dashDistance,float dashTime) {
float endPosition; float endPosition;
int dashDirection; int dashDirection;

+ 3
- 0
playable/Assets/Scripts/stickController.cs View File

@ -8,6 +8,7 @@ public class stickController : MonoBehaviour {
public bool isAttacking; public bool isAttacking;
public bool isSpinning; public bool isSpinning;
// Use this for initialization // Use this for initialization
void Start () { void Start () {
@ -51,4 +52,6 @@ public class stickController : MonoBehaviour {
} }
} }

Loading…
Cancel
Save