Example #1
0
        public IGrid ExcludeValueFromCell(Point p, NumericValue value)
        {
            var clone = new Grid(this);

            clone._grid[p.X, p.Y] = clone._grid[p.X, p.Y].ExcludeValue(value);

            return clone;
        }
Example #2
0
        public ICell ExcludeValue(NumericValue value)
        {
            var copyExcludeValue = new List<NumericValue>(_possibleValues);
            copyExcludeValue.Remove(value);

            copyExcludeValue.Sort();

            return new Cell(copyExcludeValue);
        }
        public void GivenVariableNumberWhenSubtractVariableNumberThenResultIsInOriginalUom()
        {
            var originalUom    = InternalUnitSystemManager.Instance.UnitOfMeasures["m"].ToModelUom();
            var originalValue  = new NumericValue(originalUom, 1.75);
            var originalNumber = new NumericRepresentationValue(RepresentationInstanceList.vrDistanceTraveled.ToModelRepresentation(), originalValue);

            var secondUom    = _ftUnitOfMeasure.ToModelUom();
            var secondNumber = new NumericValue(secondUom, 3.5);

            var expected = 0.6832; //1.75m + (3.5ft -> m)
            var actual   = originalNumber.Subtract(secondNumber);

            Assert.IsInstanceOf <NumericRepresentationValue>(actual);
            Assert.AreEqual(expected, actual.Value.Value, Epsilon);
            Assert.AreSame(originalUom, actual.Value.UnitOfMeasure);
        }
Example #4
0
 public DroneBay(SerializableDroneBay droneBay, Database database)
 {
     ItemId                   = new ItemId <DroneBay>(droneBay.Id, droneBay.FileName);
     EnergyConsumption        = new NumericValue <float>(droneBay.EnergyConsumption, 0, 1000);
     PassiveEnergyConsumption = new NumericValue <float>(droneBay.PassiveEnergyConsumption, 0, 1000);
     Range              = new NumericValue <float>(droneBay.Range, 1, 100);
     DamageMultiplier   = new NumericValue <float>(droneBay.DamageMultiplier, 0.01f, 100);
     DefenseMultiplier  = new NumericValue <float>(droneBay.DefenseMultiplier, 0.01f, 100);
     SpeedMultiplier    = new NumericValue <float>(droneBay.SpeedMultiplier, 0.01f, 100);
     Capacity           = new NumericValue <int>(droneBay.Capacity, 1, 100);
     ActivationType     = droneBay.ActivationType;
     LaunchSound        = droneBay.LaunchSound;
     LaunchEffectPrefab = droneBay.LaunchEffectPrefab;
     ControlButtonIcon  = droneBay.ControlButtonIcon;
     ImprovedAi         = droneBay.ImprovedAi;
 }
        public void GivenVariableNumberWhenMultiplyVariableNumberWithCompositeUnitOfMeasureThenCombinedUnitOfMeasure()
        {
            var leftUom   = _ftUnitOfMeasure.ToModelUom();
            var leftValue = new NumericValue(leftUom, 52.78);
            var left      = new NumericRepresentationValue(RepresentationInstanceList.vrDistanceTraveled.ToModelRepresentation(), leftValue);

            var rightUom   = InternalUnitSystemManager.Instance.UnitOfMeasures["ft1sec-1"].ToModelUom();
            var rightValue = new NumericValue(rightUom, 2.85);
            var right      = new NumericRepresentationValue(RepresentationInstanceList.vrDistanceTraveled.ToModelRepresentation(), rightValue);

            var product = left.Multiply(right, RepresentationInstanceList.vrDistanceTraveled.ToModelRepresentation());

            Assert.AreSame(RepresentationInstanceList.vrDistanceTraveled.ToModelRepresentation().Code, product.Representation.Code);
            Assert.AreEqual("ft2sec-1", product.Value.UnitOfMeasure.Code);
            Assert.AreEqual(150.423, product.Value.Value);
        }
Example #6
0
        public void Load(SerializableNode serializable, Database database)
        {
            DefaultTransition = new NumericValue <int>(serializable.DefaultTransition, 0, 1000);
            QuestLogText      = serializable.Message;

            Transitions = serializable.Transitions?.Select(transition =>
            {
                var requirement = new Requirement(transition.Requirement ?? new SerializableRequirement(), database);
                return(new QuestTransition
                {
                    TargetNode = new NumericValue <int>(transition.TargetNode, 1, 1000),
                    Requirement = requirement,
                    Weight = new NumericValue <float>(transition.Weight, 0, 100),
                });
            }).ToArray();
        }
Example #7
0
        public static VariableValue ConvertCdf(VariableValue variableValue, string targetUnit)
        {
            if (variableValue.UnitOfMeasure == targetUnit)
            {
                return(variableValue);
            }

            var sourceUnitOfMeasure = GetUomCdf(variableValue.UnitOfMeasure);
            var targetUnitOfMeasure = GetUomCdf(targetUnit);
            var bn = new NumericValue(sourceUnitOfMeasure.ToModelUom(), variableValue.Value);

            bn.ConvertToUnit(targetUnitOfMeasure);
            var convertedValue = bn.Value;

            return(new VariableValue(variableValue.Representation, targetUnit, convertedValue));
        }
Example #8
0
        private Ingredient LoadProductRelation(XmlNode productRelationNode, ProductMix productMix)
        {
            var productId       = productRelationNode.GetXmlNodeValue("@A");
            var productQuantity = productRelationNode.GetXmlNodeValue("@B");

            if (string.IsNullOrEmpty(productId) || string.IsNullOrEmpty(productQuantity))
            {
                return(null);
            }

            long quantity;

            if (!long.TryParse(productQuantity, NumberStyles.Integer, CultureInfo.InvariantCulture, out quantity) ||
                quantity < 0)
            {
                return(null);
            }

            Product product;

            if (_taskDocument.Products.TryGetValue(productId, out product) == false)
            {
                return(null);
            }

            var unit         = _taskDocument.UnitsByItemId.FindById(productId);
            var numericValue = new NumericValue(unit.ToAdaptUnit(), unit.ConvertFromIsoUnit(quantity));

            var ingredient = new ActiveIngredient
            {
                Description = product.Description,
            };

            var productComponent = new ProductComponent
            {
                IngredientId = product.Id.ReferenceId,
                Quantity     = new NumericRepresentationValue(null, numericValue.UnitOfMeasure, numericValue)
            };

            if (productMix.ProductComponents == null)
            {
                productMix.ProductComponents = new List <ProductComponent>();
            }
            productMix.ProductComponents.Add(productComponent);

            return(ingredient);
        }
Example #9
0
        public BulletBody(BulletBodySerializable serializable, Database database)
        {
            Type          = serializable.Type;
            Size          = new NumericValue <float>(serializable.Size, 0f, 1000f);
            Velocity      = new NumericValue <float>(serializable.Velocity, 0f, 1000f);
            Range         = new NumericValue <float>(serializable.Range, 0f, 1E+09f);
            Lifetime      = new NumericValue <float>(serializable.Lifetime, 0f, 1E+09f);
            Weight        = new NumericValue <float>(serializable.Weight, 0f, 1E+09f);
            HitPoints     = new NumericValue <int>(serializable.HitPoints, 0, 999999999);
            Color         = Helpers.ColorFromString(serializable.Color);
            BulletPrefab  = database.GetBulletPrefabId(serializable.BulletPrefab);
            EnergyCost    = new NumericValue <float>(serializable.EnergyCost, 0f, 1E+09f);
            CanBeDisarmed = serializable.CanBeDisarmed;
            FriendlyFire  = serializable.FriendlyFire;

            OnDataDeserialized(serializable, database);
        }
        public ComponentStats(SerializableComponentStats stats, Database database)
        {
            ItemId = new ItemId <ComponentStats>(stats.Id, stats.FileName);

            Type = stats.Type;

            ArmorPoints                 = new NumericValue <float>(stats.ArmorPoints, -1000, 1000);
            ArmorRepairRate             = new NumericValue <float>(stats.ArmorRepairRate, -1000, 1000);
            ArmorRepairCooldownModifier = new NumericValue <float>(stats.ArmorRepairCooldownModifier, -1f, 1f);

            EnergyPoints                   = new NumericValue <float>(stats.EnergyPoints, -1000, 1000);
            EnergyRechargeRate             = new NumericValue <float>(stats.EnergyRechargeRate, -1000, 1000);
            EnergyRechargeCooldownModifier = new NumericValue <float>(stats.EnergyRechargeCooldownModifier, -1f, 1f);

            ShieldPoints                   = new NumericValue <float>(stats.ShieldPoints, -1000, 1000);
            ShieldRechargeRate             = new NumericValue <float>(stats.ShieldRechargeRate, -1000, 1000);
            ShieldRechargeCooldownModifier = new NumericValue <float>(stats.ShieldRechargeCooldownModifier, -1f, 1f);

            Weight = new NumericValue <float>(stats.Weight, -10000, 10000);

            KineticResistance = new NumericValue <float>(stats.KineticResistance, -1000, 1000);
            EnergyResistance  = new NumericValue <float>(stats.EnergyResistance, -1000, 1000);
            ThermalResistance = new NumericValue <float>(stats.ThermalResistance, -1000, 1000);

            RammingDamage    = new NumericValue <float>(stats.RammingDamage, 0, 1000);
            EnergyAbsorption = new NumericValue <float>(stats.EnergyAbsorption, 0, 1000);

            EnginePower = new NumericValue <float>(stats.EnginePower, 0, 20);
            TurnRate    = new NumericValue <float>(stats.TurnRate, 0, 20);

            Autopilot = stats.Autopilot;

            DroneDamageModifier    = new NumericValue <float>(stats.DroneDamageModifier, -5, 5);
            DroneRangeModifier     = new NumericValue <float>(stats.DroneRangeModifier, -5, 5);
            DroneDefenseModifier   = new NumericValue <float>(stats.DroneDefenseModifier, -5, 5);
            DroneSpeedModifier     = new NumericValue <float>(stats.DroneSpeedModifier, -5, 5);
            DronesBuiltPerSecond   = new NumericValue <float>(stats.DronesBuiltPerSecond, 0, 10);
            DroneBuildTimeModifier = new NumericValue <float>(stats.DroneBuildTimeModifier, 0, 10);

            WeaponFireRateModifier   = new NumericValue <float>(stats.WeaponFireRateModifier, -1, 1);
            WeaponDamageModifier     = new NumericValue <float>(stats.WeaponDamageModifier, -1, 1);
            WeaponRangeModifier      = new NumericValue <float>(stats.WeaponRangeModifier, -1, 1);
            WeaponEnergyCostModifier = new NumericValue <float>(stats.WeaponEnergyCostModifier, -1, 1);

            AlterWeaponPlatform = stats.AlterWeaponPlatform;
        }
