示例#1
0
        public static int MaxLeapYearsInYears(int numberOfYears)
        {
            int numberOfLeapYears = (numberOfYears.Abs() + 3) / 4;

            numberOfLeapYears = numberOfLeapYears - (numberOfLeapYears / 25) + ((numberOfLeapYears + 75) / 100);
            return(numberOfLeapYears);
        }
示例#2
0
        public void Abst_ShouldReturnAbsoluteValues()
        {
            // Arrange
            sbyte   aByte    = -10;
            short   aShort   = -20;
            int     aInt     = -30;
            long    aLong    = -40;
            float   aFloat   = -50.0F;
            double  aDouble  = -60.0;
            decimal aDecimal = (decimal) - 70.0;


            // Act

            short   absByte    = aByte.Abs();
            short   absShort   = aShort.Abs();
            int     absInt     = aInt.Abs();
            long    absLong    = aLong.Abs();
            float   absFloat   = aFloat.Abs();
            double  absDouble  = aDouble.Abs();
            decimal absDecimal = aDecimal.Abs();

            // Assert
            Assert.Equal(10, absByte);
            Assert.Equal(20, absShort);
            Assert.Equal(30, absInt);
            Assert.Equal(40, absLong);
            Assert.Equal(50, absFloat);
            Assert.Equal(60, absDouble);
            Assert.Equal(70, absDecimal);
        }
示例#3
0
        /// <summary>
        /// Returns a regular polygon sized by the inradius.
        /// </summary>
        /// <param name="numberOfSides">The number of sides.</param>
        /// <param name="inRadius">The inradius.</param>
        /// <returns>RegularPolygon.</returns>
        public static RegularPolygon RegularPolygonByInradius(int numberOfSides, double inRadius)
        {
            numberOfSides = NMath.Max(_minNumberOfSides, numberOfSides.Abs());
            double circumRadius = inRadius.Abs() * Trig.Sec(Numbers.Pi / numberOfSides);

            return(new RegularPolygon(numberOfSides, circumRadius));
        }
示例#4
0
        public static int MinLeapYearsInYears(int numberOfYears)
        {
            int numberOfLeapYears = numberOfYears.Abs() / 4;

            numberOfLeapYears = numberOfLeapYears - ((numberOfLeapYears + 24) / 25) + (numberOfLeapYears / 100);
            return(numberOfLeapYears);
        }
示例#5
0
        public double Distance(Point p)
        {
            int    numerator   = diffY * p.X - diffX * p.Y + p2.X * p1.Y - p2.Y * p1.X;
            double denominator = (diffY * diffY + diffX * diffX).Sqrt();

            return(numerator.Abs() / denominator);
        }
示例#6
0
        /// <summary>
        /// Shifts decimal variable places. <para>If negative, shift left; otherwise, shift right.</para>
        /// </summary>
        /// <param name="Value"></param>
        /// <param name="Shifts"></param>
        /// <returns></returns>
        public static double Shift(this double Value, int Shifts = 1)
        {
            var LeftOrRight = Shifts < 0;

            for (var i = 0; i < Shifts.Abs(); i++)
            {
                Value = LeftOrRight ? Value / 10 : Value * 10;
            }
            return(Value);
        }
示例#7
0
        private static List <int> CutN(this List <int> deck, int n)
        {
            if (n > 0)
            {
                var cut = deck.Take(n);

                deck = deck.Skip(n).ToList();
                deck.AddRange(cut);
            }
            else
            {
                var cut = deck.TakeLast(n.Abs());

                deck = deck.Take(deck.Count - n.Abs()).ToList();

                deck.InsertRange(0, cut);
            }

            return(deck);
        }
示例#8
0
    public void TestToolkitAbs()
    {
        int i  = 10;
        int ni = -10;

        Assert.AreEqual(10, i.Abs());
        Assert.AreEqual(10, ni.Abs());
        Assert.AreEqual(5, (-5).Abs());
        Assert.AreEqual(5, 5. Abs());
        Assert.AreEqual(0, 0. Abs());
    }
        public void Extension_ListExtension_Enumerator(int i, int sum)
        {
            var en = i.Enumerator();

            Assert.That(en.Sum(), Is.EqualTo(sum));
            Assert.That(en.Count(), Is.EqualTo(i.Abs()));

            for (int j = i - 1; j >= 0; j--)
            {
                Assert.That(i.Enumerator().Contains(j), Is.True);
            }
        }
