CaculatorResult ComputeResult(mmopb.CalculatorResultChange_ack ack)
    {
        CaculatorResult ret = new CaculatorResult();

        ret.results[0] = ack.cal_1;
        ret.results[1] = ack.cal_2;
        ret.results[2] = ack.cal_3;
        ret.results[3] = ack.cal_4;
        ret.results[4] = ack.cal_5;
        ret.results[5] = ack.cal_6;
        return(ret);
    }
Esempio n. 2
0
    public void Handle(byte[] message)
    {
        string msgName;
        var    msg = ProtoHelper.DecodeWithName(message, out msgName);

        //连接上服务器
        if (msg is mmopb.JoinGame_ack)
        {
            isConnected = true;
            var joinGameAck = msg as mmopb.JoinGame_ack;
        }
        //第一次加入房间列表获取所有房间
        else if (msg is mmopb.GetRoom_ack)
        {
            var getRoomAck = msg as mmopb.GetRoom_ack;
            getRoomAckList.Add(getRoomAck);
        }
        //获取所有房间结束
        else if (msg is mmopb.GetRoom_fin)
        {
            isGetRoomFinish = true;
        }
        //每有新房间被其他人建立,新建新房间
        else if (msg is mmopb.NewRoom_ack)
        {
            Debug.Log("NewRoom_ack");
            newRoomAck = msg as mmopb.NewRoom_ack;
            isNewRoom  = true;
        }
        //以房主身份创建房间
        else if (msg is mmopb.CreateRoom_ack)
        {
            Debug.Log("CreateRoom_ack");
            var createRoomAck = msg as mmopb.CreateRoom_ack;
            gender      = createRoomAck.gender;
            inRoomNum   = createRoomAck.RoomID;
            firstInRoom = true;
            isInRoom    = true;
        }
        //加入房间失败
        else if (msg is mmopb.SelectRoom_err)
        {
            Debug.Log("加入房间失败");
        }
        //加入房间
        else if (msg is mmopb.SelectRoom_ack)
        {
            var selectRoonAck = msg as mmopb.SelectRoom_ack;
            inRoomNum    = selectRoonAck.RoomID;
            gender       = selectRoonAck.gender;
            anotherName  = selectRoonAck.name;
            isInRoom     = true;
            secondInRoom = true;
        }
        //刷新房间列表
        else if (msg is mmopb.RefreshRoomInfo_ack)
        {
            refreshRoomAck = msg as mmopb.RefreshRoomInfo_ack;
            isRefreshRoom  = true;
        }
        //自己退房
        else if (msg is mmopb.LeaveRoom_ack)
        {
            isLeaveRoom = true;
        }
        //别人退房
        else if (msg is mmopb.PlayerLeaveRoom_ack)
        {
            playerLeaveRoomAck = msg as mmopb.PlayerLeaveRoom_ack;
            gender             = playerLeaveRoomAck.gender;
            isPlayerLeaveRoom  = true;
        }
        //别人加进来房间
        else if (msg is mmopb.NewPlayerJoin_ack)
        {
            Debug.Log("newPlayjoin");
            var newPlayerJoinAck = msg as mmopb.NewPlayerJoin_ack;
            anotherName  = newPlayerJoinAck.name;
            secondInRoom = true;
        }
        //聊天ack
        else if (msg is mmopb.Chat_ack)
        {
            chatAck   = msg as mmopb.Chat_ack;
            isChatAck = true;
        }
        //返回主菜单
        else if (msg is mmopb.ReturnToHomePage_ack)
        {
            SceneManager.LoadScene("LevelMenu");
        }
        //计算时延
        else if (msg is mmopb.CheckTime_ack)
        {
            Debug.Log(msgName);
            var   ackmsg = msg as mmopb.CheckTime_ack;
            float delay  = Time.time - ackmsg.LocalTime;
            DelayTime.Add(delay);
        }
        //开始游戏
        else if (msg is mmopb.StartGame_req)
        {
            var startGameReq = msg as mmopb.StartGame_req;
            startDelay = startGameReq.StartDelay;
            Debug.Log("startDelay:" + startDelay);
            isReceiveStartReq = true;
        }
        //角色控制
        else if (msg is mmopb.UserActor_ack)
        {
            var userActorAck = msg as mmopb.UserActor_ack;
            actorAckList.Add(userActorAck);
            isReceiveActorAck = true;
        }
        //道具:计算器
        else if (msg is mmopb.CalculatorResultChange_ack)
        {
            var calculatorResultAck = msg as mmopb.CalculatorResultChange_ack;
            calculatorResultChange_Ack = calculatorResultAck;
            isNewResult = true;
        }
        //道具:开关
        else if (msg is mmopb.SwitchStateChange_ack)
        {
            switchState = (msg as mmopb.SwitchStateChange_ack).state;
            switchID    = (msg as mmopb.SwitchStateChange_ack).id;
            isNewSwitch = true;
        }
        //强制同步位置
        else if (msg is mmopb.SetPosition_ack)
        {
            var setPosition = msg as mmopb.SetPosition_ack;
            if (setPosition.gender != gender)
            {
                newSetPosition       = new Vector2(setPosition.position.x, setPosition.position.y);
                isReceiveSetPosition = true;
            }
        }
        //道具:书本
        else if (msg is mmopb.BookStateChange_ack)
        {
            var bookStateAck = msg as mmopb.BookStateChange_ack;
            if (bookStateAck.state)
            {
                isReceiveBookState = true;
            }
        }
        //道具:伞
        else if (msg is mmopb.UmberllaCheck_ack)
        {
            umberllaAck       = msg as mmopb.UmberllaCheck_ack;
            isReceiveUmberlla = true;
        }
        //道具:面具
        else if (msg is mmopb.MaskCheck_ack)
        {
            maskCheckAck       = msg as mmopb.MaskCheck_ack;
            isReceiveMaskCheck = true;
        }
        //道具:钥匙
        else if (msg is mmopb.KeyCheck_ack)
        {
            keyCheckAck = msg as mmopb.KeyCheck_ack;
            isKeyCheck  = true;
        }
    }