예제 #1
0
    public void RefreshContent(City city, CityOptionsPanel.ProductionConstruction constructibleElementDefinition, int index, GameObject client)
    {
        IGuiPanelHelper guiPanelHelper = Services.GetService <global::IGuiService>().GuiPanelHelper;

        Diagnostics.Assert(guiPanelHelper != null, "Unable to access GuiPanelHelper");
        UnitDesign unitDesign = constructibleElementDefinition.ConstructibleElement as UnitDesign;
        GuiElement guiElement2;

        if (unitDesign != null)
        {
            this.ConstructibleName.Text   = GuiUnitDesign.GetTruncatedTitle(unitDesign, this.ConstructibleName);
            this.ConstructibleImage.Image = null;
            GuiElement guiElement;
            Texture2D  image;
            if (guiPanelHelper.TryGetGuiElement(unitDesign.UnitBodyDefinitionReference, out guiElement) && guiPanelHelper.TryGetTextureFromIcon(guiElement, global::GuiPanel.IconSize.Small, out image))
            {
                this.ConstructibleImage.Image = image;
            }
        }
        else if (guiPanelHelper.TryGetGuiElement(constructibleElementDefinition.ConstructibleElement.Name, out guiElement2))
        {
            AgeUtils.TruncateString(AgeLocalizer.Instance.LocalizeString(guiElement2.Title), this.ConstructibleName, out this.temp, '.');
            this.ConstructibleName.Text = this.temp;
            Texture2D image2;
            if (guiPanelHelper.TryGetTextureFromIcon(guiElement2, global::GuiPanel.IconSize.Small, out image2))
            {
                this.ConstructibleImage.Image = image2;
            }
            else
            {
                this.ConstructibleImage.Image = null;
            }
        }
        else
        {
            this.ConstructibleName.Text   = string.Empty;
            this.ConstructibleImage.Image = null;
        }
        if (this.AgeTransform.AgeTooltip != null)
        {
            this.AgeTransform.AgeTooltip.Class   = constructibleElementDefinition.ConstructibleElement.TooltipClass;
            this.AgeTransform.AgeTooltip.Content = constructibleElementDefinition.ConstructibleElement.Name;
            if (constructibleElementDefinition.ConstructibleElement is BoosterGeneratorDefinition)
            {
                this.AgeTransform.AgeTooltip.ClientData = new BoosterGeneratorTooltipData(city.Empire, city, constructibleElementDefinition.ConstructibleElement);
            }
            else
            {
                this.AgeTransform.AgeTooltip.ClientData = new ConstructibleTooltipData(city.Empire, city, constructibleElementDefinition.ConstructibleElement);
            }
        }
        this.ConstructibleButton.OnActivateMethod     = "OnOptionSelect";
        this.ConstructibleButton.OnActivateObject     = client;
        this.ConstructibleButton.OnActivateDataObject = constructibleElementDefinition.ConstructibleElement;
        this.ConstructibleButton.OnMiddleClickMethod  = "OnRightClick";
        this.ConstructibleButton.OnMiddleClickObject  = client;
        this.ConstructibleButton.OnRightClickMethod   = "OnRightClick";
        this.ConstructibleButton.OnRightClickObject   = client;
        this.AgeTransform.Enable = (constructibleElementDefinition.Flags.Length == 0);
    }
예제 #2
0
    public void RefreshContent(global::Empire empire, UnitDesign design, GameObject client, AgeTransform anchor, bool allowDoubleClick)
    {
        this.Reset();
        IGuiPanelHelper guiPanelHelper = Services.GetService <global::IGuiService>().GuiPanelHelper;

        Diagnostics.Assert(guiPanelHelper != null, "Unable to access GuiPanelHelper");
        this.UnitDesign = design;
        if (this.tooltip != null)
        {
            this.tooltip.Anchor     = anchor;
            this.tooltip.Class      = this.UnitDesign.TooltipClass;
            this.tooltip.ClientData = new ConstructibleTooltipData(empire, null, this.UnitDesign);
            this.tooltip.Content    = this.UnitDesign.Name;
        }
        this.UnitName.Text = GuiUnitDesign.GetTruncatedTitle(this.UnitDesign, this.UnitName);
        if (this.PrivateerGroup != null)
        {
            this.PrivateerGroup.Visible = this.IsMercenary(empire, this.UnitDesign);
        }
        GuiElement guiElement;

        if (guiPanelHelper.TryGetGuiElement(this.UnitDesign.UnitBodyDefinition.Name, out guiElement))
        {
            Texture2D image;
            if (guiPanelHelper.TryGetTextureFromIcon(guiElement, global::GuiPanel.IconSize.Small, out image))
            {
                this.UnitPortrait.Image = image;
            }
        }
        else
        {
            this.UnitPortrait.Image = null;
        }
        this.UnitToggle.State          = false;
        this.UnitToggle.OnSwitchMethod = "OnUnitDesignToggle";
        this.UnitToggle.OnSwitchObject = client;
        if (this.DoubleClickButton != null)
        {
            if (allowDoubleClick)
            {
                this.DoubleClickButton.AgeTransform.Visible = true;
                this.DoubleClickButton.OnDoubleClickMethod  = "OnDoubleClickDesignCB";
                this.DoubleClickButton.OnDoubleClickObject  = client;
            }
            else
            {
                this.DoubleClickButton.AgeTransform.Visible = false;
            }
        }
        this.LifeGauge.AgeTransform.Alpha = 0f;
    }
