using UnityEngine;
|
|
using System.Collections;
|
|
using UnityEngine.UI;
|
|
|
|
public class menuContrller : MonoBehaviour {
|
|
|
|
public GameObject menu;
|
|
public GameObject options;
|
|
public GameObject levelSelect;
|
|
public GameObject instructions;
|
|
public GameObject xboxLayout;
|
|
public GameObject btn_1player;
|
|
public GameObject btn_2player;
|
|
public GameObject btn_3player;
|
|
public GameObject btn_4player;
|
|
public GameObject txt_score;
|
|
public GameObject txt_confetti;
|
|
public levelController control;
|
|
public GameObject alpaca;
|
|
public GameObject platypuss;
|
|
public GameObject goat;
|
|
public GameObject kangaroo;
|
|
private bool p1Enabled = false;
|
|
private bool p2Enabled = false;
|
|
private bool p3Enabled = false;
|
|
private bool p4Enabled = false;
|
|
|
|
// Use this for initialization
|
|
void Start () {
|
|
control = GameObject.FindGameObjectWithTag ("GameController").GetComponent<levelController> ();
|
|
|
|
}
|
|
|
|
// Update is called once per frame
|
|
void Update () {
|
|
|
|
if (Input.GetAxisRaw ("Vertical_P1") == 1) {
|
|
Debug.Log("button hit");
|
|
p1Enabled = true;
|
|
btn_1player.GetComponent<Image> ().color = Color.green;
|
|
|
|
}
|
|
|
|
if (Input.GetAxisRaw ("Vertical_P2") == 1) {
|
|
p2Enabled = true;
|
|
btn_2player.GetComponent<Image> ().color = Color.green;
|
|
|
|
}
|
|
|
|
if (Input.GetAxisRaw ("Vertical_P3") == 1) {
|
|
p3Enabled = true;
|
|
btn_3player.GetComponent<Image> ().color = Color.green;
|
|
|
|
}
|
|
|
|
if (Input.GetAxisRaw ("Vertical_P4") == 1) {
|
|
p4Enabled = true;
|
|
btn_4player.GetComponent<Image> ().color = Color.green;
|
|
|
|
}
|
|
|
|
if (Input.GetButtonDown ("start") && menu.activeSelf)
|
|
panelSelect ("levelSelect");
|
|
if (Input.GetButtonDown ("start") && levelSelect.activeSelf) {
|
|
int tempRand = Mathf.RoundToInt(Random.Range (1,3));
|
|
if (tempRand == 2)
|
|
levelStart("Level1");
|
|
else
|
|
levelStart("Level2");
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
public void panelSelect (string panel){
|
|
|
|
btn_1player.GetComponent<Image> ().color = Color.grey;
|
|
btn_2player.GetComponent<Image> ().color = Color.grey;
|
|
btn_3player.GetComponent<Image> ().color = Color.grey;
|
|
btn_4player.GetComponent<Image> ().color = Color.grey;
|
|
p1Enabled = false;
|
|
p2Enabled = false;
|
|
p3Enabled = false;
|
|
p4Enabled = false;
|
|
|
|
|
|
menu.SetActive (false);
|
|
options.SetActive (false);
|
|
levelSelect.SetActive (false);
|
|
instructions.SetActive (false);
|
|
xboxLayout.SetActive (false);
|
|
alpaca.SetActive (true);
|
|
goat.SetActive (true);
|
|
platypuss.SetActive (true);
|
|
kangaroo.SetActive (true);
|
|
|
|
if (panel == "menu")
|
|
menu.SetActive (true);
|
|
|
|
if (panel =="options")
|
|
options.SetActive (true);
|
|
if (panel == "levelSelect") {
|
|
levelSelect.SetActive (true);
|
|
alpaca.SetActive (false);
|
|
goat.SetActive (false);
|
|
platypuss.SetActive (false);
|
|
kangaroo.SetActive (false);
|
|
}
|
|
if (panel == "instructions") {
|
|
instructions.SetActive (true);
|
|
alpaca.SetActive (false);
|
|
goat.SetActive (false);
|
|
platypuss.SetActive (false);
|
|
kangaroo.SetActive (false);
|
|
}
|
|
if (panel == "xboxLayout") {
|
|
xboxLayout.SetActive (true);
|
|
alpaca.SetActive (false);
|
|
goat.SetActive (false);
|
|
platypuss.SetActive (false);
|
|
kangaroo.SetActive (false);
|
|
}
|
|
}
|
|
|
|
public void playerSelect (int players){
|
|
|
|
control.playerCount = players;
|
|
|
|
if (players == 1) {
|
|
btn_1player.GetComponent<Image> ().color = Color.green;
|
|
p1Enabled = true;
|
|
}
|
|
if (players == 2) {
|
|
btn_2player.GetComponent<Image> ().color = Color.green;
|
|
p2Enabled = true;
|
|
}
|
|
if (players == 3) {
|
|
btn_3player.GetComponent<Image> ().color = Color.green;
|
|
p3Enabled = true;
|
|
}
|
|
if (players == 4) {
|
|
btn_4player.GetComponent<Image> ().color = Color.green;
|
|
p4Enabled = true;
|
|
}
|
|
|
|
|
|
}
|
|
|
|
public void levelStart (string level){
|
|
control.p1Enabled = p1Enabled;
|
|
control.p2Enabled = p2Enabled;
|
|
control.p3Enabled = p3Enabled;
|
|
control.p4Enabled = p4Enabled;
|
|
|
|
if (p1Enabled || p2Enabled || p3Enabled || p4Enabled)
|
|
Application.LoadLevel (level);
|
|
|
|
}
|
|
|
|
public void scoreChange (float score){
|
|
|
|
txt_score.GetComponent<Text> ().text = "" + Mathf.RoundToInt(score);
|
|
control.maxScore = Mathf.RoundToInt (score);
|
|
|
|
}
|
|
|
|
public void confettiSlider (float confetti){
|
|
txt_confetti.GetComponent<Text> ().text = "" + Mathf.RoundToInt(confetti);
|
|
control.confetti = Mathf.RoundToInt (confetti);
|
|
}
|
|
|
|
public void exit(){
|
|
Application.Quit ();
|
|
}
|
|
|
|
}
|