Example #11
0
 private ShipSettingsData(ShipSettingsSerializable serializable, Database database)
 {
     ItemId = new ItemId <ShipSettingsData>(serializable.Id, serializable.FileName);
     DefaultWeightPerCell         = new NumericValue <float>(serializable.DefaultWeightPerCell, 1f, 1000f);
     MinimumWeightPerCell         = new NumericValue <float>(serializable.MinimumWeightPerCell, 1f, 1000f);
     BaseArmorPoints              = new NumericValue <float>(serializable.BaseArmorPoints, 0f, 10000f);
     ArmorPointsPerCell           = new NumericValue <float>(serializable.ArmorPointsPerCell, 0f, 10000f);
     ArmorRepairCooldown          = new NumericValue <float>(serializable.ArmorRepairCooldown, 0f, 60f);
     BaseEnergyPoints             = new NumericValue <float>(serializable.BaseEnergyPoints, 0f, 1000f);
     BaseEnergyRechargeRate       = new NumericValue <float>(serializable.BaseEnergyRechargeRate, 0f, 100f);
     EnergyRechargeCooldown       = new NumericValue <float>(serializable.EnergyRechargeCooldown, 0f, 60f);
     BaseShieldRechargeRate       = new NumericValue <float>(serializable.BaseShieldRechargeRate, 0f, 100f);
     ShieldRechargeCooldown       = new NumericValue <float>(serializable.ShieldRechargeCooldown, 0f, 60f);
     BaseDroneReconstructionSpeed = new NumericValue <float>(serializable.BaseDroneReconstructionSpeed, 0f, 1f);
     MaxVelocity = new NumericValue <float>(serializable.MaxVelocity, 5f, 30f);
     MaxTurnRate = new NumericValue <float>(serializable.MaxTurnRate, 5f, 30f);
 }
Example #12
0
        /// <inheritdoc />
        public override void VisitGenericNumericValue <T>(NumericValue <T> value)
        {
            switch (operation)
            {
            case Operations.Identical:
                result = OutSet.CreateBool(false);
                break;

            case Operations.NotIdentical:
                result = OutSet.CreateBool(true);
                break;

            default:
                base.VisitGenericNumericValue(value);
                break;
            }
        }
Example #13
0
        /// <summary>
        /// Creates Chromeleon specific formatted data.
        /// </summary>
        /// <param name="localize">True to localize display names and values. False otherwise.</param>
        /// <returns>The string containing a Chromeleon compatible formatted string.</returns>
        public string CreateFormattedData(bool localize)
        {
            var xmlDoc = new XDocument();
            var root   = new XElement("CmFormattedData");

            xmlDoc.Add(root);

            var deviceObject = CreateObject("Device Properties", "MyDeviceType", "MyDeviceID");

            root.Add(deviceObject);

            if (localize)
            {
                var textProperty = CreatePropertyWithValue(Resources.TextPropertyDisplayName, Text);
                deviceObject.Add(textProperty);
            }
            else
            {
                var textProperty = CreatePropertyWithValue("Text", Text);
                deviceObject.Add(textProperty);
            }

            if (localize)
            {
                var numProperty = CreatePropertyWithValue(Resources.NumericValueDisplayName, NumericValue.ToString(NumberFormatInfo.InvariantInfo));
                deviceObject.Add(numProperty);
            }
            else
            {
                var numProperty = CreatePropertyWithValue("Numerical Value", NumericValue.ToString(NumberFormatInfo.CurrentInfo));
                deviceObject.Add(numProperty);
            }

            var sb       = new StringBuilder();
            var settings = new XmlWriterSettings();

            settings.Encoding = Encoding.Unicode;

            using (var writer = XmlWriter.Create(sb, settings))
            {
                xmlDoc.WriteTo(writer);
            }

            return(sb.ToString());
        }
Example #14
0
        //
        // Check for (basically) atomic equations involving one unknown and constants otherwise.
        //
        private static FlatEquation SimplifyForMultipliersAndConstants(FlatEquation inEq)
        {
            if (inEq.lhsExps.Count != 1 || inEq.rhsExps.Count != 1)
            {
                return(inEq);
            }

            //
            // Figure out what we're looking at.
            //
            NumericValue   value   = null;
            GroundedClause unknown = null;

            if (inEq.lhsExps[0] is NumericValue)
            {
                value   = inEq.lhsExps[0] as NumericValue;
                unknown = inEq.rhsExps[0];
            }
            else if (inEq.rhsExps[0] is NumericValue)
            {
                value   = inEq.rhsExps[0] as NumericValue;
                unknown = inEq.lhsExps[0];
            }
            // Not the type of equation we were looking for.
            else
            {
                return(inEq);
            }

            //
            // Divide both sides to simplify.
            //
            if (unknown.multiplier != 1)
            {
                NumericValue newValue = new NumericValue(value.DoubleValue / unknown.multiplier);

                // reset the multiplier
                unknown.multiplier = 1;

                return(new FlatEquation(Utilities.MakeList <GroundedClause>(unknown), Utilities.MakeList <GroundedClause>(newValue)));
            }

            // Nothing happened so return original
            return(inEq);
        }
Example #15
0
        public DroneBay(DroneBaySerializable serializable, Database database)
        {
            Id = new ItemId <DroneBay>(serializable.Id, serializable.FileName);
            EnergyConsumption        = new NumericValue <float>(serializable.EnergyConsumption, 0f, 1E+09f);
            PassiveEnergyConsumption = new NumericValue <float>(serializable.PassiveEnergyConsumption, 0f, 1E+09f);
            Range              = new NumericValue <float>(serializable.Range, 1f, 1000f);
            DamageMultiplier   = new NumericValue <float>(serializable.DamageMultiplier, 0.01f, 1000f);
            DefenseMultiplier  = new NumericValue <float>(serializable.DefenseMultiplier, 0.01f, 1000f);
            SpeedMultiplier    = new NumericValue <float>(serializable.SpeedMultiplier, 0.01f, 1000f);
            ImprovedAi         = serializable.ImprovedAi;
            Capacity           = new NumericValue <int>(serializable.Capacity, 1, 1000);
            ActivationType     = serializable.ActivationType;
            LaunchSound        = serializable.LaunchSound;
            LaunchEffectPrefab = serializable.LaunchEffectPrefab;
            ControlButtonIcon  = serializable.ControlButtonIcon;

            OnDataDeserialized(serializable, database);
        }
        public void ConditionField_In_NumericValues()
        {
            const string expected = "F1 In (0,1,2.3)";

            var values  = new double[] { 0, 1, 2.3 };
            var iValues = new IValue[values.Length];

            for (var i = 0; i < values.Length; i++)
            {
                iValues[i] = new NumericValue <double>(values[i]);
            }

            Conditions.Add(new Field("F1"), RelationalOperators.In, new ValueArray(iValues));

            var actual = GenerateSqlString();

            Assert.AreEqual(expected, actual);
        }
Example #17
0
        private void SetSeriesText(OpenXmlCompositeElement seriesItem, ChartSeriesElement newSeriesItem, string seriesHeader)
        {
            SeriesText seriesText = seriesItem.Elements <SeriesText>().First();

            seriesText.StringReference.Formula.Text = newSeriesItem.SeriesTextAddress;
            seriesText.StringReference.StringCache.RemoveAllChildren <StringPoint>();
            StringPoint stringReferencePoint = new StringPoint()
            {
                Index = (UInt32Value)((uint)0)
            };
            NumericValue stringReferenceNumericValue = new NumericValue()
            {
                Text = seriesHeader
            };

            stringReferencePoint.Append(stringReferenceNumericValue);
            seriesText.StringReference.StringCache.Append(stringReferencePoint);
        }
Example #18
0
 private DeviceData(DeviceSerializable serializable, Database database)
 {
     ItemId                   = new ItemId <DeviceData>(serializable.Id, serializable.FileName);
     DeviceClass              = serializable.DeviceClass;
     EnergyConsumption        = new NumericValue <float>(serializable.EnergyConsumption, 0f, 1000f);
     PassiveEnergyConsumption = new NumericValue <float>(serializable.PassiveEnergyConsumption, 0f, 1000f);
     Power             = new NumericValue <float>(serializable.Power, 0f, 1000f);
     Range             = new NumericValue <float>(serializable.Range, 0f, 1000f);
     Size              = new NumericValue <float>(serializable.Size, 0f, 1000f);
     Cooldown          = new NumericValue <float>(serializable.Cooldown, 0f, 1000f);
     Offset            = serializable.Offset;
     ActivationType    = serializable.ActivationType;
     Color             = Utils.ColorUtils.ColorFromString(serializable.Color);
     Sound             = new AudioClipId(serializable.Sound);
     EffectPrefab      = serializable.EffectPrefab;
     ObjectPrefab      = serializable.ObjectPrefab;
     ControlButtonIcon = serializable.ControlButtonIcon;
 }
Example #19
0
        private void LoadTotalQuantity(XmlNode inputNode, ProductMix productMix)
        {
            var quantityValue = inputNode.GetXmlNodeValue("@G");

            double quantity;

            if (!double.TryParse(quantityValue, NumberStyles.Float, CultureInfo.InvariantCulture, out quantity))
            {
                return;
            }

            var unit     = LoadUnit(inputNode);
            var userUnit = _taskDocument.Units.FindById(inputNode.GetXmlNodeValue("@D"));

            var numericValue = new NumericValue(unit.ToAdaptUnit(), unit.ConvertFromIsoUnit(quantity));

            productMix.TotalQuantity = new NumericRepresentationValue(null, userUnit.ToAdaptUnit(), numericValue);
        }
Example #20
0
 public override int GetHashCode()
 {
     unchecked
     {
         var hash = 17;
         hash += 23 * StorageType.GetHashCode();
         hash += 23 * DataType.GetHashCode();
         if (IsNumeric)
         {
             hash += 23 * NumericValue.GetHashCode();
         }
         else
         {
             hash += 23 * StringValue.GetHashCode();
         }
         return(hash);
     }
 }
Example #21
0
        /// <inheritdoc />
        public override void VisitGenericNumericValue <T>(NumericValue <T> value)
        {
            // When comparing, both operands are converted to boolean
            switch (operation)
            {
            case Operations.GreaterThan:
                result = OutSet.CreateBool(false);
                break;

            case Operations.LessThanOrEqual:
                result = OutSet.CreateBool(true);
                break;

            default:
                base.VisitGenericNumericValue(value);
                break;
            }
        }
