Ejemplo n.º 1
0
        // Init
        //-------------------------------------------------
        public apModifierParamSetGroup(apPortrait portrait, apModifierBase parentModifier, int layerIndex)
        {
            LinkPortrait(portrait, parentModifier);

            _layerIndex  = layerIndex;
            _layerWeight = 1.0f;
            _blendMethod = BLEND_METHOD.Interpolation;
        }
Ejemplo n.º 2
0
 public void SetSubOption(BLEND_METHOD blendMethod, bool isAutoEndIfNotLoop)
 {
     _blendMethod = blendMethod;
     _isAutoEnd   = isAutoEndIfNotLoop;
     if (_isLoop)
     {
         _isAutoEnd = false;                //<<Loop일때 AutoEnd는 불가능하다
     }
 }
        /// <summary>
        /// [Please do not use it] Set AnimClip to get data
        /// </summary>
        /// <param name="playData"></param>
        /// <param name="layer"></param>
        /// <param name="blendMethod"></param>
        /// <param name="isAutoEndIfNotLoop"></param>
        /// <param name="isEditor"></param>
        public void SetAnimClip(apAnimPlayData playData, int layer, BLEND_METHOD blendMethod, bool isAutoEndIfNotLoop, bool isEditor)
        {
            _linkedAnimClip = playData._linkedAnimClip;
            _targetRootUnit = playData._linkedOptRootUnit;

            //추가
            if (_linkedAnimClip._parentPlayUnit != null &&
                _linkedAnimClip._parentPlayUnit != this)
            {
                //이미 다른 PlayUnit이 사용중이었다면..
                _linkedAnimClip._parentPlayUnit.SetEnd();
                //_linkedAnimClip._parentPlayUnit._linkedAnimClip = null;
            }
            _linkedAnimClip._parentPlayUnit = this;

            _layer = layer;

            _isLoop    = _linkedAnimClip.IsLoop;
            _isAutoEnd = isAutoEndIfNotLoop;
            if (_isLoop)
            {
                _isAutoEnd = false;                //<<Loop일때 AutoEnd는 불가능하다
            }


            _blendMethod = blendMethod;

            _isPause                = false;
            _playStatus             = PLAY_STATUS.Ready;
            _isPlayStartEventCalled = false;
            _isEndEventCalled       = false;


            //_speedRatio = 1.0f;

            _isFirstFrame   = true;
            _nextPlayStatus = _playStatus;

            //추가 1.14
            _isResetFrameOnReadyStatus = true;

            if (isEditor)
            {
                _linkedAnimClip.Stop_Editor(false);                //Stop은 하되 업데이트는 하지 않는다. (false)
            }
            else
            {
                _linkedAnimClip.Stop_Opt(false);
            }

            _unitWeight          = 0.0f;
            _totalRequestWeights = 0.0f;
        }
Ejemplo n.º 4
0
        //3) Layer_CalParamResult
        public void Calculate_CalParamResult(float layerWeight,
                                             int iLayer,
                                             apModifierBase.BLEND_METHOD blendMethod,
                                             apCalculatedLog resultStackLayerLog
                                             )
        {
            _weight = layerWeight;
            _calResultParamLayerIndex = iLayer;
            //_calResultParamBlendType = blendMethod;
            switch (blendMethod)
            {
            case apModifierBase.BLEND_METHOD.Additive:
                _layerBlendType = BLEND_METHOD.Additive;
                break;

            case apModifierBase.BLEND_METHOD.Interpolation:
                _layerBlendType = BLEND_METHOD.Interpolation;
                break;
            }
            resultStackLayerLog.LinkLog_ResultParam(this);
        }
