/// <summary> /// Initializes the NetworkManager by: /// Spawning all the components needed. /// Listening to events. /// </summary> public static void Initialize() { Main.Log("Initializing NetworkManager"); isHost = false; isClient = false; if (!UGameObject.Exists("NetworkManager")) { networkManager = Object.Instantiate(new GameObject(), Vector3.zero, Quaternion.identity); networkManager.name = "NetworkManager"; server = networkManager.AddComponent <XmlUnityServer>(); client = networkManager.AddComponent <UnityClient>(); client.Disconnected += OnClientDisconnected; Object.DontDestroyOnLoad(networkManager); server.configuration = new TextAsset(File.ReadAllText("./Mods/DVMultiplayer/Resources/config.xml")); } if (UI == null) { UI = new NetworkingUI(); UI.Setup(); } }
// Start is called before the first frame update private void Start() { ///////////////////////////////// /// Properties initialization //...clientsId = new List<int>(); //... this is a List object! clients = new List <IClient>(); //.. Nov 1 serverReference = GetComponent <XmlUnityServer>(); availableStartPositions = new List <Vector3>(); availableStartPositions.Add(new Vector3(-2, 1, -2)); // Front left corner availableStartPositions.Add(new Vector3(2, 1, -2)); // Front right corner availableStartPositions.Add(new Vector3(-2, 1, 2)); // Rear left corner availableStartPositions.Add(new Vector3(2, 1, 2)); // Rear right corner //////////////////////////////// /// Events subscription serverReference.Server.ClientManager.ClientConnected += ClientConnected; serverReference.Server.ClientManager.ClientDisconnected += ClientDisconnected; /////////////////////////////// /// Load the game scene SceneManager.LoadScene("MainGameScene", LoadSceneMode.Additive); /////////////////////////////// /// Instantiate a second ball //...InstantiateResource("BouncyBall", new Vector3(2, 1, -2)); ///BAD CAUSED A CRASH!!! //... this is from Part 9 -- see "networkObjects" above networkObjects = new List <NetworkObject>(); }
void Start() { xmlServer = GetComponent <XmlUnityServer>(); server = xmlServer.Server; server.ClientManager.ClientConnected += OnClientConnected; server.ClientManager.ClientDisconnected += OnClientDisconnected; }
void Start() { /*roles.Add("WEREWOLF"); * roles.Add("ROBBER"); * roles.Add("SEER"); * roles.Add("MASON"); * roles.Add("MASON"); * roles.Add("WEREWOLF");*/ roles.Add("ROBBER"); roles.Add("DRUNK"); roles.Add("WEREWOLF"); roles.Add("SEER"); roles.Add("MASON"); roles.Add("ROBBER"); assignroles = new List <string>(roles); //Initialise XMLUnityServer serverReference = GetComponent <XmlUnityServer>(); // Events subscription serverReference.Server.ClientManager.ClientConnected += ClientConnected; serverReference.Server.ClientManager.ClientDisconnected += ClientDisconnected; }
private void Awake() { externalIP.text = new WebClient().DownloadString("http://icanhazip.com"); darkRiftServer = gameObject.GetComponent <XmlUnityServer>(); server = gameObject.GetComponent <TTSServer>(); hudCanvas.SetActive(false); }
// Start is called before the first frame update void Start() { clientsId = new List <int>(); serverReference = GetComponent <XmlUnityServer>(); networkObjects = new List <NetworkObject>(); serverReference.Server.ClientManager.ClientConnected += ClientConnected; serverReference.Server.ClientManager.ClientDisconnected += ClientDisconnected; SceneManager.LoadScene("Game", LoadSceneMode.Additive); }
private void Start() { ////////////////// /// Properties initialization clientsId = new List <int>(); serverReference = GetComponent <XmlUnityServer>(); networkObjects = new List <NetworkObject>(); ////////////////// /// Events subscription serverReference.Server.ClientManager.ClientConnected += ClientConnected; serverReference.Server.ClientManager.ClientDisconnected += ClientDisconnected; SceneManager.LoadScene("MainGameScene", LoadSceneMode.Additive); }
// Start is called before the first frame update void Start() { clientsId = new List <int>(); clients = new List <IClient>(); playerSelf.id = 1; //id used to uniquely identify the controllable player from the other controllable players playerRep.id = 1; //id used to match the representation of the player with its corresponding controllable player on that player's client serverReference = GetComponent <XmlUnityServer>(); ////////////////// /// Events subscription serverReference.Server.ClientManager.ClientConnected += ClientConnected; serverReference.Server.ClientManager.ClientDisconnected += ClientDisconnected; SceneManager.LoadScene("MainGameScene", LoadSceneMode.Additive); networkObjects = new List <NetworkObject>(); }
private void Awake() { clientPlayerMap = new Dictionary <ushort, ushort>(); idMap = GetComponent <TTSIDMap>(); darkRiftServer = GetComponent <XmlUnityServer>(); }
// Start is called before the first frame update void Start() { darkRiftServer = GameObject.FindGameObjectWithTag("Network").GetComponent <XmlUnityServer>(); }