Example #1
0
        /// <summary>
        /// [Please do not use it] Update Animation
        /// </summary>
        /// <param name="tDelta"></param>
        public void Update(float tDelta)
        {
            //_isUpdated = false;

            _tmpIsEnd = false;

            //_unitWeight *= weightCorrectRatio;//<<이거 안해요

            if (_linkedAnimClip._parentPlayUnit != this)
            {
                //PlayUnit이 더이상 이 AnimClip을 제어할 수 없게 되었다
                //Link Release를 하고 업데이트도 막는다.
                //Debug.LogError("AnimPlayUnit Invalid End");
                ReleaseLink();
                return;
            }

            PLAY_STATUS requestedNextPlayStatus = _nextPlayStatus;

            switch (_playStatus)
            {
            case PLAY_STATUS.Ready:
            {
                if (_isFirstFrame)
                {
                    //_unitWeight = 0.0f;
                    //_prevUnitWeight = 0.0f;
                    _linkedAnimClip.SetPlaying_Opt(false);
                    _linkedAnimClip.SetFrame_Opt(_linkedAnimClip.StartFrame);
                    //Debug.Log("Ready");
                }
                //if (!_isPause)
                //{
                //	if (_isDelayIn)
                //	{
                //		//딜레이 후에 플레이된다.
                //		_tDelay += tDelta;
                //		if (_tDelay > _delayToPlayTime)
                //		{
                //			_unitWeight = 0.0f;
                //			_isDelayIn = false;
                //			ChangeNextStatus(PLAY_STATUS.PlayWithFadeIn);//<<플레이 된다.
                //		}
                //	}
                //}
            }
            break;


            //case PLAY_STATUS.PlayWithFadeIn:
            //	{
            //		if(_isFirstFrame)
            //		{
            //			//_tFade = 0.0f;
            //			//_prevUnitWeight = _unitWeight;

            //			//플레이 시작했다고 알려주자
            //			if (!_isPlayStartEventCalled)
            //			{
            //				_parentQueue.OnAnimPlayUnitPlayStart(this);
            //				_isPlayStartEventCalled = true;
            //			}
            //			//Debug.Log("Play With Fade In");
            //		}
            //		if (!_isPause)
            //		{
            //			//_tFade += tDelta;

            //			if (_tFade < _fadeInTime)
            //			{
            //				//_unitWeight = (_prevUnitWeight * (_fadeInTime - _tFade) + 1.0f * _tFade) / _fadeInTime;

            //				_tmpIsEnd = _linkedAnimClip.Update_Opt(tDelta * _speedRatio);
            //			}
            //			//else
            //			//{
            //			//	_unitWeight = 1.0f;
            //			//	//Fade가 끝났으면 Play
            //			//	ChangeNextStatus(PLAY_STATUS.Play);
            //			//}
            //		}
            //	}
            //	break;

            case PLAY_STATUS.Play:
            {
                if (_isFirstFrame)
                {
                    //_unitWeight = 1.0f;
                    //_prevUnitWeight = 1.0f;

                    //플레이 시작했다고 알려주자
                    if (!_isPlayStartEventCalled)
                    {
                        _parentQueue.OnAnimPlayUnitPlayStart(this);
                        _isPlayStartEventCalled = true;
                    }
                    //Debug.Log("Play");
                    _linkedAnimClip.SetPlaying_Opt(true);
                }

                if (!_isPause)
                {
                    _linkedAnimClip.SetPlaying_Opt(true);
                    _tmpIsEnd = _linkedAnimClip.Update_Opt(tDelta * _speedRatio);
                    //_isUpdated = true;

                    //if (_isDelayOut)
                    //{
                    //	//딜레이 후에 FadeOut된다.
                    //	_tDelay += tDelta;
                    //	if (_tDelay > _delayToEndTime)
                    //	{
                    //		_isDelayOut = false;
                    //		_unitWeight = 1.0f;
                    //		ChangeNextStatus(PLAY_STATUS.PlayWithFadeOut);//<<플레이 종료를 위한 FadeOut
                    //	}
                    //}
                }
                else
                {
                    _linkedAnimClip.SetPlaying_Opt(false);
                }
            }
            break;

            //case PLAY_STATUS.PlayWithFadeOut:
            //	{
            //		if(_isFirstFrame)
            //		{
            //			//_tFade = 0.0f;
            //			//_prevUnitWeight = _unitWeight;
            //			//Debug.Log("Play With Fade Out");
            //		}

            //		if (!_isPause)
            //		{
            //			//_tFade += tDelta;

            //			if (_tFade < _fadeOutTime)
            //			{
            //				//_unitWeight = (_prevUnitWeight * (_fadeOutTime - _tFade) + 0.0f * _tFade) / _fadeOutTime;

            //				_tmpIsEnd = _linkedAnimClip.Update_Opt(tDelta * _speedRatio);
            //			}
            //			//else
            //			//{
            //			//	_unitWeight = 0.0f;
            //			//	ChangeNextStatus(PLAY_STATUS.End);
            //			//}
            //		}
            //	}
            //	break;


            case PLAY_STATUS.End:
            {
                //아무것도 안합니더
                if (_isFirstFrame)
                {
                    //Debug.Log("End");
                    //_unitWeight = 0.0f;
                    ReleaseLink();
                }
            }
            break;
            }

            if (_tmpIsEnd && _isAutoEnd)
            {
                //종료가 되었다면 (일단 Loop는 아니라는 것)
                //조건에 따라 End로 넘어가자
                SetEnd();
            }

            //스테이트 처리
            //if(_nextPlayStatus != _playStatus)
            if (requestedNextPlayStatus != _playStatus)
            {
                _playStatus     = requestedNextPlayStatus;
                _nextPlayStatus = _playStatus;
                _isFirstFrame   = true;
            }
            else if (_isFirstFrame)
            {
                _isFirstFrame = false;
            }
        }
        /// <summary>
        /// [Please do not use it] Update Animation
        /// </summary>
        /// <param name="tDelta"></param>
        public void Update(float tDelta)
        {
            _tmpIsEnd = false;


            if (_linkedAnimClip._parentPlayUnit != this)
            {
                //PlayUnit이 더이상 이 AnimClip을 제어할 수 없게 되었다
                //Link Release를 하고 업데이트도 막는다.

                ReleaseLink();
                return;
            }

            PLAY_STATUS requestedNextPlayStatus = _nextPlayStatus;
            float       speedRatio = _linkedAnimClip._speedRatio;

            switch (_playStatus)
            {
            case PLAY_STATUS.Ready:
            {
                if (_isFirstFrame)
                {
                    //_unitWeight = 0.0f;
                    //_prevUnitWeight = 0.0f;
                    _linkedAnimClip.SetPlaying_Opt(false);
                    if (_isResetFrameOnReadyStatus)
                    {
                        _linkedAnimClip.SetFrame_Opt(_linkedAnimClip.StartFrame, false);
                    }
                    _isResetFrameOnReadyStatus = true;                                    //True가 기본값
                }
            }
            break;



            case PLAY_STATUS.Play:
            {
                if (_isFirstFrame)
                {
                    //_unitWeight = 1.0f;
                    //_prevUnitWeight = 1.0f;

                    //플레이 시작했다고 알려주자
                    if (!_isPlayStartEventCalled)
                    {
                        _parentQueue.OnAnimPlayUnitPlayStart(this);
                        _isPlayStartEventCalled = true;
                    }
                    //Debug.Log("Play");
                    _linkedAnimClip.SetPlaying_Opt(true);
                }

                if (!_isPause)
                {
                    _linkedAnimClip.SetPlaying_Opt(true);
                    _tmpIsEnd = _linkedAnimClip.Update_Opt(tDelta * speedRatio);
                }
                else
                {
                    _linkedAnimClip.SetPlaying_Opt(false);
                }
            }
            break;

            case PLAY_STATUS.End:
            {
                //아무것도 안합니더
                if (_isFirstFrame)
                {
                    ReleaseLink();
                }
            }
            break;
            }

            if (_tmpIsEnd && _isAutoEnd)
            {
                //종료가 되었다면 (일단 Loop는 아니라는 것)
                //조건에 따라 End로 넘어가자
                SetEnd();
            }

            //스테이트 처리
            //if(_nextPlayStatus != _playStatus)
            if (requestedNextPlayStatus != _playStatus)
            {
                _playStatus     = requestedNextPlayStatus;
                _nextPlayStatus = _playStatus;
                _isFirstFrame   = true;
            }
            else if (_isFirstFrame)
            {
                _isFirstFrame = false;
            }
        }