Example #1
0
    public void SetupPortrait(Kaiju kaiju, Empire playerEmpire)
    {
        this.Kaiju = kaiju;
        if (this.Portrait != null)
        {
            IGuiPanelHelper guiPanelHelper = Services.GetService <global::IGuiService>().GuiPanelHelper;
            Diagnostics.Assert(guiPanelHelper != null, "Unable to access GuiPanelHelper");
            Texture2D image;
            if (guiPanelHelper.TryGetTextureFromIcon(this.KaijuGuiElement, global::GuiPanel.IconSize.Large, out image))
            {
                this.Portrait.Image = image;
            }
        }
        Amplitude.Unity.Gui.IGuiService service = Services.GetService <global::IGuiService>();
        Diagnostics.Assert(service != null);
        KaijuTameCost kaijuTameCost = KaijuCouncil.GetKaijuTameCost();

        this.CostGroup.Visible = this.Kaiju.IsWild();
        KaijuCouncil agency = this.Kaiju.KaijuEmpire.GetAgency <KaijuCouncil>();

        this.CostValue.Text = GuiFormater.FormatGui(kaijuTameCost.GetValue(playerEmpire), false, true, false, 0) + service.FormatSymbol(ELCPUtilities.UseELCPSymbiosisBuffs ? agency.ELCPResourceName : kaijuTameCost.ResourceName);
        if (this.Background != null)
        {
            this.Background.TintColor = this.Kaiju.Empire.Color;
        }
        this.AgeTransform.AgeTooltip.Content = AgeLocalizer.Instance.LocalizeString(KaijuTechPortrait.PortraitClickTooltip);
    }