示例#10
0
 public static T GetByFoldedIndex <T>(this T[] array, int index)
 {
     if (array == null || array.Length == 0)
     {
         return(default(T));
     }
     if (index < 0)
     {
         index = index.Abs();
     }
     return(array[index % array.Length]);
 }
示例#11
0
    public static int Mod(this int value, int modulo)
    {
        if (modulo < 1)
        {
            return(0);
        }

        if (value < 0)
        {
            value += Mathf.CeilToInt((float)value.Abs() / modulo) * modulo;
        }

        return(value % modulo);
    }
示例#12
0
    public bool Contains(Vector2 x, bool strict = false)
    {
        int ad = a.To(b).Cross(a.To(x)).Sgn();
        int bd = b.To(c).Cross(b.To(x)).Sgn();
        int cd = c.To(a).Cross(c.To(x)).Sgn();

        if (strict)
        {
            return(ad == bd && bd == cd);
        }
        return((ad == bd && bd == cd) ||
               (ad == 0 && bd == cd) ||
               (bd == 0 && cd == ad) ||
               (cd == 0 && ad == bd) ||
               (ad.Abs() + bd.Abs() + cd.Abs() == 1)); // one 1 or -1; two 0.
    }
示例#13
0
        public static DateTime AddWorkingDays(this DateTime start, int workingDates)
        {
            if (start.isWeekend() && workingDates == 0)
            {
                workingDates = 1;
            }
            var sign = Math.Sign(workingDates);

            return(Enumerable
                   .Range(1, int.MaxValue)
                   .Select(x => start.AddDays(x * sign))
                   .Where(date => date.DayOfWeek != DayOfWeek.Saturday && date.DayOfWeek != DayOfWeek.Sunday)
                   .Select((date, i) => new { date, i })
                   .SkipWhile(a => a.i <= workingDates.Abs())
                   .First().date);
        }
示例#14
0
            public InternalItem(int itemID, Point3D loc, Mobile caster, Map map, TimeSpan duration, int val) : base(itemID)
            {
                var canFit = SpellHelper.AdjustField(ref loc, map, 12, false);

                Visible = false;
                Movable = false;
                Light   = LightType.Circle300;

                MoveToWorld(loc, map);

                m_Caster = caster;

                m_End = Core.Now + duration;

                m_Timer = new InternalTimer(this, TimeSpan.FromSeconds(val.Abs() * 0.2), caster.InLOS(this), canFit);
                m_Timer.Start();
            }
示例#15
0
        /// <summary>
        /// Update the SnapInfo structure with the deltas of the connector's connection point to the first nearby shape connection point found.
        /// </summary>
        protected void UpdateWithNearElementConnectionPoints(List <SnapInfo> nearElements)
        {
            foreach (SnapInfo si in nearElements)
            {
                // TODO: FirstOrDefault, or Where, returning a list of nearby CP's?
                ConnectionPoint nearConnectionPoint = si.NearElement.GetConnectionPoints().FirstOrDefault(cp => cp.Point.IsNear(si.LineConnectionPoint.Point, SNAP_CONNECTION_POINT_RANGE));

                if (nearConnectionPoint != null)
                {
                    Point sourceConnectionPoint = si.LineConnectionPoint.Point;
                    int   neardx = nearConnectionPoint.Point.X - sourceConnectionPoint.X;   // calculate to match possible delta sign
                    int   neardy = nearConnectionPoint.Point.Y - sourceConnectionPoint.Y;
                    si.NearConnectionPoint = nearConnectionPoint;
                    si.AbsDx = neardx.Abs();
                    si.AbsDy = neardy.Abs();
                }
            }
        }
