// 更新关卡日常数据 public void UpdateStageDailyData(StageDailyData stagedata) { if (stagedata == null) { return; } if (!mPlayerStageDailyData.ContainsKey(stagedata.stageid)) { mPlayerStageDailyData.Add(stagedata.stageid, stagedata); } else { StageDailyData old = mPlayerStageDailyData[stagedata.stageid]; old.daily_times = stagedata.daily_times; } }
// 服务器同步关卡通关数据 public void SyncStagePass(role_stage stagedata) { if (stagedata == null) { return; } if (!DataManager.Scene_StageSceneTable.ContainsKey(stagedata.stage_id)) { return; } Scene_StageSceneTableItem passstageres = DataManager.Scene_StageSceneTable[stagedata.stage_id] as Scene_StageSceneTableItem; if (passstageres == null) { return; } PlayerDataModule module = ModuleManager.Instance.FindModule <PlayerDataModule>(); if (module == null) { return; } bool firstPass = !module.IsStageHasPassed((int)stagedata.stage_id); // 更新角色的关卡数据 StageData newdata = new StageData(); newdata.stageid = (int)stagedata.stage_id; newdata.maxgrade = (StageGrade)stagedata.max_grade; newdata.maxcombo = stagedata.max_combo; newdata.killrate = stagedata.kill_rate; newdata.passtimerecord = stagedata.passtime_record; newdata.passtimes = stagedata.pass_times; module.UpdateStageData(newdata); if (passstageres.mEnterTimes > 0) { StageDailyData newdailydata = new StageDailyData(); newdailydata.stageid = (int)stagedata.stage_id; newdailydata.daily_times = module.GetStageDailyTimes((int)stagedata.stage_id) + 1; module.UpdateStageDailyData(newdailydata); } // 更新战区星星数 if (firstPass && mSubTypeDatas.ContainsKey(SceneManager.GetSceneType(passstageres))) { Dictionary <int, StageFightZone> zonedata = mSubTypeDatas[SceneManager.GetSceneType(passstageres)].mFightZoneDatas; if (zonedata != null && zonedata.ContainsKey(passstageres.mZoneId)) { zonedata[passstageres.mZoneId].mStarNum++; } } if (!mUnlockDatas.ContainsKey(ConditionType.STAGE_GRADE)) { return; } ArrayList list = mUnlockDatas[ConditionType.STAGE_GRADE]; if (list == null) { return; } // 检查是否有因此解锁的关卡 System.Type type = typeof(Scene_StageSceneTableItem); foreach (StageUnlockData unlockdata in list) { if (unlockdata.condition == null) { continue; } if (unlockdata.condition.mParam1 != stagedata.stage_id) { continue; } if (!DataManager.Scene_StageSceneTable.ContainsKey(unlockdata.stageid)) { continue; } bool success = true; Scene_StageSceneTableItem stageres = DataManager.Scene_StageSceneTable[unlockdata.stageid] as Scene_StageSceneTableItem; for (uint i = 0; i < Scene_StageSceneTableItem.MAX_UNLOCK_CONDITION_COUNT; ++i) { System.Reflection.FieldInfo fieldid = type.GetField("mUnlockCondId" + i.ToString()); int unlockcondid = (int)fieldid.GetValue(stageres); if (unlockcondid < 0) { continue; } if (!ConditionManager.Instance.CheckCondition(unlockcondid)) { success = false; break; } } // 有因此解锁的关卡 if (success) { UnlockStageActionParam param = new UnlockStageActionParam(); param.stageid = unlockdata.stageid; Net.Instance.DoAction((int)Message.MESSAGE_ID.ID_MSG_SCENE_UNLOCK, param); } } StagePassServerEvent stageevent = new StagePassServerEvent(StagePassServerEvent.STAGE_PASS_SERVER_EVENT); stageevent.mStageData = newdata; EventSystem.Instance.PushEvent(stageevent); SceneManager.Instance.RequestEnterLastCity(); }