private void ValueTrackBar_Scroll(object sender, EventArgs e)
        {
            double percentage = (double)ValueTrackBar.Value / ValueTrackBar.Maximum;

            Value = MathPlus.Lerp(MinValue, MaxValue, percentage);
            ValueNumericUpDown.Value = (decimal)Value;
        }
Esempio n. 2
0
    void Update()
    {
        // try and target the player (which is a singleton because it's a single player game)
        var player = MetaGame.Instance.GetPlayer();

        if (player == null)
        {
            return;
        }
        var directionToPlayer = player.transform.position - transform.position;
        var angleToPlayer     = MathPlus.NormalizeAngle(Mathf.Atan2(directionToPlayer.y, directionToPlayer.x) * Mathf.Rad2Deg - 90);
        var myAngle           = MathPlus.NormalizeAngle(transform.eulerAngles.z);

        var turnAmount = Mathf.Clamp((angleToPlayer - myAngle) / 45, -1, 1);

        if (Controller == null)
        {
            return;
        }
        Controller.RotationCommand = turnAmount;

        var playerIsClose = directionToPlayer.magnitude < Controller.Card.AIRange;

        Controller.IsFiring = playerIsClose && (Mathf.Abs(angleToPlayer - myAngle) < 20);

        Controller.Throttle = 1;
    }
        void UpdateValueTrackBar()
        {
            double tValue = (MathPlus.Lerp(0, 1, (1 - (MaxValue - Value) / (MaxValue - MinValue))));

            if (tValue > 1)
            {
                tValue = 1;
            }
            if (tValue < 0 || double.IsNaN(tValue))
            {
                tValue = 0;
            }
            ValueTrackBar.Value = (int)(tValue * 1000);
        }
Esempio n. 4
0
        /// <summary>
        /// Average value operation.
        /// </summary>
        /// <param name="args">
        ///            Result from the expressions evaluation. </param>
        /// <exception cref="DynamicError">
        ///             Dynamic error. </exception>
        /// <returns> Result of fn:avg operation. </returns>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public static org.eclipse.wst.xml.xpath2.api.ResultSequence avg(java.util.Collection args) throws org.eclipse.wst.xml.xpath2.processor.DynamicError
        public static ResultSequence avg(ICollection args)
        {
            var j = args.GetEnumerator();

            j.MoveNext();
            ResultSequence arg = (ResultSequence)j.Current;

            if (arg == null || arg.empty())
            {
                return(ResultSequenceFactory.create_new());
            }

            int elems = 0;

            MathPlus total = null;

            TypePromoter tp = new ScalarTypePromoter();

            tp.considerSequence(arg);

            for (var i = arg.iterator(); i.MoveNext();)
            {
                ++elems;
                AnyAtomicType conv = tp.promote((AnyType)i.Current);
                if (conv != null)
                {
                    if (conv is XSDouble && ((XSDouble)conv).nan() || conv is XSFloat && ((XSFloat)conv).nan())
                    {
                        return(ResultSequenceFactory.create_new(tp.promote(new XSFloat(float.NaN))));
                    }
                    if (total == null)
                    {
                        total = (MathPlus)conv;
                    }
                    else
                    {
                        total = (MathPlus)total.plus(ResultSequenceFactory.create_new(conv)).first();
                    }
                }
            }

            if (!(total is MathDiv))
            {
                DynamicError.throw_type_error();
            }

            return(((MathDiv)total).div(ResultSequenceFactory.create_new(new XSInteger(new System.Numerics.BigInteger(elems)))));
        }
Esempio n. 5
0
        /// <summary>
        /// Sum operation.
        /// </summary>
        /// <param name="args">
        ///            Result from the expressions evaluation. </param>
        /// <exception cref="DynamicError">
        ///             Dynamic error. </exception>
        /// <returns> Result of fn:sum operation. </returns>
//JAVA TO C# CONVERTER WARNING: Method 'throws' clauses are not available in .NET:
//ORIGINAL LINE: public static org.eclipse.wst.xml.xpath2.api.ResultSequence sum(org.eclipse.wst.xml.xpath2.api.ResultSequence arg, org.eclipse.wst.xml.xpath2.processor.internal.types.AnyAtomicType zero) throws org.eclipse.wst.xml.xpath2.processor.DynamicError
        public static ResultSequence sum(ResultSequence arg, AnyAtomicType zero)
        {
            if (arg.empty())
            {
                return(ResultSequenceFactory.create_new(zero));
            }

            MathPlus total = null;

            TypePromoter tp = new ScalarTypePromoter();

            tp.considerSequence(arg);

            for (var i = arg.iterator(); i.MoveNext();)
            {
                AnyAtomicType conv = tp.promote((AnyType)i.Current);

                if (conv == null)
                {
                    conv = zero;
                }

                if (conv is XSDouble && ((XSDouble)conv).nan() || conv is XSFloat && ((XSFloat)conv).nan())
                {
                    return(ResultSequenceFactory.create_new(tp.promote(new XSFloat(float.NaN))));
                }
                if (total == null)
                {
                    total = (MathPlus)conv;
                }
                else
                {
                    total = (MathPlus)total.plus(ResultSequenceFactory.create_new(conv)).first();
                }
            }

            return(ResultSequenceFactory.create_new((AnyType)total));
        }
Esempio n. 6
0
 public static double Minimum(double a, double b)
 {
     return(MathPlus.Min(a, b));
 }
Esempio n. 7
0
 public static double Maximum(double a, double b)
 {
     return(MathPlus.Max(a, b));
 }
Esempio n. 8
0
 public static double NthRoot(double radicand, double radical)
 {
     return(MathPlus.Root(radicand, radical));
 }
Esempio n. 9
0
 public static double SquareRoot(double val)
 {
     return(MathPlus.Sqrt(val));
 }
Esempio n. 10
0
 public static double Logarithm(double val)
 {
     return(MathPlus.Log10(val));
 }
Esempio n. 11
0
 public static double LogarithmE(double val)
 {
     return(MathPlus.Ln(val));
 }
Esempio n. 12
0
 public static double LogarithmN(double val, double baseNum)
 {
     return(MathPlus.Log(val, baseNum));
 }
Esempio n. 13
0
 public override IResultValue Evaluate()
 {
     return(new ResultNumberReal(MathPlus.Pow((double)First.Evaluate().ToDecimal(), (double)Second.Evaluate().ToDecimal())));
 }
Esempio n. 14
0
 public static double MinList(List <double> list)
 {
     return(MathPlus.Min(list));
 }
Esempio n. 15
0
 public static double MaxList(List <double> list)
 {
     return(MathPlus.Max(list));
 }