示例#1
0
    public void RspTakeTaskReward(NetMsg msg)
    {
        ResponseTaskReward data = msg.rspTaskReward;

        GameRoot.Instance.SetPlayerDataByTask(data);
        UpdateTaskWndUI();
    }
示例#2
0
 public void SetPlayerDataByTask(ResponseTaskReward taskData)
 {
     PlayerData.coin       = taskData.coin;
     PlayerData.lv         = taskData.lv;
     PlayerData.exp        = taskData.exp;
     PlayerData.taskReward = taskData.taskArr;
 }
示例#3
0
    public void ReqTaskDataTake(MsgPack packMsg)
    {
        RequestTaskReward data = packMsg._msg.reqTaskReward;

        NetMsg netMsg = new NetMsg
        {
            cmd = (int)MsgCommand.Cmd_RspTaskReward,
        };

        PlayerData    playerData  = cacheSvc.GetPlayerDataBySession(packMsg._session);
        TaskRewardCfg taskDataCfg = configSvc.GetTaskRewardData(data.taskId);
        TaskData      taskData    = CalcTaskRewardData(playerData, data.taskId);

        if (taskData.progress == taskDataCfg.count && !taskData.bTaked)
        {
            playerData.coin += taskDataCfg.coin;
            CommonTools.CalcExp(playerData, taskDataCfg.exp);
            taskData.bTaked = true;

            //更新任务进度数据
            UpdateTaskProgress(playerData, taskData);
            //更新数据库
            if (!cacheSvc.UpdatePlayerData(playerData.id, playerData))
            {
                netMsg.err = (int)ErroCode.Error_UpdateDB;
            }
            else
            {
                ResponseTaskReward rspData = new ResponseTaskReward
                {
                    coin    = playerData.coin,
                    lv      = playerData.lv,
                    exp     = playerData.exp,
                    taskArr = playerData.taskReward
                };
                netMsg.rspTaskReward = rspData;
            }
        }
        else
        {
            netMsg.err = (int)ErroCode.Error_ClientData;
        }

        packMsg._session.SendMsg(netMsg);
    }