예제 #1
0
파일: SceneLogic.cs 프로젝트: profiles/Fish
 public void ResetScene(JoinRoomData jrd, bool bFirst = false)
 {
     NetServices.Instance.CmdHandler = this;
     ResetPlayerData(jrd, bFirst);
     if (bFirst == false)
     {
         RefreshScene();
     }
 }
    internal bool TryClearJoinRoomDataIfRoom(string room, out JoinRoomData joinRoomData)
    {
        bool result = false;

        joinRoomData = default(JoinRoomData);
        lock (joinRoomDataLock)
        {
            if (signedJoinRoomData != null && RoomIdentifier.EqualsIgnoreInstanceId(signedJoinRoomData.Data.room, room))
            {
                result             = true;
                joinRoomData       = signedJoinRoomData.Data;
                signedJoinRoomData = null;
            }
        }
        return(result);
    }
    internal bool TryClearJoinRoomData(out JoinRoomData joinRoomData)
    {
        bool result = false;

        joinRoomData = default(JoinRoomData);
        lock (joinRoomDataLock)
        {
            if (signedJoinRoomData != null)
            {
                result             = true;
                joinRoomData       = signedJoinRoomData.Data;
                signedJoinRoomData = null;
            }
        }
        return(result);
    }
예제 #4
0
파일: SceneLogic.cs 프로젝트: profiles/Fish
    public void ResetPlayerData(JoinRoomData jrd, bool bFirst)
    {
        byte serverSeat         = jrd.Seat;
        byte serverLauncherType = jrd.LauncherType;

        SceneObjMgr.Instance.SwapBackgroundImage(jrd.BackgroundImage);
        m_RoomType      = jrd.RoomID;
        m_RoomRateIndex = FishConfig.Instance.m_TableInfo.m_TableConfig[m_RoomType].MinRate;// ExtraSetting.RoomDataList[m_RoomType].RoomRateIdx;
        //管理器初始化
        if (bFirst || SceneRuntime.BackgroundIndex != jrd.BackgroundImage)
        {
            m_EffectMgr.ClearBackEffect();
            m_EffectMgr.LoadBackEffect(jrd.BackgroundImage);
        }
        SceneRuntime.Inversion       = serverSeat > 1;
        SceneRuntime.BackgroundIndex = jrd.BackgroundImage;
        m_PlayerMgr.MyClientSeat     = SceneRuntime.ServerToClientSeat(serverSeat);
        PlayerMgr.ClearAllPlayer();
        //加入自己
        bool launcherValid;
        byte clientLauncherType;

        SceneRuntime.CheckLauncherValid(
            serverLauncherType,
            out clientLauncherType,
            out launcherValid);
        //获取自己的消息
        RoleMe pMe = PlayerRole.Instance.RoleInfo.RoleMe;

        pMe.SetSeat(serverSeat);
        PlayerExtraData pPlayer = new PlayerExtraData();

        pPlayer.playerData.GoldNum =
            (int)PlayerRole.Instance.GetPlayerGlobelBySeat(pMe.GetSeat());
        pPlayer.playerData.ID     = pMe.GetUserID();
        pPlayer.playerData.ImgCrc = pMe.GetFaceID();
        pPlayer.playerData.Level  = (byte)pMe.GetLevel();
        pPlayer.playerData.Name   = pMe.GetNickName();
        m_PlayerMgr.PlayerJoin(pPlayer,
                               m_PlayerMgr.MyClientSeat,
                               jrd.RateIndex,
                               clientLauncherType,
                               launcherValid);
        m_PlayerMgr.UpdateEnergy(jrd.Energy);
    }
예제 #5
0
        public async Task JoinRoom(UserConnection connection, JoinRoomData data)
        {
            if (!this.Rooms.Any(x => x.Name == data.RoomName))
            {
                await connection.SendPacketAsync(new Packet(PacketType.Fail, new ReasonData()
                {
                    Reason = "Room no longer exists!"
                }));

                return;
            }

            var room = Rooms.First(x => x.Name == data.RoomName);

            room.Users.Add(connection.GetUser());

            connection.SetRoom(room);

            await connection.SendPacketAsync(new Packet(PacketType.JoinRoom, null));

            await Task.Delay(1500);

            await sendRoomUpdate(room);
        }