예제 #3
0
    public void RefreshContent()
    {
        if (this.KaijuGarrison == null)
        {
            return;
        }
        if (this.KaijuGarrison.Owner != null)
        {
            if (this.KaijuGarrison.Kaiju.OnArmyMode())
            {
                this.AgeTransform.Visible = false;
                return;
            }
            this.AgeTransform.Visible             = true;
            this.FactionIcon.AgeTransform.Visible = true;
            this.StatusImage.AgeTransform.Visible = false;
            this.StatusTurns.AgeTransform.Visible = false;
            this.TameCost.AgeTransform.Visible    = false;
            GuiEmpire guiEmpire = new GuiEmpire(this.KaijuGarrison.Owner);
            this.FactionIcon.Image              = guiEmpire.GuiFaction.GetImageTexture(global::GuiPanel.IconSize.LogoSmall, false);
            this.FactionIcon.TintColor          = guiEmpire.Color;
            this.Frame.TintColor                = guiEmpire.Color;
            this.PinLine.TintColor              = guiEmpire.Color;
            this.KaijuIcon.TintColor            = guiEmpire.Color;
            this.StatusPanel.AgeTooltip.Content = string.Empty;
        }
        else
        {
            this.AgeTransform.Visible             = true;
            this.FactionIcon.AgeTransform.Visible = false;
            this.StatusImage.AgeTransform.Visible = true;
            this.StatusTurns.AgeTransform.Visible = true;
            this.Frame.TintColor     = this.KaijuGarrison.Empire.Color;
            this.PinLine.TintColor   = this.KaijuGarrison.Empire.Color;
            this.KaijuIcon.TintColor = this.KaijuGarrison.Empire.Color;
            KaijuCouncil agency = this.KaijuGarrison.KaijuEmpire.GetAgency <KaijuCouncil>();
            if (this.KaijuGarrison.Kaiju.IsWild())
            {
                this.StatusTurns.Text  = agency.RelocationETA.ToString();
                this.StatusImage.Image = AgeManager.Instance.FindDynamicTexture("Gui/DynamicBitmaps/Icons/kaijuMoveIcon", false);
                this.StatusPanel.AgeTooltip.Content = "%KaijuTurnsToMoveDescription";
            }
            else if (this.KaijuGarrison.Kaiju.IsStunned())
            {
                this.StatusTurns.Text  = this.KaijuGarrison.Kaiju.GetRemainingTurnBeforeStunFinish().ToString();
                this.StatusImage.Image = AgeManager.Instance.FindDynamicTexture("Gui/DynamicBitmaps/Icons/kaijuStunnedIcon", false);
                this.StatusPanel.AgeTooltip.Content = "%KaijuStunnedDescription";
            }
            KaijuTameCost kaijuTameCost = KaijuCouncil.GetKaijuTameCost();
            this.TameCost.AgeTransform.Visible = true;
            this.TameCost.Text = GuiFormater.FormatGui(kaijuTameCost.GetValue(this.empire), false, true, false, 0) + this.GuiService.FormatSymbol((ELCPUtilities.UseELCPSymbiosisBuffs ? agency.ELCPResourceName.ToString() : kaijuTameCost.ResourceName.ToString()) + "Dark");
        }
        if (this.statusPanelTooltip != null)
        {
            this.statusPanelTooltip.Content = "%KaijuSpawnedProperties";
        }
        if (this.panelTooltip != null)
        {
            GuiElement kaijuFactionGuiElement = this.KaijuFactionGuiElement;
            if (kaijuFactionGuiElement != null)
            {
                this.panelTooltip.Content = kaijuFactionGuiElement.Description;
            }
        }
        this.UnitNumber.Text = this.KaijuGarrison.UnitsCount.ToString();
        string text = (this.KaijuGuiUnit == null) ? this.KaijuGarrison.Kaiju.Name.ToString() : GuiUnitDesign.GetTruncatedTitle(this.KaijuGuiUnit.UnitDesign, this.KaijuName);

        this.KaijuName.Text = text;
    }
