Exemplo n.º 1
0
        protected void Notify(StrategiaStrategy strategy, bool requirementsMet)
        {
            const string title = "Strategy Availability Changed";

            // Check for an existing message
            MessageSystem.Message message = MessageSystem.Instance.FindMessages(m => m.messageTitle == title).FirstOrDefault();
            if (message != null)
            {
                message.IsRead = false;
            }
            else
            {
                messageStrategies = new Dictionary <string, bool>();
            }

            // Add our strategy to the list
            messageStrategies[strategy.Title] = requirementsMet;

            // Build the message
            string msg = "";

            if (messageStrategies.Any(p => p.Value))
            {
                msg += "<b>New strategies available:</b>\n";
            }
            foreach (string strategyTitle in messageStrategies.Where(p => p.Value).Select(p => p.Key))
            {
                msg += "    " + strategyTitle + "\n";
            }
            if (messageStrategies.Any(p => !p.Value))
            {
                if (!string.IsNullOrEmpty(msg))
                {
                    msg += "\n";
                }
                msg += "<b>Strategies no longer available:</b>\n";
            }
            foreach (string strategyTitle in messageStrategies.Where(p => !p.Value).Select(p => p.Key))
            {
                msg += "    " + strategyTitle + "\n";
            }

            if (message == null)
            {
                MessageSystem.Instance.AddMessage(new MessageSystem.Message(title, msg,
                                                                            MessageSystemButton.MessageButtonColor.BLUE, MessageSystemButton.ButtonIcons.ALERT));
            }
            else
            {
                message.message = msg;
            }
        }
Exemplo n.º 2
0
        protected void Notify(StrategiaStrategy strategy, bool requirementsMet)
        {
            const string title = "Strategy Availability Changed";

            // Check for an existing message
            MessageSystem.Message message = MessageSystem.Instance.FindMessages(m => m.messageTitle == title).FirstOrDefault();
            if (message != null)
            {
                message.IsRead = false;
            }
            else
            {
                messageStrategies = new Dictionary<string, bool>();
            }

            // Add our strategy to the list
            messageStrategies[strategy.Title] = requirementsMet;

            // Build the message
            string msg = "";
            if (messageStrategies.Any(p => p.Value))
            {
                msg += "<b>New strategies available:</b>\n";
            }
            foreach (string strategyTitle in messageStrategies.Where(p => p.Value).Select(p => p.Key))
            {
                msg += "    " + strategyTitle + "\n";
            }
            if (messageStrategies.Any(p => !p.Value))
            {
                if (!string.IsNullOrEmpty(msg))
                {
                    msg += "\n";
                }
                msg += "<b>Strategies no longer available:</b>\n";
            }
            foreach (string strategyTitle in messageStrategies.Where(p => !p.Value).Select(p => p.Key))
            {
                msg += "    " + strategyTitle + "\n";
            }

            if (message == null)
            {
                MessageSystem.Instance.AddMessage(new MessageSystem.Message(title, msg,
                    MessageSystemButton.MessageButtonColor.BLUE, MessageSystemButton.ButtonIcons.ALERT));
            }
            else
            {
                message.message = msg;
            }
        }
Exemplo n.º 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));
        }
Exemplo n.º 4
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);
        }