Beispiel #1
0
        protected override string GenerateCostText()
        {
            string result = "";

            IEnumerable <Strategy> activeStrategies = StrategySystem.Instance.Strategies.Where(s => s.IsActive);

            conflictStrategy = activeStrategies.OfType <UpgradeableStrategy>().Where(s => s.Name == Name && s.Level != Level).FirstOrDefault();
            float fundsDiscount      = 0.0f;
            float scienceDiscount    = 0.0f;
            float reputationDiscount = 0.0f;

            if (conflictStrategy != null)
            {
                fundsDiscount      = Math.Min(InitialCostFunds, conflictStrategy.InitialCostFunds);
                scienceDiscount    = Math.Min(InitialCostScience, conflictStrategy.InitialCostScience);
                reputationDiscount = Math.Min(InitialCostReputation, conflictStrategy.InitialCostReputation);
            }

            // Write out the cost line
            string costLine = "";

            if (InitialCostFunds != 0)
            {
                costLine += "<color=#B4D455>£ " + (InitialCostFunds - fundsDiscount).ToString("N0") + "</color>";
                if (fundsDiscount > 0.0f)
                {
                    costLine += "<color=#B4D455> (-" + fundsDiscount.ToString("N0") + ")</color>";
                }
                costLine += "    ";
            }
            if (InitialCostScience != 0)
            {
                costLine += "<color=#6DCFF6>© " + (InitialCostScience - scienceDiscount).ToString("N0") + "</color>";
                if (scienceDiscount > 0.0f)
                {
                    costLine += "<color=#B4D455> (-" + scienceDiscount.ToString("N0") + ")</color>";
                }
                costLine += "    ";
            }
            if (InitialCostReputation != 0)
            {
                costLine += "<color=#E0D503>¡ " + (InitialCostReputation - reputationDiscount).ToString("N0") + "</color>";
                if (reputationDiscount > 0.0f)
                {
                    costLine += "<color=#B4D455> (-" + reputationDiscount.ToString("N0") + ")</color>";
                }
            }
            if (!string.IsNullOrEmpty(costLine))
            {
                result += "\n<b><color=#EDED8B>Setup Cost:</color></b> " + costLine + "\n";
            }

            return(result);
        }
Beispiel #2
0
        protected override string GenerateEffectText()
        {
            string result = "";

            IEnumerable <Strategy> activeStrategies = StrategySystem.Instance.Strategies.Where(s => s.IsActive);
            UpgradeableStrategy    conflictStrategy = activeStrategies.OfType <UpgradeableStrategy>().Where(s => s.Name == Name && s.Level != Level).FirstOrDefault();

            if (conflictStrategy != null)
            {
                result = "<i><color=#8BED8B>Can " + (conflictStrategy.Level > Level ? "downgrade" : "upgrade") + " from " + conflictStrategy.Title + " to " + Title + ".</color></i>\n\n";
            }

            return(result + base.GenerateEffectText());
        }
Beispiel #3
0
        protected override bool CanActivate(ref string reason)
        {
            lastActivationRequest = this;

            // Force the active strategies text to be updated next tick
            AdminResizer.Instance.ticks = 0;

            // If we are at max strategies, only allow activation if it would be an upgrade
            IEnumerable <Strategy> activeStrategies = StrategySystem.Instance.Strategies.Where(s => s.IsActive);
            int limit = GameVariables.Instance.GetActiveStrategyLimit(ScenarioUpgradeableFacilities.GetFacilityLevel(SpaceCenterFacility.Administration)) - 1;

            if (activeStrategies.Count() >= limit)
            {
                UpgradeableStrategy upgradeable = this as UpgradeableStrategy;
                if (upgradeable != null && activeStrategies.OfType <UpgradeableStrategy>().Any(s => s.Name == upgradeable.Name))
                {
                    return(true);
                }
                else
                {
                    reason = "The Administration Building cannot support more than " + limit + " active strategies at this level.";
                    return(false);
                }
            }

            // Special requirements
            foreach (StrategyEffect effect in Effects)
            {
                IRequirementEffect requirement = effect as IRequirementEffect;
                if (requirement != null)
                {
                    string unmetReason;
                    if (!requirement.RequirementMet(out unmetReason))
                    {
                        reason = requirement.RequirementText();
                        if (!string.IsNullOrEmpty(unmetReason))
                        {
                            reason += " (" + unmetReason + ")";
                        }

                        return(false);
                    }
                }
            }

            return(base.CanActivate(ref reason));
        }
Beispiel #4
0
        protected override void OnRegister()
        {
            base.OnRegister();

            // Check for upgrades
            IEnumerable <Strategy> activeStrategies = StrategySystem.Instance.Strategies.Where(s => s.IsActive);
            UpgradeableStrategy    conflictStrategy = activeStrategies.OfType <UpgradeableStrategy>().Where(s => s.Name == Name && s.Level != Level).FirstOrDefault();

            if (conflictStrategy != null)
            {
                // Remove the other strategy
                conflictStrategy.ForceDeactivate();


                // Force a redraw, but not until the next update
                strategiesNeedRedraw = true;
            }

            // Register callbacks
            GameEvents.Modifiers.OnCurrencyModifierQuery.Add(new EventData <CurrencyModifierQuery> .OnEvent(OnEffectQuery));
        }