Example #1
0
    private string GetFormattedPrice(Tradable tradable, int quantity)
    {
        float priceWithSalesTaxes = tradable.GetPriceWithSalesTaxes(TradableTransactionType.Buyout, base.Empire, (float)quantity);

        ConstructionCost[] costs = new ConstructionCost[]
        {
            new ConstructionCost(DepartmentOfTheTreasury.Resources.EmpireMoney, priceWithSalesTaxes, true, false)
        };
        return(GuiFormater.FormatCost(base.Empire, costs, false, 1, null));
    }
Example #2
0
    private void RefreshForceShiftingButton()
    {
        if (this.ForceShiftButton == null || this.Garrison == null || this.Garrison.Empire == null)
        {
            return;
        }
        this.ForceShiftButton.Visible = false;
        this.ForceShiftButton.Enable  = false;
        if (this.IsOtherEmpire || !this.interactionsAllowed)
        {
            return;
        }
        DepartmentOfScience agency = this.Garrison.Empire.GetAgency <DepartmentOfScience>();

        if (agency == null || agency.GetTechnologyState("TechnologyDefinitionOrbUnlock17WinterShifters") != DepartmentOfScience.ConstructibleElement.State.Researched)
        {
            return;
        }
        if (this.selectedUnits.Count > 0)
        {
            List <Unit> list = new List <Unit>(this.selectedUnits);
            list.RemoveAll((Unit match) => !match.IsShifter() || !match.IsInCurrentSeasonForm());
            if (list.Count > 0)
            {
                ConstructionCost[] unitForceShiftingCost = this.DepartmentOfTheTreasury.GetUnitForceShiftingCost(list);
                AgeUtils.CleanLine(GuiFormater.FormatCost(this.garrison.Empire, unitForceShiftingCost, false, 1, null), ref this.monochromaticFormat);
                this.ForceShiftButtonPriceLabel.Text = GuiFormater.FormatCost(this.garrison.Empire, unitForceShiftingCost, false, 0, null);
                this.ForceShiftButton.Visible        = true;
                if (this.DepartmentOfTheTreasury.CanAfford(unitForceShiftingCost))
                {
                    if (!this.garrison.IsInEncounter)
                    {
                        this.ForceShiftButton.AgeTooltip.Content = AgeLocalizer.Instance.LocalizeString("%ForceShiftTabOKFormat").Replace("$Value", this.monochromaticFormat.ToString());
                        this.ForceShiftButton.Enable             = true;
                    }
                    else
                    {
                        this.ForceShiftButton.AgeTooltip.Content = AgeLocalizer.Instance.LocalizeString("%ArmyLockedInBattleDescription");
                    }
                }
                else
                {
                    this.ForceShiftButton.AgeTooltip.Content = AgeLocalizer.Instance.LocalizeString("%ForceShiftTabCannotAffordDescription") + " : " + this.monochromaticFormat;
                }
            }
        }
    }
Example #3
0
    protected void DisplayPrice()
    {
        ConstructionCost[] costs = new ConstructionCost[]
        {
            new ConstructionCost(DepartmentOfTheTreasury.Resources.EmpireMoney, this.Price, true, false)
        };
        string text = GuiFormater.FormatCost(this.empire, costs, false, 1, null);

        this.PriceLabel.Text = text;
        AgeTooltip ageTooltip = this.PriceLabel.AgeTransform.AgeTooltip;

        if (ageTooltip != null)
        {
            string        formattedLine = AgeLocalizer.Instance.LocalizeString("%MarketplaceTradablePriceDescription").Replace("$TradableName", this.LocalizedName).Replace("$Price", text);
            StringBuilder stringBuilder = new StringBuilder();
            AgeUtils.CleanLine(formattedLine, ref stringBuilder);
            ageTooltip.Content = stringBuilder.ToString();
        }
    }
