コード例 #1
0
 public static Vector3 Clamp(Vector3 vector, Vector2 rangeX, Vector2 rangeY, Vector2 rangeZ)
 {
     vector.x = MathfExtend.Clamp(vector.x, rangeX);
     vector.y = MathfExtend.Clamp(vector.y, rangeY);
     vector.z = MathfExtend.Clamp(vector.z, rangeZ);
     return(vector);
 }
コード例 #2
0
        public static T GetInverse <T>(T value) where T : struct, IConvertible
        {
            Debug.Assert(typeof(T).IsEnum && Enum.GetNames(typeof(T)).Length == 2);

            auxInteger = Convert.ToInt32(value);
            auxInteger = MathfExtend.AddValueInCircle(auxInteger, 1, 2);
            return((T)Enum.ToObject(typeof(T), auxInteger));
        }
コード例 #3
0
        public static Vector3 Lerp(Vector2 rangeX, Vector2 rangeY, Vector2 rangeZ, Vector3 t, FunctionEnum function = FunctionEnum.Linear)
        {
            Vector3 vector;

            vector.x = MathfExtend.Lerp(rangeX.x, rangeX.y, t.x, function);
            vector.y = MathfExtend.Lerp(rangeY.x, rangeY.y, t.y, function);
            vector.z = MathfExtend.Lerp(rangeZ.x, rangeZ.y, t.z, function);
            return(vector);
        }
コード例 #4
0
ファイル: GIFExtend.cs プロジェクト: FeboGameDeveloper/Pearl
 // Update is called once per frame
 protected void Update()
 {
     if (useGIF && sprites != null && _timer.IsFinish())
     {
         _currentIndex = MathfExtend.ChangeInCircle(_currentIndex, 1, sprites.Length);
         _timer.Reset();
         SetFrame();
     }
 }
コード例 #5
0
        private void SetBar()
        {
            if (circleBar)
            {
                currentPiece = MathfExtend.ChangeInCircle(currentPiece, 1, pieces.Length);
            }

            if (pieces != null && barImage != null && currentPiece < pieces.Length)
            {
                spriteManagr.SetSprite(pieces[currentPiece]);
            }
        }
コード例 #6
0
        public float Follow(float newNumber)
        {
            float x = newNumber - currentNumber;

            if (x == 0)
            {
                return(currentNumber);
            }

            int sign = MathfExtend.Sign(x);

            x = Mathf.Abs(x);

            float y = Mathf.Abs(polynomial.Evalutate(x));

            currentNumber = MathfExtend.NotPassTheFrontier(currentNumber, y * sign, newNumber);
            return(currentNumber);
        }
コード例 #7
0
        public void Translate(Vector3 translateVector, FunctionEnum function = FunctionEnum.Linear)
        {
            Vector3 newVector = GetCurrentValue() + translateVector;

            if (useLimitX)
            {
                newVector.x = isPercent ? MathfExtend.Lerp(rangeX, translateVector.x, function) : MathfExtend.Clamp(newVector.x, rangeX);
            }
            if (useLimitY)
            {
                newVector.y = isPercent ? MathfExtend.Lerp(rangeY, translateVector.y, function) : MathfExtend.Clamp(newVector.y, rangeY);
            }
            if (useLimitZ)
            {
                newVector.z = isPercent ? MathfExtend.Lerp(rangeZ, translateVector.z, function) : MathfExtend.Clamp(newVector.z, rangeZ);
            }

            SetCurrentValue(newVector);
        }
コード例 #8
0
        public static Vector3 Lerp(float t, params Vector3[] vectors)
        {
            if (vectors.Length == 1)
            {
                return(vectors[0]);
            }
            else if (vectors.Length > 1)
            {
                int   keysNum = vectors.Length;
                float delta   = 1f / (keysNum - 1);
                int   piece   = t == 1 ? keysNum - 2 : Mathf.FloorToInt(t / delta);

                float r = MathfExtend.Percent(t - (delta * piece), delta);

                return(Vector3.Lerp(vectors[piece], vectors[piece + 1], r));
            }
            else
            {
                return(Vector3.zero);
            }
        }
コード例 #9
0
ファイル: Statistics.cs プロジェクト: FeboGameDeveloper/Pearl
        public static float Median(params float[] numbers)
        {
            if (numbers.IsAlmostSpecificCount())
            {
                Array.Sort(numbers);
                float Length = numbers.Length;

                if (MathfExtend.IsOdd(numbers.Length))
                {
                    return(numbers[(int)((Length + 1) / 2)]);
                }
                else
                {
                    float aux1 = numbers[(int)(Length / 2)];
                    float aux2 = numbers[(int)((Length / 2) + 1)];

                    return(Average(aux1, aux2));
                }
            }

            LogManager.LogWarning("The median is wrong");
            return(0f);
        }
コード例 #10
0
        public void GetScale(Transform tr, float position)
        {
            if (tr == null)
            {
                return;
            }

            float percent  = MathfExtend.Percent(position, positionForMinScale, positionForMaxScale);
            float newScale = Mathf.Lerp(addedScaleRange.x, addedScaleRange.y, percent);

            if (_originsScales != null && !_originsScales.ContainsKey(tr))
            {
                _originsScales.Add(tr, tr.localScale);
                if (tr.TryGetComponent <PearlObject>(out var obj))
                {
                    obj.DisactiveHandler += OnDisableLayer;
                }
            }

            Vector3 oiginScale = _originsScales[tr];

            tr.localScale = new Vector3(oiginScale.x + newScale, oiginScale.y + newScale, oiginScale.z + newScale);
        }
コード例 #11
0
 public static Vector3 Clamp(Vector3 vector, Range rangeX, Range rangeY)
 {
     vector.x = MathfExtend.Clamp(vector.x, rangeX);
     vector.y = MathfExtend.Clamp(vector.y, rangeY);
     return(vector);
 }