public void ReqGuide(MsgPack pack) { ReqGuide data = pack.msg.reqGuide; GameMsg msg = new GameMsg { cmd = (int)CMD.RspGuide }; PlayerData pd = cacheSvc.GetPlayerDataBySession(pack.session); GuideCfg gc = cfgSvc.GetGuideCfg(data.guideid); // 更新引导ID if (pd.guideid == data.guideid) { // 检测是否是智者点拨任务 if (pd.guideid == 1001) { TaskSys.Instance.CalcTaskPrgs(pd, 1); } pd.guideid += 1; // 更新玩家数据 pd.coin += gc.coin; Common.CalcExp(pd, gc.exp); // 数据更新数据库 if (cacheSvc.UpdatePlayerData(pd.id, pd) == false) { msg.err = (int)ErrorCode.UpdateDBError; } else { msg.rspGuide = new RspGuide { guideid = pd.guideid, coin = pd.coin, lv = pd.lv, exp = pd.exp }; } } else { msg.err = (int)ErrorCode.ServerDataError; } pack.session.SendMsg(msg); }
/// <summary> /// 引导任务请求 /// </summary> public void ReqGuide(MsgPack pack) { ReqGuide reqGuide = pack.msg.reqGuide; GameMsg msg = new GameMsg { cmd = (int)CMD.RspGuide, }; PlayerData pd = cacheSvc.GetPlayerDataBySession(pack.session); AutoGuideCfg agc = cfgSvc.GetGuideCfgData(pd.guideId); //校验 if (pd.guideId == reqGuide.guideId) { //检查为智者点播任务 if (pd.guideId == 1001) { TaskSys.Instance.CalcTaskPrgs(pd, 1); } //更新玩家数据 pd.guideId++; pd.coin += agc.coin; PECommon.CalExp(pd, agc.exp); if (!cacheSvc.UpdataPlayerData(pd.id, pd)) { //如果数据库更新出错 msg.err = (int)ErrorCode.UpdateDBError; } else { RspGuide rspGuide = new RspGuide { guideId = pd.guideId, coin = pd.guideId, lv = pd.lv, exp = pd.exp, }; msg.rspGuide = rspGuide; } } else { msg.err = (int)ErrorCode.ServerDataError; } pack.session.SendMsg(msg); }
public void ReqGuide(MsgPack pack) { ReqGuide data = pack.msg.reqGuide; GameMsg msg = new GameMsg { cmd = (int)CMD.RspGuided }; // 更新任务 ID PlayerData pd = cacheSev.GetPlayerDataBySession(pack.session); if (pd.guidid == data.guidID) { switch (pd.guidid) { case 1001: msg.pshTaskPrgs = TaskSystem.Instance.CalcTaskPrg(pd, 1); break; } pd.guidid += 1; // 更新玩家数据 AutoGuideCfg guidCfg = cfgSev.GetAutoGuidCfg(data.guidID); pd.coin += guidCfg.coin; NETCommon.CalcExp(pd, guidCfg.exp); if (!cacheSev.UpdatePlayerData(pd)) { msg.err = (int)ErrorCode.UpdateDBError; } else { msg.rspGuide = new RspGuide { guideid = pd.guidid, coin = pd.coin, lv = pd.lv, exp = pd.exp, addExp = guidCfg.exp }; } } else { msg.err = (int)ErrorCode.ServerDataError; } pack.session.SendMsg(msg); }
public void ClickNextBtn() { GameEntry.Sound.PlayUISound(Constants.UIClickBtn); index += 1; if (index == dialogArr.Length) { //TODO 发送任务引导完成信息 CSPacketBase msg = new ReqGuide { Guideid = curtTaskData.ID }; GameEntry.Net.SendMsg(msg); Close(true); } else { SetTalk(); } }
/// <summary> /// 处理任务完成逻辑 /// </summary> public void ReqGuide(MsgPack pack) { ReqGuide data = pack.msg.reqGuide; GameMsg msg = new GameMsg { cmd = (int)CMD.RspGuide, }; PlayerData pd = cacheSvc.GetPlayerDataBySettion(pack.session); if (pd.guideid == data.guideid)//一次安全校验,如果客户端数据和服务端对不上,直接踢下线 { //是否为智者引导任务 if (pd.guideid == 1001) { TaskSys.Instance.CalcTaskPrgs(pd, 1); } GuideTaskCfg gtc = cfgSvc.GetGuideTaskCfgData(pd.guideid); //缓存数据变化 pd.guideid++; pd.coin += gtc.coin; PECommon.CaculExp(pd, gtc.exp); if (cacheSvc.UpdatePlayerData(pd.id, pd)) { msg.rspGuide = new RspGuide { guideid = pd.guideid, coin = pd.coin, exp = pd.exp, lv = pd.lv }; } else { msg.err = (int)ErrorCode.UpdateDbError; } } else { msg.err = (int)ErrorCode.ServerDataError; } pack.session.SendMsg(msg); }
public void HandleReqGuide(MsgPack pack) { ReqGuide reqData = pack.msg.ReqGuide; NetMsg newMsg = new NetMsg { cmd = (int)MsgType.RspGuide, }; PlayerData pd = CacheSvc.Instance.GetPlayerDataBySession(pack.session); if (pd == null || pd.GuideID != reqData.guideId) { //数据异常 newMsg.err = (int)ErrorCode.ServerDataError; } else { CfgGuide cfg = CfgSvc.Instance.GetGuideCfg(reqData.guideId); if (cfg != null) { //更新数据(缓存和数据库) pd.GuideID += 1; PECommonTool.AddExp(ref pd, cfg.exp); //更新到数据库 todo if (!CacheSvc.Instance.UpdatePlayerDataToDB(pd.ID, pd)) { newMsg.err = (int)ErrorCode.UpdateDBFailed; } else { newMsg.RspGuide = new RspGuide { guideId = pd.GuideID, data = pd, }; } } } pack.session.SendMsg(newMsg); }
public void ReqGuide(MsgPack pack) { ReqGuide data = pack.gameMsg.val as ReqGuide; PlayerData pd = cacheSvc.GetPlayerDataBySession(pack.session); GuideCfg gc = cfgSvc.GetGuideData(data.guideid); GameMsg msg = new GameMsg { cmd = (int)CMD.RspGuide }; //更新引导ID if (pd.guideid == data.guideid) { if (pd.guideid == 1001) { TaskSys.Instance.CalcTaskPrgs(pd, 1); } pd.guideid++; pd.coin += gc.coin; Common.CalcExp(pd, gc.exp); if (!cacheSvc.UpdatePlayerData(pd.id, pd)) { msg.err = (int)ErrorCode.UpdateDBError; } else { msg.val = new RspGuide { guideid = pd.guideid, coin = pd.coin, lv = pd.lv, exp = pd.exp }; } } else { msg.err = (int)ErrorCode.ServerDataError; } pack.session.SendMsg(msg); }
public void ReqGuide(MsgPack pack) { ReqGuide data = (ReqGuide)pack.msg; SCPacketBase msg = new RspGuide(); PlayerData pd = cacheSvc.GetPlayerDataBySession(pack.session); GuideCfg gc = cfgSvc.GetGuideCfg(data.Guideid); //更新引导ID if (pd.Guideid == data.Guideid) { //检测是否为智者点拔任务 if (pd.Guideid == 1001) { TaskSys.Instance.CalcTaskPrgs(pd, 1); } pd.Guideid += 1; //更新玩家数据 pd.Coin += gc.coin; KDCommon.CalcExp(pd, gc.exp); if (!cacheSvc.UpdatePlayerData(pd.Id, pd)) { msg.error = (int)ErrorCode.UpdateDBError; } else { msg = new RspGuide { Guideid = pd.Guideid, Coin = pd.Coin, Lv = pd.Lv, Exp = pd.Exp }; } } else { msg.error = (int)ErrorCode.ServerDataError; } pack.session.SendMsg(msg); }
public void ReqGuide(MsgPack msgs) { ReqGuide data = msgs.msg.reqGuide; GameMsg msg = new GameMsg { cmd = (int)CMD.ResGuied }; PlayerData pd = cacheSvc.GetPlayeDataBySession(msgs.session); AutoGuideCfg cfg = CfgSvc.Instance.GetGuideCfg(data.guideId); //更新引导ID if (pd.guideid == data.guideId) { pd.guideid++; //更新玩家数据 pd.coin += cfg.coin; CalcExp(pd, cfg.exp); if (!cacheSvc.UpdatePlayerData(pd.id, pd)) { msg.err = (int)ErrorCode.UpdateDbError; } else { msg.resGuide = new ResGuide { guideId = pd.guideid, coin = pd.coin, exp = pd.exp, lv = pd.lv }; } } else { msg.err = (int)ErrorCode.ServerDataError; } msgs.session.SendMsg(msg); }
public void ReqGuide(MsgPack pack) { ReqGuide data = pack.msg.reqGuide; GameMsg msg = new GameMsg { cmd = (int)CMD.RspGuide }; PlayerData pd = cacheSrv.GetPlayerDataBySession(pack.serverSession); GuideCfg guideConfig = cfgSvc.GetGuideCfgData(pd.guideid); //更新引导ID if (pd.guideid == data.guidid) { pd.guideid += 1; //更新玩家数据 pd.coin += guideConfig.coin; CalculateExp(pd, guideConfig.exp); if (!cacheSrv.UpdatePlayerData(pd.id, pd)) { msg.err = (int)ErroroCode.UpdateDBError; } else { msg.rspGuide = new RspGuide { coin = pd.coin, exp = pd.exp, lv = pd.lv, guideid = pd.guideid, }; } } else//开挂了 { msg.err = (int)ErroroCode.ServerDataError; } //发送数据 pack.serverSession.SendMsg(msg); }
public void ReqGuide(MsgPack pack) { ReqGuide data = pack.msg.reqGuide; GameMsg msg = new GameMsg { cmd = (int)CMD.RspGuide }; PlayerData pd = cacheSvc.GetPlayerDataSession(pack.session); GuideCfg gc = cfgSys.GetGuideCfg(data.guideid); if (pd.guideid == data.guideid) { pd.guideid += 1; pd.coin += gc.coin; calcExp(pd, gc.exp); if (!cacheSvc.UpdatePlayerData(pd.id, pd)) { msg.err = (int)ErrorCode.UpdateDBError; } else { msg.rspGuide = new RspGuide { guideid = pd.guideid, coin = pd.coin, lv = pd.lv, exp = pd.exp }; } } else { msg.err = (int)ErrorCode.ServerDataError; } pack.session.SendMsg(msg); }