public override void Update(TimeSpan deltaT, Entity owner)
 {
     if (!IsDisabled)
     {
         Capacity += (int)Math.Round(CurrentPower * Efficacy * deltaT.TotalSeconds);
     }
 }
 public override void HandleMessage(Message message)
 {
     if (message.Command == SetPowerLevelCommand)
     {
         PowerLevel = new BoundedValue(200, 0, message.Content.ToObject <int>());
     }
 }
Esempio n. 3
0
        public ForecastResult ForecastInvestment(decimal lumpSum, decimal monthlyInvestment, int timeInMonths, decimal targetValue, RiskLevel riskLevel)
        {
            var annualGrowth = GetAnnualGrowthFigures(riskLevel);
            var result       = new ForecastResult();
            var time         = DateTime.Today;

            var narrowBounds = new BoundedValue <decimal>(lumpSum, lumpSum);
            var wideBounds   = new BoundedValue <decimal>(lumpSum, lumpSum);

            for (var i = 0; i < timeInMonths; i++)
            {
                var currentInvestment = lumpSum + (i * monthlyInvestment);

                var point = new ForecastPoint(
                    time.AddMonths(i),
                    currentInvestment,
                    narrowBounds,
                    wideBounds,
                    targetValue);

                narrowBounds = CalculateGrowth(narrowBounds, annualGrowth.NarrowBoundsPercentage, monthlyInvestment);
                wideBounds   = CalculateGrowth(wideBounds, annualGrowth.WideBoundsPercentage, monthlyInvestment);

                result.DataPoints.Add(point);
            }

            return(result);
        }
        public bool TryConsumeEnergy(int value)
        {
            if (Capacity.Current < value)
            {
                return(false);
            }

            Capacity -= value;
            return(true);
        }
Esempio n. 5
0
        private BoundedValue <decimal> CalculateGrowth(BoundedValue <decimal> currentValue, BoundedValue <double> growthPercentages, decimal monthlyInvestment)
        {
            var monthlyGrowthLowerPercentage = (decimal)AdjustAnnualGrowthToMonthly(growthPercentages.Lower);
            var monthlyGrowthLower           = (1.0m + monthlyGrowthLowerPercentage / 100.0m) * (currentValue.Lower + monthlyInvestment);


            var monthlyGrowthUpperPercentage = (decimal)AdjustAnnualGrowthToMonthly(growthPercentages.Upper);
            var monthlyGrowthUpper           = (1.0m + monthlyGrowthUpperPercentage / 100.0m) * (currentValue.Upper + monthlyInvestment);

            var result = new BoundedValue <decimal>(monthlyGrowthLower, monthlyGrowthUpper);

            return(result);
        }
        public override void Update(TimeSpan deltaT, Entity owner)
        {
            if (IsDisabled)
            {
                return;
            }

            var currentEnergy = (int)Math.Round(CurrentPower * deltaT.TotalSeconds);

            if (!owner.Powergrid.TryConsumeEnergy(currentEnergy))
            {
                PowerLevel = new BoundedValue(200, 0, 0);
            }
        }
 protected PoweredModule(Template template) : base(template)
 {
     PowerLevel = new BoundedValue(200, 0, 0);
 }
 protected StarshipModule(Template template) : base(template)
 {
     Hitpoints = new BoundedValue(template.Hitpoints);
 }
Esempio n. 9
0
 public BattleStats()
 {
     Health = new BoundedValue(100);
 }
 public PowerplantModule(Template template) : base(template)
 {
     Priority     = 1;
     NominalPower = template.Powerplant.Power;
     Capacity     = new BoundedValue(template.Powerplant.Capacity);
 }
Esempio n. 11
0
 public AnnualGrowthFigures(BoundedValue <double> wideBoundsPercentage, BoundedValue <double> narrowBoundsPercentage)
 {
     WideBoundsPercentage   = wideBoundsPercentage;
     NarrowBoundsPercentage = narrowBoundsPercentage;
 }
Esempio n. 12
0
 public HullComponent(int hitpoints)
 {
     Hitpoints = new BoundedValue(hitpoints);
     Modules   = new ModulesCollection();
 }