Ejemplo n.º 5
0
        //2) Layer_ParamSetGroup
        public void CalculateParamSetGroup(float layerWeight,
                                           int iLayer,
                                           apModifierParamSetGroup.BLEND_METHOD blendType,
                                           apModifierParamSetGroupVertWeight paramSetGroupVertWeight,
                                           apCalculatedLog calPraramResultLog
                                           )
        {
            _weight = layerWeight;
            _paramSetGroupLayerIndex = iLayer;
            switch (blendType)
            {
            case apModifierParamSetGroup.BLEND_METHOD.Additive:
                _layerBlendType = BLEND_METHOD.Additive;
                break;

            case apModifierParamSetGroup.BLEND_METHOD.Interpolation:
                _layerBlendType = BLEND_METHOD.Interpolation;
                break;
            }
            //_paramSetGroupBlendType = blendType;
            _paramSetGroupVertWeight = paramSetGroupVertWeight;            //<<보통은 Null
            LinkLog_ModLayerParent(calPraramResultLog);
        }
        public void Mecanim_Update(float weight, float timeRatio, int playOrder, int playLayer, BLEND_METHOD blendMethod, float speed)
        {
            if (_linkedAnimClip == null)
            {
                //Debug.LogError("No AnimClip");
                return;
            }
            _unitWeight          = weight;
            _totalRequestWeights = 1.0f;

            _blendMethod = blendMethod;
            _playOrder   = playOrder;
            _layer       = playLayer;

            _isMecanimResetable = false;
            //_isMecanimLoopingFrame = false;

            //2.28 일단 이거 제외 [1.1.6]
            //1.1.4 / 1.1.5에서 메카님 음수 speed에 적용하려고 만든 것 같은데, 오작동을 일으킨다.
            //Debug.Log("Mecanim [" + timeRatio + " ( " + speed + " )]");
            //if((speed > 0.0f && timeRatio < _timeRatioPrev) ||
            //	(speed < 0.0f && timeRatio > _timeRatioPrev))
            //{
            //	//Debug.LogWarning("[" + _linkedAnimClip._name + "] 메카님 Speed와 TimeRatio 증감이 반대 : " + (timeRatio - _timeRatioPrev) + " / Speed : " + speed);
            //	//Debug.LogWarning("[" + _linkedAnimClip._name + "] 메카님 Speed와 TimeRatio 증감이 반대 : " + _timeRatioPrev + " >> " + timeRatio + " / Speed : " + speed);
            //	//Speed와 맞지 않은 증감폭이다.

            //	//이전
            //	//timeRatio = _timeRatioPrev - (timeRatio - _timeRatioPrev);<<이게 문제.. 근데 왜..
            //}
            //_timeRatioPrev = timeRatio;//<<1.1.6에서 삭제


            if (_linkedAnimClip.IsLoop)
            {
                //int curTimeRatioLoopCount = (int)timeRatio;
                //if(_mecanimTimeRatioLoopCount != curTimeRatioLoopCount)
                //{
                //	Debug.LogError("[Index Changed] _isMecanimLoopingFrame > True : " + timeRatio + " (" + _mecanimTimeRatioLoopCount + " >> " + curTimeRatioLoopCount + ")");
                //	//루프 카운트가 바뀌었다. > //이번 프레임에서 루프가 된다.
                //	_isMecanimLoopingFrame = true;
                //	_mecanimTimeRatioLoopCount = curTimeRatioLoopCount;
                //}
                //else
                //{
                //	if(
                //		(speed > 0.0f && timeRatio < 0.0f) ||
                //		(speed < 0.0f && timeRatio > 0.0f)
                //		)
                //	{
                //		Debug.LogError("[Speed And Time Inverted] _isMecanimLoopingFrame > True : " + timeRatio + " (Speed : " + speed + ")");
                //		//앞으로 진행하는데, timeRatio가 뒤로 가거나 또는 그 반대
                //		//Loop가 발생한 것이다.
                //		_isMecanimLoopingFrame = true;
                //	}
                //}

                if (timeRatio > 1.0f)
                {
                    timeRatio -= (int)timeRatio;
                }
                else if (timeRatio < 0.0f)
                {
                    timeRatio = (1.0f - Mathf.Abs(timeRatio) - (int)Mathf.Abs(timeRatio));
                }
            }
            else
            {
                if (timeRatio > 1.0f)
                {
                    //timeRatio = 2.0f;//이전
                    timeRatio = 1.0f;                    //변경
                }
                else if (timeRatio < 0.0f)
                {
                    //timeRatio = -1.0f;//이전
                    timeRatio = 0.0f;                    //변경
                }
                else
                {
                    //Time Ratio가 0~1의 값을 가지면 Reset이 가능하다.
                    _isMecanimResetable = true;
                }
            }

            _mecanimTime = timeRatio * _mecanimTimeLength;



            bool isResetFrame = false;

            if (!_linkedAnimClip.IsLoop && _isMecanimResetable)
            {
                if (speed > 0.0f)
                {
                    if (_mecanimTime < _mecanimTimePrev)
                    {
                        isResetFrame = true;
                        _linkedAnimClip.ResetEvents();
                        _linkedAnimClip.ResetFrame();
                    }
                }
                else if (speed < 0.0f)
                {
                    if (_mecanimTime > _mecanimTimePrev)
                    {
                        isResetFrame = true;
                        _linkedAnimClip.ResetEvents();
                        _linkedAnimClip.ResetFrame();
                    }
                }
            }
            //if(_isMecanimLoopingFrame)
            //{
            //	Debug.LogError(">> Reset Event");
            //	_linkedAnimClip.ResetEvents();
            //}

            //TODO : 여기서 tDelta로만 Forward/Backward를 결정하는게 아니라, 메카님의 Speed로 방향을 인식하도록 바꾸어야 한다.
            if (!isResetFrame)
            {
                _mecanimDeltaTime = _mecanimTime - _mecanimTimePrev;
                if (_mecanimTimeLength > 0.0f)
                {
                    if (_mecanimDeltaTime < 0.0f && speed > 0.0f)
                    {
                        //진행 방향과 시간이 반대라면
                        while (_mecanimDeltaTime < 0.0f)
                        {
                            _mecanimDeltaTime += _mecanimTimeLength;
                        }
                    }
                    else if (_mecanimDeltaTime > 0.0f && speed < 0.0f)
                    {
                        //진행 방향과 시간이 반대라면
                        while (_mecanimDeltaTime > 0.0f)
                        {
                            _mecanimDeltaTime -= _mecanimTimeLength;
                        }
                    }
                }

                //변경 1.17 : 일반 Update_Opt에서 UpdateMecanim_Opt로 변경한다.
                //_linkedAnimClip.UpdateMecanim_Opt(_mecanimTime - _mecanimTimePrev, speed);
            }
            else
            {
                _mecanimDeltaTime = _mecanimTime;
                //변경 1.17 : 일반 Update_Opt에서 UpdateMecanim_Opt로 변경한다.
                //_linkedAnimClip.UpdateMecanim_Opt(_mecanimTime, speed);
            }
            _linkedAnimClip.UpdateMecanim_Opt(_mecanimDeltaTime, speed);

            _mecanimTimePrev = _mecanimTime;
        }
