Browse Source

GUI 4 Player Select Updated

master
unknown 9 years ago
parent
commit
b88faafee6
5 changed files with 65 additions and 25 deletions
  1. BIN
      playable/Assets/Scenes/Level1.unity
  2. BIN
      playable/Assets/Scenes/Menu_Scene.unity
  3. +4
    -0
      playable/Assets/Scripts/levelController.cs
  4. +55
    -11
      playable/Assets/Scripts/menuContrller.cs
  5. +6
    -14
      playable/Assets/sceneController.cs

BIN
playable/Assets/Scenes/Level1.unity View File


BIN
playable/Assets/Scenes/Menu_Scene.unity View File


+ 4
- 0
playable/Assets/Scripts/levelController.cs View File

@ -6,6 +6,10 @@ public class levelController : MonoBehaviour {
public int playerCount;
public int maxScore;
public int confetti;
public bool p1Enabled;
public bool p2Enabled;
public bool p3Enabled;
public bool p4Enabled;
public static levelController control;

+ 55
- 11
playable/Assets/Scripts/menuContrller.cs View File

@ -9,6 +9,7 @@ public class menuContrller : MonoBehaviour {
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;
@ -19,14 +20,46 @@ public class menuContrller : MonoBehaviour {
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;
}
}
public void panelSelect (string panel){
@ -68,24 +101,35 @@ public class menuContrller : MonoBehaviour {
}
public void playerSelect (int players){
btn_2player.GetComponent<Image> ().color = Color.grey;
btn_3player.GetComponent<Image> ().color = Color.grey;
btn_4player.GetComponent<Image> ().color = Color.grey;
control.playerCount = players;
if (players == 2)
btn_2player.GetComponent<Image> ().color = Color.red;
if (players == 3)
btn_3player.GetComponent<Image> ().color = Color.red;
if (players == 4)
btn_4player.GetComponent<Image> ().color = Color.red;
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;
Application.LoadLevel (level);
}

+ 6
- 14
playable/Assets/sceneController.cs View File

@ -40,20 +40,12 @@ public class sceneController : MonoBehaviour {
void Start () {
control = GameObject.FindGameObjectWithTag ("GameController").GetComponent<levelController> ();
player1.SetActive (false);
player2.SetActive (false);
player3.SetActive (false);
player4.SetActive (false);
playerCount = control.playerCount;
if (playerCount >= 1)
player1.SetActive (true);
if (playerCount >= 2)
player2.SetActive (true);
if (playerCount >= 3)
player3.SetActive (true);
if (playerCount >= 4)
player4.SetActive (true);
player1.SetActive (control.p1Enabled);
player2.SetActive (control.p2Enabled);
player3.SetActive (control.p3Enabled);
player4.SetActive (control.p4Enabled);
playerScript1.maxScore = control.maxScore;
playerScript2.maxScore = control.maxScore;

Loading…
Cancel
Save