示例#16
0
        public Animation(
            int[] frames,
            float frameStep,
            PlayMode playMode,
            int maxLoops      = 0,
            Action onFinished = null,
            Action onLoop     = null)
        {
            _frames = frames;
            _initialDelayPerFrame = frameStep.Abs() / _defaultFrameRate;
            _initialMaxLoops      = maxLoops.Abs();
            _initialPlayMode      = playMode;

            Frames     = new ReadOnlyCollection <int>(_frames);
            OnFinished = onFinished;
            OnLoop     = onLoop;
            ResetChanges();
        }
示例#17
0
        /// <summary>
        /// Raise this number to an integer power.
        /// Should be faster than Math.Pow because it does not
        /// need to deal with the general case.
        /// </summary>
        /// <param name="value"></param>
        /// <param name="power">The exponent to raise this number to</param>
        /// <returns></returns>
        public static double Power(this double value, int power)
        {
            if (power < 0)
            {
                return(1 / (value.Power(power.Abs())));
            }
            double result = 1.0;

            while (power > 0)
            {
                if (power % 2 == 1)
                {
                    result *= value;
                }
                power >>= 1;
                value  *= value;
            }
            return(result);
        }
示例#18
0
            public bool lineOfSight(asteroid to, List <asteroid> asteroids)
            {
                int dx = (to.x - this.x).Abs();
                int dy = (to.y - this.y).Abs();

                foreach (asteroid a in asteroids)
                {
                    if (a != this && a != to)
                    {
                        int dxa = a.x - this.x;
                        int dya = a.y - this.y;
                        if (dxa.Abs() <= dx && dya.Abs() <= dy && sameAngle(to, a))
                        {
                            return(false);
                        }
                    }
                }
                return(true);
            }
示例#19
0
        /// <summary>Subtracts in a circle from maximum to minimum range and back around.</summary>
        /// <remarks>The subtracting value should still be positive!</remarks>
        /// <param name="value">The base value.</param>
        /// <param name="subtraction">How much to subtract.</param>
        /// <param name="minimum">The minimum of the range.</param>
        /// <param name="maximum">The maximum of the range.</param>
        /// <returns></returns>
        public static int CircleSubtract(this int value, int subtraction, int minimum, int maximum)
        {
            if (subtraction < 0)
            {
                Debug.LogWarning("Subtraction should still be a positive integer.");
                return(value);
            }

            // start by subtracting
            value -= subtraction;

            if (value < minimum)
            {
                int remainder = value - (minimum - 1);
                value = maximum - remainder.Abs();
            }

            return(value);
        }
        /// <summary>
        /// Function to return a formatted string containing the memory amount.
        /// </summary>
        /// <param name="amount">Amount of memory in bytes to format.</param>
        /// <returns>A string containing the formatted amount of memory.</returns>
        /// <remarks>
        /// This will produce a string value with the number of bytes suffixed with the word 'bytes' if less than 1023, the number of kilobytes suffixed with the abbreviation 'KB' if the value is
        /// within the range of 1024 to 1048575, the number of megabytes suffixed with the abbreviation MB if the value is within the range of 1048576 to 1073741823, or the number of gigabytes
        /// with the suffix of 'GB' if the value is greater than 1073741823.
        /// <code language="csharp">
        /// int bytes = 999;
        /// int kilobytes = 2048;
        /// int megabytes = 3145728;
        /// int gigabytes = int.MaxValue;
        ///
        /// Console.WriteLine(bytes.FormatMemory());
        /// Console.WriteLine(kilobytes.FormatMemory());
        /// Console.WriteLine(megabytes.FormatMemory());
        /// Console.WriteLine(gigabytes.FormatMemory());
        ///
        /// // Produces: "128 bytes", "2.0 KB", "3.0 MB", and "2 GB".
        /// </code>
        /// <para>
        /// If the value cannot be represented with a string suffix, then the number of bytes will be displayed as default.
        /// </para>
        /// </remarks>
        public static string FormatMemory(this int amount)
        {
            double scale = amount.Abs() / 1073741824.0;

            if (scale >= 1.0)
            {
                return(GetCultureString(scale >= 1.0 ? scale : amount, Resources.GOR_UNIT_MEM_GB));
            }

            scale = amount / 1048576.0;

            if (scale >= 1.0)
            {
                return(GetCultureString(scale >= 1.0 ? scale : amount, Resources.GOR_UNIT_MEM_MB));
            }

            scale = amount / 1024.0;

            return(GetCultureString(scale >= 1.0 ? scale : amount, scale >= 1.0 ? Resources.GOR_UNIT_MEM_KB : Resources.GOR_UNIT_MEM_BYTES, false));
        }