Example #4
0
 private bool CanHealUnitsAndExplain()
 {
     this.HealButton.Visible = false;
     if (this.IsOtherEmpire)
     {
         return(false);
     }
     if (this.selectedUnits.Count > 0)
     {
         List <Unit> list = new List <Unit>(this.selectedUnits);
         list.RemoveAll((Unit match) => !match.CheckUnitAbility(UnitAbility.UnitAbilityInstantHeal, -1));
         list.RemoveAll((Unit match) => !match.IsWounded());
         if (list.Count > 0)
         {
             ConstructionCost[] unitHealCost = this.DepartmentOfTheTreasury.GetUnitHealCost(list);
             AgeUtils.CleanLine(GuiFormater.FormatCost(this.garrison.Empire, unitHealCost, false, 1, null), ref this.monochromaticFormat);
             this.HealButtonPriceLabel.Text = GuiFormater.FormatCost(this.garrison.Empire, unitHealCost, false, 0, null);
             this.HealButton.Visible        = true;
             if (list.Exists((Unit unit) => !unit.HasEnoughActionPointLeft(1)))
             {
                 this.HealButton.AgeTooltip.Content = AgeLocalizer.Instance.LocalizeString("%HealTabNoActionPointDescription");
             }
             else if (this.DepartmentOfTheTreasury.CanAfford(unitHealCost))
             {
                 if (!this.garrison.IsInEncounter)
                 {
                     this.HealButton.AgeTooltip.Content = AgeLocalizer.Instance.LocalizeString("%HealTabOKFormat").Replace("$Value", this.monochromaticFormat.ToString());
                     return(true);
                 }
                 this.HealButton.AgeTooltip.Content = AgeLocalizer.Instance.LocalizeString("%ArmyLockedInBattleDescription");
             }
             else
             {
                 this.HealButton.AgeTooltip.Content = AgeLocalizer.Instance.LocalizeString("%HealTabCannotAffordDescription") + " : " + this.monochromaticFormat;
             }
         }
     }
     return(false);
 }
Example #5
0
 private bool CanConvertVillage(Army army, Village village, DepartmentOfTheTreasury departmentOfTheTreasury, List <StaticString> failureFlags)
 {
     if (village == null)
     {
         failureFlags.Add(ArmyAction.NoCanDoWhileSystemError);
         return(false);
     }
     if (village.HasBeenConverted)
     {
         failureFlags.Add(ArmyAction_Convert.NoCanDoWhileVillageIsAlreadyConverted);
         return(false);
     }
     if (!village.HasBeenPacified)
     {
         failureFlags.Add(ArmyAction_BaseVillage.NoCanDoWhileVillageIsNotPacified);
         return(false);
     }
     if (village.PointOfInterest.SimulationObject.Tags.Contains(DepartmentOfDefense.PillageStatusDescriptor))
     {
         failureFlags.Add(ArmyAction_Convert.NoCanDoWhileVillageIsPillaged);
         return(false);
     }
     if (village.PointOfInterest.SimulationObject.Tags.Contains(DepartmentOfCreepingNodes.InfectedPointOfInterest))
     {
         failureFlags.Add(ArmyAction_Convert.NoCanDoWhileVillageIsInfected);
         return(false);
     }
     ConstructionCost[] convertionCost = this.GetConvertionCost(army, village);
     if (!departmentOfTheTreasury.CanAfford(convertionCost))
     {
         failureFlags.Add(ArmyAction_Convert.NoCanDoWhileCannotAfford);
         this.lastConvertCostDescription = GuiFormater.FormatCost(army.Empire, convertionCost, false, 1, null);
         return(false);
     }
     return(true);
 }
Example #6
0
    private void RefreshCosts()
    {
        IConstructionCost[] array              = this.ArmyAction.Costs;
        ArmyAction_Bribe    armyAction_Bribe   = this.ArmyAction as ArmyAction_Bribe;
        ArmyAction_Convert  armyAction_Convert = this.ArmyAction as ArmyAction_Convert;

        if (armyAction_Bribe != null || armyAction_Convert != null)
        {
            Village village = this.Target as Village;
            if (village != null)
            {
                IConstructionCost[] array2 = null;
                if (armyAction_Bribe != null)
                {
                    IConstructionCost[] array3 = armyAction_Bribe.GetBribeCosts(this.Army, village);
                    array2 = array3;
                }
                else if (armyAction_Convert != null)
                {
                    IConstructionCost[] array3 = armyAction_Convert.GetConvertionCost(this.Army, village);
                    array2 = array3;
                }
                if (array2 != null && array2.Length != 0)
                {
                    if (array == null)
                    {
                        array = array2;
                    }
                    else
                    {
                        Array.Resize <IConstructionCost>(ref array, array.Length + array2.Length);
                        Array.Copy(array2, 0, array, array.Length - array2.Length, array2.Length);
                    }
                }
            }
        }
        if (this.Army != null && this.Army.Empire != null && array != null && array.Length != 0)
        {
            this.ActionCostLabel.AgeTransform.Visible = true;
            if (ELCPUtilities.UseELCPSymbiosisBuffs && this.ArmyAction is ArmyAction_TameUnstunnedKaiju)
            {
                KaijuGarrison kaijuGarrison = this.Target as KaijuGarrison;
                if (kaijuGarrison != null)
                {
                    KaijuCouncil agency = kaijuGarrison.KaijuEmpire.GetAgency <KaijuCouncil>();
                    if (agency != null)
                    {
                        ConstructionCost constructionCost = new ConstructionCost(agency.ELCPResourceName, KaijuCouncil.GetKaijuTameCost().GetValue(this.Army.Empire), true, true);
                        array = new IConstructionCost[]
                        {
                            constructionCost
                        };
                    }
                }
            }
            this.ActionCostLabel.Text = GuiFormater.FormatCost(this.Army.Empire, array, false, 1, this.Army);
            this.ActionDescription.AgeTransform.PixelMarginBottom = this.ActionCostLabel.AgeTransform.PixelMarginBottom + this.ActionCostLabel.AgeTransform.Height;
            return;
        }
        this.ActionCostLabel.AgeTransform.Visible = false;
        this.ActionCostLabel.Text = string.Empty;
        this.ActionDescription.AgeTransform.PixelMarginBottom = this.ActionCostLabel.AgeTransform.PixelMarginBottom;
    }