Example #2
0
 public void RefreshCanExecute()
 {
     if (this.ArmyAction != null && !this.Army.IsEmpty)
     {
         this.failure.Clear();
         bool flag;
         if (this.ArmyAction is IArmyActionWithTargetSelection && this.ArmyAction is IArmyActionWithUnitSelection)
         {
             this.armyActionTargets.Clear();
             (this.ArmyAction as IArmyActionWithTargetSelection).FillTargets(this.Army, this.armyActionTargets, ref this.failure);
             flag = this.ArmyAction.CanExecute(this.Army, ref this.failure, new object[]
             {
                 this.unitListPanel.SelectUnits,
                 this.armyActionTargets
             });
         }
         else if (this.ArmyAction is IArmyActionWithTargetSelection)
         {
             this.armyActionTargets.Clear();
             (this.ArmyAction as IArmyActionWithTargetSelection).FillTargets(this.Army, this.armyActionTargets, ref this.failure);
             flag = this.ArmyAction.CanExecute(this.Army, ref this.failure, new object[]
             {
                 this.armyActionTargets
             });
         }
         else if (this.ArmyAction is IArmyActionWithUnitSelection)
         {
             flag = this.ArmyAction.CanExecute(this.Army, ref this.failure, new object[]
             {
                 this.unitListPanel.SelectUnits
             });
         }
         else
         {
             flag = this.ArmyAction.CanExecute(this.Army, ref this.failure, new object[0]);
         }
         flag &= (!this.failure.Contains(ArmyAction.NoCanDoWhileMoving) && !this.failure.Contains(ArmyAction.NoCanDoWhileTutorial));
         if (!this.failure.Contains(ArmyAction.NoCanDoWhileHidden))
         {
             this.AgeTransform.AgeTooltip.Content = string.Empty;
             GuiElement guiElement;
             if (Services.GetService <Amplitude.Unity.Gui.IGuiService>().GuiPanelHelper.TryGetGuiElement(this.ArmyAction.Name, out guiElement))
             {
                 if (this.failure.Count == 0)
                 {
                     this.AgeTransform.AgeTooltip.Content = "#50FF50#" + AgeLocalizer.Instance.LocalizeString(guiElement.Title).ToUpper() + "#REVERT#";
                 }
                 else
                 {
                     this.AgeTransform.AgeTooltip.Content = "#FF5050#" + AgeLocalizer.Instance.LocalizeString(guiElement.Title).ToUpper() + "#REVERT#";
                 }
             }
             if (this.ArmyAction is IArmyActionWithToggle)
             {
                 bool flag2 = this.failure.Contains(ArmyAction.NoCanDoWhileToggledOn);
                 if (flag2)
                 {
                     this.failure.RemoveAll((StaticString failureFlag) => failureFlag.Equals(ArmyAction.NoCanDoWhileToggledOn));
                 }
                 IArmyActionWithToggle armyActionWithToggle = this.ArmyAction as IArmyActionWithToggle;
                 this.ActionToggle.AgeTransform.Enable = flag;
                 this.ActionImage.AgeTransform.Alpha   = ((this.ActionToggle.AgeTransform.Enable && !flag2) ? 1f : 0.5f);
                 this.ActionToggle.State = ((flag || flag2) && armyActionWithToggle.IsToggled(this.Army));
                 if (this.ActionToggle.State && !this.ModifierSector.IsStarted())
                 {
                     this.ModifierSector.StartAnimation();
                 }
                 else if (!this.ActionToggle.State && this.ModifierSector.IsStarted())
                 {
                     this.ModifierSector.Reset();
                 }
                 if (this.failure.Count == 0)
                 {
                     if (this.ActionToggle.State)
                     {
                         StaticString toggledOnDescriptionOverride = armyActionWithToggle.ToggledOnDescriptionOverride;
                         if (!StaticString.IsNullOrEmpty(toggledOnDescriptionOverride))
                         {
                             AgeTooltip ageTooltip = this.AgeTransform.AgeTooltip;
                             ageTooltip.Content = ageTooltip.Content + " : " + AgeLocalizer.Instance.LocalizeString("%" + toggledOnDescriptionOverride);
                         }
                         else
                         {
                             AgeTooltip ageTooltip2 = this.AgeTransform.AgeTooltip;
                             ageTooltip2.Content = ageTooltip2.Content + " : " + AgeLocalizer.Instance.LocalizeString(this.ArmyAction.FormatDescription("%" + this.ArmyAction.Name + "OffDescription"));
                         }
                     }
                     else
                     {
                         StaticString toggledOffDescriptionOverride = armyActionWithToggle.ToggledOffDescriptionOverride;
                         if (!StaticString.IsNullOrEmpty(toggledOffDescriptionOverride))
                         {
                             AgeTooltip ageTooltip3 = this.AgeTransform.AgeTooltip;
                             ageTooltip3.Content = ageTooltip3.Content + " : " + AgeLocalizer.Instance.LocalizeString("%" + toggledOffDescriptionOverride);
                         }
                         else
                         {
                             AgeTooltip ageTooltip4 = this.AgeTransform.AgeTooltip;
                             ageTooltip4.Content = ageTooltip4.Content + " : " + AgeLocalizer.Instance.LocalizeString(this.ArmyAction.FormatDescription("%" + this.ArmyAction.Name + "OnDescription"));
                         }
                     }
                 }
             }
             else
             {
                 this.ActionButton.AgeTransform.Enable = flag;
                 this.ActionImage.AgeTransform.Alpha   = ((!this.ActionButton.AgeTransform.Enable) ? 0.5f : 1f);
                 if (this.failure.Count == 0)
                 {
                     AgeTooltip ageTooltip5 = this.AgeTransform.AgeTooltip;
                     ageTooltip5.Content = ageTooltip5.Content + " : " + AgeLocalizer.Instance.LocalizeString(this.ArmyAction.FormatDescription("%" + this.ArmyAction.Name + "Description"));
                     if (this.ArmyAction is ArmyActionWithCooldown)
                     {
                         float num = (this.ArmyAction as ArmyActionWithCooldown).ComputeCooldownDuration(this.Army);
                         this.AgeTransform.AgeTooltip.Content = this.AgeTransform.AgeTooltip.Content.Replace("$CooldownDuration", num.ToString());
                     }
                 }
             }
             if (this.failure.Count > 0)
             {
                 AgeTooltip ageTooltip6 = this.AgeTransform.AgeTooltip;
                 ageTooltip6.Content = ageTooltip6.Content + " : " + AgeLocalizer.Instance.LocalizeString(this.ArmyAction.FormatDescription("%" + this.failure[0] + "Description"));
                 if (this.ArmyAction is ArmyActionWithCooldown)
                 {
                     float num2 = (this.ArmyAction as ArmyActionWithCooldown).ComputeRemainingCooldownDuration(this.Army);
                     this.AgeTransform.AgeTooltip.Content = this.AgeTransform.AgeTooltip.Content.Replace("$RemainingCooldownDuration", num2.ToString());
                 }
             }
         }
         float costInActionPoints = this.ArmyAction.GetCostInActionPoints();
         if (costInActionPoints > 0f)
         {
             AgeTooltip ageTooltip7 = this.AgeTransform.AgeTooltip;
             ageTooltip7.Content = ageTooltip7.Content + "\n \n" + AgeLocalizer.Instance.LocalizeString("%ArmyActionPointRequirementFormat").Replace("$Value", costInActionPoints.ToString());
         }
         for (int i = 0; i < this.ArmyAction.Costs.Length; i++)
         {
             string text  = this.ArmyAction.Costs[i].ResourceName;
             bool   flag3 = false;
             if (ELCPUtilities.UseELCPSymbiosisBuffs && this.ArmyAction is ArmyAction_TameUnstunnedKaiju)
             {
                 foreach (IGameEntity gameEntity in this.armyActionTargets)
                 {
                     Kaiju kaiju = gameEntity as Kaiju;
                     if (kaiju != null)
                     {
                         KaijuCouncil agency = kaiju.KaijuEmpire.GetAgency <KaijuCouncil>();
                         if (agency != null)
                         {
                             text  = agency.ELCPResourceName;
                             flag3 = true;
                             break;
                         }
                     }
                 }
             }
             if (!string.IsNullOrEmpty(text) && !text.Equals(DepartmentOfTheTreasury.Resources.ActionPoint))
             {
                 float num3 = this.ArmyAction.GetCostForResource(text, this.Army.Empire);
                 if (flag3)
                 {
                     num3 = KaijuCouncil.GetKaijuTameCost().GetValue(this.Army.Empire);
                 }
                 if (num3 != 0f)
                 {
                     DepartmentOfTheTreasury agency2 = this.Army.Empire.GetAgency <DepartmentOfTheTreasury>();
                     float f = 0f;
                     if (agency2.TryGetResourceStockValue(this.Army.Empire.SimulationObject, text, out f, false))
                     {
                         GuiElement guiElement2;
                         if (Services.GetService <global::IGuiService>().GuiPanelHelper.TryGetGuiElement(text, out guiElement2) && guiElement2 is ExtendedGuiElement)
                         {
                             ExtendedGuiElement extendedGuiElement = guiElement2 as ExtendedGuiElement;
                             if (extendedGuiElement == null)
                             {
                                 Diagnostics.LogError("Resource extended gui is 'null'.");
                             }
                             string text2        = AgeLocalizer.Instance.LocalizeString(extendedGuiElement.Title);
                             string symbolString = extendedGuiElement.SymbolString;
                             string arg          = string.Format(AgeLocalizer.Instance.LocalizeString("%ArmyActionResourceRequirementFormat"), new object[]
                             {
                                 num3,
                                 text2,
                                 symbolString,
                                 Mathf.Ceil(f)
                             });
                             this.AgeTransform.AgeTooltip.Content = string.Format("{0}\n\n\n{1}", this.AgeTransform.AgeTooltip.Content, arg);
                         }
                         else
                         {
                             Diagnostics.LogError("Could not retrieve the resource gui element.");
                         }
                     }
                 }
             }
         }
     }
 }
