Soulman’s Mansion

Description

Soulman's Mansion was a group project at the end of my 1st year at Game Technology & Producing at Saxion. A 1v1 online game where one player is the ghost and one player is the human.
The human has to search the mansion for fuses and put them in the generator to light up the house and banish the ghost.
He also has a flashlight at his disposal that reveals the ghost and makes the ghost reappear at a random location.
The ghost has to scare the human away by touching the player or throwing objects at him.

(The gameplay video has muted game sounds due to inappropriate skype chat)

My contribution

  • Networking, Network compatible gameplay
  • Menu/UI implementation (not HUD)
  • Game managing
  • Scene switching
  • Random item/player spawns
  • Ghost spotting (with other programmer)
  • Holding/Throwing objects (with other programmer)
  • Pickup
  • Head bobbing
  • Touching and Pushing player/objects
  • Knockback
  • A spectator version of the game, used for making the trailer

Code snippets

This is my code responsible for the menus/UI. Input for finding network games also handled here.

//================================== GUI ===============================
	
	// GUI
	private void OnGUI ()
	{
		GUI.skin = guiSkin;
		currentWidth = Screen.width;
		currentHeight = Screen.height;
		scale.x = Screen.width/originalWidth; // calculate hor scale
		scale.y = Screen.height/originalHeight; // calculate vert scale
		scale.z = 1;
		var svMat = GUI.matrix; // save current matrix
		// substitute matrix - only scale is altered from standard
		GUI.matrix = Matrix4x4.TRS(Vector3.zero, Quaternion.identity, scale);
		// draw your GUI controls here:
		
		switch (Network.peerType) {
			
		case NetworkPeerType.Disconnected:
			if(menuState == "Main")
				showMainMenu();
			else if(menuState == "Play")
				showPlayMenu ();
			else if(menuState == "Host")
				showHostMenu ();
			else if(menuState == "Join")
				showJoinMenu ();
			else if(menuState == "HTP")
				showHowToPlay ();
			else if(menuState == "HTPGhost")
				showHowToPlayGhost ();
			else if(menuState == "HTPHuman")
				showHowToPlayHuman ();
			else if(menuState == "Controls")
				showControls ();
			else if(menuState == "ControlsGhost")
				showControlsGhost ();
			else if(menuState == "ControlsHuman")
				showControlsHuman ();
			else if(menuState == "Credits")
				showCredits ();
			else if(menuState == "Settings")
				showSettingsScreen ();
			break;
			
		case NetworkPeerType.Client:
			if(menuState == "Wait")
				showWaitMenu();
			else if(menuState == "Choice"){
				showChoiceMenu();
			}
			if(inGameMenu){
				if(!popup)
					showDim();
				if(!gameOver && menuState == "Game")
					showIngameMenu();
			}
			if(menuState == "End"){
				showEndMenu();
			}
			if(menuState == "HTP")
				showHowToPlay ();
			else if(menuState == "HTPGhost")
				showHowToPlayGhost ();
			else if(menuState == "HTPHuman")
				showHowToPlayHuman ();
			else if(menuState == "Controls")
				showControls ();
			else if(menuState == "ControlsGhost")
				showControlsGhost ();
			else if(menuState == "ControlsHuman")
				showControlsHuman ();
			else if(menuState == "Begin")
				showBeginScreen ();
			else if(menuState == "Settings")
				showSettingsScreen ();
			break;
			
		case NetworkPeerType.Server:
			if(menuState == "Wait"){
				showWaitMenu();
			}
			else if(menuState == "Choice"){
				showChoiceMenu();
				CheckForSpawn();
			}
			if(inGameMenu){
				if(!popup)
					showDim();
				if(!gameOver && menuState == "Game")
					showIngameMenu();
			}
			if(menuState == "End"){
				showEndMenu();
				CheckForSpawn();
			}
			if(menuState == "HTP")
				showHowToPlay ();
			else if(menuState == "HTPGhost")
				showHowToPlayGhost ();
			else if(menuState == "HTPHuman")
				showHowToPlayHuman ();
			else if(menuState == "Controls")
				showControls ();
			else if(menuState == "ControlsGhost")
				showControlsGhost ();
			else if(menuState == "ControlsHuman")
				showControlsHuman ();
			else if(menuState == "Begin"){
				showBeginScreen ();
				CheckForReady();
			}
			else if(menuState == "Settings")
				showSettingsScreen ();
			break;
			
		}
		if(popup){
			showDim ();
			showPopup();
		}
		GUI.matrix = svMat; // restore matrix
		
	}
	
	void doWindow(int windowID){
		
		switch (windowID){
			
		case 0: // Main Menu
			if (GUILayout.Button ("PLAY")) {
				menuState = "Play";
				audio.PlayOneShot(buttonClickSound);
			}
			if (GUILayout.Button ("HOW TO PLAY")) {
				menuState = "HTP";
				audio.PlayOneShot(buttonClickSound);
			}
			if (GUILayout.Button ("CONTROLS")) {
				menuState = "Controls";
				audio.PlayOneShot(buttonClickSound);
			}
			if (GUILayout.Button ("SETTINGS")) {
				menuState = "Settings";
				audio.PlayOneShot(buttonClickSound);
			}
			if (GUILayout.Button ("CREDITS")) {
				menuState = "Credits";
				audio.PlayOneShot(buttonClickSound);
			}
			if (GUILayout.Button ("EXIT")) {
				audio.PlayOneShot(buttonClickSound);
				#if UNITY_EDITOR
				UnityEditor.EditorApplication.isPlaying = false;
				#endif
				Application.Quit();
			}
			break;
			//-------------------------------------------------------------
		case 1: // Play Menu
			if (GUILayout.Button ("HOST")) {
				menuState = "Host";
				audio.PlayOneShot(buttonClickSound);
			}
			
			if (GUILayout.Button ("JOIN")) {
				menuState = "Join";
				audio.PlayOneShot(buttonClickSound);
				RefreshHostList();
			}
			
			if (GUILayout.Button ("BACK")) {
				menuState = "Main";
				audio.PlayOneShot(buttonClickSound);
			}
			break;
			//-------------------------------------------------------------
		case 2: // Host Menu
			
			GUILayout.BeginHorizontal();
			GUILayout.Label("PLAYER NAME:","TextFieldLabel");
			GUI.SetNextControlName ("playerName");
			playerName = GUILayout.TextField(playerName.ToUpper(),12);
			if(playerName == "" && GUI.GetNameOfFocusedControl () != "playerName")
				playerName = defaultPlayerName;
			if(GUI.changed)
				GameSettings.SetPlayerName(playerName);
			GUILayout.EndHorizontal();
			
			GUILayout.BeginHorizontal();
			GUILayout.Label("SERVER NAME:","TextFieldLabel");
			GUI.SetNextControlName ("serverName");
			serverName = GUILayout.TextField(serverName.ToUpper(),20);
			if(serverName == "" && GUI.GetNameOfFocusedControl () != "serverName")
				serverName = defaultServerName;
			GUILayout.EndHorizontal();
			
			GUILayout.BeginHorizontal();
			GUILayout.Label("SERVER PORT:","TextFieldLabel");
			GUI.SetNextControlName ("serverPort");
			serverPort = GUILayout.TextField(serverPort.ToUpper(),5);
			serverPort = Regex.Replace(serverPort, @"[^0-9]", "");
			if(serverPort == "" && GUI.GetNameOfFocusedControl () != "serverPort")
				serverPort = defaultPort;
			GUILayout.EndHorizontal();
			
			GUILayout.BeginHorizontal();
			GUILayout.Label("PUBLIC GAME: ","TextFieldLabel");
			if(publicGame){
				if(GUILayout.Button("YES","ToggleButton")){
					publicGame = false;
					audio.PlayOneShot(buttonClickSound);
				}
			}
			else{
				if(GUILayout.Button("NO","ToggleButton")){
					publicGame = true;
					audio.PlayOneShot(buttonClickSound);
				}
			}
			GUILayout.EndHorizontal();
			
			if (GUILayout.Button ("HOST",GUILayout.Height(50)) && typeName != "" && serverName != "") {
				audio.PlayOneShot(buttonClickSound);
				Network.InitializeServer(2, int.Parse(serverPort), !Network.HavePublicAddress());
				if(publicGame){
					MasterServer.RegisterHost(typeName,serverName);
				}
			}
			
			GUILayout.Space(20);
			
			if (GUILayout.Button ("BACK",GUILayout.Height(50))) {
				audio.PlayOneShot(buttonClickSound);
				menuState = "Play";
			}
			break;
			//-------------------------------------------------------------
		case 3: // Join Menu
			
			GUILayout.BeginHorizontal();
			
			GUILayout.Label("PLAYER NAME:","TextFieldLabel");
			GUI.SetNextControlName ("playerName");
			playerName = GUILayout.TextField(playerName.ToUpper(),12);
			if(playerName == "" && GUI.GetNameOfFocusedControl () != "playerName")
				playerName = defaultPlayerName;
			if(GUI.changed)
				GameSettings.SetPlayerName(playerName);
			GUILayout.EndHorizontal();
			
			GUILayout.Space(20);
			
			GUILayout.BeginHorizontal();
			GUILayout.BeginVertical();
			GUILayout.Label("PUBLIC GAMES");
			if (hostList != null)
			{
				for (int i = 0; i < hostList.Length; i++)
				{
					if (GUILayout.Button(hostList[i].gameName)){
						audio.PlayOneShot(buttonClickSound);
						JoinServer(hostList[i]);
					}
				}
			}
			GUILayout.EndVertical();
			GUILayout.Space(200);
			GUILayout.BeginVertical();
			GUILayout.Label("JOIN PRIVATE GAME");
			
			GUILayout.BeginHorizontal();
			GUILayout.Label("HOST IP:","TextFieldLabel");
			GUI.SetNextControlName ("connectIP");
			connectIP = GUILayout.TextField (connectIP.ToUpper(),15);
			connectIP = Regex.Replace(connectIP, @"[^0-9#.@]", "");
			if(connectIP == "" && GUI.GetNameOfFocusedControl () != "connectIP")
				connectIP = defaultIP;
			GUILayout.EndHorizontal();
			
			GUILayout.BeginHorizontal();
			GUILayout.Label("HOST PORT:","TextFieldLabel");
			GUI.SetNextControlName ("connectPort");
			connectPort = GUILayout.TextField (connectPort.ToUpper(),5);
			connectPort = Regex.Replace(connectPort, @"[^0-9]", "");
			if(connectPort == "" && GUI.GetNameOfFocusedControl () != "connectPort")
				connectPort = defaultPort;
			GUILayout.EndHorizontal();
			
			if(GUILayout.Button("JOIN") && connectPort != "" && connectIP != ""){
				audio.PlayOneShot(buttonClickSound);
				Network.Connect (connectIP.ToUpper(), int.Parse(connectPort.ToUpper()));
			}
			
			GUILayout.EndVertical();
			GUILayout.EndHorizontal();
			
			if (GUILayout.Button ("REFRESH",GUILayout.Height(50))) {
				audio.PlayOneShot(buttonClickSound);
				RefreshHostList();
			}
			
			GUILayout.Space(20);
			
			if (GUILayout.Button ("BACK",GUILayout.Height(50))) {
				audio.PlayOneShot(buttonClickSound);
				menuState = "Play";
			}
			break;
			//-------------------------------------------------------------
		case 4: // Wait Menu
			if(Network.peerType == NetworkPeerType.Server && waitingForPlayer)
				GUILayout.Label("SERVER (INTERNAL): "+serverIP+":"+serverPort);
			
			GUILayout.Space(5);
			
			if(Network.peerType == NetworkPeerType.Server && waitingForPlayer){
				GUILayout.Label ("WAITING FOR OTHER PLAYER TO CONNECT");
			}
			
			GUILayout.Space(5);
			
			GUILayout.Label("HOST: "+hostName);
			
			if(!waitingForPlayer){
				GUILayout.Label("CONNECTED: "+clientName);
				GUILayout.Space(5);
				GUILayout.Label ("GOING TO CHOICE MENU IN: "+(int)(choiceDelay - (Time.time - choiceTime)));
			}
			GUILayout.Space(5);
			if(GUILayout.Button ("BACK")){
				audio.PlayOneShot(buttonClickSound);
				if(Network.peerType == NetworkPeerType.Server)
					BackDisconnect("Host");
				else if(Network.peerType == NetworkPeerType.Client)
					BackDisconnect("Join");
			}
			break;
			//-------------------------------------------------------------
		case 5: // Choice Menu
			ChooseGUI();
			GUILayout.Space(10);
			if(GUILayout.Button ("BACK")){
				audio.PlayOneShot(buttonClickSound);
				if(Network.peerType == NetworkPeerType.Server)
					BackDisconnect("Host");
				else if(Network.peerType == NetworkPeerType.Client)
					BackDisconnect("Join");
			}
			break;
			//-------------------------------------------------------------
		case 6: // Ingame controls
			if(!popup)
				GUI.BringWindowToFront(6);
			if (GUILayout.Button ("BACK")){
				audio.PlayOneShot(buttonClickSound);
				SetInGame(false);
			}
			if (GUILayout.Button ("HOW TO PLAY")){
				audio.PlayOneShot(buttonClickSound);
				menuState = "HTP";
			}
			if (GUILayout.Button ("CONTROLS")){
				audio.PlayOneShot(buttonClickSound);
				menuState = "Controls";
			}
			if (GUILayout.Button ("SETTINGS")){
				audio.PlayOneShot(buttonClickSound);
				menuState = "Settings";
			}
			if(GUILayout.Button ("MAIN MENU")){
				audio.PlayOneShot(buttonClickSound);
				LeaveGame();
			}
			break;
			//-------------------------------------------------------------
		case 7: // Dimming
			break;
			//-------------------------------------------------------------
		case 8: // End menu
			if(!popup)
				GUI.BringWindowToFront(8);
			GUILayout.Label ("WINNER: "+winner);
			GUILayout.Space(10);
			GUILayout.Label("CHOOSE SIDE TO PLAY AGAIN");
			ChooseGUI();
			if(GUILayout.Button("MAIN MENU")){
				audio.PlayOneShot(buttonClickSound);
				LeaveGame();;
			}
			if(endResult == "WonAsGhost"){
				GUI.DrawTexture(new Rect(0,200,800,500),ghostWinTex,ScaleMode.StretchToFill);
			}
			else if(endResult == "WonAsHuman"){
				GUI.DrawTexture(new Rect(0,200,800,500),humanWinTex,ScaleMode.StretchToFill);
			}
			else if(endResult == "LostAsGhost"){
				GUI.DrawTexture(new Rect(0,200,800,500),ghostLossTex,ScaleMode.StretchToFill);
			}
			else if(endResult == "LostAsHuman"){
				GUI.DrawTexture(new Rect(0,200,800,500),humanLossTex,ScaleMode.StretchToFill);
			}
			break;
			//-------------------------------------------------------------
		case 9: // Popup Menu
			GUI.BringWindowToFront(7);
			GUI.BringWindowToFront(9);
			GUILayout.Space(20);
			GUILayout.Label(popupText,"ErrorLabel");
			GUILayout.Space(50);
			if(GUILayout.Button ("CLOSE")){
				audio.PlayOneShot(buttonClickSound);
				popup = false;
			}
			break;
		case 10: // HTP Menu
			if(GUILayout.Button("GHOST")){
				menuState = "HTPGhost";
				audio.PlayOneShot(buttonClickSound);
			}
			if(GUILayout.Button("HUMAN")){
				menuState = "HTPHuman";
				audio.PlayOneShot(buttonClickSound);
			}
			if(GUILayout.Button("BACK")){
				if(inGameMenu){
					menuState = "Game";
				}
				else{
					menuState = "Main";
				}
				audio.PlayOneShot(buttonClickSound);
			}
			break;
		case 11: // HTPGhost Menu
			if(GUILayout.Button("BACK")){
				menuState = "HTP";
				audio.PlayOneShot(buttonClickSound);
			}
			GUI.DrawTexture(new Rect(0,20,700,500),htpGhostTex,ScaleMode.StretchToFill);
			break;
		case 12: // HTPHuman Menu
			if(GUILayout.Button("BACK")){
				menuState = "HTP";
				audio.PlayOneShot(buttonClickSound);
			}
			GUI.DrawTexture(new Rect(0,20,700,500),htpHumanTex,ScaleMode.StretchToFill);
			break;
		case 13: // CONTROLS
			if(GUILayout.Button("GHOST")){
				menuState = "ControlsGhost";
				audio.PlayOneShot(buttonClickSound);
			}
			if(GUILayout.Button("HUMAN")){
				menuState = "ControlsHuman";
				audio.PlayOneShot(buttonClickSound);
			}
			if(GUILayout.Button("BACK")){
				if(inGameMenu){
					menuState = "Game";
				}
				else{
					menuState = "Main";
				}
				audio.PlayOneShot(buttonClickSound);
			}
			break;
		case 14: // ControlsGhost Menu
			if(GUILayout.Button("BACK")){
				menuState = "Controls";
				audio.PlayOneShot(buttonClickSound);
			}
			GUI.DrawTexture(new Rect(0,110,350,300),controlsGhostTex,ScaleMode.StretchToFill);
			break;
		case 15: // ControlsHuman Menu
			if(GUILayout.Button("BACK")){
				menuState = "Controls";
				audio.PlayOneShot(buttonClickSound);
			}
			GUI.DrawTexture(new Rect(0,110,350,300),controlsHumanTex,ScaleMode.StretchToFill);
			break;
		case 16: // Credits
			if(GUILayout.Button("BACK")){
				menuState = "Main";
				audio.PlayOneShot(buttonClickSound);
			}
			GUI.DrawTexture(new Rect(0,110,500,300),creditsTex,ScaleMode.StretchToFill);
			break;
		case 17: // Begin Screen
			if((spawnType == "Ghost" && ghostReady) || (spawnType == "Human" && humanReady)){
				if(GUILayout.Button ("WAITING")){
					audio.PlayOneShot(buttonClickSound);
				}
			}
			else if (GUILayout.Button ("CLICK TO GET READY")){
				audio.PlayOneShot(buttonClickSound);
				networkView.RPC("ReadyUp",RPCMode.All,spawnType);
			}
			if(spawnType == "Ghost"){
				GUI.DrawTexture(new Rect(0,120,700,500),ghostBeginTex,ScaleMode.StretchToFill);
			}
			else if(spawnType == "Human"){
				GUI.DrawTexture(new Rect(0,120,700,500),humanBeginTex,ScaleMode.StretchToFill);
			}
			break;
		case 18: // Settings
			GUILayout.Space(14);
			GUILayout.BeginHorizontal();
			GUILayout.Label("BRIGHTNESS:  ","SliderLabel");
			GameSettings.brightness = GUILayout.HorizontalSlider(brightnessTemp,-1,1);
			if(GameSettings.brightness != brightnessTemp){
				GameSettings.UpdateCameras();
				brightnessTemp = GameSettings.brightness;
			}
			GUILayout.EndHorizontal();
			if(GUILayout.Button("BACK")){
				if(inGameMenu){
					menuState = "Game";
				}
				else{
					menuState = "Main";
				}
				audio.PlayOneShot(buttonClickSound);
			}
			break;
		}		
	}
	
	void showMainMenu(){
		mainWindowRect = GUILayout.Window(0, mainWindowRect, doWindow, "MAIN MENU");
	}
	
	void showPlayMenu(){
		playWindowRect = GUILayout.Window(1, playWindowRect, doWindow, "HOST/JOIN GAME");
	}
	
	void showHostMenu(){
		hostWindowRect = GUILayout.Window(2, hostWindowRect, doWindow, "HOST GAME");
	}
	
	void showJoinMenu(){
		joinWindowRect = GUILayout.Window(3, joinWindowRect, doWindow, "JOIN GAME");
	}
	
	void showWaitMenu(){
		waitWindowRect = GUILayout.Window(4, waitWindowRect, doWindow, "WAITING MENU");
	}
	
	void showChoiceMenu(){
		choiceWindowRect = GUILayout.Window(5, choiceWindowRect, doWindow, "CHOOSE SIDE");
	}
	
	void showIngameMenu(){
		ingameWindowRect = GUILayout.Window(6, ingameWindowRect, doWindow, "GAME");
	}
	
	void showDim(){
		Rect dimRect = new Rect(0,0,originalWidth,originalHeight);
		dimRect = GUI.Window (7,dimRect,doWindow,"","Dim");
	}
	
	void showEndMenu(){
		endWindowRect = GUILayout.Window(8, endWindowRect, doWindow, "GAME OVER");
	}
	
	void showPopup(){
		popupWindowRect = GUILayout.Window(9, popupWindowRect, doWindow, "ERROR", "Popup");
	}
	
	void showHowToPlay(){
		htpWindowRect = GUILayout.Window(10, htpWindowRect, doWindow, "HOW TO PLAY");
	}
	
	void showHowToPlayGhost(){
		htpGhostWindowRect = GUILayout.Window(11, htpGhostWindowRect, doWindow, "HOW TO PLAY AS GHOST");
	}
	
	void showHowToPlayHuman(){
		htpHumanWindowRect = GUILayout.Window(12, htpHumanWindowRect, doWindow, "HOW TO PLAY AS HUMAN");
	}
	
	void showControls(){
		controlsWindowRect = GUILayout.Window(13, controlsWindowRect, doWindow, "CONTROLS");
	}
	
	void showControlsGhost(){
		controlsGhostWindowRect = GUILayout.Window(14, controlsGhostWindowRect, doWindow, "CONTROLS");
	}
	
	void showControlsHuman(){
		controlsHumanWindowRect = GUILayout.Window(15, controlsHumanWindowRect, doWindow, "CONTROLS");
	}
	
	void showCredits(){
		creditsWindowRect = GUILayout.Window(16, creditsWindowRect, doWindow, "CREDITS");
	}

	void showBeginScreen(){
		beginWindowRect = GUILayout.Window(17, beginWindowRect, doWindow, "");
	}

	void showSettingsScreen(){
		settingsWindowRect = GUILayout.Window(18, settingsWindowRect, doWindow, "SETTINGS");
	}

	void ChooseGUI(){
		if (!choiceMade && (ghostChoice || playerChoice)) {
			if(ghostChoice)
				GUILayout.Label("OTHER PLAYER CHOSE: GHOST");
			else if (playerChoice)
				GUILayout.Label("OTHER PLAYER CHOSE: PLAYER");
		}
		GUILayout.BeginHorizontal();
		if(choiceMade){
			GUILayout.Label(spawnType.ToUpper() + " CHOSEN");
		}
		if(!ghostChoice && !choiceMade){
			if(GUILayout.Button ("GHOST")){
				audio.PlayOneShot(buttonClickSound);
				networkView.RPC("GhostChosen",RPCMode.All,playerName);
				spawnType = "Ghost";
				choiceMade = true;
			}
		}
		if(!ghostChoice && !playerChoice)
			GUILayout.Label("|");
		if(!playerChoice && !choiceMade){
			if(GUILayout.Button ("HUMAN")){
				audio.PlayOneShot(buttonClickSound);
				networkView.RPC("PlayerChosen",RPCMode.All,playerName);
				spawnType = "Human";
				choiceMade = true;
			}
		}
		GUILayout.EndHorizontal();
	}
	
	void Popup(string popupString){
		popupText = popupString;
		popup = true;
	}
	
	void BackDisconnect(string newState){
		backing = true;
		Network.Disconnect();
		menuState = newState;
	}
	
	void LeaveGame(){
		leaving = true;
		Network.Disconnect();
	}