예제 #6
0
    public bool Handle(NetCmdPack pack)
    {
        if (pack.cmd.GetCmdType() == NetCmdType.CMD_JOIN_ROOM_RESULT)
        {
            NetCmdJoinRoomResult ncj = (NetCmdJoinRoomResult)pack.cmd;
            JoinRoomData         ncg = new JoinRoomData();
            ncg.RoomID          = ncj.RoomID;
            ncg.BackgroundImage = ncj.BackgroundImage;
            ncg.LauncherType    = ncj.LauncherType;
            ncg.Seat            = ncj.Seat;
            ncg.RateIndex       = 0;
            if (ncj.Result == 0)
            {
                State = HallState.HALL_JOIN_FAILED;
                GlobalEffectMgr.Instance.CloseLoadingMessage();
            }
            else
            {
                NetServices.Instance.CmdHandler = null;
                LogicManager.Instance.Forward(ncg);
            }
            return(true);
        }
        else if (pack.cmd.GetCmdType() == NetCmdType.CMD_LC_JoinTable)
        {
            LC_Cmd_JoinTableResult ncb = (LC_Cmd_JoinTableResult)pack.cmd;

            tagUserOperationEvent pUOM = new tagUserOperationEvent((ncb.Result ? UserOperateMessage.UOM_Table_JoinTable_Sucess : UserOperateMessage.UOM_Table_JoinTable_Failed_7));
            MsgEventHandle.HandleMsg(pUOM);

            if (ncb.Result)
            {
                //在玩家身上设置玩家桌子ID
                PlayerRole.Instance.RoleInfo.RoleMe.SetTableTypeID(ncb.bTableTypeID);

                NetServices.Instance.CmdHandler = null;

                PlayerRole.Instance.RoleGameData.OnHandleRoleJoinTable();//表示玩家已经进入房间了
                JoinRoomData ncg = new JoinRoomData();
                ncg.RoomID          = ncb.bTableTypeID;
                ncg.BackgroundImage = ncb.BackgroundImage;
                ncg.LauncherType    = ncb.LauncherType;
                ncg.Seat            = ncb.SeatID;
                ncg.RateIndex       = ncb.RateIndex;
                ncg.Energy          = ncb.Energy;
                LogicManager.Instance.Forward(ncg);
            }
            else
            {
                State = HallState.HALL_JOIN_FAILED;
                GlobalEffectMgr.Instance.CloseLoadingMessage();
            }
            return(true);
        }
        else if (pack.cmd.GetCmdType() == NetCmdType.CMD_CHANGE_IMG)
        {
            NetCmdImgChange cmd = (NetCmdImgChange)pack.cmd;
            HeaderManager.Instance.GetPlayerHeader(cmd.PlayerID, cmd.ImgCrcValue, HeaderOptType.HEADER_FRIEND, null);
            return(true);
        }
        return(false);
    }
예제 #7
0
 private void Client_JoinRoom(JoinRoomData data)
 {
     goToRoomView();
 }
