Ejemplo n.º 1
0
        private void Start()
        {
            mat         = GetComponent <MeshRenderer>().material;
            HeightState = CurvedStateStruct <float> .Init(
                1,
                (float left, float right) => { return(left + right); },
                (float left, float right) => { return(left * right); },
                .3f
                );

            ColorState = CurvedStateStruct <Color> .Init(
                Color.white,
                (Color left, Color right) => { return(left + right); },
                (float left, Color right) => { return(left * right); },
                .2f
                );

            HeightState.SetCurve(Curves[0]);
            ColorState.SetCurve(Curves[1]);
        }
        /// <summary>
        /// 생성 메소드
        /// </summary>
        /// <param name="initial">초기값</param>
        /// <param name="adder">덧셈 연산</param>
        /// <param name="multiplier">실수와의 곱셈 연산</param>
        /// <param name="time">변하는데 걸리는 시간(초)(마지막 To()로부터)</param>
        /// <returns>객체</returns>
        public static CurvedStateStruct <T> Init(T initial, DAdd <T> adder, DMultiply <T> multiplier, float time = 1.0f)
        {
            CurvedStateStruct <T> ret = new CurvedStateStruct <T> {
                add      = adder,
                multiply = multiplier,
                Start    = initial,
                Target   = initial,
                Now      = initial,
                Timer    = time
            };

            ret.Running = false;
            ret.SetCurve(AnimationCurve.Linear(0, 0, 1, 1));
            runningQueue.Add(ret);
            if (!runner.IsAlive)
            {
                runner = new Thread(new ThreadStart(ThreadRun));
            }
            runner.Start();
            return(ret);
        }