示例#21
0
        public static double PowTen(this int x)
        {
            double v = 10;

            for (int i = 0; i < x.Abs(); i++)
            {
                v *= 10;
            }
            if (x == 0)
            {
                return(1);
            }
            if (x > 0)
            {
                return(v);
            }
            else
            {
                return(1 / v);
            }
        }
示例#22
0
        public static double PowX(this int x, int y)
        {
            double z = x;

            for (int i = 1; i < y.Abs(); i++)
            {
                z *= x;
            }
            if (x == 0)
            {
                return(1);
            }
            if (x > 0)
            {
                return(z);
            }
            else
            {
                return(1 / z);
            }
        }
示例#23
0
 public void createHeatMapSplodgeAccelerated(int x, int y, int radius = 20)
 {
     //Iterate over Y axis, negative RAD to + RAD
     Parallel.For(-radius, radius, yy =>
     {
         //Iterate over X axis, negative RAD to + RAD
         for (int xx = -radius; xx < radius; xx++)
         {
             //Chopping the value to avoid edge build up
             if (x + xx < 1024 && y + yy < 1024 && x + xx > 0 && y + yy > 0)
             {
                 //Add density to that pixel
                 addToPixelDensity((x + xx).Clamp(0, 1023), (y + yy).Clamp(0, 1023),
                                   (
                                       (radius - xx.Abs()) *
                                       (radius - yy.Abs()) -
                                       radius
                                   ) * 2);
             }
         }
     }); //Parallel.For
 }
示例#24
0
 private static int[] GetPrimaryValues(Rotation[][][] rotations, ref int dimension, ref int moduleId)
 {
     if (Application.isEditor)
     {
         LogPrimaryValues();
     }
     int[] output = new int[rotations.Length];
     for (int i = 0; i < rotations.Length; i++)
     {
         Debug.LogFormat("[The Octadecayotton #{0}]: ROTATION {1}", moduleId, i + 1);
         for (int j = 0; j < rotations[i].Length; j++)
         {
             if (rotations[i][j].Length != 1)
             {
                 for (int k = 0; k < rotations[i][j].Length; k++)
                 {
                     output[i] += GetPrimaryValue(rotations[i][j][k], rotations[i][j][(k + 1) % rotations[i][j].Length], moduleId);
                 }
             }
             else
             {
                 output[i] += GetPrimaryValue(rotations[i][j][0], rotations[i][j][0], moduleId);
             }
         }
     }
     Debug.LogFormat("[The Octadecayotton #{0}]: The primary values are {1}.", moduleId, output.Select(i => i.Abs()).Join(", "));
     return(output);
 }
 public void Abs_ShouldBehaveAsMathAbs_IfInt(int value) => Assert.Equal(Math.Abs(value), value.Abs());