Example #7
0
 private bool CanRetrofitUnitsAndExplain()
 {
     this.RetrofitButtonPriceLabel.AgeTransform.Visible = false;
     if (this.IsOtherEmpire)
     {
         return(false);
     }
     if (this.Garrison.IsInEncounter)
     {
         this.RetrofitButton.AgeTooltip.Content = "%ArmyLockedInBattleDescription";
         return(false);
     }
     if (this.selectedUnits.Count == 0)
     {
         this.RetrofitButton.AgeTooltip.Content = "%ArmyEmptySelectionDescription";
         return(false);
     }
     this.RetrofitComputeCandidates();
     if (this.retrofitableUnits.Count == 0)
     {
         this.RetrofitButton.AgeTooltip.Content = "%RetrofitTabNoCandidateDescription";
         return(false);
     }
     ConstructionCost[] array = this.departmentOfDefense.GetRetrofitCosts(this.retrofitableUnits.ToArray());
     if (array.Length == 0)
     {
         array = new ConstructionCost[]
         {
             new ConstructionCost("EmpireMoney", 0f, true, false)
         };
     }
     AgeUtils.CleanLine(GuiFormater.FormatCost(this.Garrison.Empire, array, false, 1, null), ref this.monochromaticFormat);
     this.RetrofitButtonPriceLabel.Text = GuiFormater.FormatCost(this.Garrison.Empire, array, false, 0, null);
     this.RetrofitButtonPriceLabel.AgeTransform.Visible = this.CanDisplayRetrofitCost();
     for (int i = 0; i < this.retrofitableUnits.Count; i++)
     {
         DepartmentOfDefense.CheckRetrofitPrerequisitesResult checkRetrofitPrerequisitesResult = this.departmentOfDefense.CheckRetrofitPrerequisites(this.retrofitableUnits[i], array);
         if (checkRetrofitPrerequisitesResult == DepartmentOfDefense.CheckRetrofitPrerequisitesResult.GarrisonArmyIsInEncounter)
         {
             this.RetrofitButton.AgeTooltip.Content = AgeLocalizer.Instance.LocalizeString("%ArmyLockedInBattleDescription");
             return(false);
         }
         if (checkRetrofitPrerequisitesResult == DepartmentOfDefense.CheckRetrofitPrerequisitesResult.GarrisonCityIsUnderSiege)
         {
             this.RetrofitButton.AgeTooltip.Content = AgeLocalizer.Instance.LocalizeString("%RetrofitTabGarrisonCityUnderSiegeDescription");
             return(false);
         }
         if (checkRetrofitPrerequisitesResult == DepartmentOfDefense.CheckRetrofitPrerequisitesResult.RegionDoesntBelongToUs || checkRetrofitPrerequisitesResult == DepartmentOfDefense.CheckRetrofitPrerequisitesResult.WorldPositionIsNotValid)
         {
             this.RetrofitButton.AgeTooltip.Content = AgeLocalizer.Instance.LocalizeString("%RetrofitTabNotInOwnRegionDescription");
             return(false);
         }
     }
     if (!this.DepartmentOfTheTreasury.CanAfford(array))
     {
         this.RetrofitButton.AgeTooltip.Content = AgeLocalizer.Instance.LocalizeString("%RetrofitTabCannotAffordDescription") + " : " + this.monochromaticFormat;
         return(false);
     }
     this.RetrofitButton.AgeTooltip.Content = AgeLocalizer.Instance.LocalizeString("%RetrofitTabOKDescription") + " : " + this.monochromaticFormat;
     return(true);
 }