Example #1
0
    private void ApplyCompoundEffects(CompoundJSON compound, int sign = -1)
    {
        if (compound.Type == CompoundType.Armor)
        {
            foreach (KeyValuePair <R, float> item in compound.Effects)
            {
                if (item.Key == R.Temperature || item.Key == R.Pressure || item.Key == R.Humidity || item.Key == R.Radiation)
                {
                    _unitController.SelectedUnit.Resistance[item.Key].ChangePosition(PPMath.Round((sign * item.Value) / 100f));
                }
                else
                {
                    _unitController.SelectedUnit.Props[item.Key].Value += (int)item.Value * sign;
                }
            }

            _unitDefenseUpdateCommand.Execute(_unitController.SelectedUnit);
        }

        if (compound.Type == CompoundType.Weapon)
        {
            foreach (KeyValuePair <R, float> item in compound.Effects)
            {
                if (item.Key == R.Temperature || item.Key == R.Pressure || item.Key == R.Humidity || item.Key == R.Radiation)
                {
                    _unitController.SelectedUnit.Impact[item.Key].Value     += (int)(item.Value * sign);
                    _planetController.SelectedPlanet.Impact[item.Key].Value += (int)(item.Value * sign);
                }
                else
                {
                    _unitController.SelectedUnit.Props[item.Key].Delta += (int)item.Value * sign;
                }
            }
        }
    }
Example #2
0
    public PlanetProperty(double value, float variation)
    {
        Value     = value;
        Variation = variation;

        for (int i = 0; i <= 100; i++)
        {
            HexDistribution[i] = new WeightedValue(PPMath.Round(i / 100f), 0);
        }
    }
Example #3
0
    public bool ChangePosition(float delta)
    {
        //because JSON parser sets Position outside of the constructor, we have to take the latest value here instead
        if (_defaultPosition == float.MaxValue)
        {
            _defaultPosition = Position.Value;
        }

        Position.Value = PPMath.Round(Position.Value + delta, 2);
        bool increase = false;


        if (delta > 0)
        {
            if (Position.Value > _defaultPosition)
            {
                Consumption.Value++;
                increase = true;
            }
            if (Position.Value <= _defaultPosition)
            {
                Consumption.Value--;
            }
        }

        if (delta < 0)
        {
            if (Position.Value >= _defaultPosition)
            {
                Consumption.Value--;
            }
            if (Position.Value < _defaultPosition)
            {
                Consumption.Value++;
                increase = true;
            }
        }

        return(increase);
    }
Example #4
0
 private void UpdateProperty(R type)
 {
     Props[type].SetValue(PPMath.Round(_life.Props[type].Value, 2), PPMath.Round(_life.Props[type].Value - LastProps[type], 2));
     LastProps[type] = _life.Props[type].Value;
 }