Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using UnityEngine;
- using System.Collections;
- public class MultiPlayerScript : MonoBehaviour {
- private string titleMessage = "Game Prototype";
- private string connectToIP = "127.0.0.1";
- private int connectionPort = "26500";
- private bool useNAT = false;
- private string ipAddress;
- private string port;
- private int numberOfPlayers = 10;
- public string playerName;
- public string serverName;
- public string serverNameForClient;
- private bool iWantToSetupAServer = false;
- private bool iWantToConnectToAServer = false;
- private Rect connectionWindowRect;
- private int connectionWindowWidth = 400;
- private int connectionWindowHeight = 280;
- private int buttonHeight = 60;
- private int leftIndent;
- private int topIndent;
- void Start () {
- }
- void Update () {
- }
- void ConnectWindow(int windowID)
- {
- GUILayout.Space(15);
- if(iWantToSetupAServer == false && iWantToConnectToAServer == false)
- {
- if(GUILayout.Button("Setup a server", GUILayout.height(buttonHeight)))
- {
- iWantToSetupAServer = true;
- }
- GUILayer.Space(10);
- if(GUILayout.Button("Connect to a server", GUILayout.Height(buttonHeight)))
- {
- iWantToConnectToAServer = true;
- }
- GUILayout.Space(10);
- if(Application.isWebPlayer == false && Application.isEditor == false)
- {
- if(GUILayout.Button("Exit Prototype", GUILayout.Height(buttonHeight)))
- {
- Application.Quit();
- }
- }
- }
- }
- void OnGUI()
- {
- if(Network.peerType == NetworkPeerType.Disconnected)
- {
- leftIndent = Screen.width / 2 - connectionWindowWidth / 2;
- topIndent = Screen.height /2 - connectionWindowHeight / 2;
- connectionWindowRect = new Rect(leftIndent, topIndent, connectionWindowWidth,
- connectionWindowHeight);
- connectionWindowRect = GUILayout.Window(0, connectionWindowRect, ConnectWindow,
- titleMessage);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement