Ejemplo n.º 1
0
    private void RefreshSelectedFaction()
    {
        GuiFaction selectedGuiFaction = this.GetSelectedGuiFaction(this.guiFactions);

        this.FactionDroplist.ItemTable = (from guiFaction in this.guiFactions
                                          select guiFaction.IconAndTitle).ToArray <string>();
        this.FactionDroplist.TooltipTable = (from guiFaction in this.guiFactions
                                             select guiFaction.Description).ToArray <string>();
        this.FactionDroplist.ReadOnly          = this.IsReadOnly;
        this.FactionDroplist.OnSelectionObject = base.gameObject;
        this.FactionDroplist.OnSelectionMethod = "OnChangeFactionCB";
        if (selectedGuiFaction == null)
        {
            this.FactionDroplist.SelectedItem     = 0;
            this.FactionPortrait.Image            = null;
            this.FactionLogo.AgeTransform.Visible = false;
            return;
        }
        this.FactionDroplist.SelectedItem     = this.guiFactions.IndexOf(selectedGuiFaction);
        this.FactionPortrait.Image            = selectedGuiFaction.GetImageTexture(GuiPanel.IconSize.Leader, false);
        this.FactionLogo.AgeTransform.Visible = true;
        this.FactionLogo.Image     = selectedGuiFaction.GetImageTexture(GuiPanel.IconSize.LogoSmall, false);
        this.FactionLogo.TintColor = Color.white;
        this.AdvancedFactionButton.AgeTransform.Enable = !this.IsReadOnly;
    }
Ejemplo n.º 2
0
    private void OnDoubleClickGuiFaction(GuiFaction guiFaction)
    {
        IDownloadableContentService service = Services.GetService <IDownloadableContentService>();

        if (service != null)
        {
            bool flag;
            if (service.TryCheckAgainstRestrictions(DownloadableContentRestrictionCategory.LobbyFaction, guiFaction.Faction.Name, out flag) && !flag)
            {
                return;
            }
            if (guiFaction.Faction.Affinity != null && service.TryCheckAgainstRestrictions(DownloadableContentRestrictionCategory.LobbyFactionAffinity, guiFaction.Faction.Affinity.Name, out flag) && !flag)
            {
                return;
            }
            foreach (FactionTrait factionTrait in Faction.EnumerableTraits(guiFaction.Faction))
            {
                if (!service.TryCheckAgainstRestrictions(DownloadableContentRestrictionCategory.LobbyFactionTrait, factionTrait.Name, out flag) || !flag)
                {
                    return;
                }
            }
        }
        this.OnToggleGuiFaction(guiFaction);
        this.OnSelectCB(null);
    }
Ejemplo n.º 3
0
    private void SetupGuiFaction(AgeTransform tableItem, GuiFaction guiFaction, int index)
    {
        FactionCard component = tableItem.GetComponent <FactionCard>();

        component.SetContent(guiFaction, base.gameObject);
        ISessionService service = Services.GetService <ISessionService>();

        Diagnostics.Assert(service != null);
        bool lobbyData = service.Session.GetLobbyData <bool>("CustomFactions", true);

        if (guiFaction.IsCustom && !lobbyData)
        {
            component.AgeTransform.Enable             = false;
            component.AgeTransform.AgeTooltip.Content = "%CustomFactionsNotAllowed";
        }
        else
        {
            component.AgeTransform.Enable             = true;
            component.AgeTransform.AgeTooltip.Content = string.Empty;
        }
        IDownloadableContentService service2 = Services.GetService <IDownloadableContentService>();
        bool flag;

        if (service2 != null && service2.TryCheckAgainstRestrictions(DownloadableContentRestrictionCategory.LobbyFaction, component.GuiFaction.Faction.Name, out flag) && !flag)
        {
            component.AgeTransform.Enable             = false;
            component.AgeTransform.AgeTooltip.Content = "%RestrictedDownloadableContentTitle";
        }
        if ((service.Session.SessionMode == SessionMode.Single || !service.Session.GetLobbyData <bool>("SpectatorMode", false) || service.Session.GetLobbyData <int>("NumberOfMajorFactions", 0) < 3) && guiFaction.Name == "FactionELCPSpectator")
        {
            component.AgeTransform.Enable             = false;
            component.AgeTransform.AgeTooltip.Content = "%GameOptionSpectatorModeDisabled";
        }
    }
Ejemplo n.º 4
0
 private void RefreshParticipantScoreLine(AgeTransform tableitem, EmpireInfo empireInfo, int index)
 {
     tableitem.SetupCustomELCPScaling(this.ParticipantsScoreTableScale);
     if (this.visibleEmpires.Contains(empireInfo.EmpireIndex))
     {
         tableitem.Visible = true;
         ParticipantScoreLine component = tableitem.GetComponent <ParticipantScoreLine>();
         component.ParticipantName.AgeTransform.SetupCustomELCPScaling(this.ParticipantsScoreTableScale);
         component.ParticipantScore.AgeTransform.SetupCustomELCPScaling(this.ParticipantsScoreTableScale);
         component.ParticipantLogoBackground.TintColor = empireInfo.FactionColor;
         component.ParticipantName.Text = empireInfo.LocalizedName;
         GuiFaction guiFaction = new GuiFaction(empireInfo.Faction);
         component.ParticipantLogo.Image = guiFaction.GetImageTexture(GuiPanel.IconSize.LogoLarge, true);
         Snapshot[] snapshots = this.Snapshot.Snapshots;
         string     name      = string.Format("Turn #{0}", snapshots.Length - 1);
         Snapshot   snapshot;
         Snapshot   snapshot2;
         if (this.Snapshot.TryGetSnapshot(name, out snapshot) && snapshot.TryGetSnapshot(empireInfo.EmpireName, out snapshot2))
         {
             float num;
             snapshot2.TryRead(this.CurrentScoreDefinition.Name, out num);
             string str      = "";
             int    decimals = 0;
             component.ParticipantScore.WordWrap = false;
             if (num >= 1000f)
             {
                 str = "k";
                 if (num <= 10000f)
                 {
                     num      = Mathf.Round(num / 100f);
                     num     /= 10f;
                     decimals = 1;
                 }
                 else if (num <= 999999f)
                 {
                     num = Mathf.Round(num / 1000f);
                 }
                 else if (num <= 9999999f)
                 {
                     num      = Mathf.Round(num / 100000f);
                     num     /= 10f;
                     str      = "M";
                     decimals = 1;
                 }
                 else if (num > 9999999f)
                 {
                     num = Mathf.Round(num / 1000000f);
                     str = "M";
                 }
             }
             component.ParticipantScore.Text = GuiFormater.FormatGui(num, false, false, false, decimals) + str;
             return;
         }
     }
     else
     {
         tableitem.Visible = false;
     }
 }
Ejemplo n.º 5
0
 public static string GetFactionSymbolString(Empire empire, Empire empireLooking)
 {
     if (GuiEmpire.IsKnownByLookingPlayer(empire, empireLooking))
     {
         GuiFaction guiFaction = new GuiFaction(empire.Faction);
         return(guiFaction.Icon);
     }
     return("\\7800\\");
 }
Ejemplo n.º 6
0
 private void OnChangeFactionCB(GameObject gameObject)
 {
     if (this.CompetitorIsLocalOwner)
     {
         AgeControlDropList component = gameObject.GetComponent <AgeControlDropList>();
         if (component != null)
         {
             GuiFaction guiFaction = this.guiFactions[component.SelectedItem];
             this.SelectFaction(guiFaction.Faction);
         }
     }
 }
    private void CreateCustomFaction()
    {
        this.Faction.Affinity        = new XmlNamedReference(this.selectedAffinity.Name);
        this.Faction.AffinityMapping = new XmlNamedReference(this.SelectedAffinityMapping.Name);
        this.Faction.TraitReferences = (from guiTrait in this.selectedGuiTraits
                                        select new XmlNamedReference(guiTrait.Name)).ToArray <XmlNamedReference>();
        this.Faction.LocalizedName        = this.NameTextField.AgePrimitiveLabel.Text.Trim();
        this.Faction.LocalizedDescription = this.DescriptionTextField.AgePrimitiveLabel.Text.Trim();
        this.Faction.Author     = this.AuthorTextField.AgePrimitiveLabel.Text.Trim();
        this.Faction.IsCustom   = true;
        this.Faction.IsStandard = false;
        List <GuiError> list = new List <GuiError>();

        if (!GuiFaction.IsValidCustomFaction(this.Faction, list))
        {
            string message = string.Join("\r\n", (from guiError in list
                                                  select guiError.ToString()).ToArray <string>());
            MessagePanel.Instance.Show(message, "%CustomFactionInvalidCustomFactionTitle", MessagePanelButtons.Ok, null, MessagePanelType.WARNING, new MessagePanelButton[0]);
            this.HandleCancelRequest();
            return;
        }
        if (string.IsNullOrEmpty(this.Faction.FileName))
        {
            string        path          = System.IO.Path.Combine(Amplitude.Unity.Framework.Application.GameDirectory, "Custom Factions");
            DirectoryInfo directoryInfo = new DirectoryInfo(path);
            if (!directoryInfo.Exists)
            {
                directoryInfo.Create();
            }
            string text = this.Faction.LocalizedName;
            char[] invalidFileNameChars = System.IO.Path.GetInvalidFileNameChars();
            foreach (char oldChar in invalidFileNameChars)
            {
                text = text.Replace(oldChar, '@');
            }
            this.Faction.FileName = System.IO.Path.Combine(directoryInfo.FullName, text);
            this.Faction.FileName = System.IO.Path.ChangeExtension(this.Faction.FileName, ".xml");
        }
        if (!string.IsNullOrEmpty(this.Faction.FileName))
        {
            ISerializationService service = Services.GetService <ISerializationService>();
            if (service != null)
            {
                XmlSerializer xmlSerializer = service.GetXmlSerializer <Faction>();
                if (xmlSerializer != null)
                {
                    using (Stream stream = File.Open(this.Faction.FileName, FileMode.Create))
                    {
                        xmlSerializer.Serialize(stream, this.Faction);
                    }
                }
            }
        }
        IDatabase <Faction> database = Databases.GetDatabase <Faction>(false);

        database.Touch(this.Faction);
        base.GuiService.GetGuiPanel <MenuNewGameScreen>().OnCustomFactionChanged(this.Faction);
        base.GuiService.GetGuiPanel <MenuFactionScreen>().Show(new object[]
        {
            this.empireIndex,
            this.Faction
        });
        this.Faction = null;
    }
Ejemplo n.º 8
0
    public void RefreshContent(List <GuiFaction> guiFactions, List <Color> colorsList, bool isGameAlreadyLaunchedOnce, bool canModifyOwnEmpireSettings, bool guiLocked)
    {
        if (this.Session == null || !this.Session.IsOpened)
        {
            this.AgeTransform.Enable = false;
            return;
        }
        this.AgeTransform.Enable        = true;
        this.CompetitorIsHuman          = (this.EmpireIndex == 0);
        this.CompetitorIsLocalOwner     = false;
        this.hasGameBeenLaunchedOnce    = isGameAlreadyLaunchedOnce;
        this.canModifyOwnEmpireSettings = canModifyOwnEmpireSettings;
        string x = string.Format("LockEmpire{0}", this.EmpireIndex);

        this.empireLocked = this.Session.GetLobbyData <bool>(x, false);
        this.LockEmpireToggle.AgeTransform.Enable = this.Session.IsHosting;
        this.LockEmpireToggle.State = this.empireLocked;
        string text      = string.Format("Empire{0}", this.EmpireIndex);
        string lobbyData = this.Session.GetLobbyData <string>(text, null);

        if (string.IsNullOrEmpty(lobbyData))
        {
            Diagnostics.LogError("Lobby data is null for 'keyLobbyDataEmpire' (keyLobbyDataEmpire: '{0}').", new object[]
            {
                text
            });
            base.GetComponent <AgeTransform>().Enable = false;
            return;
        }
        if (lobbyData.StartsWith("AI"))
        {
            this.CompetitorIsHuman      = false;
            this.CompetitorIsLocalOwner = this.Session.IsHosting;
        }
        else
        {
            this.CompetitorIsHuman = true;
        }
        for (int i = 0; i < this.PlayersTitleLabels.Length; i++)
        {
            this.PlayersTitleLabels[i].AgeTransform.Visible = false;
            this.PlayerReadyToggles[i].AgeTransform.Visible = false;
            this.PlayerKickButtons[i].AgeTransform.Visible  = false;
            this.PlayerHostingIcons[i].AgeTransform.Visible = false;
        }
        if (this.CompetitorIsHuman)
        {
            this.EmpireType.Text = "%CompetitorEmpireTypeHumanTitle";
            this.EmpireType.AgeTransform.AgeTooltip.Content = "%CompetitorEmpireTypeHumanDescription";
            string[] array = lobbyData.Split(Amplitude.String.Separators, StringSplitOptions.RemoveEmptyEntries);
            for (int j = 0; j < array.Length; j++)
            {
                this.RefreshPlayerLine(array[j], j);
            }
        }
        else
        {
            this.EmpireType.Text = "%CompetitorEmpireTypeComputerTitle";
            this.EmpireType.AgeTransform.AgeTooltip.Content = "%CompetitorEmpireTypeComputerDescription";
            this.PlayersTitleLabels[0].AgeTransform.Visible = true;
            this.PlayersTitleLabels[0].Text = "%CompetitorAIPlayerTitle";
            this.PlayersTitleLabels[0].AgeTransform.AgeTooltip.Content = "%CompetitorEmpireTypeComputerDescription";
        }
        string x2         = string.Format("_EmpireReserved{0}", this.EmpireIndex);
        string lobbyData2 = this.Session.GetLobbyData <string>(x2, null);

        if (!string.IsNullOrEmpty(lobbyData2))
        {
            string[] array2 = lobbyData2.Split(Amplitude.String.Separators, StringSplitOptions.RemoveEmptyEntries);
            List <Steamworks.SteamID> list = new List <Steamworks.SteamID>();
            for (int k = 0; k < array2.Length; k++)
            {
                ulong num = Convert.ToUInt64(array2[k], 16);
                if (num != 0UL)
                {
                    list.Add(new Steamworks.SteamID(num));
                }
            }
            if (list.Count > 0)
            {
                string text2 = string.Empty;
                for (int l = 0; l < list.Count; l++)
                {
                    Steamworks.SteamAPI.SteamFriends.RequestUserInformation(list[l], true);
                    text2 = text2 + ((text2.Length <= 0) ? string.Empty : ",") + Steamworks.SteamAPI.SteamFriends.GetFriendPersonaName(list[l]);
                }
                this.EmpireType.Text = string.Format("{0} #A0A0A0#({1})#REVERT#", AgeLocalizer.Instance.LocalizeString(this.EmpireType.Text), text2);
            }
        }
        this.EmpireNumber.Text = (this.EmpireIndex + 1).ToString();
        this.guiFactions       = new List <GuiFaction>(guiFactions);
        this.RefreshSelectedFaction();
        if (!this.Session.GetLobbyData <bool>("CustomFactions", true))
        {
            for (int m = 0; m < this.guiFactions.Count; m++)
            {
                if (this.guiFactions[m].IsCustom)
                {
                    this.FactionDroplist.EnableItem(m, false);
                    this.FactionDroplist.SetItemTooltip(m, "%CustomFactionsNotAllowed");
                }
                else
                {
                    this.FactionDroplist.EnableItem(m, true);
                }
            }
            Faction selectedFaction = this.GetSelectedFaction();
            if (selectedFaction != null && selectedFaction.IsCustom)
            {
                Faction             faction  = this.guiFactions[0].Faction;
                IDatabase <Faction> database = Databases.GetDatabase <Faction>(false);
                if (database != null)
                {
                    faction = database.FirstOrDefault((Faction iterator) => iterator.IsStandard && !iterator.IsHidden);
                }
                this.SelectFaction(faction);
                this.AgeTransform.Enable = false;
                return;
            }
        }
        else
        {
            Faction selectedFaction2 = this.GetSelectedFaction();
            for (int n = 0; n < this.guiFactions.Count; n++)
            {
                if (this.guiFactions[n].IsCustom && !GuiFaction.IsValidCustomFaction(this.guiFactions[n].Faction, null))
                {
                    this.FactionDroplist.EnableItem(n, false);
                    this.FactionDroplist.SetItemTooltip(n, "%CustomFactionInvalidCustomFactionTitle");
                    if (selectedFaction2 != null && selectedFaction2.Name == this.guiFactions[n].Faction.Name)
                    {
                        this.SelectFaction(this.guiFactions[0].Faction);
                    }
                }
            }
        }
        if (this.Session.SessionMode == SessionMode.Single || !this.Session.GetLobbyData <bool>("SpectatorMode", false) || this.Session.GetLobbyData <int>("NumberOfMajorFactions", 0) < 3)
        {
            for (int num2 = 0; num2 < this.guiFactions.Count; num2++)
            {
                if (this.guiFactions[num2].Faction.Name == "FactionELCPSpectator")
                {
                    this.FactionDroplist.EnableItem(num2, false);
                    this.FactionDroplist.SetItemTooltip(num2, "%GameOptionSpectatorModeDisabled");
                }
                else
                {
                    this.FactionDroplist.EnableItem(num2, true);
                }
            }
            if (this.GetSelectedFaction().Name == "FactionELCPSpectator")
            {
                Faction             faction2  = this.guiFactions[0].Faction;
                IDatabase <Faction> database2 = Databases.GetDatabase <Faction>(false);
                if (database2 != null)
                {
                    faction2 = database2.FirstOrDefault((Faction iterator) => iterator.IsStandard && !iterator.IsHidden && iterator.Name != "FactionELCPSpectator");
                }
                this.SelectFaction(faction2);
                this.AgeTransform.Enable = false;
                return;
            }
        }
        IDownloadableContentService service = Services.GetService <IDownloadableContentService>();

        if (service != null)
        {
            for (int num3 = 0; num3 < this.guiFactions.Count; num3++)
            {
                if (this.guiFactions[num3].IsStandard || this.guiFactions[num3].IsCustom)
                {
                    bool flag = false;
                    if (!service.TryCheckAgainstRestrictions(DownloadableContentRestrictionCategory.LobbyFaction, this.guiFactions[num3].Name, out flag) || !flag)
                    {
                        this.FactionDroplist.EnableItem(num3, false);
                        this.FactionDroplist.SetItemTooltip(num3, "%RestrictedDownloadableContentTitle");
                    }
                    else if (this.guiFactions[num3].Faction.Affinity != null && (!service.TryCheckAgainstRestrictions(DownloadableContentRestrictionCategory.LobbyFactionAffinity, this.guiFactions[num3].Faction.Affinity, out flag) || !flag))
                    {
                        this.FactionDroplist.EnableItem(num3, false);
                        this.FactionDroplist.SetItemTooltip(num3, "%RestrictedDownloadableContentTitle");
                    }
                    else
                    {
                        foreach (FactionTrait factionTrait in Faction.EnumerableTraits(this.guiFactions[num3].Faction))
                        {
                            if (!service.TryCheckAgainstRestrictions(DownloadableContentRestrictionCategory.LobbyFactionTrait, factionTrait.Name, out flag) || !flag)
                            {
                                this.FactionDroplist.EnableItem(num3, false);
                                this.FactionDroplist.SetItemTooltip(num3, "%RestrictedDownloadableContentTitle");
                                break;
                            }
                        }
                    }
                }
            }
        }
        ISessionService service2         = Services.GetService <ISessionService>();
        Faction         selectedFaction3 = this.GetSelectedFaction();

        if (selectedFaction3 != null && this.FactionConstrainedIcon != null)
        {
            if (Faction.IsOptionDefinitionConstrained(selectedFaction3, service2.Session))
            {
                this.FactionConstrainedIcon.AgeTransform.Visible = true;
            }
            else
            {
                this.FactionConstrainedIcon.AgeTransform.Visible = false;
            }
        }
        this.RefreshColorDropList(colorsList);
        this.RefreshHandicapDroplist(lobbyData);
        bool flag2 = !this.empireLocked && !guiLocked;

        if (!this.CompetitorIsHuman && this.Session.SessionMode != SessionMode.Single)
        {
            this.JoinButton.AgeTransform.Visible = true;
            this.NoJoinBackground.Visible        = false;
            this.JoinButton.AgeTransform.Enable  = (flag2 && !this.empireLocked);
        }
        else
        {
            this.JoinButton.AgeTransform.Visible = false;
            this.NoJoinBackground.Visible        = true;
        }
        if (this.Session.GetLobbyData <bool>(string.Format("Empire{0}Eliminated", this.EmpireIndex), false))
        {
            if (!this.Session.GetLobbyData <bool>("SpectatorMode", false) || this.CompetitorIsHuman)
            {
                this.JoinButton.AgeTransform.Visible = false;
                this.NoJoinBackground.Visible        = true;
            }
            else
            {
                this.JoinButton.AgeTransform.Visible = true;
                this.NoJoinBackground.Visible        = false;
            }
            this.EmpireType.Text = string.Format("{0} #FF0000#({1})#REVERT#", AgeLocalizer.Instance.LocalizeString(this.EmpireType.Text), AgeLocalizer.Instance.LocalizeString("%CompetitorEliminatedTitle"));
        }
        this.CurrentPlayerHighlight.Visible = this.IsMySlot;
    }