Example #22
0
        public InstalledComponent(InstalledComponentSerializable serializable, Database database)
        {
            Component = database.GetComponentId(serializable.ComponentId);
            if (Component.IsNull)
            {
                throw new DatabaseException(this.GetType().Name + ".Component cannot be null");
            }
            Modification = serializable.Modification;
            Quality      = serializable.Quality;
            Locked       = serializable.Locked;
            X            = new NumericValue <int>(serializable.X, -32768, 32767);
            Y            = new NumericValue <int>(serializable.Y, -32768, 32767);
            BarrelId     = new NumericValue <int>(serializable.BarrelId, 0, 255);
            Behaviour    = new NumericValue <int>(serializable.Behaviour, 0, 10);
            KeyBinding   = new NumericValue <int>(serializable.KeyBinding, -10, 10);

            OnDataDeserialized(serializable, database);
        }
Example #23
0
 public Device(SerializableDevice device, Database database)
 {
     ItemId                   = new ItemId <Device>(device.Id, device.FileName);
     DeviceClass              = device.DeviceClass;
     EnergyConsumption        = new NumericValue <float>(device.EnergyConsumption, 0, 1000);
     PassiveEnergyConsumption = new NumericValue <float>(device.PassiveEnergyConsumption, 0, 1000);
     Power             = new NumericValue <float>(device.Power, 0, 1000);
     Range             = new NumericValue <float>(device.Range, 0, 1000);
     Size              = new NumericValue <float>(device.Size, 0, 1000);
     Cooldown          = new NumericValue <float>(device.Cooldown, 0, 1000);
     Lifetime          = new NumericValue <float>(device.Lifetime, 0, 1000);
     Offset            = device.Offset;
     ActivationType    = device.ActivationType;
     Color             = Helpers.ColorFromString(device.Color);
     Sound             = device.Sound;
     EffectPrefab      = device.EffectPrefab;
     ObjectPrefab      = device.ObjectPrefab;
     ControlButtonIcon = device.ControlButtonIcon;
 }
Example #24
0
        private static NumericRepresentationValue GetAccuracy(decimal?accuracyValue)
        {
            if (!accuracyValue.HasValue || accuracyValue < 0m || accuracyValue > 65m)
            {
                return(null);
            }
            double accuracy = Convert.ToDouble(accuracyValue.Value);

            var accuracyUnitOfMeasure = UnitSystemManager.GetUnitOfMeasure("m");
            var numericValue          = new NumericValue(accuracyUnitOfMeasure, accuracy);
            var numericRepresentation = new NumericRepresentation
            {
                DecimalDigits = 1,
                MaxValue      = new NumericValue(accuracyUnitOfMeasure, 65),
                MinValue      = new NumericValue(accuracyUnitOfMeasure, 0),
            };

            return(new NumericRepresentationValue(numericRepresentation, numericValue.UnitOfMeasure, numericValue));
        }
Example #25
0
	public static void Show(NumericValue numVal, EditorWindow ed)
	{
		if (numVal == null) 
		{
			Debug.LogError("Invalid value");
			return;
		}

		// make sure DB is loaded
		if (!UniRPGEditorGlobal.LoadDatabase()) return;

		// create window
		GlobalVarSelectWiz window = EditorWindow.GetWindow<GlobalVarSelectWiz>(true, "Select Variable", true);
		window.inited = false; 
		window.ed = ed;
		window.numVal = numVal;

		// show window
		window.ShowUtility();
	}
Example #26
0
        public ShipSettings(SerializableShipSettings settings, Database database)
        {
            DefaultWeightPerCell = new NumericValue <float>(settings.DefaultWeightPerCell, 1, 1000);
            MinimumWeightPerCell = new NumericValue <float>(settings.MinimumWeightPerCell, 1, 1000);

            BaseArmorPoints     = new NumericValue <float>(settings.BaseArmorPoints, 0, 10000);
            ArmorPointsPerCell  = new NumericValue <float>(settings.ArmorPointsPerCell, 0, 10000);
            ArmorRepairCooldown = new NumericValue <float>(settings.ArmorRepairCooldown, 0, 60);

            BaseEnergyPoints       = new NumericValue <float>(settings.BaseEnergyPoints, 0, 1000);
            BaseEnergyRechargeRate = new NumericValue <float>(settings.BaseEnergyRechargeRate, 0, 100);
            EnergyRechargeCooldown = new NumericValue <float>(settings.EnergyRechargeCooldown, 0, 60);

            BaseShieldRechargeRate = new NumericValue <float>(settings.BaseShieldRechargeRate, 0, 100);
            ShieldRechargeCooldown = new NumericValue <float>(settings.ShieldRechargeCooldown, 0, 60);

            BaseDroneReconstructionSpeed = new NumericValue <float>(settings.BaseDroneReconstructionSpeed, 0, 1);

            MaxVelocity = new NumericValue <float>(settings.MaxVelocity, 5, 30);
            MaxTurnRate = new NumericValue <float>(settings.MaxTurnRate, 5, 30);
        }