示例#26
0
        public static void ErfTest()
        {
            // reference solution
            var erf = new[]
            {
                0,
                0.84270079294971486934122063508261, // 1
                0.99532226501895273416206925636725, // 2
                0.99997790950300141455862722387042, // 3
                0.99999998458274209971998114784033, // 4
                0.99999999999846254020557196514981, // 5
            };

            for (int i = -5; i < 5; i++)
            {
                var f1     = Fun.Erf(i);
                var f2     = Fun.Erf2(i);
                var should = erf[i.Abs()] * i.Sign();
                var e1     = (f1 - should).Abs();
                var e2     = (f2 - should).Abs();

                Report.Line("Erf1 error {0}", e1);
                Report.Line("Erf2 error {0}", e2);

                if (e1 < e2)
                {
                    Report.Line("Erf1");
                }
                else
                {
                    Report.Line("Erf2");
                }

                var test1 = e1.ApproximateEquals(0, 1e-6);
                Report.Line("Erf1 valid={0}", test1);
                Assert.True(test1);
                var test2 = e2.ApproximateEquals(0, 1e-6);
                Report.Line("Erf2 valid={0}", test2);
                Assert.True(test2);
            }

            // reference solution
            var erfClose = new[]
            {
                0,
                0.1124629160182848922032750717439683832216962991597025, // 0.1
                0.2227025892104784541401390068001438163882690384302276, // 0.2
                0.3286267594591274276389140478667565511699180962626758, // 0.3
                0.4283923550466684551036038453201724441218629285225903, // 0.4
                0.5204998778130465376827466538919645287364515757579637, // 0.5
                0.6038560908479259225626224360567232065642733648000979, // 0.6
                0.6778011938374184729756288092441513967162881743348702, // 0.7
                0.7421009647076604861671105865029458773176895799147087, // 0.8
                0.7969082124228321285187247851418859375486580415858037, // 0.9
            };

            for (int i = 1; i < 10; i++)
            {
                var v      = i / 10.0;
                var f1     = Fun.Erf(v);
                var f2     = Fun.Erf2(v);
                var should = erfClose[i.Abs()] * i.Sign();
                var e1     = (f1 - should).Abs();
                var e2     = (f2 - should).Abs();

                Report.Line("Erf1 error {0}", e1);
                Report.Line("Erf2 error {0}", e2);

                if (e1 < e2)
                {
                    Report.Line("Erf1");
                }
                else
                {
                    Report.Line("Erf2");
                }

                var test1 = e1.ApproximateEquals(0, 1e-6);
                Report.Line("Erf1 valid={0}", test1);
                Assert.True(test1);
                var test2 = e2.ApproximateEquals(0, 1e-6);
                Report.Line("Erf2 valid={0}", test2);
                Assert.True(test2);
            }
        }
示例#27
0
文件: GCD.cs 项目: lulzzz/HedgeHog
 static int GCD(int a, int b) =>
 b == 0 || a == 0 ? a + b : GCD(b.Abs().Min(a.Abs()), a.Abs().Max(b.Abs()) % b.Abs().Min(a.Abs()));