예제 #4
0
    public void RefreshContent(GuiUnit guiUnit, GameObject client, AgeTransform anchor)
    {
        this.Reset();
        if (guiUnit.UnitDesign == null)
        {
            this.DestroyedCrossImage.Alpha = 0f;
            this.LevelUpImage.Alpha        = 0f;
            this.LastStandImage.Alpha      = 0f;
            this.UnitName.Text             = "Unknown";
            if (this.tooltip != null && guiUnit.UnitSnapshot != null)
            {
                this.tooltip.Class   = "Simple";
                this.tooltip.Content = string.Format("Unknown Unit Design: {0}, {1}, {2} (in Empire {3})", new object[]
                {
                    guiUnit.UnitSnapshot.UnitDesignDefinitionName,
                    guiUnit.UnitSnapshot.UnitDesignModel,
                    guiUnit.UnitSnapshot.UnitDesignModelRevision,
                    guiUnit.Empire.Index
                });
            }
            return;
        }
        this.GuiUnit = guiUnit;
        if (this.tooltip != null)
        {
            this.tooltip.Anchor     = anchor;
            this.tooltip.Class      = "Unit";
            this.tooltip.ClientData = this.GuiUnit;
            this.tooltip.Content    = this.GuiUnit.UnitDesign.UnitBodyDefinitionReference;
        }
        this.UnitName.Text      = GuiUnitDesign.GetTruncatedTitle(this.GuiUnit.UnitDesign, this.UnitName);
        this.UnitPortrait.Image = this.GuiUnit.GetPortraitTexture(global::GuiPanel.IconSize.Small);
        this.UnitLevel.Text     = this.GuiUnit.LevelDisplayed.ToString();
        IGuiPanelHelper guiPanelHelper = Services.GetService <global::IGuiService>().GuiPanelHelper;

        Diagnostics.Assert(guiPanelHelper != null, "Unable to access GuiPanelHelper");
        IDownloadableContentService service = Services.GetService <IDownloadableContentService>();
        GuiElement guiElement;
        Texture2D  image;

        if (service != null && service.IsShared(DownloadableContent13.ReadOnlyName) && this.GuiUnit.IsShifted && guiPanelHelper.TryGetGuiElement(this.GuiUnit.UnitDesign.Name, out guiElement) && guiPanelHelper.TryGetTextureFromIcon(guiElement, global::GuiPanel.IconSize.ShiftedSmall, out image))
        {
            this.UnitPortrait.Image = image;
        }
        this.UnitToggle.State = false;
        if (client != null)
        {
            this.UnitToggle.OnSwitchMethod      = "OnUnitToggle";
            this.UnitToggle.OnMiddleClickMethod = "OnUnitToggle";
            this.UnitToggle.OnRightClickMethod  = "OnUnitToggle";
            this.UnitToggle.OnSwitchObject      = client;
            this.UnitToggle.AgeTransform.Enable = true;
        }
        else
        {
            this.UnitToggle.OnSwitchMethod      = string.Empty;
            this.UnitToggle.OnSwitchObject      = null;
            this.UnitToggle.AgeTransform.Enable = false;
        }
        if (this.PrivateerGroup != null)
        {
            this.PrivateerGroup.Visible = this.IsMercenary(this.GuiUnit);
        }
        this.LifeGauge.AgeTransform.PercentTop = 100f * (1f - this.GuiUnit.HealthRatio);
        this.LifeGauge.TintColor          = this.GuiUnit.HealthColor;
        this.LifeGauge.AgeTransform.Alpha = 1f;
        this.DestroyedCrossImage.Alpha    = ((this.GuiUnit.Health <= 0f) ? 1f : 0f);
        this.LevelUpImage.Alpha           = ((!this.GuiUnit.HasJustLeveledUp) ? 0f : 1f);
        this.LastStandImage.Alpha         = ((!this.GuiUnit.HasBeenLastStanding) ? 0f : 1f);
        this.UndeadImage.Alpha            = ((!this.GuiUnit.HasRisenFromTheDead) ? 0f : 1f);
        if (this.EmbarkedGroup != null && (guiUnit.Unit != null || guiUnit.UnitSnapshot != null))
        {
            this.EmbarkedGroup.Visible = ((guiUnit.Unit != null && guiUnit.Unit.Embarked) || (guiUnit.UnitSnapshot != null && guiUnit.UnitSnapshot.Embarked));
        }
    }