Exemplo n.º 1
0
    private void CallBack_Binary_LoginServer(byte[] _msgData)
    {
        ByteStreamBuff _tmpbuff = new ByteStreamBuff(_msgData);

        Debug.Log(_tmpbuff.Read_Int());
        Debug.Log(_tmpbuff.Read_Float());
        Debug.Log(_tmpbuff.Read_UniCodeString());
        Debug.Log(_tmpbuff.Read_UniCodeString());
        _tmpbuff.Close();
        _tmpbuff = null;
    }
Exemplo n.º 2
0
    private void gameCmd(byte[] data)
    {
        ByteStreamBuff _tmpbuff = new ByteStreamBuff(data);
        int            flag     = _tmpbuff.Read_Byte();

        switch (flag)
        {
        case MAP_FLAG:
            int[,] tmp_game_map = new int[GAME_H, GAME_W];
            List <Cooder> tmp_li_m = new List <Cooder>();
            List <Cooder> tmp_li_e = new List <Cooder>();
            int           nodeSum;
            int           x, y;
            nodeSum = _tmpbuff.Read_Int();
            for (int i = 0; i < nodeSum; i++)
            {
                x = _tmpbuff.Read_Byte();
                y = _tmpbuff.Read_Byte();
                tmp_game_map[x, y] = SER_FLAG;
                if (game_sc_mode == SER_FLAG)
                {
                    tmp_li_m.Add(new Cooder(x, y));
                }
                else
                {
                    tmp_li_e.Add(new Cooder(x, y));
                }
            }
            nodeSum = _tmpbuff.Read_Int();
            for (int i = 0; i < nodeSum; i++)
            {
                x = _tmpbuff.Read_Byte();
                y = _tmpbuff.Read_Byte();
                tmp_game_map[x, y] = CLI_FLAG;
                if (game_sc_mode == CLI_FLAG)
                {
                    tmp_li_m.Add(new Cooder(x, y));
                }
                else
                {
                    tmp_li_e.Add(new Cooder(x, y));
                }
            }

            food.x = _tmpbuff.Read_Byte();
            food.y = _tmpbuff.Read_Byte();

            game_map   = tmp_game_map;
            snake_li_m = tmp_li_m;
            snake_li_e = tmp_li_e;
            break;

        case COM_DONE:
            game_online_flag = 1;
            game_sc_mode     = _tmpbuff.Read_Byte();
            game_move_per_ms = _tmpbuff.Read_Int();
            // GAME_H = _tmpbuff.Read_Int();
            // GAME_W = _tmpbuff.Read_Int();
            game_map   = new int[GAME_H, GAME_W];
            snake_li_m = new List <Cooder>();
            snake_li_e = new List <Cooder>();
            food       = new Cooder(0, 0);


            // controlMap = new int[GAME_H, GAME_W];
            // for(int i=0;i<GAME_H;++i){
            //     for(int j=0;j<GAME_W;++j){
            //         controlMap[i,j]=_tmpbuff.Read_Byte();
            //     }
            // }
            //Debug.Log("COM_DOWN");
            break;

        case GAME_STATE_FLAG:
            win_los_flag = _tmpbuff.Read_Byte();
            break;

        case FOOD_FLAG:
            break;

        default:
            Debug.Log("Unknow flag!");
            break;
        }
    }