Example #1
0
    public void OnNetHandler(ushort packetId, System.Object obj)
    {
        Log.Error("SceneMgr OnNetHandler packetId:" + packetId);
        if (packetId == Msg.P_ACK_SCENE_PLAYERS)
        {
            AckScenePlayers scenePlayers = obj as AckScenePlayers;
            foreach (MsgScenePlayer msgPlayer in scenePlayers.players)
            {
                SceneAddPlayer(msgPlayer);
            }
        }
        else if (packetId == Msg.P_ACK_SCENE_ENTER)
        {
            AckSceneEnter  sceneEnter = obj as AckSceneEnter;
            MsgScenePlayer msgPlayer  = sceneEnter.player;

            SceneAddPlayer(msgPlayer);
        }
        else if (packetId == Msg.P_ACK_SCENE_EXIT)
        {
            AckSceneExit sceneExit = obj as AckSceneExit;
            SceneData.DelPlayer(sceneExit.uid);
        }
        else if (packetId == Msg.P_ACK_SCENE_POS_ROT_OK)
        {
            AckScenePosRotOk posRotOk    = obj as AckScenePosRotOk;
            ScenePlayer      scenePlayer = SceneData.GetPlayer(posRotOk.uid);
            if (scenePlayer != null)
            {
                scenePlayer.moveSync.SetPositionAndRotation(posRotOk.posrot);
            }
            else
            {
                Debug.Log("P_ACK_SCENE_POS_ROT_OK no player");
            }
        }
        else if (packetId == Msg.P_ACK_SCENE_ANIM_MOVE_OK)
        {
            AckSceneAnimMoveOk animMoveOk  = obj as AckSceneAnimMoveOk;
            ScenePlayer        scenePlayer = SceneData.GetPlayer(animMoveOk.uid);
            if (scenePlayer != null)
            {
                scenePlayer.moveSync.SetAnim(animMoveOk.is_move);
            }
            else
            {
                Debug.Log("P_ACK_SCENE_ANIM_MOVE_OK no player");
            }
        }
        else if (packetId == Msg.P_ACK_SCENE_ANIM_OK)
        {
            AckSceneAnimOk animOk      = obj as AckSceneAnimOk;
            ScenePlayer    scenePlayer = SceneData.GetPlayer(animOk.uid);
            if (scenePlayer != null)
            {
                scenePlayer.animSync.SetAnim(animOk);
            }
            else
            {
                Debug.Log("P_ACK_SCENE_ANIM_OK no player");
            }
        }
    }