예제 #1
0
        //-------------------------------------------------------------------------
        // 桌子广播
        public void broadcast(ref DesktopNotify desktop_notify)
        {
            StreamData sd = new StreamData();

            sd.event_id = StreamEventId.DesktopStreamEvent;
            sd.param1   = desktop_notify;
            var grain_desktop = Entity.getUserData <GrainCellDesktop>();

            grain_desktop.AsyncStream.OnNextAsync(sd);
        }
예제 #2
0
        //-------------------------------------------------------------------------
        // 桌子通知
        void s2cPlayerDesktopNotify(DesktopNotify desktop_notify)
        {
            switch (desktop_notify.id)
            {
            case DesktopNotifyId.DesktopInit:    // 桌子初始化
            {
                EbLog.Note("ClientPlayerDesktop.s2cPlayerDesktopNotify() DesktopInit");

                CoPlayer.CoPlayerLobby.hideLobby();

                clearDesktop();

                var desktop_data = EbTool.protobufDeserialize <DesktopData>(desktop_notify.data);

                DesktopConfigData = desktop_data.desktop_cfg_data;
                //UiMbPlayDesktop ui_desk = UiMgr.Instance.createUi<UiMbPlayDesktop>(_eUiLayer.Background);
                //ui_desk.setDeskInfo(this, 60f);

                byte index = 0;
                AllSeat = new SeatInfo[DesktopConfigData.seat_num];
                foreach (var i in AllSeat)
                {
                    SeatInfo seat_info = new SeatInfo();
                    seat_info.index           = index;
                    seat_info.et_playermirror = null;
                    AllSeat[index]            = seat_info;
                    index++;
                }

                EntityData me_data = desktop_data.list_actormirror.Find((EntityData entity_data) =>
                    {
                        return(entity_data.entity_guid.Equals(CoPlayer.Entity.Guid));
                    });

                _initActorMirror(me_data);

                foreach (var i in desktop_data.list_actormirror)
                {
                    if (i.entity_guid.Equals(CoPlayer.Entity.Guid))
                    {
                        continue;
                    }

                    _initActorMirror(i);
                }

                var            co_me    = MeMirror.getComponent <ClientActorMirror <DefActorMirror> >();
                byte           me_id    = co_me.Def.PropActorIdInDesktop.get();
                RenderListener listener = new RenderListener(this);
                Scene = new CRenderScene();
                //var loading = UiMgr.Instance.createUi<UiMbLoading>(_eUiLayer.Loading);
                //Scene.onSceneLoading = loading.setLoadProgress;//null;//ui_mgr.getLoading().setRateOfProgress;
                //Scene.create(mMyPlayerId, mbSingle, false, listener, "RenderSceneConfigure.json",
                //    new JsonPacketReader("Media/Fishing/FishLord/").readJsonPacketList(),
                //    new JsonPacketReader("Media/Fishing/Route/").readRouteJsonPacketList());
            }
            break;

            case DesktopNotifyId.PlayerSceneAction:    // 玩家场景操作
            {
                var vec_param = EbTool.protobufDeserialize <List <string> >(desktop_notify.data);

                if (Scene != null)
                {
                    Scene.sceneOnRecvFromLogic(vec_param);
                }
            }
            break;

            case DesktopNotifyId.PlayerSceneAoIUpdate:    // 玩家场景广播
            {
                var ev_aoi = EbTool.protobufDeserialize <_tAoIEvent>(desktop_notify.data);

                if (Scene != null && Init)
                {
                    Scene.sceneOnRecvAoIFromLogic(ev_aoi.vec_param);
                }
            }
            break;

            case DesktopNotifyId.PlayerChat:    // 玩家聊天广播
            {
                if (string.IsNullOrEmpty(DesktopConfigData.desktop_etguid))
                {
                    return;
                }

                var msg_recv = EbTool.protobufDeserialize <ChatMsgRecv>(desktop_notify.data);

                Entity et_playermirror = null;
                MapEtActorMirrorByGuid.TryGetValue(msg_recv.et_player_guid_send, out et_playermirror);
                if (et_playermirror != null)
                {
                    var co_playermirror = et_playermirror.getComponent <ClientActorMirror <DefActorMirror> >();
                    co_playermirror.desktopChat(msg_recv);
                }
            }
            break;

            case DesktopNotifyId.PlayerEnter:    // 玩家进入桌子
            {
                if (string.IsNullOrEmpty(DesktopConfigData.desktop_etguid))
                {
                    return;
                }

                EntityData et_playermirror_data = EbTool.protobufDeserialize <EntityData>(desktop_notify.data);

                if (MapEtActorMirrorByGuid.ContainsKey(et_playermirror_data.entity_guid))
                {
                    return;
                }

                var et_playermirror = EntityMgr.genEntity <EtPlayerMirror, Entity>(et_playermirror_data, Entity);
                var co_actormirror  = et_playermirror.getComponent <ClientActorMirror <DefActorMirror> >();
                MapEtActorMirrorByGuid[et_playermirror.Guid] = et_playermirror;

                //byte seat_index = co_actormirror.Def.mPropSeatIndex.get();
                //if (isValidSeatIndex(seat_index))
                //{
                //    AllSeat[seat_index].et_playermirror = et_playermirror;
                //}

                EbLog.Note("ClientPlayerDesktop.s2cPlayerDesktopNotify() PlayerEnter PlayerEtGuid=" + et_playermirror.Guid);
            }
            break;

            case DesktopNotifyId.PlayerLeave:    // 玩家离开桌子
            {
                if (string.IsNullOrEmpty(DesktopConfigData.desktop_etguid))
                {
                    return;
                }

                string player_et_guid = EbTool.protobufDeserialize <string>(desktop_notify.data);

                EbLog.Note("ClientPlayerDesktop.s2cPlayerDesktopNotify() PlayerLeave PlayerEtGuid=" + player_et_guid);

                Entity et_playermirror = null;
                if (MapEtActorMirrorByGuid.TryGetValue(player_et_guid, out et_playermirror))
                {
                    var co_actormirror = et_playermirror.getComponent <ClientActorMirror <DefActorMirror> >();
                    MapEtActorMirrorByGuid.Remove(player_et_guid);

                    foreach (var i in AllSeat)
                    {
                        if (i.et_playermirror != null && i.et_playermirror.Guid == player_et_guid)
                        {
                            i.et_playermirror = null;
                            break;
                        }
                    }

                    et_playermirror.close();
                }
            }
            break;

            case DesktopNotifyId.PlayerOb:    // 玩家Ob
            {
                if (string.IsNullOrEmpty(DesktopConfigData.desktop_etguid))
                {
                    return;
                }

                string player_etguid = EbTool.protobufDeserialize <string>(desktop_notify.data);

                EbLog.Note("ClientPlayerDesktop.s2cPlayerDesktopNotify() PlayerOb PlayerEtGuid=" + player_etguid);

                Entity et_playermirror = null;
                if (MapEtActorMirrorByGuid.TryGetValue(player_etguid, out et_playermirror))
                {
                    var co_actormirror = et_playermirror.getComponent <ClientActorMirror <DefActorMirror> >();
                    co_actormirror.playerOb();
                }
            }
            break;

            case DesktopNotifyId.PlayerSitdown:    // 玩家坐下
            {
                if (string.IsNullOrEmpty(DesktopConfigData.desktop_etguid))
                {
                    return;
                }

                var sitdown_data = EbTool.protobufDeserialize <PlayerSitdownData>(desktop_notify.data);

                EbLog.Note("ClientPlayerDesktop.s2cPlayerDesktopNotify() PlayerSitdown PlayerEtGuid=" + sitdown_data.player_etguid);

                Entity et_playermirror = null;
                if (MapEtActorMirrorByGuid.TryGetValue(sitdown_data.player_etguid, out et_playermirror))
                {
                    var co_actormirror = et_playermirror.getComponent <ClientActorMirror <DefActorMirror> >();
                    co_actormirror.playerSitdown(sitdown_data.seat_index, sitdown_data.stack, sitdown_data.state);
                }
            }
            break;

            case DesktopNotifyId.PlayerWaitWhile:    // 玩家暂离
            {
                if (string.IsNullOrEmpty(DesktopConfigData.desktop_etguid))
                {
                    return;
                }

                var waitwhile_data = EbTool.protobufDeserialize <PlayerWaitWhileData>(desktop_notify.data);

                EbLog.Note("ClientPlayerDesktop.s2cPlayerDesktopNotify() PlayerWaitWhile PlayerEtGuid=" + waitwhile_data.player_etguid);

                Entity et_playermirror = null;
                if (MapEtActorMirrorByGuid.TryGetValue(waitwhile_data.player_etguid, out et_playermirror))
                {
                    var co_actormirror = et_playermirror.getComponent <ClientActorMirror <DefActorMirror> >();
                    co_actormirror.playerWaitWhile(waitwhile_data.wait_while_tm);
                }
            }
            break;

            case DesktopNotifyId.PlayerReturn:    // 玩家返回
            {
                if (string.IsNullOrEmpty(DesktopConfigData.desktop_etguid))
                {
                    return;
                }

                var return_data = EbTool.protobufDeserialize <PlayerReturnData>(desktop_notify.data);

                EbLog.Note("ClientPlayerDesktop.s2cPlayerDesktopNotify() PlayerReturn PlayerEtGuid=" + return_data.player_etguid);

                Entity et_playermirror = null;
                if (MapEtActorMirrorByGuid.TryGetValue(return_data.player_etguid, out et_playermirror))
                {
                    var co_actormirror = et_playermirror.getComponent <ClientActorMirror <DefActorMirror> >();
                    co_actormirror.playerReturn(return_data.stack, return_data.state);
                }
            }
            break;

            default:
                break;
            }
        }