Exemplo n.º 1
0
        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);
        }