You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

147 lines
3.2 KiB

using UnityEngine;
using System.Collections;
using UnityEngine.UI;
public class sceneController : MonoBehaviour {
public GameObject player1;
public GameObject player2;
public GameObject player3;
public GameObject player4;
public levelController control;
private int playerCount;
public GameObject options;
public bool paused = false;
public GameObject confettiText;
public GameObject scoreText;
public playerId id1;
public playerId id2;
public playerId id3;
public playerId id4;
private playerController playerScript1;
private playerController playerScript2;
private playerController playerScript3;
private playerController playerScript4;
private bool exit = false;
// Use this for initialization
void Awake(){
playerScript1 = player1.GetComponent<playerController> ();
playerScript2 = player2.GetComponent<playerController> ();
playerScript3 = player3.GetComponent<playerController> ();
playerScript4 = player4.GetComponent<playerController> ();
}
void Start () {
control = GameObject.FindGameObjectWithTag ("GameController").GetComponent<levelController> ();
player1.SetActive (control.p1Enabled);
player2.SetActive (control.p2Enabled);
player3.SetActive (control.p3Enabled);
player4.SetActive (control.p4Enabled);
playerScript1.maxScore = control.maxScore;
playerScript2.maxScore = control.maxScore;
playerScript3.maxScore = control.maxScore;
playerScript4.maxScore = control.maxScore;
playerScript1.confettiOnHit = control.confetti;
playerScript2.confettiOnHit = control.confetti;
playerScript3.confettiOnHit = control.confetti;
playerScript4.confettiOnHit = control.confetti;
}
// Update is called once per frame
void Update () {
if (Input.GetButtonDown("start")) {
paused = !paused;
}
optionsSelect ();
}
public void optionsSelect(){
if (paused) {
Time.timeScale = 0.0f;
options.SetActive (true);
} else if (!paused) {
Time.timeScale = 1.0f;
options.SetActive (false);
}
if (exit) {
Time.timeScale = 1.0f;
Application.LoadLevel("Menu_Scene");
}
}
public void confetti(float confettiAmount){
control.confetti = Mathf.RoundToInt(confettiAmount);
confettiText.GetComponent<Text> ().text = "" + Mathf.RoundToInt(confettiAmount);
playerScript1.confettiOnHit = control.confetti;
playerScript2.confettiOnHit = control.confetti;
playerScript3.confettiOnHit = control.confetti;
playerScript4.confettiOnHit = control.confetti;
}
public void sccore (float scoreMax){
control.maxScore = Mathf.RoundToInt(scoreMax);
scoreText.GetComponent<Text> ().text = "" + Mathf.RoundToInt(scoreMax);
playerScript1.maxScore = control.maxScore;
playerScript2.maxScore = control.maxScore;
playerScript3.maxScore = control.maxScore;
playerScript4.maxScore = control.maxScore;
}
public void mute (bool muted){
if (muted)
AudioListener.volume = 0.0f;
else
AudioListener.volume = 1.0f;
}
public void dispID (bool visible){
id1.idVanishDisp = visible;
id2.idVanishDisp = visible;
id3.idVanishDisp = visible;
id4.idVanishDisp = visible;
}
public void exitLevel (){
Time.timeScale = 1.0f;
exit = true;
}
public void resumeGame(){
paused = false;
}
}