コード例 #1
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);
                }
            }
        }
コード例 #2
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);
                    }
                }
            }
        }