Exemplo n.º 1
0
        /// <summary>
        /// 흔들 거리는 애니메이션을 시뮬레이트하기위한 삼각 함수 변수 계산
        /// </summary>
        protected virtual void CalculateTrigonometricVariables(float timeMultiplier = 1f)
        {
            time += Time.deltaTime * (JiggleFrequency * timeMultiplier);

            currentJigglePower = Mathf.Lerp(currentJigglePower, targetPowerValue, Time.deltaTime * 20f);

            for (int i = 0; i < RandomLevel; i++)
            {
                for (int j = 0; j < 2; j++)
                {
                    TrigonoParams parameters = trigParams[i + j];

                    float timeValue     = time * parameters.RandomTimeMul + parameters.TimeOffset;
                    float multiplyValue = JiggleTiltValue * parameters.Multiplier * currentJigglePower / AdditionalSpeedValue;

                    if (j % 2 == 0)
                    {
                        parameters.Value = Mathf.Sin(timeValue) * multiplyValue;
                    }
                    else
                    {
                        parameters.Value = Mathf.Cos(timeValue) * multiplyValue;
                    }
                }
            }

            easedPowerProgress -= Time.deltaTime * JiggleDecelerate * AdditionalSpeedValue;
            easedPowerProgress  = Mathf.Max(ConstantJiggleValue, easedPowerProgress);

            targetPowerValue = EaseInOutCubic(0f, 1f, easedPowerProgress);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 애니메이션을 위한 삼각 함수 변수를 매번 다르게 재설정하기
        /// </summary>
        protected virtual void RandomizeVariables()
        {
            time = Random.Range(-Mathf.PI, Mathf.PI);

            trigParams = new List <TrigonoParams>();

            // 각각의 임의의 레벨은 2 개의 삼각 함수  (걸프 및 코사인)
            for (int i = 0; i < RandomLevel; i++)
            {
                for (int t = 0; t < 2; t++)
                {
                    TrigonoParams newParams = new TrigonoParams();
                    newParams.Randomize();
                    trigParams.Add(newParams);
                }
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// Resetting trigonometric variables for animation to look different every time
        /// </summary>
        protected virtual void RandomizeVariables(float transition = 1f)
        {
            if (transition >= 1f)
            {
                time = Random.Range(-Mathf.PI * 5f, Mathf.PI * 5f);

                trigParams = new List <TrigonoParams>();

                // Each random level have 2 trigonometric functions (sinus and cosinus)
                for (int i = 0; i < RandomLevel; i++)
                {
                    for (int t = 0; t < 2; t++)
                    {
                        TrigonoParams newParams = new TrigonoParams();
                        newParams.Randomize();
                        trigParams.Add(newParams);
                    }
                }
            }
            else
            {
                time = Mathf.Lerp(time, Random.Range(-Mathf.PI * 5f, Mathf.PI * 5f), transition);

                // Each random level have 2 trigonometric functions (sinus and cosinus)
                for (int i = 0; i < RandomLevel; i++)
                {
                    for (int t = 0; t < 2; t++)
                    {
                        TrigonoParams newParams = new TrigonoParams();
                        newParams.Randomize();
                        trigParams[i + t].Multiplier    = Mathf.Lerp(trigParams[i + t].Multiplier, newParams.Multiplier, transition);
                        trigParams[i + t].RandomTimeMul = Mathf.Lerp(trigParams[i + t].RandomTimeMul, newParams.RandomTimeMul, transition);
                        trigParams[i + t].TimeOffset    = Mathf.Lerp(trigParams[i + t].TimeOffset, newParams.TimeOffset, transition);
                        trigParams[i + t].Value         = Mathf.Lerp(trigParams[i + t].Value, newParams.Value, transition);
                    }
                }
            }
        }