예제 #1
0
 void Start()
 {
     state = new ClientWiiState();
     playerCam = transform.FindChild("Main Camera");
     controller = GetComponent<CharacterController>();
     bJump = true;
 }
예제 #2
0
 void updateWiiState(ClientWiiState _state)
 {
     state = _state;
 }
예제 #3
0
    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;
    }