Example #27
0
        public Device(DeviceSerializable serializable, Database database)
        {
            Id                       = new ItemId <Device>(serializable.Id, serializable.FileName);
            DeviceClass              = serializable.DeviceClass;
            EnergyConsumption        = new NumericValue <float>(serializable.EnergyConsumption, 0f, 1E+09f);
            PassiveEnergyConsumption = new NumericValue <float>(serializable.PassiveEnergyConsumption, 0f, 1E+09f);
            Power                    = new NumericValue <float>(serializable.Power, 0f, 1000f);
            Range                    = new NumericValue <float>(serializable.Range, 0f, 1000f);
            Size                     = new NumericValue <float>(serializable.Size, 0f, 1000f);
            Cooldown                 = new NumericValue <float>(serializable.Cooldown, 0f, 1000f);
            Lifetime                 = new NumericValue <float>(serializable.Lifetime, 0f, 1000f);
            Offset                   = serializable.Offset;
            ActivationType           = serializable.ActivationType;
            Color                    = Helpers.ColorFromString(serializable.Color);
            Sound                    = serializable.Sound;
            EffectPrefab             = serializable.EffectPrefab;
            ObjectPrefab             = serializable.ObjectPrefab;
            ControlButtonIcon        = serializable.ControlButtonIcon;

            OnDataDeserialized(serializable, database);
        }
Example #28
0
        private static NumericRepresentationValue GetAccuracy(string accuracyValue)
        {
            double accuracy;

            if (accuracyValue.ParseValue(out accuracy) == false ||
                accuracy < 0 || accuracy > 65)
            {
                return(null);
            }

            var accuracyUnitOfMeasure = UnitSystemManager.GetUnitOfMeasure("m");
            var numericValue          = new NumericValue(accuracyUnitOfMeasure, accuracy);
            var numericRepresentation = new NumericRepresentation
            {
                DecimalDigits = 1,
                MaxValue      = new NumericValue(accuracyUnitOfMeasure, 65),
                MinValue      = new NumericValue(accuracyUnitOfMeasure, 0),
            };

            return(new NumericRepresentationValue(numericRepresentation, numericValue.UnitOfMeasure, numericValue));
        }
Example #29
0
        /// <summary>
        /// Modify/Add categories into chart XML
        /// </summary>
        /// <param name="column_index">Corresponds to the column index that needs to be modified in chart spreadsheet (Ex: A, B, C, ...)</param>
        /// <param name="row_index">Corresponds to the column index that needs to be modified in excel </param>
        /// <param name="new_value">Corresponds to the new value we need to insert to the cell </param>
        protected override void ModifyChartXML_Categories(string column_index, uint row_index, string new_value)
        {
            foreach (LineChartSeries linechart_series in chart_part.ChartSpace.Descendants <LineChartSeries>().ToList())
            {
                CategoryAxisData category_axis_data = linechart_series.Descendants <CategoryAxisData>().FirstOrDefault();
                if (category_axis_data == null)
                {
                    // If no StringReference --> Clone one from the 1st (usually we go in this when we create a new BarChartSeries)
                    BarChartSeries   template_barchartseries   = chart_part.ChartSpace.Descendants <BarChartSeries>().FirstOrDefault();
                    CategoryAxisData template_categoryaxisdata = template_barchartseries.Descendants <CategoryAxisData>().FirstOrDefault();
                    CategoryAxisData new_categoryaxisdata      = new CategoryAxisData(template_categoryaxisdata.OuterXml);
                    linechart_series.Append(new_categoryaxisdata);
                }
                else
                {
                    StringReference sr = category_axis_data.Descendants <StringReference>().FirstOrDefault();
                    // If there is a StringReference --> Update its values
                    StringCache sc = sr.Descendants <StringCache>().First();
                    try
                    {
                        StringPoint  sp = sc.Descendants <StringPoint>().ElementAt((int)row_index - 2);
                        NumericValue nv = sp.Descendants <NumericValue>().First();
                        nv.Text = new_value;
                    }
                    catch (Exception)
                    {
                        // Create new data and append to previous XML
                        sc.PointCount.Val = sc.PointCount.Val + 1;
                        NumericValue nv = new NumericValue(new_value);
                        StringPoint  sp = new StringPoint(nv);
                        sp.Index = (uint)sc.Descendants <StringPoint>().ToList().Count;
                        sc.Append(sp);

                        // Change fomula range
                        DocumentFormat.OpenXml.Drawing.Charts.Formula f = sr.Descendants <DocumentFormat.OpenXml.Drawing.Charts.Formula>().FirstOrDefault();
                        f.Text = worksheet_name + "!$A$2:$A$" + GetRowIndexByNum((int)row_index - 2).ToString();
                    }
                }
            }
        }
Example #30
0
        public String GetSerializedValue()
        {
            if (IsListValue == true)
            {
                return(System.Text.Json.JsonSerializer.Serialize(Addresses.Select(x => x.Value)));
            }
            else
            {
                if (IsTextValue == true)
                {
                    return(System.Text.Json.JsonSerializer.Serialize(SingleValue));
                }
                else if (IsDeviceValue == true)
                {
                    return(System.Text.Json.JsonSerializer.Serialize(DeviceId));
                }
                else if (IsBooleanValue == true)
                {
                    return(BooleanValue == true ? "true" : "false");
                }
                else if (IsNumericValue)
                {
                    return(NumericValue.ToString());
                }
                else if (IsNullableNumericValue == true)
                {
                    if (NullableNumericValue.HasValue == true)
                    {
                        return(NullableNumericValue.Value.ToString());
                    }
                    else
                    {
                        return("null");
                    }
                }

                return(String.Empty);
            }
        }
Example #31
0
        public override string ToString()
        {
            switch (Type)
            {
            case DataType.String:
                return(StringValue);

            case DataType.Numeric:
                return(NumericValue.ToString());

            case DataType.Boolean:
                return(BoolValue.ToString());

            case DataType.DateTime:
                return(DateTimeValue.ToString());

            case DataType.TimeSpan:
                return(TimeSpanValue.ToString());

            default:
                return("");
            }
        }
