3
using UnityEngine; using System.Collections; using UnityEngine.UI; public class multiplayerui : MonoBehaviour { //main panels under container public GameObject MultiPlayerMainPanel; public GameObject PassNPlayPanel; public GameObject SplitScreenPanel; public GameObject GroupPlayPanel; public GameObject ScorePanel; public GameObject ComingSoonPanel; //panels under PassNPlay panel public GameObject InputPanel; public GameObject OutputPanel; public GameObject NumberPanel; public GameObject ReadyPanel; public GameObject TimerText; //panels under GroupPlay panel public GameObject MainPanel; public GameObject HostPanel; public GameObject JoinPanel; public GameObject GamePanel; //panels under Score panel public GameObject BodyPanel; public GameObject ScoreGroupBodyPanel; //pass and play timer public GameObject timer; //reset pass and play variables QandAScript_PassAndPlay qaScript; GameObject camera; public void Start() { camera = GameObject.FindGameObjectWithTag ("MainCamera"); qaScript = camera.GetComponent<QandAScript_PassAndPlay> (); } public void passnplayclicked(){ MultiPlayerMainPanel.SetActive (false); PassNPlayPanel.SetActive (true); TimerText.SetActive (false); } public void splitscreenclicked(){ MultiPlayerMainPanel.SetActive (false); SplitScreenPanel.SetActive (true); } public void groupplayclicked(){ MultiPlayerMainPanel.SetActive (false); GroupPlayPanel.SetActive (true); }

Multiplayer u i

Embed Size (px)

DESCRIPTION

Multiplayer ui

Citation preview

Page 1: Multiplayer u i

�using UnityEngine;using System.Collections;using UnityEngine.UI;

public class multiplayerui : MonoBehaviour {

//main panels under containerpublic GameObject MultiPlayerMainPanel;public GameObject PassNPlayPanel;public GameObject SplitScreenPanel;public GameObject GroupPlayPanel;public GameObject ScorePanel;public GameObject ComingSoonPanel;

//panels under PassNPlay panelpublic GameObject InputPanel;public GameObject OutputPanel;public GameObject NumberPanel;public GameObject ReadyPanel;public GameObject TimerText;

//panels under GroupPlay panelpublic GameObject MainPanel;public GameObject HostPanel;public GameObject JoinPanel;public GameObject GamePanel;

//panels under Score panelpublic GameObject BodyPanel;public GameObject ScoreGroupBodyPanel;

//pass and play timerpublic GameObject timer;

//reset pass and play variablesQandAScript_PassAndPlay qaScript;GameObject camera;

public void Start(){

camera = GameObject.FindGameObjectWithTag ("MainCamera");qaScript = camera.GetComponent<QandAScript_PassAndPlay> ();}

public void passnplayclicked(){MultiPlayerMainPanel.SetActive (false);PassNPlayPanel.SetActive (true);TimerText.SetActive (false);

}

public void splitscreenclicked(){MultiPlayerMainPanel.SetActive (false);SplitScreenPanel.SetActive (true);

}

public void groupplayclicked(){MultiPlayerMainPanel.SetActive (false);GroupPlayPanel.SetActive (true);

}

Page 2: Multiplayer u i

public void onlineclicked(){StartCoroutine (comingsoon ());

}

IEnumerator comingsoon(){ComingSoonPanel.SetActive (true);yield return new WaitForSeconds (0.75f);ComingSoonPanel.SetActive (false);

}

//start pass and play public void goclicked(){

ReadyPanel.SetActive (false);InputPanel.SetActive (true);OutputPanel.SetActive (true);NumberPanel.SetActive (true);TimerText.SetActive (true);

qaScript.StartQuestion ();timer.GetComponent<TimerScript_PassAndPlay>().startTimer = true;timer.GetComponent<TimerScript_PassAndPlay>().startingTime = (in

t)Time.time;timer.GetComponent<TimerScript_PassAndPlay>().timerLimit=(int)St

aticScript.sliderValue;camera.GetComponent<NumPadScript> ().clearScreen ();

}

public void hostclicked(){MainPanel.SetActive (false);HostPanel.SetActive (true);JoinPanel.SetActive (false);GamePanel.SetActive (false);

}

public void joinclicked(){MainPanel.SetActive (false);HostPanel.SetActive (false);JoinPanel.SetActive (true);GamePanel.SetActive (false);

}

public void startclicked(){MainPanel.SetActive (false);HostPanel.SetActive (false);JoinPanel.SetActive (false);GamePanel.SetActive (true);

}

public void multiplayerbackbtnclicked(){Application.LoadLevel (0);

}

public void backbtnclicked(){MultiPlayerMainPanel.SetActive (true);PassNPlayPanel.SetActive (false);SplitScreenPanel.SetActive (false);GroupPlayPanel.SetActive (false);

Page 3: Multiplayer u i

ScorePanel.SetActive (false);ReadyPanel.SetActive (true);InputPanel.SetActive (false);OutputPanel.SetActive (false);NumberPanel.SetActive (false);TimerText.SetActive (false);

//reset variablesqaScript.resetAllVariables();

}

public void groupbackbtnclicked(){MainPanel.SetActive (true);HostPanel.SetActive (false);JoinPanel.SetActive (false);GamePanel.SetActive (false);

}

void Update(){

if (Input.GetKeyDown (KeyCode.Escape)) {if(PassNPlayPanel.activeInHierarchy || SplitScreenPanel.

activeInHierarchy || ScorePanel.activeInHierarchy)backbtnclicked();

else if(MultiPlayerMainPanel.activeInHierarchy)multiplayerbackbtnclicked();

else if(GroupPlayPanel.activeInHierarchy && MainPanel.activeInHierarchy)

backbtnclicked();else if(GroupPlayPanel.activeInHierarchy && !MainPanel.a

ctiveInHierarchy)groupbackbtnclicked();

}}

}