public void NetLogin(SocketIOEvent socketEvent) { JSONObject data = socketEvent.data; Debug.Log("Response from server: " + data.ToString()); bool isHost = data.GetField("isHost").b; if (isHost) { string hostIP = data.GetField("HostIP").str; string debug = "You are the new host: " + hostIP; Debug.Log(debug); UIDebugScript.write(debug); network.StartHost(); } else { string hostIP = data.GetField("HostIP").str; string clientIP = data.GetField("ClientIP").str; string debug = "You are the client " + clientIP + " connected to " + hostIP; Debug.Log(debug); UIDebugScript.write(debug); network.networkAddress = hostIP; network.StartClient(); } }
//[Command] void Remove() { bool successful = PlayerContainer.Remove(player); UIDebugScript.write(successful.ToString()); NetworkServer.Destroy(g_fighter); Debug.Log(player.ToString() + " quit the game."); }
void ApplyMovement() { Vector2 positionDelta = innerPosition - centerPosition; UIDebugScript.write(joystickSprite.name + ": (" + position.x + ", " + position.y + ")"); if (isNormalize == false) { if (positionDelta.x > radius) { positionDelta.x = radius; } if (positionDelta.x < -radius) { positionDelta.x = -radius; } if (positionDelta.y > radius) { positionDelta.y = radius; } if (positionDelta.y < -radius) { positionDelta.y = -radius; } } else { if (positionDelta.magnitude > radius) { positionDelta = positionDelta.normalized * radius; } } position.x = positionDelta.x / radius; position.y = positionDelta.y / radius; innerPosition = centerPosition + positionDelta; Ray ray = UICamera.mainCamera.ScreenPointToRay(innerPosition); float dist = 0.0f; if (plane.Raycast(ray, out dist)) { Vector3 currentPosition = ray.GetPoint(dist); // Release joystick. joystickSprite.transform.position = currentPosition; } }