コード例 #1
0
ファイル: PercentType-Examples.cs プロジェクト: ntwest/KSPDev
 void FormatFixed()
 {
     #region PercentTypeDemo2_FormatFixed
     Debug.Log(PercentType.Format(0.12345678, format: "0.0000"));
     // Prints: "12.3457%"
     Debug.Log(PercentType.Format(0.12345678, format: "0.00"));
     // Prints: "12.35%"
     #endregion
 }
コード例 #2
0
        public void PercentTypeNonNullShouldCreateInstance()
        {
            decimal[] testVals = { -1, decimal.MaxValue, decimal.MinusOne, decimal.One, decimal.Zero };

            foreach (var val in testVals)
            {
                PercentType q = val;
                Assert.IsNotNull(q, $"Failed to instantiate PercentType with value={val}");
                Assert.AreEqual(q.Value, val);
            }
        }
コード例 #3
0
ファイル: PercentType-Examples.cs プロジェクト: ntwest/KSPDev
 void FormatDefault()
 {
     #region PercentTypeDemo2_FormatDefault
     Debug.Log(PercentType.Format(0.004));
     // Prints: "0.40%"
     Debug.Log(PercentType.Format(0.0041));
     // Prints: "0.41%"
     Debug.Log(PercentType.Format(0.01));
     // Prints: "1.0%"
     Debug.Log(PercentType.Format(0.014));
     // Prints: "1.4%"
     Debug.Log(PercentType.Format(0.0145));
     // Prints: "1.45%"
     Debug.Log(PercentType.Format(0.01456));
     // Prints: "1.46%"
     Debug.Log(PercentType.Format(0.1));
     // Prints: "10%"
     Debug.Log(PercentType.Format(0.105));
     // Prints: "11%"
     Debug.Log(PercentType.Format(5.5));
     // Prints: "550%"
     #endregion
 }
コード例 #4
0
 /// <summary>
 /// Parameter value should be 0.0 - 1.0f.
 /// Percent type should be INCREASING/DECREASING.
 /// </summary>
 /// <param name="percentNormalized">Percent normalized.</param>
 public AttributeBonusPercent(float percentNormalized, PercentType percentType)
 {
     this.percentNormalized = percentNormalized;
     this.percentType       = percentType;
 }
コード例 #5
0
ファイル: tests.cs プロジェクト: MihaChug/prris-1
        void AddRules(ref Shop shop)
        {
            List <Product> productsInDiscount = new List <Product>();

            productsInDiscount.Add(A);
            productsInDiscount.Add(B);
            PercentType    discount = new PercentType(10);
            List <Product> productsNotInDiscount = new List <Product>();

            shop.AddRule(new RuleBuyItAll(discount, productsInDiscount, productsNotInDiscount));

            List <Product> productsInDiscount2 = new List <Product>();

            productsInDiscount2.Add(D);
            productsInDiscount2.Add(E);
            PercentType discount2 = new PercentType(5);

            DiscountModuleForOnlineStore.ValueType discount4 = new DiscountModuleForOnlineStore.ValueType(10);
            shop.AddRule(new RuleBuyItAll(discount4, productsInDiscount2, productsNotInDiscount));

            List <Product> productsInDiscount3 = new List <Product>();

            productsInDiscount3.Add(E);
            productsInDiscount3.Add(F);
            productsInDiscount3.Add(G);
            shop.AddRule(new RuleBuyItAll(discount2, productsInDiscount3, productsNotInDiscount));

            List <Product> productsInDiscount4    = new List <Product>();
            List <Product> productsNotInDiscount2 = new List <Product>();

            productsInDiscount4.Add(A);
            productsInDiscount4.Add(K);
            productsNotInDiscount2.Add(A);
            shop.AddRule(new RuleBuyItAll(discount2, productsInDiscount4, productsNotInDiscount2));

            List <Product> productsInDiscount5    = new List <Product>();
            List <Product> productsNotInDiscount3 = new List <Product>();

            productsInDiscount5.Add(A);
            productsInDiscount5.Add(L);
            productsNotInDiscount3.Add(A);
            shop.AddRule(new RuleBuyItAll(discount2, productsInDiscount5, productsNotInDiscount3));

            List <Product> productsInDiscount6    = new List <Product>();
            List <Product> productsNotInDiscount4 = new List <Product>();

            productsInDiscount6.Add(A);
            productsInDiscount6.Add(M);
            productsNotInDiscount4.Add(A);
            shop.AddRule(new RuleBuyItAll(discount2, productsInDiscount6, productsNotInDiscount4));

            List <Product> productsNotInDiscount5 = new List <Product>();

            productsNotInDiscount5.Add(A);
            productsNotInDiscount5.Add(C);

            int amount = 3;

            shop.AddRule(new RuleBuyMoreThan(discount2, productsNotInDiscount5, amount));

            amount = 4;
            shop.AddRule(new RuleBuyMoreThan(discount, productsNotInDiscount5, amount));

            amount = 5;
            PercentType discount3 = new PercentType(20);

            shop.AddRule(new RuleBuyMoreThan(discount3, productsNotInDiscount5, amount));
        }
コード例 #6
0
 /// <summary>
 /// Parameter value should be 0.0 - 1.0f.
 /// Percent type should be INCREASING/DECREASING.
 /// </summary>
 /// <param name="percentNormalized">Percent normalized.</param>
 public AttributeBonusPercent(float percentNormalized, PercentType percentType)
 {
     this.percentNormalized = percentNormalized;
     this.percentType = percentType;
 }