public override void handleMessage(QTMessage message) { switch (message.messageType) { case QTMessage.type.REQUEST_SYNC: WorkerServerQTClient qtRemoteClient = (WorkerServerQTClient)client; foreach (ServerQTObject obj in WorkerServerManager.instance.spawnManager.spawnedObjects.Values) { SpawnMessage spawnMessage = new SpawnMessage(); spawnMessage.objectID = obj.objectID; spawnMessage.prefabName = obj.prefabName; spawnMessage.spawnPosition = QTUtils.getSyncPositionMessageFromObject(obj); spawnMessage.spawnRotation = QTUtils.getSyncRotationMessageFromObject(obj); spawnMessage.active = obj.gameObject.activeSelf; qtRemoteClient.sendMessage(spawnMessage); foreach (BaseQTObjectComponent comp in obj.objectComponents.Values) { comp.serverComponent.syncAllFields(); } } break; } }
public override void handleMessage(QTMessage message) { switch (message.messageType) { case QTMessage.type.READY: WorkerServerQTClient qtRemoteClient = (WorkerServerQTClient)client; ReadyMessage readyMessage = (ReadyMessage)message; if (!qtRemoteClient.ready && readyMessage.state) { qtRemoteClient.ready = readyMessage.state; SessionMessage sessionMessage = new SessionMessage(); sessionMessage.session = qtRemoteClient.session; qtRemoteClient.sendMessage(sessionMessage); QTDebugger.instance.debug(QTDebugger.debugType.BASE, "Client(" + client.getIP() + ") is ready..."); WorkerServerManager.instance.onClientReady(qtRemoteClient); } else { qtRemoteClient.ready = readyMessage.state; } break; } }
public void sendMessageToAllReady(QTMessage message) { foreach (ServerQTClient qtRemoteClient in connections.clients.ToList()) { WorkerServerQTClient workerClient = (WorkerServerQTClient)qtRemoteClient; if (workerClient.ready) { qtRemoteClient.sendMessage(message); } } }
public void updateVRAction(string actionName, object value) { WorkerServerQTClient qtRemoteClient = (WorkerServerQTClient)client; if (qtRemoteClient.syncedVRActions.ContainsKey(actionName) == false) { qtRemoteClient.syncedVRActions.Add(actionName, value); } else { qtRemoteClient.syncedVRActions[actionName] = value; } }
public void updateAxisState(string axis, float value) { WorkerServerQTClient qtRemoteClient = (WorkerServerQTClient)client; if (qtRemoteClient.syncedAxis.ContainsKey(axis) == false) { qtRemoteClient.syncedAxis.Add(axis, value); } else { qtRemoteClient.syncedAxis[axis] = value; } }
public void updateState(KeyCode key, bool state) { WorkerServerQTClient qtRemoteClient = (WorkerServerQTClient)client; if (qtRemoteClient.syncedKeys.ContainsKey(key) == false) { qtRemoteClient.syncedKeys.Add(key, state); } else { qtRemoteClient.syncedKeys[key] = state; } }
public void updateVRRotation(SteamVR_Input_Sources source, Vector3 value) { WorkerServerQTClient qtRemoteClient = (WorkerServerQTClient)client; if (qtRemoteClient.syncedVRRotations.ContainsKey(source) == false) { qtRemoteClient.syncedVRRotations.Add(source, value); } else { qtRemoteClient.syncedVRRotations[source] = value; } }
public override void handleServerUpdate() { WorkerServerQTClient qtRemoteClient = (WorkerServerQTClient)WorkerServerManager.instance.connections.clients.Find(c => c.session.id == obj.ownerID); if (qtRemoteClient != null) { Dictionary <KeyCode, bool> keys = qtRemoteClient.syncedKeys; Dictionary <string, float> axis = qtRemoteClient.syncedAxis; bool keySpace = keys.ContainsKey(KeyCode.Space) ? keys[KeyCode.Space] : false; float axisX = axis.ContainsKey("Mouse X") ? axis["Mouse X"] : 0; float axisY = axis.ContainsKey("Mouse Y") ? axis["Mouse Y"] : 0; float moveX = axis.ContainsKey("Horizontal") ? axis["Horizontal"] : 0; float moveZ = axis.ContainsKey("Vertical") ? axis["Vertical"] : 0; //Rotation float mouseX = axisX * mouseSensitivity * Time.deltaTime; float mouseY = axisY * mouseSensitivity * Time.deltaTime; xRotation -= mouseY; xRotation = Mathf.Clamp(xRotation, -90f, 90f); playerCamera.gameObject.transform.localRotation = Quaternion.Euler(xRotation, 0f, 0f); playerBody.Rotate(Vector3.up * mouseX); //Position Vector3 move = playerBody.transform.right * moveX + playerBody.forward * moveZ; controller.Move(move * speed * Time.deltaTime); //Gravity isGrounded = Physics.CheckSphere(playerGround.position, groundDistance, groundMask); if (isGrounded && velocity.y < 0f) { velocity.y = -2f; } if (isGrounded && keySpace == true) { velocity.y = Mathf.Sqrt(jumpHeight * -2f * gravity); } velocity.y += gravity * Time.deltaTime; controller.Move(velocity * Time.deltaTime); //Animation playerAnimator.SetFloat("forward", moveZ); } }
public override void handleConnects() { TcpClient masterTCPClient = new TcpClient("127.0.0.1", 8111); masterClient = new WorkerQTClient(manager, masterTCPClient); masterClient.remoteType = BaseQTClient.clientType.MASTER_SERVER; QTDebugger.instance.networkClient = masterClient; QTDebugger.instance.debug(QTDebugger.debugType.BASE, "Connected to master server..."); while (true) { TcpClient tcpClient = manager.server.AcceptTcpClient(); WorkerServerQTClient client = new WorkerServerQTClient(manager, tcpClient); client.onConnectionClosed += manager.onClientDisconnected; manager.onClientConnected(client); } }