Example #32
0
            public NumericValue Apply(NumericValue input)
            {
                NumericValue result;

                if (this.IntegerOperation != null &&
                    (input.ValueType == RpnValueType.Integer || input.ValueType == RpnValueType.Binary))
                {
                    double opResult = this.IntegerOperation(input.ToInteger());
                    result = new DoubleValue(opResult);
                }
                else if (this.DoubleOperation != null && input.ValueType != RpnValueType.Complex)
                {
                    double opResult = this.DoubleOperation(input.ToDouble());
                    result = new DoubleValue(opResult);
                }
                else
                {
                    Complex opResult = this.ComplexOperation(input.ToComplex());
                    result = new ComplexValue(opResult);
                }

                return(result);
            }
Example #33
0
 private AmmunitionObsoleteData(AmmunitionObsoleteSerializable serializable, Database database)
 {
     ItemId              = new ItemId <AmmunitionObsoleteData>(serializable.Id, serializable.FileName);
     AmmunitionClass     = serializable.AmmunitionClass;
     DamageType          = serializable.DamageType;
     Impulse             = new NumericValue <float>(serializable.Impulse, 0f, 10f);
     Recoil              = new NumericValue <float>(serializable.Recoil, 0f, 10f);
     Size                = new NumericValue <float>(serializable.Size, 0f, 1000f);
     InitialPosition     = serializable.InitialPosition;
     AreaOfEffect        = new NumericValue <float>(serializable.AreaOfEffect, 0f, 1000f);
     Damage              = new NumericValue <float>(serializable.Damage, 0f, 1000f);
     Range               = new NumericValue <float>(serializable.Range, 0f, 1000f);
     Velocity            = new NumericValue <float>(serializable.Velocity, 0f, 1000f);
     LifeTime            = new NumericValue <float>(serializable.LifeTime, 0f, 1000f);
     HitPoints           = new NumericValue <int>(serializable.HitPoints, 0, 1000);
     IgnoresShipVelocity = serializable.IgnoresShipVelocity;
     EnergyCost          = new NumericValue <float>(serializable.EnergyCost, 0f, 1000f);
     CoupledAmmunitionId = database.GetAmmunitionObsoleteId(serializable.CoupledAmmunitionId);
     Color               = Utils.ColorUtils.ColorFromString(serializable.Color);
     FireSound           = new AudioClipId(serializable.FireSound);
     HitEffectPrefab     = serializable.HitEffectPrefab;
     BulletPrefab        = serializable.BulletPrefab;
 }
Example #34
0
 public Variable(NumericValue value)
     : base(StorageDataType.Any, null)
 {
     NumericValue = value;
 }
Example #35
0
 public NumericVariable(NumericValue value)
     : base(StorageDataType.Numeric, null)
 {
     Value = value;
 }
 public void OnRecieveHealing(ref float value,IRPGSource source)
 {
     if (!Effect.IsSupressed && RecieveHealing) {
         NumericValue v=new NumericValue("value",value);
         nValues.Add(v);
         Paramter s=new Paramter("source",source);
         ExecuteScript(new Paramter[]{s});
         nValues.Remove(v);
         value=v.Value;
     }
 }
Example #37
0
	/// <summary>show a field where the designer can either enter a value or choose a global variable</summary>
	public static NumericValue GlobalNumericVarOrValueField(EditorWindow ed, string label, NumericValue numericVal, int labelWidth = 100, int fieldWidth = 0)
	{
		if (numericVal == null) return numericVal;
		GUILayoutOption[] opts = (fieldWidth > 0 ? new GUILayoutOption[2] { GUILayout.MinWidth(50), GUILayout.Width(fieldWidth) } : new GUILayoutOption[1] { GUILayout.MinWidth(50) });
		EditorGUILayout.BeginHorizontal();
		{
			if (!string.IsNullOrEmpty(label))
			{
				if (labelWidth > 0) GUILayout.Label(label, GUILayout.Width(labelWidth));
				else GUILayout.Label(label);
				EditorGUILayout.Space();
			}

			int sel = 0;
			if (numericVal.isCustom) sel = 2;
			else if (!string.IsNullOrEmpty(numericVal.numericVarName)) sel = 1;
			sel = EditorGUILayout.Popup(sel, ValueFieldOpts, GUILayout.MaxWidth(60));

			if (sel == 0)
			{
				numericVal.isCustom = false;
				numericVal.Val = EditorGUILayout.FloatField(numericVal.Val, opts);
			}
			else if (sel == 1)
			{
				numericVal.isCustom = false;
				if (string.IsNullOrEmpty(numericVal.numericVarName)) numericVal.numericVarName = "-";
				if (GUILayout.Button(numericVal.numericVarName, opts)) GlobalVarSelectWiz.Show(numericVal, ed);
			}
			else if (sel == 2)
			{
				numericVal.isCustom = true;
				EditorGUILayout.BeginVertical();
				numericVal.customVarName = EditorGUILayout.TextField(numericVal.customVarName, opts);
				TargetTypeField(ed, null, numericVal.customVarSubject, null);
				EditorGUILayout.EndVertical();
			}
			GUILayout.FlexibleSpace();
		}
		EditorGUILayout.EndHorizontal();
		return numericVal;

		//if (numericVal==null) return numericVal;
		//EditorGUILayout.BeginHorizontal();
		//{
		//	if (!string.IsNullOrEmpty(label))
		//	{
		//		if (labelWidth > 0) GUILayout.Label(label, GUILayout.Width(labelWidth));
		//		else GUILayout.Label(label);
		//		EditorGUILayout.Space();
		//	}
		//	if (!string.IsNullOrEmpty(numericVal.numericVarName))
		//	{
		//		GUI.enabled = false;
		//		if (fieldWidth > 0) EditorGUILayout.TextField(numericVal.numericVarName, GUILayout.Width(fieldWidth));
		//		else EditorGUILayout.TextField(numericVal.numericVarName);
		//		GUI.enabled = true;
		//	}
		//	else
		//	{
		//		if (fieldWidth > 0) numericVal.Val = EditorGUILayout.FloatField(numericVal.GetValue(null, null), GUILayout.Width(fieldWidth));
		//		else numericVal.Val = EditorGUILayout.FloatField(numericVal.GetValue(null, null));
		//	}

		//	if (GUILayout.Button(new GUIContent(UniRPGEdGui.Icon_Tag, "Select variable"), EditorStyles.miniButton, GUILayout.Width(25)))
		//	{
		//		GlobalVarSelectWiz.Show(numericVal, ed);
		//	}
		//}
		//EditorGUILayout.EndHorizontal();
		//return numericVal;
	}
 public void OnTakeDamage(ref float value, string Type,IRPGSource source)
 {
     if (!Effect.IsSupressed && TakeDamage) {
         NumericValue v=new NumericValue("value",value);
         nValues.Add(v);
         StringValue t=new StringValue("type",Type);
         sValues.Add(t);
         Paramter s=new Paramter("source",source);
         ExecuteScript(new Paramter[]{s});
         nValues.Remove(v);
         sValues.Remove(t);
         value=v.Value;
     }
 }
