Example #1
0
        //상대 player 정보 수신
        void GetPlayerInfo()
        {
            while (true)
            {
                int buffSize = 0;
                byte[] inStream = new byte[LENGTH.MAX_PACKET_LEN];
                buffSize = clientSocket.ReceiveBufferSize;
                clientSocket.Receive (inStream);
                enemyPlayer = ByteToPlayer (inStream);

                if (enemyPlayer.task == "GameStart")
                {
                    connecting = true;
                    gameReady = true;
                    spIndex = enemyPlayer.spawnIndex;
                }
                else if (connecting == true && enemyPlayer.task == "Playing")
                    getInfo = true;
            }
        }
Example #2
0
 //byte[]를 gameprotocol로 변환
 gameProtocol ByteToPlayer(byte [] inStream)
 {
     string inPut = System.Text.Encoding.UTF8.GetString (inStream);
     enemyPlayer = JsonFx.Json.JsonReader.Deserialize <gameProtocol> (inPut);
     return enemyPlayer;
 }
Example #3
0
        /*
        void Awake ()
        {

        }
        */
        void Start()
        {
            //game server와 connect
            clientSocket.Connect ("127.0.0.1", 9001);

            //Protocol 생성
            myPlayer = new gameProtocol ();
            enemyPlayer = new gameProtocol ();

            //Game 방 접속 알리기
            byte[] firstStream = SendGameReady ();
            clientSocket.Send (firstStream);

            //
            Thread ctThread = new Thread(GetPlayerInfo);
            ctThread.Start();
        }