Here is a part of my NetworkManager script for pairing 2 players for a game.

// ----------------------------------------------------------------------------
	void CheckForSpawn(){ // only server checks this
		if(choicesMade && !spawned){
			networkView.RPC ("LoadLevel",RPCMode.All,gameLevel,lastLevelPrefix+1);
			spawned = true;
		}
	}

	void CheckForReady(){
		if(ghostReady && humanReady && !gameStarted){
			gameStarted = true;
			networkView.RPC ("StartGame",RPCMode.All);
		}
	}

	[RPC]
	void StartGame(){
		menuState = "Game";
		if(spawnType == "Human"){
			SpawnPlayer();
		}
		else if(spawnType == "Ghost"){
			SpawnGhost();
		}
		GameObject.Find ("StandByCamera").GetComponent ().enabled = false;
		GameObject.Find ("StandByCamera").GetComponent ().enabled = false;
	}

	[RPC]
	void ReadyUp(string type){
		if(type == "Ghost"){
			ghostReady = true;
		}
		else if(type == "Human"){
			humanReady = true;
		}
	}
			
	[RPC]
	void GhostChosen(string name){
		ghostCharName = name;
		ghostChoice = true;
		if(playerChoice)
			choicesMade = true;
	}
	
	[RPC]
	void PlayerChosen(string name){
		playerCharName = name;
		playerChoice = true;
		if(ghostChoice)
			choicesMade = true;
	}
	
	//=================================== NETWORKING =========================
	void OnMasterServerEvent(MasterServerEvent msEvent)
	{
		if (msEvent == MasterServerEvent.HostListReceived)
			hostList = MasterServer.PollHostList();
	}
	
	void OnFailedToConnectToMasterServer(NetworkConnectionError info){
		Popup("COULD NOT CONNECT TO MASTERSERVER");
	}
	
	private void RefreshHostList()
	{
		MasterServer.RequestHostList(typeName);
	}
	
	void JoinServer(HostData host){
		Network.Connect(host);
	}
	
	void OnConnectedToServer()
	{
		choiceTime = Time.time;
		waitingForPlayer = false;
		menuState = "Wait";
		networkView.RPC ("SetClientName",RPCMode.All,playerName);
	}
	
	private void OnDisconnectedFromServer (NetworkDisconnection mode)
	{	
		waitingForPlayer = true;
		waitingForChoice = false;
		ResetChoices ();
		if(!backing){
			LoadLevel (menuLevel,lastLevelPrefix+1);
			if(!leaving)
				Popup("DISCONNECTED FROM SERVER");
			else
				leaving = false;
		}
		else{
			backing = false;
		}
	}
	
	private void OnFailedToConnect (NetworkConnectionError error)
	{
		if(Network.peerType != NetworkPeerType.Server)
			Popup("COULD NOT CONNECT: " + error.ToString().ToUpper());
	}
	
	private void OnServerInitialized (NetworkPlayer player)
	{
		menuState = "Wait";
		networkView.RPC ("SetHostName",RPCMode.AllBuffered,playerName);
		waitingForPlayer = true;
		waitingForChoice = false;
		serverIP = player.ipAddress;
	}
	
	private void OnPlayerConnected (NetworkPlayer player)
	{
		choiceTime = Time.time;
		waitingForChoice = true;
		waitingForPlayer = false;
	}
	
	private void OnPlayerDisconnected (NetworkPlayer player)
	{
		waitingForChoice = false;
		waitingForPlayer = true;
		Network.RemoveRPCs(player, 0);
		Network.DestroyPlayerObjects(player);
		Popup(clientName + " DISCONNECTED");
		LeaveGame ();
	}

Info

1st year group project (grade: 9)
Genre: Scary/1v1 Online
Engine: Unity 4
Platform: Windows PC/Mac

Programming:
Richard Nazarian
Willem-Jan Eeftingh
Michelle Tang

Artwork:
Dmitry Kulikovskis
Kassym Kushkimbayev
Hang Nguyen
Borg Scheers
Rene Groen