Example #39
0
 protected SolidObject(NumericValue<Mass> mass)
     : base(mass)
 {
 }
Example #40
0
 public override NumericValue Add(NumericValue addend)
 {
     return new LongValue(value_Renamed + addend.ToLong());
 }
Example #41
0
 public override NumericValue Subtract(NumericValue subend)
 {
     return new LongValue(value_Renamed - subend.ToLong());
 }
Example #42
0
 public void ConvertNumericValueToInt(NumericValue value, int valueAsInt)
 {
     Assert.AreEqual((int)value, valueAsInt);
 }
Example #43
0
 public bool MayHaveValue(NumericValue value)
 {
     return _possibleValues.Contains(value);
 }
Example #44
0
 public VariableOrExpression(NumericValue value)
     : base(value)
 {
 }
Example #45
0
        public IGrid SetCell(Point p, NumericValue toSet)
        {
            var clone = new Grid(this);

            foreach (var value in Cell.Cell._allNumericValues)
            {
                if (value == toSet)
                {
                    continue;
                }
                clone._grid[p.X, p.Y] = clone._grid[p.X, p.Y].ExcludeValue(value);
            }

            return clone;
        }
 public NumericRepresentationValue(NumericRepresentation representation, NumericValue value)
 {
     Representation = representation;
     Value = value;
 }
 public NumericRepresentationValue(NumericRepresentation representation, UnitOfMeasure userProvidedUnitOfMeasure, NumericValue value)
 {
     Representation = representation;
     UserProvidedUnitOfMeasure = userProvidedUnitOfMeasure;
     Value = value;
 }
Example #48
0
        public IGrid SetCell(Point p, NumericValue value)
        {
            var tos = _grids.Peek();
            var newGrid = tos.SetCell(p, value);

            newGrid = ClearRange(p, value, newGrid);

            CheckWhetherThereIsASolution(newGrid);

            _grids.Push(newGrid);
            _redo.Clear();

            return newGrid;
        }
 /// <summary>
 /// Sets the numeric operator and value.
 /// </summary>
 /// <param name="rootObject">The root object.</param>
 /// <param name="complexComponentValue">The complex component value.</param>
  private static void SetNumericOperatorAndValue(DataStructureComponentValueQueryType rootObject, IComplexComponentValue complexComponentValue)
 {
      var numericValue = new NumericValue { TypedValue = decimal.Parse(complexComponentValue.Value, CultureInfo.InvariantCulture), @operator = complexComponentValue.OrderedOperator.OrdOperator };
      rootObject.NumericValue.Add(numericValue);
 }
Example #50
0
        private NumericValue decode_NumericValue(string spelling, string regex, int length)
        {
            push("*NumericValue", spelling, regex);

            bool decoded = true;
            int start = index;

            NumericValue numericValue = null;
            try
            {
                string value = text.Substring(index, length);
                if ((decoded = Regex.IsMatch(value, regex)))
                {
                    index += length;
                    numericValue = new NumericValue(value, null);
                }
            }
            catch (IndexOutOfRangeException)
            {
                decoded = false;
            }

            pop("*NumericValue", decoded, index - start);

            return numericValue;
        }
Example #51
0
 private static IGrid ClearRange(Point p, NumericValue value, IGrid newGrid)
 {
     foreach (var rangeP in new Range(p))
     {
         if (newGrid[rangeP].IsDefined)
         {
             continue;
         }
         newGrid = newGrid.ExcludeValueFromCell(rangeP, value);
         if (newGrid[rangeP].IsDefined)
         {
             newGrid = ClearRange(rangeP, newGrid[rangeP].Value, newGrid);
         }
     }
     return newGrid;
 }