Example #1
0
    public static void AddPlayer(MsgScenePlayer msgScenePlayer, GameObject go)
    {
        if (scenePlayers.ContainsKey(msgScenePlayer.uid))
        {
            scenePlayers.Remove(msgScenePlayer.uid);
        }
        ScenePlayer scenePlayer = new ScenePlayer();

        scenePlayer.uid   = msgScenePlayer.uid;
        scenePlayer.uname = msgScenePlayer.uname;
        scenePlayer.pos_x = msgScenePlayer.scene_pos_rot.pos_x;
        scenePlayer.pos_y = msgScenePlayer.scene_pos_rot.pos_y;
        scenePlayer.pos_z = msgScenePlayer.scene_pos_rot.pos_z;
        scenePlayer.rot_x = msgScenePlayer.scene_pos_rot.rot_x;
        scenePlayer.rot_y = msgScenePlayer.scene_pos_rot.rot_y;
        scenePlayer.rot_z = msgScenePlayer.scene_pos_rot.rot_z;

        scenePlayer.moveSync = go.GetComponent <PlayerMoveSync>();
        GameObject.Destroy(go.GetComponent <PlayerMove>());

        scenePlayer.animSync = go.GetComponent <PlayerAnimationSync>();
        GameObject.Destroy(go.GetComponent <PlayerAnimation>());

        scenePlayers.Add(scenePlayer.uid, scenePlayer);
    }
Example #2
0
    private void SceneAddPlayer(MsgScenePlayer msgPlayer)
    {
        MsgScenePosRot posRot = msgPlayer.scene_pos_rot;

        GameObject player = Instantiate(
            playerPrefab,
            new Vector3(posRot.pos_x, posRot.pos_y, posRot.pos_z),
            Quaternion.identity);

        player.transform.eulerAngles = new Vector3(posRot.rot_x, posRot.rot_y, posRot.rot_z);

        SceneData.AddPlayer(msgPlayer, player);
    }
Example #3
0
    public Packet Encode()
    {
        Packet packet        = new Packet();
        ushort players_count = (ushort)this._players.Count;

        packet.WriteUshort(players_count);
        for (ushort i = 0; i < players_count; i++)
        {
            MsgScenePlayer xxx = this._players[i];
            packet.WriteBuffer(xxx.GetBuffer());
        }
        packet.Encode(Msg.P_ACK_SCENE_PLAYERS);
        return(packet);
    }
Example #4
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");
            }
        }
    }
Example #5
0
 public AckSceneEnter(Packet packet)
 {
     this._player = new MsgScenePlayer(packet);
 }
Example #6
0
 public AckSceneEnter(Packet packet)
 {
     this._player = new MsgScenePlayer(packet);
 }