示例#28
0
        static bool Prefix(DateFile __instance, ref int __result, ref int presetItemId, ref int temporaryId,
                           ref int bookObbs, ref int buffObbs, ref int sBuffObbs)
        {
            if (!Main.enabled)
            {
                return(true);              //mod未开启
            }
            var  presetItem = __instance.presetitemDate[presetItemId];
            int  itemTyp    = presetItem[5].ParseInt();
            int  equipTyp   = presetItem[1].ParseInt();//1武器,2防具,3饰品
            bool isFood     = itemTyp == 34 || itemTyp == 35;

            if (isFood)//食物
            {
                if (presetItem[6].ParseInt() == 1)
                {
                    return(true);                              //可堆叠,是野果
                }
                if (!Main.settings.SetFood)
                {
                    return(true);
                }
            }
            else
            {
                if (presetItem[4] != "4")
                {
                    return(true);                     //排除非装备
                }
                if (equipTyp <= 0 || equipTyp >= 4)
                {
                    return(true);                               //装备类型不符
                }
                if ((equipTyp == 1 && !Main.settings.SetWeapon) || (equipTyp == 2 && !Main.settings.SetArmor) ||
                    (equipTyp == 3 && !Main.settings.SetJewelry))
                {
                    return(true);                                             //装备类型对应选项未开启
                }
                if (itemTyp == 42)
                {
                    return(true);              //排除奇书宝典
                }
                if (itemTyp == 36)
                {
                    return(true);              //排除神兵
                }
                if (itemTyp == 21 || presetItem[31].ParseInt() > 0)
                {
                    return(true);                                               //排除书籍
                }
            }
            if (!Main.settings.IMBA || !Main.settings.global)//仅对玩家制造的物品生效
            {
                System.Diagnostics.StackTrace st = new System.Diagnostics.StackTrace(false);
                if (!st.GetFrames().Select(f => f.GetMethod().Name).Any(n => n.Contains("SetMakeItem")))
                {
                    return(true);
                }
            }
            Dictionary <int, string> newItem = new Dictionary <int, string>();
            int newItemId;

            if (temporaryId < 0)
            {
                newItemId = temporaryId;
                GameData.Items.RemoveItem(temporaryId);
                __instance.itemsChangeDate.Remove(temporaryId);
            }
            else
            {
                __instance.newItemId++;
                newItemId = __instance.newItemId;
            }
            newItem[999] = presetItemId.ToString();//物品类型id
            int  duration = presetItem[902].ParseInt();
            bool isFixed  = duration <= 0;

            duration = duration.Abs();
            var seed = DateFile.instance.randSeed;

            //毒素
            if (Main.settings.IMBA && Main.settings.changePoison)
            {
                for (int i = 0; i < 6; i++)
                {
                    newItem[i + 71] = Main.settings.poison[i].ToString();
                }
            }
            //食物
            if (isFood)
            {
                //耐久
                int minimum = 50;
                duration     = isFixed ? duration : 1 + duration * seed.Next(minimum, 101) / 100;
                newItem[902] = duration.ToString(); //最大耐久
                newItem[901] = duration.ToString(); //当前耐久
                if (Main.settings.FoodAttr[0] != 0 || seed.Next(0, 100) < buffObbs)
                {
                    int attrTyp = Main.settings.FoodAttr[0] != 0
                        ? Main.settings.FoodAttr[0] == 1
                            ? Main.settings.FoodAttr[1] + 50501
                            : Main.settings.FoodAttr[2] + 50601
                        : (seed.Next(0, 100) < 50)
                            ? seed.Next(0, 16) + 50501
                            : seed.Next(0, 14) + 50601;
                    newItem[attrTyp] = (Mathf.Max(presetItem[8].ParseInt() / 2, 1) * 20).ToString();
                }
            }
            //装备
            else
            {
                if (Main.settings.IMBA && Main.settings.家宝)
                {
                    DateFile.instance.ChangItemDate(newItemId, 92, 900);
                    DateFile.instance.ChangItemDate(newItemId, 93, 1800);
                }
                if (Main.settings.IMBA && Main.settings.神兵)
                {
                    isFixed    = true;
                    duration   = 9;
                    newItem[5] = "36";
                }
                //武器
                if (equipTyp == 1)
                {
                    //耐久
                    if (!isFixed)
                    {
                        int minimum = Main.settings.WeaponMoreDuration ? 80 : 50;
                        duration = 1 + duration * seed.Next(minimum, 101) / 100;
                    }
                    newItem[902] = duration.ToString(); //最大耐久
                    newItem[901] = duration.ToString(); //当前耐久
                    //式
                    bool freeTyp = Main.settings.IMBA && Main.settings.freeTyp;
                    if (freeTyp || presetItem[606].ParseInt() > 0)
                    {
                        string attackTypText = "";
                        var    newTyps       = new string[6];
                        for (int i = 0; i < 6; i++)
                        {
                            newTyps[i] = Main.AttackTypId[Main.settings.AttackTyp[i]];
                        }
                        List <string> presetTyps = new List <string>(presetItem[7].Split('|'));
                        if (!freeTyp)
                        {
                            for (int i = 0; i < 6; i++)
                            {
                                if (presetTyps.Contains(newTyps[i]))
                                {
                                    presetTyps.Remove(newTyps[i]);
                                }
                                else
                                {
                                    newTyps[i] = "";
                                }
                            }
                        }
                        for (int i = 0; i < 6; i++)
                        {
                            if (newTyps[i] == "")
                            {
                                string typ = presetTyps.Random();
                                newTyps[i] = typ;
                                presetTyps.Remove(typ);
                            }
                        }
                        attackTypText = string.Join("|", newTyps);
                        newItem[7]    = attackTypText;
                    }
                    //内伤比例
                    if (Main.settings.IMBA && Main.settings.changeRate)
                    {
                        newItem[10] = Main.settings.rate.ToString();
                    }
                    //功法发挥
                    if (Main.settings.WeaponEngraving != 0 || seed.Next(0, 100) < buffObbs)
                    {
                        int carving = Main.settings.WeaponEngraving;
                        if (carving == 0)
                        {
                            carving = seed.Next(1, 4);
                        }
                        if (buffObbs == 999)
                        {
                            carving *= 100;
                        }
                        newItem[505] = carving.ToString();
                    }
                    //词条
                    int power = presetItem[504].ParseInt();
                    if ((Main.settings.WeaponPower[0] != 3 || Main.settings.WeaponPower[3] != 5) || (power != 0 && seed.Next(0, 100) < sBuffObbs))
                    {
                        if (Main.settings.WeaponPower[0] == 3)     //其他
                        {
                            if (Main.settings.WeaponPower[3] == 5) //随机
                            {
                                List <int> powerList = new List <int>
                                {
                                    2,
                                    3,
                                    4,
                                    5,
                                    6,
                                    7,
                                    8,
                                    9,
                                    10,
                                    11,
                                    12,
                                    13,
                                    101,
                                    102,
                                    103,
                                    104,
                                    105,
                                    106,
                                    107,
                                    108,
                                    109,
                                    110,
                                    111,
                                    112,
                                    401,
                                    402,
                                    403,
                                    404,
                                    407
                                };
                                if (power < 0)
                                {
                                    powerList.Add(power.Abs());//武器杀
                                }
                                int material = presetItem[506].ParseInt();
                                if (material != 0)                 // 没有布杀
                                {
                                    powerList.Add(209 + material); //材质杀
                                }
                                power = powerList.Random();
                            }
                            else
                            {
                                power = Main.settings.WeaponPower[3] == 4 ? 407 : 401 + Main.settings.WeaponPower[3];
                            }
                        }
                        //杀
                        else if (Main.settings.WeaponPower[0] == 2)
                        {
                            if (Main.settings.WeaponPower[2] == 1)//材质杀
                            {
                                int material = presetItem[506].ParseInt();
                                power = material == 0 ? 0 :209 + material; //没有布杀
                            }
                            else
                            {
                                power = power.Abs(); //武器杀
                            }
                        }
                        // 破 辟
                        else
                        {
                            power = (Main.settings.WeaponPower[0] == 0 ? 2 : 101) + Main.settings.WeaponPower[1];
                        }
                        if (power > 0)
                        {
                            ChangeNewItemSPower(newItem, presetItemId, power);
                        }
                    }
                }
                //防具
                else if (equipTyp == 2)
                {
                    //耐久
                    if (!isFixed)
                    {
                        int minimum = 50;
                        duration = 1 + duration * seed.Next(minimum, 101) / 100;
                    }
                    newItem[902] = duration.ToString(); //最大耐久
                    newItem[901] = duration.ToString(); //当前耐久
                    if (Main.settings.ArmorAttr != 0 || seed.Next(0, 100) < buffObbs)
                    {
                        int attrTyp = (Main.settings.ArmorAttr == 0) ? seed.Next(0, 6) : (Main.settings.ArmorAttr - 1);
                        newItem[51361 + attrTyp] = (Mathf.Max(int.Parse(presetItem[8]) / 2, 1) * ((buffObbs != 999) ? 5 : 10)).ToString();
                    }
                    if (Main.settings.ArmorPower != 1 && (Main.settings.ArmorPower != 0 || seed.Next(0, 100) < sBuffObbs))
                    {
                        int power;
                        if (Main.settings.ArmorPower == 0)
                        {
                            List <int> list2 = new List <int>
                            {
                                401,
                                402,
                                405,
                                406,
                                407
                            };
                            power = list2.Random();
                        }
                        else
                        {
                            power = Main.settings.ArmorPower <= 3 ? Main.settings.ArmorPower + 399 : Main.settings.ArmorPower + 401;
                        }
                        ChangeNewItemSPower(newItem, presetItemId, power);
                    }
                }
                //饰品
                else
                {
                    //耐久
                    if (!isFixed)
                    {
                        int minimum = 50;
                        duration = 1 + duration * seed.Next(minimum, 101) / 100;
                    }
                    newItem[902] = duration.ToString(); //最大耐久
                    newItem[901] = duration.ToString(); //当前耐久
                    if (Main.settings.JewelryAttr[0] != 0 || seed.Next(0, 100) < buffObbs)
                    {
                        int attrTyp = Main.settings.JewelryAttr[0] == 0
                            ? seed.Next(0, 100) < 50
                                ? seed.Next(0, 16) + 50501
                                : seed.Next(0, 14) + 50601
                            : Main.settings.JewelryAttr[0] == 1
                                ? Main.settings.JewelryAttr[1] + 50501
                                : Main.settings.JewelryAttr[2] + 50601;
                        newItem[attrTyp] = (Mathf.Max(presetItem[8].ParseInt() / 2, 1) * ((buffObbs != 999) ? 5 : 10)).ToString();
                    }
                    if (Main.settings.JewelryPowerMustBe || seed.Next(0, 100) < sBuffObbs)
                    {
                        ChangeNewItemSPower(newItem, presetItemId, 407);
                    }
                }
            }
            GameData.Items.AddItem(newItemId, newItem);
            __result = newItemId;
            return(false);
        }
