/// <summary> /// 设置选中数据 /// </summary> /// <param name="data">数据</param> public void SetChoiceData(LTHeroBattleAPI.HeroBattleData data) { /* * EB.Debug.LogError("[" + Time.frameCount + "]服务器已经下发数据:当前的操作行为:Status:" + data.Status + ",是否为玩家:" + (data.OpenUid == LoginManager.Instance.LocalUserId.Value)); */ choiceData.choiceState = data.Status.Equals("banhero") ? 0 : data.Status.Equals("selecthero") ? 1 : 2; choiceData.openUid = data.OpenUid; choiceData.lessTime = EB.Time.After(data.NextTS); for (int i = 0; i < data.Sides.Length; i++) { if (data.Sides[i].Uid == LoginManager.Instance.LocalUserId.Value) //若是玩家自己 { choiceData.selfInfo.name = data.Sides[i].Name; choiceData.selfInfo.uid = data.Sides[i].Uid; choiceData.selfInfo.level = data.Sides[i].Level; choiceData.selfInfo.portrait = data.Sides[i].Portrait; choiceData.selfInfo.frame = data.Sides[i].Frame; choiceData.selfInfo.isSelf = true; choiceData.selfBans.Clear(); for (int j = 0; j < data.Sides[i].BandTplIds.Length; j++) { int tplID = 0; if (!int.TryParse(data.Sides[i].BandTplIds[j], out tplID)) { continue; } HeroBattleChoiceCellData cell = choiceData.selfChoices.Find(p => p.heroTplID == tplID); if (cell != null) { choiceData.selfBans.Add(cell); } else { EB.Debug.LogError("choiceData.selfBans cell is null tplID={0}", tplID); } } choiceData.selfChoices.Clear(); for (int j = 0; j < data.Sides[i].SelectHeroIds.Count; j++) { if (data.Sides[i].SelectHeroIds[j] != null) { int id = EB.Dot.Integer("id", data.Sides[i].SelectHeroIds[j], 0); int tplID = EB.Dot.Integer("tplId", data.Sides[i].SelectHeroIds[j], 0); int star = EB.Dot.Integer("star", data.Sides[i].SelectHeroIds[j], 0); int level = EB.Dot.Integer("level", data.Sides[i].SelectHeroIds[j], 0); int peak = EB.Dot.Integer("proficiency.1.1", data.Sides[i].SelectHeroIds[j], 0); int upgrade = EB.Dot.Integer("upgrade", data.Sides[i].SelectHeroIds[j], 0); int charType = EB.Dot.Integer("charType", data.Sides[i].SelectHeroIds[j], -1); string roleGrade = EB.Dot.String("roleGrade", data.Sides[i].SelectHeroIds[j], ""); int awakenLevel = EB.Dot.Integer("awaken", data.Sides[i].SelectHeroIds[j], 0); int skin = EB.Dot.Integer("skin", data.Sides[i].SelectHeroIds[j], 0); int artifactLevel = EB.Dot.Integer("artifact_equip.enhancement_level", data.Sides[i].SelectHeroIds[j], -1); HeroBattleChoiceCellData cell = GetHeroCell(tplID); if (cell != null) { cell.star = star; cell.type = (Hotfix_LT.Data.eRoleAttr)charType; cell.upGrade = upgrade; cell.level = level; cell.peak = peak; cell.artifactLevel = artifactLevel; cell.skin = skin; cell.modelName = Hotfix_LT.Data.CharacterTemplateManager.Instance.GetHeroInfo(tplID - 1, skin).model_name; cell.isAwake = awakenLevel; choiceData.selfChoices.Add(cell); } else { EB.Debug.LogError("choiceData.SelectHero cell is null tplID={0}", tplID); } } } } else { choiceData.otherInfo.name = data.Sides[i].Name; choiceData.otherInfo.uid = data.Sides[i].Uid; //机器人情况下,强行修改和我的分段一样 //if (data.Sides[i].Uid == 0) //{ // choiceData.otherInfo.level = choiceData.selfInfo.level; // choiceData.otherInfo.score = LadderManager.Instance.Info.Point; //} //else { choiceData.otherInfo.level = data.Sides[i].Level; } choiceData.otherInfo.portrait = data.Sides[i].Portrait; choiceData.otherInfo.frame = data.Sides[i].Frame; choiceData.otherInfo.isSelf = false; choiceData.otherBans.Clear(); for (int j = 0; j < data.Sides[i].BandTplIds.Length; j++) { int tplID = 0; if (!int.TryParse(data.Sides[i].BandTplIds[j], out tplID)) { continue; } HeroBattleChoiceCellData cell = choiceData.otherChoices.Find(p => p.heroTplID == tplID); if (cell != null) { choiceData.otherBans.Add(cell); } else { EB.Debug.LogError("choiceData.otherBans cell is null tplID={0}", tplID); } } choiceData.otherChoices.Clear(); for (int j = 0; j < data.Sides[i].SelectHeroIds.Count; j++) { if (data.Sides[i].SelectHeroIds[j] != null) { int id = EB.Dot.Integer("id", data.Sides[i].SelectHeroIds[j], 0); int tplID = EB.Dot.Integer("tplId", data.Sides[i].SelectHeroIds[j], 0); int star = EB.Dot.Integer("star", data.Sides[i].SelectHeroIds[j], 0); int level = EB.Dot.Integer("level", data.Sides[i].SelectHeroIds[j], 0); int peak = EB.Dot.Integer("proficiency.1.1", data.Sides[i].SelectHeroIds[j], 0); int upgrade = EB.Dot.Integer("upgrade", data.Sides[i].SelectHeroIds[j], 0); int charType = EB.Dot.Integer("charType", data.Sides[i].SelectHeroIds[j], -1); string roleGrade = EB.Dot.String("roleGrade", data.Sides[i].SelectHeroIds[j], ""); int awakenLevel = EB.Dot.Integer("awaken", data.Sides[i].SelectHeroIds[j], 0); int skin = EB.Dot.Integer("skin", data.Sides[i].SelectHeroIds[j], 0); HeroBattleChoiceCellData cell = null; //判断当前对手是否为机器人 if (data.Sides[i].Uid == 0) { cell = GetMonsterInfo(tplID, skin); } else { cell = GetHeroCellCommon(tplID); } if (cell != null) { cell.star = star; cell.type = (Hotfix_LT.Data.eRoleAttr)charType; cell.upGrade = upgrade; cell.level = level; cell.peak = peak; cell.skin = skin; if (data.Sides[i].Uid != 0) { cell.modelName = Hotfix_LT.Data.CharacterTemplateManager.Instance.GetHeroInfo(cell.heroTplID - 1, skin).model_name; } cell.isAwake = awakenLevel; choiceData.otherChoices.Add(cell); } else { EB.Debug.LogError("choiceData.SelectHero cell is null tplID={0}", tplID); } } } } } if (data.Status.Equals("battle")) { //筛选出自己拥有的英雄 List <LTPartnerData> generalPL = LTPartnerDataManager.Instance.GetOwnPartnerList(); //开战前存储这次的上场的英雄,好给结算界面调用 string teamName = FormationUtil.GetCurrentTeamName(eBattleType.LadderBattle); string teamDataPath = SmallPartnerPacketRule.USER_TEAM + "." + teamName + ".team_info"; ArrayList heroIds = Johny.ArrayListPool.Claim(); for (int i = 0; i < choiceData.selfChoices.Count; i++) { if (choiceData.selfBans.Find(p => p.heroTplID == choiceData.selfChoices[i].heroTplID) == null) { LTPartnerData ltParnerData = generalPL.Find(p => p.HeroStat.id == choiceData.selfChoices[i].heroTplID); heroIds.Add(ltParnerData.HeroId); } } DataLookupsCache.Instance.CacheData(teamDataPath, heroIds); // if (LTHeroBattleEvent.NotifyHeroBattleHudFinish != null) { LTHeroBattleEvent.NotifyHeroBattleHudFinish(); } } else if (choiceData.selfChoices.Count > 0 || choiceData.otherChoices.Count > 0) //当有一边选人后延迟场景跳转 放置跳转前没有倒计时问题 { if (LTHeroBattleEvent.NotifyHeroBattleDelayToScene != null) { LTHeroBattleEvent.NotifyHeroBattleDelayToScene(); } } RefreshChoiceState(); }
private void RecordBattle(eCombatOutcome outcome)//上报友盟,是否通关 { bool tmpIsWon = outcome == eCombatOutcome.Win ? true : false; string tmpLevel = string.Empty; if (_battleType == eBattleType.MainCampaignBattle) { tmpLevel = LTMainInstanceCampaignCtrl.CampaignId.ToString(); if (!string.IsNullOrEmpty(tmpLevel)) { JudgeBattle(tmpIsWon, "Main" + tmpLevel); if (tmpIsWon) { LTChargeManager.Instance.CheckLimitedTimeGiftTrigger(Hotfix_LT.Data.LTGTriggerType.Main, tmpLevel); } } } else if (_battleType == eBattleType.InfiniteChallenge) { DataLookupsCache.Instance.SearchDataByID <string>("infiniteChallenge.info.currentlayer", out tmpLevel); if (!string.IsNullOrEmpty(tmpLevel)) { JudgeBattle(tmpIsWon, _battleType.ToString() + tmpLevel); if (tmpIsWon) { LTChargeManager.Instance.CheckLimitedTimeGiftTrigger(Hotfix_LT.Data.LTGTriggerType.UltimateTrial, tmpLevel); } } Data.NewGameConfigTemplateManager.Instance.GetEnterVigor(eBattleType.InfiniteChallenge, out int dayDisCountTime, out int NewVigor, out int oldVigor); int curDisCountTime = dayDisCountTime - LTUltimateTrialDataManager.Instance.GetCurrencyTimes(); if (outcome == eCombatOutcome.Win && curDisCountTime >= 0) { LTDailyDataManager.Instance.SetDailyDataRefreshState(); } } else if (_battleType == eBattleType.TreasuryBattle) { ArrayList rewardData; DataLookupsCache.Instance.SearchDataByID <ArrayList>("combat.rewards", out rewardData); Hashtable rewardDataTable = Johny.HashtablePool.Claim(); if (rewardData != null) { rewardDataTable = rewardData[0] as Hashtable; } tmpLevel = EB.Dot.String("gold.currentDifficulty", rewardDataTable, null); if (!string.IsNullOrEmpty(tmpLevel)) { JudgeBattle(tmpIsWon, _battleType.ToString() + tmpLevel); } } else if (_battleType == eBattleType.ExpSpringBattle) { ArrayList rewardData; DataLookupsCache.Instance.SearchDataByID <ArrayList>("combat.rewards", out rewardData); Hashtable rewardDataTable = Johny.HashtablePool.Claim(); if (rewardData != null) { rewardDataTable = rewardData[0] as Hashtable; } tmpLevel = EB.Dot.String("currentDifficulty", rewardDataTable, null); if (!string.IsNullOrEmpty(tmpLevel)) { JudgeBattle(tmpIsWon, _battleType.ToString() + tmpLevel); } } else if (_battleType == eBattleType.ChallengeCampaign) { tmpLevel = LTInstanceMapModel.Instance.CurLevelNum.ToString(); } int chapterId = 0; int.TryParse(tmpLevel, out chapterId); string teamName = FormationUtil.GetCurrentTeamName(_battleType); string teamDataPath = SmallPartnerPacketRule.USER_TEAM + "." + teamName + ".team_info"; List <int> heroInfos = new List <int>(); ArrayList teamDatas; DataLookupsCache.Instance.SearchDataByID(teamDataPath, out teamDatas); if (teamDatas != null) { for (var i = 0; i < teamDatas.Count; i++) { var td = teamDatas[i]; string heroid = EB.Dot.String("hero_id", td, ""); if (!string.IsNullOrEmpty(heroid)) { LTPartnerData data = LTPartnerDataManager.Instance.GetPartnerByHeroId(int.Parse(heroid)); if (data != null) { // IDictionary<string, int> hero = new Dictionary<string, int>(); // hero.Add(data.HeroInfo.name, data.Level); heroInfos.Add(data.InfoId); } } } } FusionTelemetry.PostCombat(_battleType.ToString(), chapterId, tmpIsWon ? 1 : 2, heroInfos, isCombatOut ? 2 : 1); }
private void OnBtnUseClicked() { if (!_canClickUseBtn) { return; } _canClickUseBtn = false; object data = GetLineupPresetData(); if (data == null) { EB.Debug.LogError("阵容信息为空"); GlobalMenuManager.Instance.CloseMenu("LTLineupPresetUI"); _canClickUseBtn = true; return; } ArrayList lineupInfo; if (data is int[]) { lineupInfo = new ArrayList(data as int[]); } else { lineupInfo = data as ArrayList; } string teamName = FormationUtil.GetCurrentTeamName(_battleType); List <TeamMemberData> originTeamMembers = new List <TeamMemberData>(LTFormationDataManager.Instance.GetTeamMemList(teamName)); int count = 0; bool hasAlivePartner = false; // 上阵英雄至少要保留一个,故先处理新英雄上阵再处理旧英雄下阵 for (var i = 0; i < lineupInfo.Count; i++) { int heroId = System.Convert.ToInt32(lineupInfo[i]); bool isAlive = true; bool isSleepTower = false; if (heroId != 0 && (_battleType == eBattleType.ChallengeCampaign || _battleType == eBattleType.AlienMazeBattle)) { isAlive = FormationUtil.IsAlive(heroId, false); } if (_battleType == eBattleType.SleepTower && LTClimingTowerHudController.Instance != null) { if (heroId != 0) { isAlive = LTClimingTowerHudController.Instance.CanUpTeam(heroId); } isSleepTower = true; } if (heroId != 0 && isAlive) { hasAlivePartner = true; var memberData = originTeamMembers.Find(member => member.HeroID == heroId); originTeamMembers.Remove(memberData); if (LTFormationDataManager.Instance.CurTeamMemberData != null) { TeamMemberData temp = LTFormationDataManager.Instance.CurTeamMemberData; if (temp.Pos == i) { LTFormationDataManager.Instance.UnUseAllianceMercenary(temp.HeroID, i, null); } } LTFormationDataManager.Instance.RequestDragHeroToFormationPos(heroId, i, teamName, () => { count += 1; if (count >= lineupInfo.Count) { RemoveFromLineup(originTeamMembers, teamName, () => _canClickUseBtn = true); } }); } else { count += 1; if (count >= lineupInfo.Count) { if (hasAlivePartner) { RemoveFromLineup(originTeamMembers, teamName, () => _canClickUseBtn = true); } else { _canClickUseBtn = true; var tips = isSleepTower ? EB.Localizer.GetString("ID_LINEUP_PRESET_ALL_SLEEPED") : EB.Localizer.GetString("ID_LINEUP_PRESET_ALL_KILLED"); MessageTemplateManager.ShowMessage(eMessageUIType.FloatingText, tips); } } } } }
public void InitItems() { List <BattleAnalyseData> heroIDs = new List <BattleAnalyseData>(); string teamName = FormationUtil.GetCurrentTeamName(SceneLogic.BattleType); string teamDataPath = SmallPartnerPacketRule.USER_TEAM + "." + teamName + ".team_info"; ArrayList teamDatas; DataLookupsCache.Instance.SearchDataByID <ArrayList>(teamDataPath, out teamDatas); ArrayList metricList; DataLookupsCache.Instance.SearchDataByID <ArrayList>("battlerMetric", out metricList); BattleAnalyseData TotleData = new BattleAnalyseData(); Dictionary <string, BattleAnalyseData> MLDic = new Dictionary <string, BattleAnalyseData>(); if (metricList != null) { for (int i = 0; i < metricList.Count; ++i)// var ml in metricList) { BattleAnalyseData data = new BattleAnalyseData(); data.heroID = EB.Dot.String("heroId", metricList[i], string.Empty); data.totalDamage = EB.Dot.Integer("totalDamage", metricList[i], 0); data.totalDamaged = EB.Dot.Integer("totalDamaged", metricList[i], 0); data.totalHealth = EB.Dot.Integer("totalHealth", metricList[i], 0); if (!string.IsNullOrEmpty(data.heroID)) { MLDic.Add(data.heroID, data); } } } if (teamDatas != null) { for (int i = 0; i < teamDatas.Count; ++i) { string heroid = EB.Dot.String("hero_id", teamDatas[i], ""); if (!string.IsNullOrEmpty(heroid)) { BattleAnalyseData data; if (MLDic.ContainsKey(heroid)) { data = MLDic[heroid]; TotleData.totalDamage += data.totalDamage; TotleData.totalDamaged += data.totalDamaged; TotleData.totalHealth += data.totalHealth; heroIDs.Add(data); } } } } if (ItemList == null) { ItemList = new List <LTBattleAnalyseItem>(); for (int i = 0; i < 6; ++i) { LTBattleAnalyseItem bodyItem = InstantiateEx <LTBattleAnalyseItem>(ItemTemplate, mGrid != null ? mGrid.transform : null, i.ToString()); ItemList.Add(bodyItem); } if (mGrid != null) { mGrid.Reposition(); } } for (int i = 0; i < heroIDs.Count; ++i) { ItemList[i].InitData(heroIDs[i], TotleData); } for (int i = heroIDs.Count; i < ItemList.Count; ++i) { ItemList[i].InitData(null, null); } }
public void LastEventPlayed(int combat_id, int logid) { var request = s_endpoint.Post("/combat/lastEventPlayed"); request.AddData("combat_id", combat_id); request.AddData("logid", logid); if (SceneLogic.BattleType == eBattleType.InfiniteChallenge || SceneLogic.BattleType == eBattleType.ChallengeCampaign) { int allPower = 0; List <TeamMemberData> temp = LTFormationDataManager.Instance.GetTeamMemList(FormationUtil.GetCurrentTeamName(SceneLogic.BattleType)); for (int j = 0; j < temp.Count; j++) { LTPartnerData data = LTPartnerDataManager.Instance.GetPartnerByHeroId(temp[j].HeroID); if (data != null) { allPower += data.powerData.curPower; } } request.AddData("br", allPower); EB.Debug.Log("LastEventPlayed set br = {0}", allPower); } request.numRetries = 1; request.suspendMethod = EB.Sparx.Request.eSuspendMethod.Finish; s_endpoint.Service(request, delegate(EB.Sparx.Response result) { if (!result.sucessful && result.fatal) { EB.Debug.LogError("CombatManager.lastEventPlayed - /combat/lastEventPlayed failed: {0}", result.error.ToString()); OnNetworkError(result); } else { //if (callback != null) //{ // callback(result); //} } }); }