public void StartJigsawClient() { JigsawMenu menu = FindObjectOfType <JigsawMenu>(); if (menu.PlayerNameInput.text.Length < 4) { StaticJigsawData.ErrorHUD.DisplayMessage("You must have a valid display name, with at least 4 characters", 5.0f); return; } string hostAddr = menu.HostAddressInput.text; if (!NetworkUtils.IsValidHexAddr(hostAddr)) { StaticJigsawData.ErrorHUD.DisplayMessage("Provided host ID is invalid. It must be 8 characters long, using 0-9 and A-B", 5.0f); return; } StaticJigsawData.LocalPlayerName = menu.PlayerNameInput.text; NetworkWorldState oldWorldState = FindObjectOfType <NetworkWorldState>(); if (oldWorldState) { Destroy(oldWorldState); } StaticJigsawData.PuzzleTexture = null; // Clear the client's texture to prevent auto-populating the puzzle pieces with their own image ObjectManager.ResetState(); networkAddress = NetworkUtils.HexToIPv4(hostAddr); networkPort = 7777; StartClient(); }
public void StartJigsawHost() { if (StaticJigsawData.PuzzleTexture == null) { StaticJigsawData.ErrorHUD.DisplayMessage("You must load a valid puzzle image in order to host a game", 5.0f); return; } JigsawMenu menu = FindObjectOfType <JigsawMenu>(); if (menu.PlayerNameInput.text.Length < 4) { StaticJigsawData.ErrorHUD.DisplayMessage("You must have a valid display name, with at least 4 characters", 5.0f); return; } StaticJigsawData.LocalPlayerName = menu.PlayerNameInput.text; StaticJigsawData.PuzzleWidth = (uint)menu.PuzzleWidthSlider.value; StaticJigsawData.PuzzleHeight = (uint)menu.PuzzleHeightSlider.value; NetworkWorldState oldWorldState = FindObjectOfType <NetworkWorldState>(); if (oldWorldState) { Destroy(oldWorldState); } ObjectManager.ResetState(); networkPort = 7777; StartHost(); }
private void ReceiveNetworkWorldState(GameObject Object) { NetWorldState = Object.GetComponent <NetworkWorldState>(); if (PlayerControllerId >= 0) { OnChangePlayerController(PlayerControllerId); } }
public override void OnStopClient() { Debug.Log("Client has stopped"); NetworkWorldState oldWorldState = FindObjectOfType <NetworkWorldState>(); if (oldWorldState) { Destroy(oldWorldState); } }
private void GenerateWorldState() { if (GameWorldPrefab != null) { GameObject gameWorldInst = GameObject.Instantiate(GameWorldPrefab, Vector3.zero, Quaternion.identity); NetworkServer.Spawn(gameWorldInst); NetWorldState = gameWorldInst.GetComponent <NetworkWorldState>(); if (NetWorldState == null) { Debug.LogError("JigsawNetworkManager has GameWorldPrefab with missing NetworkWorldState"); } } else { Debug.LogError("JigsawNetworkManager has null GameWorldPrefab property"); } }
private void ReceiveNetworkWorldState(GameObject Object) { NetWorldState = Object.GetComponent <NetworkWorldState>(); NetWorldState.OnConnectedPlayersUpdated += UpdatePlayerNames; UpdatePlayerNames(); }