示例#29
0
 public static DarkLightTag GetCarTag(int carId)
 {
     return(new DarkLightTag(CarId + carId.Abs()));
 }
示例#30
0
    void Update()
    {
        decayedScore = score - scoreDecay * Time.deltaTime;
        score        = Mathf.RoundToInt(decayedScore);
        if (score <= 0)
        {
            score = 0;
        }

        float   targetFov = 60f;
        Vector3 newCamRot = m_cam.transform.localEulerAngles;

        if (canControll)
        {
            scoreText.text = "SCORE: " + score;

            if (_moveDir.Abs() >= 0.5f)
            {
                if (!m_isRotating)
                {
                    StartCoroutine(ChangeDirection(Mathf.RoundToInt(_moveDir * 45)));

                    if (helpText)
                    {
                        helpText.text = "PICK UP TESSERACTS TO INCREASE YOUR SCORE.\nTHE MORE TESSERACTS YOU PICK UP, THE FASTER YOU GO.\nAVOID WALLS, THEY ARE NOT GOOD.";
                        Destroy(helpText.gameObject, 8f);
                    }
                }
            }

            if (!paused)
            {
                _hueOffset += hueSpeed * Time.deltaTime;
                if (_hueOffset > 179.5f)
                {
                    _hueOffset = -179.5f;
                }
                else if (_hueOffset < -179.5f)
                {
                    _hueOffset = 179.5f;
                }
                Shader.SetGlobalFloat(_hueShaderId, _hueOffset);
            }

            newCamRot.x = Mathf.Lerp(newCamRot.x, 15f, 0.05f);

            targetFov = Mathf.Lerp(minFov, maxFov, (m_speed / maxSpeed));
        }
        else
        {
            newCamRot.x = Mathf.Lerp(newCamRot.x, 0f, 0.05f);
            targetFov   = 45f;
        }
        m_cam.transform.localEulerAngles = newCamRot;

        targetSpeed = Mathf.Lerp(m_speed, decayedScore + 21, 0.9f);

        targetSpeed = Mathf.Clamp(targetSpeed, 0, maxSpeed);
        if (m_speed < targetSpeed)
        {
            rb.AddForce(transform.forward * targetSpeed * Time.deltaTime, ForceMode.Impulse);
        }

        m_speed        = rb.velocity.z;
        speedText.text = Mathf.FloorToInt(m_speed) - 1 + "MPH";

        m_cam.fieldOfView = Mathf.Lerp(m_cam.fieldOfView, targetFov, 0.05f);


        surfaceMat.SetVector("Line_Thiccness", new Vector2(0.03f, Mathf.Lerp(0.005f, 0.0f, Mathf.SmoothStep(100.0f, 200.0f, paused ? 0.0f : m_speed))));

        ReflectionRefreshTimer();
    }