Ejemplo n.º 9
0
    public override void RefreshContent()
    {
        base.RefreshContent();
        this.FactionsTable.Height = 0f;
        this.FactionsTable.ReserveChildren(this.guiFactions.Count, this.FactionCardPrefab, "Item");
        this.FactionsTable.RefreshChildrenIList <GuiFaction>(this.guiFactions, this.setupGuiFactionDelegate, true, false);
        this.FactionsTable.ArrangeChildren();
        this.FactionsTableScrollView.OnPositionRecomputed();
        this.ValidateButton.AgeTransform.Enable             = false;
        this.ValidateButton.AgeTransform.AgeTooltip.Content = null;
        this.DestroyFactionButton.AgeTransform.Enable       = false;
        this.ModifyFactionButton.AgeTransform.Enable        = false;
        this.CreateFactionButton.AgeTransform.Enable        = true;
        List <FactionCard> children = this.FactionsTable.GetChildren <FactionCard>(true);

        for (int i = 0; i < children.Count; i++)
        {
            children[i].SelectionToggle.State = (this.SelectedGuiFaction != null && children[i].GuiFaction.Faction.Name == this.SelectedGuiFaction.Faction.Name);
        }
        if (this.SelectedGuiFaction == null)
        {
            this.FactionTitle.AgeTransform.Visible                 = false;
            this.FactionTitleUnderline.AgeTransform.Visible        = false;
            this.FactionAuthor.AgeTransform.Visible                = false;
            this.FactionMoodImage.AgeTransform.Visible             = false;
            this.FactionDescriptionScrollView.AgeTransform.Visible = false;
            this.FactionTraitsScrollView.AgeTransform.Visible      = false;
            this.UnitBodyGroup.Visible = false;
            return;
        }
        this.ValidateButton.AgeTransform.Enable = true;
        if (this.SelectedGuiFaction.IsCustom)
        {
            bool enable = GuiFaction.IsValidCustomFaction(this.SelectedGuiFaction.Faction, null);
            this.ValidateButton.AgeTransform.Enable = enable;
        }
        IDownloadableContentService service = Services.GetService <IDownloadableContentService>();

        if (service != null)
        {
            bool flag;
            if (service.TryCheckAgainstRestrictions(DownloadableContentRestrictionCategory.LobbyFaction, this.SelectedGuiFaction.Faction.Name, out flag) && !flag)
            {
                this.ValidateButton.AgeTransform.Enable             = false;
                this.ValidateButton.AgeTransform.AgeTooltip.Content = "%RestrictedDownloadableContentTitle";
            }
            if (this.SelectedGuiFaction.Faction.Affinity != null && service.TryCheckAgainstRestrictions(DownloadableContentRestrictionCategory.LobbyFactionAffinity, this.SelectedGuiFaction.Faction.Affinity.Name, out flag) && !flag)
            {
                this.ValidateButton.AgeTransform.Enable             = false;
                this.ValidateButton.AgeTransform.AgeTooltip.Content = "%RestrictedDownloadableContentTitle";
            }
            if (this.ValidateButton.AgeTransform.Enable)
            {
                foreach (FactionTrait factionTrait in Faction.EnumerableTraits(this.SelectedGuiFaction.Faction))
                {
                    if (!service.TryCheckAgainstRestrictions(DownloadableContentRestrictionCategory.LobbyFactionTrait, factionTrait.Name, out flag) || !flag)
                    {
                        this.ValidateButton.AgeTransform.Enable             = false;
                        this.ValidateButton.AgeTransform.AgeTooltip.Content = "%RestrictedDownloadableContentTitle";
                        break;
                    }
                }
            }
        }
        this.DestroyFactionButton.AgeTransform.Enable          = this.SelectedGuiFaction.IsCustom;
        this.ModifyFactionButton.AgeTransform.Enable           = this.SelectedGuiFaction.IsCustom;
        this.FactionDescriptionScrollView.AgeTransform.Visible = true;
        this.FactionTitle.AgeTransform.Visible          = true;
        this.FactionTitleUnderline.AgeTransform.Visible = true;
        this.FactionAuthor.AgeTransform.Visible         = true;
        this.FactionTitle.Text  = this.SelectedGuiFaction.Title;
        this.FactionAuthor.Text = string.Empty;
        if (this.SelectedGuiFaction.Faction.Author != "AMPLITUDE Studios")
        {
            this.FactionAuthor.Text = this.SelectedGuiFaction.Faction.Author;
        }
        if (this.diplomaticNegotiationViewport != null)
        {
            this.FactionMoodImage.AgeTransform.Visible = false;
            XmlNamedReference xmlNamedReference = (!this.SelectedGuiFaction.IsRandom) ? this.SelectedGuiFaction.Faction.AffinityMapping : new XmlNamedReference(GuiFaction.FactionRandomMappingName);
            bool flag2 = this.diplomaticNegotiationViewport.AffinityMapping == null || this.diplomaticNegotiationViewport.AffinityMapping != xmlNamedReference;
            this.diplomaticNegotiationViewport.SetApparence(xmlNamedReference);
            if (flag2)
            {
                this.diplomaticNegotiationViewport.TriggerAlternativeIdle(0.1f);
            }
        }
        else
        {
            this.FactionMoodImage.AgeTransform.Visible = true;
            this.FactionMoodImage.Image = this.SelectedGuiFaction.GetImageTexture(GuiPanel.IconSize.NegotiationLarge, false);
            this.FactionDescription.AgeTransform.Height = 0f;
        }
        if (this.SelectedGuiFaction.IsRandom || this.SelectedGuiFaction.Name == "FactionELCPSpectator")
        {
            this.FactionDescription.Text = this.SelectedGuiFaction.Description;
        }
        else
        {
            this.FactionDescription.Text = AgeLocalizer.Instance.LocalizeString("%" + this.SelectedGuiFaction.Faction.Affinity.Name + "VictoryType") + "\n \n" + AgeLocalizer.Instance.LocalizeString(this.SelectedGuiFaction.Description);
        }
        this.FactionDescriptionScrollView.ResetUp();
        if (!this.SelectedGuiFaction.Faction.IsRandom)
        {
            this.FactionTraitsScrollView.AgeTransform.Visible = true;
            this.UnitBodyGroup.Visible           = true;
            this.FactionTraitsContainers.Visible = true;
            List <GuiFactionTrait> list = (from trait in Faction.EnumerableTraits(this.SelectedGuiFaction.Faction)
                                           where !trait.IsHidden && !trait.IsAffinityRelated
                                           select new GuiFactionTrait(trait)).ToList <GuiFactionTrait>();
            list.Sort();
            this.FactionTraitsTable.Height = 0f;
            this.FactionTraitsTable.ReserveChildren(list.Count, this.FactionTraitPrefab, "Item");
            this.FactionTraitsTable.RefreshChildrenIList <GuiFactionTrait>(list, this.setupGuiFactionTraitDelegate, true, false);
            this.FactionTraitsTable.ArrangeChildren();
            this.FactionTraitsScrollView.ResetUp();
            this.factionUnitBodies.Clear();
            for (int j = 0; j < this.unitBodyDefinitions.Count; j++)
            {
                UnitBodyDefinition unitBodyDefinition = this.unitBodyDefinitions[j];
                if (!unitBodyDefinition.Tags.Contains("Hidden"))
                {
                    SimulationDescriptorReference[] simulationDescriptorReferences = unitBodyDefinition.SimulationDescriptorReferences;
                    for (int k = 0; k < simulationDescriptorReferences.Length; k++)
                    {
                        if (simulationDescriptorReferences[k].Name == this.SelectedGuiFaction.Faction.Affinity.Name)
                        {
                            this.factionUnitBodies.Add(unitBodyDefinition);
                        }
                    }
                }
            }
            if (this.currentBody >= this.factionUnitBodies.Count)
            {
                this.currentBody = 0;
            }
            if (this.currentBody >= 0 && this.currentBody < this.factionUnitBodies.Count)
            {
                this.UnitBodyCard.RefreshContent(this.factionUnitBodies[this.currentBody]);
            }
            this.RefreshCurrentBody();
            return;
        }
        this.FactionTraitsScrollView.AgeTransform.Visible = false;
        this.UnitBodyGroup.Visible           = false;
        this.FactionTraitsContainers.Visible = false;
    }
Ejemplo n.º 10
0
 private void OnToggleGuiFaction(GuiFaction guiFaction)
 {
     this.SelectedGuiFaction = guiFaction;
     this.currentBody        = 0;
     this.RefreshContent();
 }