void Start() { state = new ClientWiiState(); playerCam = transform.FindChild("Main Camera"); controller = GetComponent<CharacterController>(); bJump = true; }
void updateWiiState(ClientWiiState _state) { state = _state; }
public bool StartClient() { // start the server System.Diagnostics.Process wiiServer = new System.Diagnostics.Process(); wiiServer.StartInfo.FileName = "Assets\\WiimoteServer.exe"; // wiiServer.StartInfo.UseShellExecute = false; wiiServer.StartInfo.WindowStyle = System.Diagnostics.ProcessWindowStyle.Hidden; wiiServer.Start(); //yield WaitForSeconds(5); System.Threading.Thread.Sleep(4000); // Servers ip (localhost) and port ipep = new IPEndPoint(IPAddress.Parse("127.0.0.1"), 9050); // Create a new udp socket on client side serverSocket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); // Setup local reference for Server remote = (EndPoint)ipep; // Establish connection. Sending first message in bytes to serverSocket string msg = "Hello, are you there?"; serverSocket.SendTo(Encoding.ASCII.GetBytes(msg), remote); // Get response from serverSocket String response = WaitForMsg(); String[] msgParts = response.Split(' '); if (msgParts[0].Equals(acceptConnMsg)) { Console.WriteLine("Connected to serverSocket at: " + remote.ToString()); numWiimotes = int.Parse(msgParts[1]); wiiStates = new ClientWiiState[numWiimotes]; for (int i = 0; i < numWiimotes; i++) wiiStates[i] = new ClientWiiState(); } else { Console.WriteLine("Server refused connection. Most likely because no wiimotes exist"); return false; } return true; }