public void SetPlayerDataByRspTask(RspTask taskData) { PlayerData.taskid = taskData.taskID; PlayerData.coin = taskData.coin; PlayerData.exp = taskData.exp; PlayerData.lv = taskData.lv; PlayerData.hp = taskData.hp; }
/// <summary> /// 回应任务完成请求 /// </summary> public void ReqTask(PackMsg pack) { ReqTask data = pack.msg.reqTask; ServerSession session = pack.session; GameMsg msg = new GameMsg { cmd = (int)CMD.RspTask }; PlayerData playerData = cacheSvc.GetPlayerDataCache(pack.session); AutoGuideCfg AutoGuideCfg = cfgSvc.GetAutoGuideCfg(data.taskID); //更新任务ID if (playerData.taskid == data.taskID) { PshTaskProgs pshTaskProgs = null; //更新任务智者点拨进度 if (playerData.taskid == 1001) { pshTaskProgs = TaskSys.Instance.CalcTaskProgs(playerData, 1); } playerData.taskid++; //更新玩家数据 playerData.coin += AutoGuideCfg.coin; PECommon.UpdateExp(playerData, AutoGuideCfg.exp); if (!cacheSvc.UpdatePlayerData(playerData.id, playerData)) { msg.err = (int)ErrorCode.UpdateDBError; } else { RspTask rspTask = new RspTask { taskID = playerData.taskid, coin = playerData.coin, exp = playerData.exp, lv = playerData.lv, hp = playerData.hp, }; //发送回客户端 msg.rspTask = rspTask; if (pshTaskProgs != null) { msg.pshTaskProgs = pshTaskProgs; } } } else { msg.err = (int)ErrorCode.ServerDataError; } pack.session.SendMsg(msg); }
public void RspTask(GameMsg msg) { PlayerData playerData = GameRoot.Instance.PlayerData; RspTask taskData = msg.rspTask; GameRoot.AddTipsToQueue("任务奖励 金币+" + curAutoGuideCfg.coin + " 经验+" + curAutoGuideCfg.exp, Constant.ColorRed); switch (curAutoGuideCfg.actID) { case 0: //与智者对话 break; case 1: //进入副本 EnterFuBen(); break; case 2: //进入强化 OpenStrongWindow(); break; case 3: //进入体力购买 OpenPurchaseWindow(0); break; case 4: //进入金币制造 OpenPurchaseWindow(1); break; case 5: //进入世界聊天 OpenChatWindow(); break; } //更新信息 GameRoot.Instance.SetPlayerDataByRspTask(taskData); //更新UI mainCityWindow.RefreshUI(); roleInfoWindow.RefreshUI(); if (msg.pshTaskProgs != null) { GameRoot.Instance.SetPlayerDataByPshTaskProgs(msg.pshTaskProgs); if (taskWindow.gameObject.activeInHierarchy) { taskWindow.RefreshUI(); } } }