private void SetupBattleTransmission(TransmissionVO transmission) { this.battleLogTransmission.Visible = true; this.genericTransmission.Visible = false; this.SetupNextOrDismissBattleButton(); if (this.battleTransmissionBattlesGrid.Count > 0) { return; } this.conflictResultGroup.Visible = false; this.battleTransmissionTitle.Text = LangUtils.GetHolonetTransmissionCharacterName(transmission); this.battleTransmissionBody.Text = LangUtils.GetHolonetBattleTransmissionDescText(transmission); this.battleTransmissionMedalsTotalDelta.Text = transmission.TotalPvpRatingDelta.ToString(); TournamentController tournamentController = Service.Get <TournamentController>(); bool flag = false; int count = transmission.AttackerData.Count; string planetId = ""; int num = 0; this.battleTransmissionBattlesGrid.SetTemplateItem("ItemBattleResult"); for (int i = 0; i < count; i++) { BattleEntry battleEntry = transmission.AttackerData[i]; string itemUid = battleEntry.AttackerID + i.ToString(); UXElement item = this.battleTransmissionBattlesGrid.CloneTemplateItem(itemUid); BattleParticipant defender = battleEntry.Defender; int num2 = GameUtils.CalcuateMedals(defender.AttackRating, defender.DefenseRating); int num3 = GameUtils.CalcuateMedals(defender.AttackRating + defender.AttackRatingDelta, defender.DefenseRating + defender.DefenseRatingDelta); int delta = num3 - num2; string deltaString = LangUtils.GetDeltaString(delta); this.battleTransmissionBattlesGrid.GetSubElement <UXLabel>(itemUid, "LabelOpponentLevel").Visible = false; this.battleTransmissionBattlesGrid.GetSubElement <UXLabel>(itemUid, "LabelOpponentName").Text = battleEntry.Attacker.PlayerName; this.battleTransmissionBattlesGrid.GetSubElement <UXLabel>(itemUid, "LabelMedalCount").Text = deltaString; string timeLabelFromSeconds = GameUtils.GetTimeLabelFromSeconds((int)(ServerTime.Time - battleEntry.EndBattleServerTime)); this.battleTransmissionBattlesGrid.GetSubElement <UXLabel>(itemUid, "LabelBattleTime").Text = this.lang.Get("TIME_AGO", new object[] { timeLabelFromSeconds }); bool flag2 = defender.TournamentRatingDelta != 0 && tournamentController.IsBattleInCurrentTournament(battleEntry); this.battleTransmissionBattlesGrid.GetSubElement <UXElement>(itemUid, "CampaignPoints").Visible = flag2; if (flag2 && !string.IsNullOrEmpty(battleEntry.PlanetId)) { flag = true; planetId = battleEntry.PlanetId; num += defender.TournamentRatingDelta; string deltaString2 = LangUtils.GetDeltaString(defender.TournamentRatingDelta); this.battleTransmissionBattlesGrid.GetSubElement <UXLabel>(itemUid, "LabelCampaignPoints").Text = deltaString2; this.battleTransmissionBattlesGrid.GetSubElement <UXSprite>(itemUid, "SpriteCampaignPoints").SpriteName = GameUtils.GetTournamentPointIconName(planetId); } this.battleTransmissionBattlesGrid.AddItem(item, i); } if (flag) { this.conflictResultGroup.Visible = true; this.battleTransmissionConflictPtsTotalDelta.Text = LangUtils.GetDeltaString(num); this.battleTransmissionConflictPtsSprite.SpriteName = GameUtils.GetTournamentPointIconName(planetId); } this.battleTransmissionBattlesGrid.RepositionItems(); this.battleTransmissionBattleLogLabel.Text = this.lang.Get("s_BattleLog", new object[0]); }
private void FillOutReplayShare(BattleEntry latest) { CurrentPlayer currentPlayer = Service.Get <CurrentPlayer>(); bool flag = latest.AttackerID == currentPlayer.PlayerId; string text = flag ? latest.Defender.PlayerName : latest.Attacker.PlayerName; string text2 = flag ? this.lang.Get("SQUAD_OFFENSE", new object[0]) : this.lang.Get("SQUAD_DEFENSE", new object[0]); BattleParticipant battleParticipant = flag ? latest.Attacker : latest.Defender; int num = GameUtils.CalcuateMedals(battleParticipant.AttackRating, battleParticipant.DefenseRating); int num2 = GameUtils.CalcuateMedals(battleParticipant.AttackRating + battleParticipant.AttackRatingDelta, battleParticipant.DefenseRating + battleParticipant.DefenseRatingDelta); int value = num2 - num; this.shareOppNameLabel.Text = text; this.shareTypeLabel.Text = text2; this.shareDamagePercentLabel.Text = this.lang.Get("PERCENTAGE", new object[] { latest.DamagePercent }); this.shareMedalsLabel.Text = this.lang.ThousandsSeparated(value); this.share1StarSprite.Visible = true; this.share2StarSprite.Visible = true; this.share3StarSprite.Visible = true; this.share1StarSprite.Color = ((latest.EarnedStars > 0) ? Color.white : this.grayOut); this.share2StarSprite.Color = ((latest.EarnedStars > 1) ? Color.white : this.grayOut); this.share3StarSprite.Color = ((latest.EarnedStars > 2) ? Color.white : this.grayOut); }
private int CalculateMedalsGained(BattleParticipant participant) { int result = 0; if (participant != null) { int num = GameUtils.CalcuateMedals(participant.AttackRating, participant.DefenseRating); int num2 = GameUtils.CalcuateMedals(participant.AttackRating + participant.AttackRatingDelta, participant.DefenseRating + participant.DefenseRatingDelta); result = num2 - num; } return(result); }
public void InitBattleData(List <BattleEntry> battles) { this.Priority = 1; this.AttackerData = battles; this.TotalPvpRatingDelta = 0; int count = battles.Count; for (int i = 0; i < count; i++) { BattleEntry battleEntry = battles[i]; BattleParticipant defender = battleEntry.Defender; int num = GameUtils.CalcuateMedals(defender.AttackRating, defender.DefenseRating); int num2 = GameUtils.CalcuateMedals(defender.AttackRating + defender.AttackRatingDelta, defender.DefenseRating + defender.DefenseRatingDelta); this.TotalPvpRatingDelta += num2 - num; } }
public ISerializable FromObject(object obj) { Dictionary <string, object> dictionary = obj as Dictionary <string, object>; if (dictionary == null) { return(this); } if (dictionary.ContainsKey("playerId")) { this.PlayerId = (dictionary["playerId"] as string); } if (dictionary.ContainsKey("name")) { this.PlayerName = (dictionary["name"] as string); } if (dictionary.ContainsKey("scalars")) { Dictionary <string, object> dictionary2 = dictionary["scalars"] as Dictionary <string, object>; int attackRating = 0; int defenseRating = 0; if (dictionary2 != null) { if (dictionary2.ContainsKey("attackRating")) { attackRating = Convert.ToInt32(dictionary2["attackRating"]); } if (dictionary2.ContainsKey("defenseRating")) { defenseRating = Convert.ToInt32(dictionary2["defenseRating"]); } } this.Medals = GameUtils.CalcuateMedals(attackRating, defenseRating); } if (dictionary.ContainsKey("playerModel")) { Dictionary <string, object> dictionary3 = dictionary["playerModel"] as Dictionary <string, object>; if (dictionary3 != null) { if (dictionary3.ContainsKey("faction")) { this.Faction = StringUtils.ParseEnum <FactionType>(dictionary3["faction"].ToString()); } if (dictionary3.ContainsKey("guildInfo")) { Dictionary <string, object> dictionary4 = dictionary3["guildInfo"] as Dictionary <string, object>; if (dictionary4 != null && dictionary4.ContainsKey("guildName")) { this.SquadName = WWW.UnEscapeURL(dictionary4["guildName"] as string); } } if (dictionary3.ContainsKey("map")) { Dictionary <string, object> dictionary5 = dictionary3["map"] as Dictionary <string, object>; if (dictionary5 != null && dictionary5.ContainsKey("buildings")) { List <object> list = dictionary5["buildings"] as List <object>; if (list != null) { StaticDataController staticDataController = Service.StaticDataController; int i = 0; int count = list.Count; while (i < count) { Dictionary <string, object> dictionary6 = list[i] as Dictionary <string, object>; if (dictionary6 != null && dictionary6.ContainsKey("uid")) { BuildingTypeVO buildingTypeVO = staticDataController.Get <BuildingTypeVO>(dictionary6["uid"] as string); if (buildingTypeVO.Type == BuildingType.HQ) { this.HQLevel = buildingTypeVO.Lvl; break; } } i++; } } } } this.ActiveIdentity = true; if (dictionary3.ContainsKey("identitySwitchTimes")) { Dictionary <string, object> dictionary7 = dictionary3["identitySwitchTimes"] as Dictionary <string, object>; if (dictionary7 != null && dictionary7.ContainsKey(this.PlayerId)) { this.ActiveIdentity = (Convert.ToInt32(dictionary7[this.PlayerId]) == 0); } } } } return(this); }
private void AddBattleLogItem(BattleEntry entry) { CurrentPlayer currentPlayer = Service.CurrentPlayer; bool flag = currentPlayer.PlayerId == entry.AttackerID; BattleParticipant battleParticipant; BattleParticipant battleParticipant2; if (flag) { battleParticipant = entry.Attacker; battleParticipant2 = entry.Defender; } else { battleParticipant = entry.Defender; battleParticipant2 = entry.Attacker; } string playerName = battleParticipant2.PlayerName; string guildName = battleParticipant2.GuildName; FactionType factionType = battleParticipant2.PlayerFaction; if (factionType == FactionType.Invalid) { factionType = GameUtils.GetOppositeFaction(currentPlayer.Faction); } int num = GameUtils.CalcuateMedals(battleParticipant.AttackRating, battleParticipant.DefenseRating); int num2 = GameUtils.CalcuateMedals(battleParticipant.AttackRating + battleParticipant.AttackRatingDelta, battleParticipant.DefenseRating + battleParticipant.DefenseRatingDelta); int value = num2 - num; int tournamentRatingDelta = battleParticipant.TournamentRatingDelta; bool flag2 = GameUtils.IsBattleVersionSupported(entry.CmsVersion, entry.BattleVersion); bool flag3 = Service.SquadController.StateManager.GetCurrentSquad() != null; bool visible = flag2; bool visible2 = !flag && entry.IsPvP() && !entry.Revenged && entry.PlanetId == currentPlayer.PlanetId; bool visible3 = flag2 && flag3; uint time = ServerTime.Time; int totalSeconds = (int)(time - entry.EndBattleServerTime); int count = this.itemGrid.Count; string text = string.Format("{0}{1}", "BattleLogItem", count); UXElement item = this.itemGrid.CloneTemplateItem(text); bool won = entry.Won; Color winResultColor = UXUtils.GetWinResultColor(won); UXButton subElement = this.itemGrid.GetSubElement <UXButton>(text, "BtnReplay"); subElement.Tag = entry; subElement.OnClicked = new UXButtonClickedDelegate(this.OnReplayButtonClicked); subElement.Visible = visible; UXButton subElement2 = this.itemGrid.GetSubElement <UXButton>(text, "BtnRevenge"); subElement2.Tag = entry; subElement2.OnClicked = new UXButtonClickedDelegate(this.OnRevengeButtonClicked); subElement2.Visible = visible2; if (this.revengeButtons == null) { this.revengeButtons = new List <UXButton>(); } this.revengeButtons.Add(subElement2); UXButton subElement3 = this.itemGrid.GetSubElement <UXButton>(text, "BtnShare"); subElement3.Tag = entry; subElement3.OnClicked = new UXButtonClickedDelegate(this.OnShareButtonClicked); subElement3.Visible = visible3; UXLabel subElement4 = this.itemGrid.GetSubElement <UXLabel>(text, "LabelBtnShare"); subElement4.Text = this.lang.Get("s_Share", new object[0]); UXLabel subElement5 = this.itemGrid.GetSubElement <UXLabel>(text, "LabelBtnReplay"); subElement5.Text = this.lang.Get("BUTTON_REPLAY", new object[0]); UXLabel subElement6 = this.itemGrid.GetSubElement <UXLabel>(text, "LabelBtnRevenge"); subElement6.Text = this.lang.Get("s_Revenge", new object[0]); bool flag4 = this.curTab == BattleLogTab.Attack; int value2 = (!flag4) ? entry.LootCreditsDeducted : entry.LootCreditsEarned; int value3 = (!flag4) ? entry.LootMaterialsDeducted : entry.LootMaterialsEarned; int value4 = (!flag4) ? entry.LootContrabandDeducted : entry.LootContrabandEarned; UXLabel subElement7 = this.itemGrid.GetSubElement <UXLabel>(text, "LabelCredits"); subElement7.Text = this.lang.ThousandsSeparated(value2); UXLabel subElement8 = this.itemGrid.GetSubElement <UXLabel>(text, "LabelMaterials"); subElement8.Text = this.lang.ThousandsSeparated(value3); UXElement subElement9 = this.itemGrid.GetSubElement <UXElement>(text, "Contraband"); if (currentPlayer.IsContrabandUnlocked) { subElement9.Visible = true; UXLabel subElement10 = this.itemGrid.GetSubElement <UXLabel>(text, "LabelContraband"); subElement10.Text = this.lang.ThousandsSeparated(value4); } else { subElement9.Visible = false; } UXLabel subElement11 = this.itemGrid.GetSubElement <UXLabel>(text, "LabelBasePoints"); subElement11.Text = this.lang.ThousandsSeparated(value); subElement11.TextColor = winResultColor; UXLabel subElement12 = this.itemGrid.GetSubElement <UXLabel>(text, "LabelDamage"); subElement12.Text = this.lang.Get("DAMAGE_PERCENT", new object[] { entry.DamagePercent }); UXLabel subElement13 = this.itemGrid.GetSubElement <UXLabel>(text, "LabelResult"); subElement13.Text = this.lang.Get((!won) ? "YOU_LOST" : "YOU_WON", new object[0]); subElement13.TextColor = winResultColor; UXLabel subElement14 = this.itemGrid.GetSubElement <UXLabel>(text, "LabelTimeStamp"); subElement14.Text = this.lang.Get("TIME_AGO", new object[] { GameUtils.GetTimeLabelFromSeconds(totalSeconds) }); UXLabel subElement15 = this.itemGrid.GetSubElement <UXLabel>(text, "LabelPlayerName"); subElement15.Text = playerName; UXLabel subElement16 = this.itemGrid.GetSubElement <UXLabel>(text, "LabelFactionName"); subElement16.Text = guildName; UXSprite subElement17 = this.itemGrid.GetSubElement <UXSprite>(text, "SpriteFaction"); subElement17.SpriteName = "Faction" + factionType.ToString(); if (!string.IsNullOrEmpty(entry.PlanetId)) { PlanetVO planetVO = this.sdc.Get <PlanetVO>(entry.PlanetId); UXTexture subElement18 = this.itemGrid.GetSubElement <UXTexture>(text, "TexturePlanetBg"); subElement18.LoadTexture(planetVO.LeaderboardTileTexture); } UXGrid subElement19 = this.itemGrid.GetSubElement <UXGrid>(text, "TroopsExpendedGrid"); UXElement subElement20 = this.itemGrid.GetSubElement <UXElement>(text, "TroopsExpendedTemplate"); subElement19.SetTemplateItem(subElement20.Root.name); this.AddExpendedItems(entry, text, subElement19); subElement19.RepositionItems(); bool flag5 = tournamentRatingDelta != 0; UXElement subElement21 = this.itemGrid.GetSubElement <UXElement>(text, "TournamentRating"); subElement21.Visible = flag5; if (!string.IsNullOrEmpty(entry.PlanetId)) { string tournamentPointIconName = GameUtils.GetTournamentPointIconName(entry.PlanetId); if (flag5 && !string.IsNullOrEmpty(tournamentPointIconName)) { UXSprite subElement22 = this.itemGrid.GetSubElement <UXSprite>(text, "SpriteTournamentRating"); subElement22.SpriteName = tournamentPointIconName; UXLabel subElement23 = this.itemGrid.GetSubElement <UXLabel>(text, "LabelTournamentRating"); subElement23.Text = tournamentRatingDelta.ToString(); subElement23.TextColor = winResultColor; } } this.itemGrid.AddItem(item, count); }