Example #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;
    }
Example #4
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 #5
0
    private void Client_TurnBegin_RecalculateELCPTameResource()
    {
        if (this.ELCPTameCostCooldown < 1)
        {
            return;
        }
        int num  = (this.gameService.Game as global::Game).Turn + 1;
        int num2 = num % this.ELCPTameCostCooldown;

        if (num2 != 0 && this.eLCPResourceName != StaticString.Empty)
        {
            return;
        }
        num -= num2;
        System.Random random        = new System.Random(World.Seed + base.Empire.Index * base.Empire.Index * base.Empire.Index * base.Empire.Index * base.Empire.Index + num * num);
        int           maxEraNumber  = DepartmentOfScience.GetMaxEraNumber();
        KaijuTameCost kaijuTameCost = KaijuCouncil.GetKaijuTameCost();
        Dictionary <string, List <PointOfInterestTemplate> > dictionary = KaijuTechsManager.ComputeLuxuryAbundance(this.gameService.Game as global::Game);
        List <PointOfInterestTemplate> list = new List <PointOfInterestTemplate>();
        List <string> list2 = new List <string>();

        for (int i = 0; i < kaijuTameCost.CostDefinitions.Length; i++)
        {
            KaijuTameCost.CostDefinition costDefinition = kaijuTameCost.CostDefinitions[i];
            if (!list2.Contains(costDefinition.LuxuryTier))
            {
                string[] array = costDefinition.EraNumber.Split(new char[]
                {
                    ','
                });
                bool flag = false;
                for (int j = 0; j < array.Length; j++)
                {
                    int num3 = 0;
                    if (int.TryParse(array[j], out num3) && num3 <= maxEraNumber)
                    {
                        flag = true;
                        break;
                    }
                }
                if (flag)
                {
                    list.AddRange(dictionary[costDefinition.LuxuryTier]);
                    list2.Add(costDefinition.LuxuryTier);
                }
            }
        }
        PointOfInterestTemplate pointOfInterestTemplate = list[random.Next(list.Count)];
        string empty = string.Empty;

        if (pointOfInterestTemplate.Properties.TryGetValue("ResourceName", out empty))
        {
            Diagnostics.Log("ELCP {0} Client_TurnBegin_RecalculateELCPTameResource rolled Resource {1} instead of {2}", new object[]
            {
                base.Empire.Index.ToString() + "/" + this.KaijuEmpire.KaijuFaction.LocalizedName,
                empty,
                kaijuTameCost.ResourceName
            });
            this.eLCPResourceName = new StaticString(empty);
        }
    }