Ejemplo n.º 7
0
        public void Mecanim_Update(float weight, float timeRatio, int playOrder, int playLayer, BLEND_METHOD blendMethod, float speed)
        {
            if (_linkedAnimClip == null)
            {
                //Debug.LogError("No AnimClip");
                return;
            }
            _unitWeight          = weight;
            _totalRequestWeights = 1.0f;

            _blendMethod = blendMethod;
            _playOrder   = playOrder;
            _layer       = playLayer;

            _isMecanimResetable = false;

            if (_linkedAnimClip.IsLoop)
            {
                if (timeRatio > 1.0f)
                {
                    timeRatio -= (int)timeRatio;
                }
                else if (timeRatio < 0.0f)
                {
                    timeRatio = (1.0f - Mathf.Abs(timeRatio) - (int)Mathf.Abs(timeRatio));
                }
            }
            else
            {
                if (timeRatio > 1.0f)
                {
                    timeRatio = 2.0f;
                }
                else if (timeRatio < 0.0f)
                {
                    timeRatio = -1.0f;
                }
                else
                {
                    //Time Ratio가 0~1의 값을 가지면 Reset이 가능하다.
                    _isMecanimResetable = true;
                }
            }

            _mecanimTime = timeRatio * _mecanimTimeLength;


            bool isResetFrame = false;

            if (!_linkedAnimClip.IsLoop && _isMecanimResetable)
            {
                if (speed > 0.0f)
                {
                    if (_mecanimTime < _mecanimTimePrev)
                    {
                        isResetFrame = true;
                        _linkedAnimClip.ResetEvents();
                        _linkedAnimClip.ResetFrame();
                    }
                }
                else if (speed < 0.0f)
                {
                    if (_mecanimTime > _mecanimTimePrev)
                    {
                        isResetFrame = true;
                        _linkedAnimClip.ResetEvents();
                        _linkedAnimClip.ResetFrame();
                    }
                }
            }

            //Debug.Log("Mecanim_Update - " + timeRatio);
            //_linkedAnimClip.UpdateFrame_OptMecanim(_mecanimTime - _mecanimTimePrev, speed);
            if (!isResetFrame)
            {
                _linkedAnimClip.Update_Opt(_mecanimTime - _mecanimTimePrev);                //<<기존
            }
            else
            {
                //Debug.Log("Reset Frame : _mecanimTime : " + _mecanimTime);
                _linkedAnimClip.Update_Opt(_mecanimTime);
            }

            //_linkedAnimClip.Update_Opt(Time.deltaTime * speed);//<<테스트
            _mecanimTimePrev = _mecanimTime;
        }