void ActivenessComponent::OnNotify(IParam ¶m) { std::string strActiveModule; param.GetParam(std::string("activeness"), strActiveModule); int nTargetType = ActivenessTargetConfig::GetTypeFromName(strActiveModule); ActivenessTargetConfig targetConfig; if (!ActivenessDataManager::Instance().GetTarget(nTargetType, targetConfig)) { return; } // 根据当前时间充值活动数据 ResetActivinessData(time(NULL)); ActivenessTarget* pTarget = ActivenessTargetFactory::Instance().CreateTarget(targetConfig); if (pTarget == NULL) { return; } // 用于自动释放内存 std::auto_ptr<ActivenessTarget> tempPtr(pTarget); // 设置数据 pTarget->SetProgress(GetTargetProgress(nTargetType)); if (nTargetType == ActivenessTargetConfig::EType_DanceMode) { ((ActivenessDanceModeTarget*)pTarget)->SetFinishedDanceMode(m_setFinishedDanceMode); } //目标是否完成 if (pTarget->IsTargetComplete()) { return; } // 更新目标进度 if (pTarget->UpdateProgress(param)) { // 更新component进度 UpdateTarget(*pTarget); } // 更新活跃度 if (pTarget->IsTargetComplete()) { AddActiveness(pTarget->GetTargetScore(), nTargetType); if (CanGetReward()) { // 重新通知前端 SendActivenessInfo(); } // 增加舞团试炼活力值 CommonParam commonParam; commonParam.SetParam("dance_group_active", pTarget->GetTargetScore()); NotifyAll(commonParam); } SaveActivinessDataToDb(); // 保存数据 }