private void RspLogin(object sender, GameEventArgs e) { OnReceiveSCPacketBaseEventArgs ne = e as OnReceiveSCPacketBaseEventArgs; if (ne.msgID != CMD.RspLogin) { return; } RspLogin rspLogin = (RspLogin)ne.scPacketBase; if (rspLogin.PlayerData == null) { Debug.LogError("kongxiaoxi"); return; } PECommon.SetPlayerData(rspLogin); if (rspLogin.PlayerData.Name == "") { GameEntry.UI.OpenUIForm(UIFormId.CreateForm); } else { m_GetPlayerSuccess = true; } }
private void OnLoginResponse(RspLogin response) { IsConnected = response.succ; if (_loginResultCallback != null) { _loginResultCallback(response.succ, response.session); } }
public void ReqLogin(MsgPack pack) { ReqLogin data = (ReqLogin)pack.msg; //当前账号是否已经上线 SCPacketBase msg = new RspLogin(); if (cacheSvc.IsAcctOnLine(data.Acct)) { //己上线:返回错误信息 msg.error = (int)ErrorCode.AcctIsOnline; } else { //未上线: //账号是否存在 PlayerData pd = cacheSvc.GetPlayerData(data.Acct, data.Pass); if (pd == null) { //存在,密码错误 msg.error = (int)ErrorCode.WrongPass; } else { //计算离线体力增长 int power = pd.Power; long now = timerSvc.GetNowTime(); long milliseconds = now - pd.Time; int addPower = (int)(milliseconds / (1000 * 60 * KDCommon.PowerAddSpace)) * KDCommon.PowerAddCount; if (addPower > 0) { int powerMax = KDCommon.GetPowerLimit(pd.Lv); if (pd.Power < powerMax) { pd.Power += addPower; if (pd.Power > powerMax) { pd.Power = powerMax; } } } if (power != pd.Power) { cacheSvc.UpdatePlayerData(pd.Id, pd); } msg = new RspLogin { PlayerData = pd }; //缓存账号数据 cacheSvc.AcctOnline(data.Acct, pack.session, pd); } } //回应客户端 pack.session.SendMsg(msg); }
void OnRspLogin(SocketModel model) { RspLogin rsp = SerializeUtil.Deserialize <RspLogin>(model.message); CacheManager.instance.account = rsp.account; CacheManager.instance.pwd = rsp.pwd; CacheManager.instance.nickname = rsp.nickname; CacheManager.instance.items = rsp.items; CacheManager.instance.equip = rsp.equip; UIManager.instance.Close <LoginWindow>(); UIManager.instance.Open <MainWindow>().Init(); }
public void RspLogin(GameMsg msg) { RspLogin data = msg.val as RspLogin; GameRoot.AddTips("登录成功"); GameRoot.Instance.SetPlayerData(data); //关闭登录界面 loginWnd.SetWndState(false); if (data.playerData.name == "") { createWnd.SetWndState(); } else { MainCitySys.Instance.EnterMainCity(); } }
public void RspLogin(NetMsg msg) { //如果服务器返回成功,则关闭登陆面板,打开角色创建面板或主城界面 RspLogin rspData = msg.RspLogin; mGameRoot.mLoginWnd.SetWndState(false); if (string.IsNullOrEmpty(rspData.data.Name)) { //新账号 mGameRoot.mCreateWnd.SetWndState(); } else { //旧帐号 MainCitySys.Instance.EnterMainCity(); } //保存玩家数据 mGameRoot.SetPlayerData(rspData.data); }
public void SetPlayerData(RspLogin data) { playerData = data.playerData; }
public void SetPlayerData(RspLogin msg) { this._playerData = msg.playerData; }
public void RspLogin(RspLogin msg) { }
public static void SetPlayerData(RspLogin data) { PlayerData = data.PlayerData; }
void OnReqLogin(UserToken token, SocketModel model) { ReqLogin req = SerializeUtil.Deserialize <ReqLogin>(model.message); Console.WriteLine(req.account + "请求登录"); string sql = string.Format("SELECT * FROM account WHERE account = '{0}' AND pwd = '{1}'", req.account, req.pwd); List <Account> accounts = MysqlManager.instance.ExecQuery <Account>(sql); if (accounts.Count > 0) { if (CacheManager.instance.GetAccount(req.account) == null) { token.accountid = req.account; AccountData acc = new AccountData(); acc.account = req.account; acc.pwd = req.pwd; acc.nickname = accounts[0].nickname; acc.Id = accounts[0].Id; acc.token = token; acc.diamond = accounts[0].diamond; CacheManager.instance.AddAccount(acc); CacheManager.instance.LoadAccountAll(acc.account); RspLogin rsp = new RspLogin(); rsp.account = req.account; rsp.diamond = acc.diamond; rsp.nickname = acc.nickname; List <ItemData> accItems = CacheManager.instance.GetAccountItemData(req.account); for (int i = 0; i < accItems.Count; i++) { ItemData item = accItems[i]; ItemDTO dto = new ItemDTO(); dto.id = item.Id; dto.account = item.account; dto.itemid = item.itemid; dto.count = item.count; dto.slot = item.slot; rsp.items.Add(dto); } EquipData equip = CacheManager.instance.GetAccountEquip(req.account); rsp.equip = new EquipDTO(); rsp.equip.id = equip.Id; rsp.equip.account = equip.account; rsp.equip.tank = equip.tank; rsp.equip.bullet = equip.bullet; NetworkManager.Send <RspLogin>(token, (int)MsgID.RspLogin, rsp); } else { TipsError tips = new TipsError(); tips.code = (int)ECode.ELoginError; NetworkManager.Send <TipsError>(token, (int)MsgID.TipError, tips); } } else { TipsError tips = new TipsError(); tips.code = (int)ECode.ELoginError; NetworkManager.Send <TipsError>(token, (int)MsgID.TipError, tips); } //for (int i = 0; i < CacheManager.instance.GetAllAccount().Count; i++) //{ // Console.WriteLine(CacheManager.instance.GetAllAccount()[i].account); //} }