예제 #8
0
    public bool Handle(NetCmdPack pack)
    {
        //登陆的后续命令处理
        if (pack.cmd.GetCmdType() == NetCmdType.CMD_LC_AccountOnlyIDSuccess)
        {
            //玩家登陆GameServer成功了
            LC_Cmd_AccountOnlyIDSuccess ncb = (LC_Cmd_AccountOnlyIDSuccess)pack.cmd;
            //保存玩家账号数据 登陆成功的时候
            PlayerRole.Instance.RoleInfo.RoleMe.SetRoleInfo(ncb.RoleInfo);//设置玩家的数据.
            ServerSetting.SetCallbckUrl(Utility.IPToString(ncb.OperateIP));
            //设置玩家身份标志
            if (m_AccountData != null)
            {
                if (PlayerRole.Instance.RoleInfo.RoleMe.GetIsCanResetAccount())
                {
                    m_AccountData.TAG = 1;
                }
                else
                {
                    m_AccountData.TAG = 0;
                }
                m_AccountData.SaveAccountData();
                //SaveAccountData(m_AccountData);//将账号数据保存起来
            }
            // NetServices.Instance.CmdHandler = null;
            // RuntimeData.MyAccount = m_AccountData;
            m_OnlyID = ncb.RandID;//用于登陆的唯一的ID
            PlayerRole.Instance.RoleExChange.SetPlayerRoleIsShowExChange();
            //PlayerRole.Instance.IsNeedResetTable = false;
            LogicManager.Instance.SkipToHall();
            PlayerRole.Instance.OnRoleResetOtherInfo();//清空数据并且提供事件
        }
        else if (pack.cmd.GetCmdType() == NetCmdType.CMD_LC_AccountLogonToScreen)
        {
            //玩家登陆GameServer成功了
            LC_Cmd_AccountLogonToScreen ncb = (LC_Cmd_AccountLogonToScreen)pack.cmd;
            //保存玩家账号数据 登陆成功的时候
            //PlayerRole.Instance.RoleInfo.RoleMe.SetRoleInfo(ncb.RoleInfo);//设置玩家的数据.
            //设置玩家身份标志
            if (m_AccountData != null)
            {
                if (PlayerRole.Instance.RoleInfo.RoleMe.GetIsCanResetAccount())
                {
                    GlobalLogon.Instance.AccountData.TAG = 1;
                }
                else
                {
                    GlobalLogon.Instance.AccountData.TAG = 0;
                }
                m_AccountData.SaveAccountData();
                //SaveAccountData(m_AccountData);//将账号数据保存起来
                // NetServices.Instance.CmdHandler = null;
            }
            //RuntimeData.MyAccount = m_AccountData;
            m_OnlyID = ncb.RandID;//用于登陆的唯一的ID

            // PlayerRole.Instance.IsNeedResetTable = true;
            //直接进入场景
            JoinRoomData ncg = new JoinRoomData();
            ncg.RoomID          = ncb.bTableTypeID;
            ncg.BackgroundImage = ncb.BackgroundImage;
            ncg.LauncherType    = ncb.LauncherType;
            ncg.Seat            = ncb.SeatID;
            ncg.RateIndex       = ncb.RateIndex;
            ncg.Energy          = ncb.Energy;
            //场景
            LogicManager.Instance.SkipToScene(ncg);
        }
        else if (pack.cmd.GetCmdType() == NetCmdType.CMD_LC_ResetLogonGameServer)
        {
            //玩家重新连接服务器失败了 让玩家返回登陆界面去
            LogicManager.Instance.LogOff();
            tagUserOperationEvent pUOM = new tagUserOperationEvent(UserOperateMessage.UOM_Logon_Reset_Error);
            MsgEventHandle.HandleMsg(pUOM);
        }
        else if (pack.cmd.GetCmdType() == NetCmdType.CMD_LC_JoinTable)
        {
            LC_Cmd_JoinTableResult ncb = (LC_Cmd_JoinTableResult)pack.cmd;
            if (ncb.Result)
            {
                PlayerRole.Instance.RoleInfo.RoleMe.SetTableTypeID(ncb.bTableTypeID);

                JoinRoomData ncg = new JoinRoomData();
                ncg.RoomID          = ncb.bTableTypeID;
                ncg.BackgroundImage = ncb.BackgroundImage;
                ncg.LauncherType    = ncb.LauncherType;
                ncg.Seat            = ncb.SeatID;
                ncg.RateIndex       = ncb.RateIndex;
                ncg.Energy          = ncb.Energy;
                SceneRuntime.SceneLogic.ResetPlayerData(ncg, false);
                //LogicManager.Instance.Forward(ncg);
            }
        }
        else if (pack.cmd.GetCmdType() == NetCmdType.CMD_LC_ServerChangeSocket)
        {
            //提示玩家已经在其他地方登陆了 被踢掉了
            LogicManager.Instance.LogOff();
            string str = StringTable.GetString("Account_OtherLogon");
            if (str != null)
            {
                GlobalHallUIMgr.Instance.ShowSystemTipsUI(str, 5, false);
            }
        }
        //else if(pack.cmd.GetCmdType() == NetCmdType.CMD_LC_ResetPassword)
        //{
        //    LC_Cmd_ResetPassword ncb = (LC_Cmd_ResetPassword)pack.cmd;
        //    if(ncb.Result)
        //    {
        //        GlobalLogon.Instance.AccountData.CRC1 = ncb.NewPasswordCrc1;
        //        GlobalLogon.Instance.AccountData.CRC2 = ncb.NewPasswordCrc2;
        //        GlobalLogon.Instance.AccountData.CRC3 = ncb.NewPasswordCrc3;

        //        tagErrorCodeEvent pEvent = new tagErrorCodeEvent(ErrorCode.EC_ResetPassword_Sucess);
        //        MsgEventHandle.HandleMsg(pEvent);
        //    }
        //    else
        //    {
        //        tagErrorCodeEvent pEvent = new tagErrorCodeEvent(ErrorCode.EC_ResetPassword_Failed);
        //        MsgEventHandle.HandleMsg(pEvent);
        //    }
        //    return true;
        //}
        else if (pack.cmd.GetCmdType() == NetCmdType.CMD_LC_CheckVersionError)
        {
            LogicManager.Instance.LogOff();
            tagUserOperationEvent pUOM = new tagUserOperationEvent(UserOperateMessage.UOM_Logon_Version_Error);
            MsgEventHandle.HandleMsg(pUOM);
            return(true);
        }
        else if (pack.cmd.GetCmdType() == NetCmdType.CMD_LC_LogonQueueWrite)
        {
            //排队的消息  我们让客户端继续等待
            LC_Cmd_LogonQueueWrite ncb = (LC_Cmd_LogonQueueWrite)pack.cmd;
            //触发排队等待的事件
            tagQueueWriteEvent pEvent = new tagQueueWriteEvent(ncb.WriteIndex, ncb.WriteSec, true);
            MsgEventHandle.HandleMsg(pEvent);
        }
        else if (pack.cmd.GetCmdType() == NetCmdType.CMD_LC_AccountIsFreeze)
        {
            LC_Cmd_AccountIsFreeze ncb = (LC_Cmd_AccountIsFreeze)pack.cmd;

            System.DateTime starTime = System.TimeZone.CurrentTimeZone.ToLocalTime(new System.DateTime(1970, 1, 1));
            System.DateTime pTime    = starTime.AddSeconds(System.Convert.ToDouble(ncb.EndTime));

            tagLogonAccountFreezeEvent pEvent = new tagLogonAccountFreezeEvent(pTime);
            MsgEventHandle.HandleMsg(pEvent);

            tagUserOperationEvent pUOM = new tagUserOperationEvent(UserOperateMessage.UOM_Logon_Account_Freeze_2);
            MsgEventHandle.HandleMsg(pUOM);

            LogicManager.Instance.LogOff();
            return(true);
        }
        else if (pack.cmd.GetCmdType() == NetCmdType.CMD_LC_SaveAccountInfo)
        {
            LC_Cmd_SaveAccountInfo ncb = (LC_Cmd_SaveAccountInfo)pack.cmd;
            //将账号 和 3个 密码保持起来 供使用
            if (GlobalLogon.Instance.AccountData == null)
            {
                GlobalLogon.Instance.AccountData = new AccountData();
            }
            GlobalLogon.Instance.AccountData.AccountInfo.UID  = ncb.AccountName;
            GlobalLogon.Instance.AccountData.AccountInfo.CRC1 = ncb.PasswordCrc1;
            GlobalLogon.Instance.AccountData.AccountInfo.CRC2 = ncb.PasswordCrc2;
            GlobalLogon.Instance.AccountData.AccountInfo.CRC3 = ncb.PasswordCrc3;
            GlobalLogon.Instance.AccountData.SaveAccountData();
            //GlobalLogon.Instance.SaveAccountData(GlobalLogon.Instance.AccountData);//立刻保存一次
            return(true);
        }
        else
        {
            return(false);
        }
        GlobalHallUIMgr.Instance.UpdateSystemTipsUITime(0.5f);
        return(true);
    }