Beispiel #1
0
        /// <summary>
        /// 리스트를 초기화하자.
        /// </summary>
        public void InitAndLink()
        {
            if (_animPlayDataList == null)
            {
                _animPlayDataList = new List <apAnimPlayData>();
            }
            //_animPlayDataList.Clear();

            if (_animPlayQueues == null)
            {
                _animPlayQueues = new List <apAnimPlayQueue>();
            }
            else
            {
                //일단 모두 Release를 한다.
                for (int i = 0; i < _animPlayQueues.Count; i++)
                {
                    _animPlayQueues[i].ReleaseForce();
                }

                _animPlayQueues.Clear();
            }

            _animPlayQueues.Clear();
            for (int i = MIN_LAYER_INDEX; i <= MAX_LAYER_INDEX; i++)
            {
                apAnimPlayQueue newPlayQueue = new apAnimPlayQueue(i, _portrait, this);
                _animPlayQueues.Add(newPlayQueue);
            }

            _isInitAndLink = true;
        }
Beispiel #2
0
        public void Clear()
        {
            _parentAnimPlayQueue = null;

            //_tNextPlayStart = 0.0f;
            _tBlend               = 0.0f;
            _tLive                = 0.0f;
            _isNextUnitPlayed     = false;
            _isNextUnitFrameReset = false;

            _requestType = REQUEST_TYPE.New;

            _nextPlayUnit        = null;
            _prevWaitingPlayUnit = null;
            //_prevPlayUnits.Clear();
            _prevPlayUnitKeys.Clear();
            _prevPlayUnitWeight.Clear();

            _requestWeight  = 1.0f;
            _nextUnitWeight = 1.0f;
            _prevUnitWeight = 1.0f;

            _tActiveStart  = 0.0f;
            _tActiveEnd    = 0.0f;
            _tActiveMiddle = 0.0f;
            _status        = STATUS.Ready;

            _isNextPlayUnitIsInPrevUnit = false;

            //추가 1.15 사용자가 지정한 시작 프레임을 쓸 것인지 여부 (True면 StartFrame으로 강제됨)
            _isResetPlayAtStartFrame = true;
            _frameToStart            = -1;

            ReleaseChainedRequest();
        }
        public void Clear()
        {
            _parentAnimPlayQueue = null;

            //_tNextPlayStart = 0.0f;
            _tBlend               = 0.0f;
            _tLive                = 0.0f;
            _isNextUnitPlayed     = false;
            _isNextUnitFrameReset = false;

            _requestType = REQUEST_TYPE.New;

            _nextPlayUnit        = null;
            _prevWaitingPlayUnit = null;
            _prevPlayUnits.Clear();

            _requestWeight  = 1.0f;
            _nextUnitWeight = 1.0f;
            _prevUnitWeight = 1.0f;

            _tActiveStart  = 0.0f;
            _tActiveEnd    = 0.0f;
            _tActiveMiddle = 0.0f;
            _status        = STATUS.Ready;

            _isNextPlayUnitIsInPrevUnit = false;
        }
        /// <summary>
        /// Wait for the previous animation to finish, then play it smoothly.
        /// (If the previously playing animation is a loop animation, it will not be executed.)
        /// </summary>
        /// <param name="animClipName">Name of the Animation Clip</param>
        /// <param name="fadeTime">Fade Time</param>
        /// <param name="layer">The layer to which the animation is applied. From 0 to 20</param>
        /// <param name="blendMethod">How it is blended with the animation of the lower layers</param>
        /// <param name="isAutoEndIfNotloop">If True, animation that does not play repeatedly is automatically terminated.</param>
        /// <returns>Animation data to be played. If it fails, null is returned.</returns>
        public apAnimPlayData CrossFadeQueuedAt(apAnimPlayData playData, int frame, int layer, apAnimPlayUnit.BLEND_METHOD blendMethod, float fadeTime, bool isAutoEndIfNotloop = false)
        {
            if (playData == null)
            {
                Debug.LogError("CrossFadeQueuedAt Failed : Unknown AnimPlayData");
                return(null);
            }

            if (layer < MIN_LAYER_INDEX || layer > MAX_LAYER_INDEX)
            {
                Debug.LogError("CrossFadeQueuedAt Failed : Layer " + layer + " is invalid. Layer must be between " + MIN_LAYER_INDEX + " ~ " + MAX_LAYER_INDEX);
                return(null);
            }

            if (fadeTime < 0.0f)
            {
                fadeTime = 0.0f;
            }

            //Debug.Log("CrossFadeQueued [" + animClipName + "]");

            apAnimPlayQueue playQueue      = _animPlayQueues[layer];
            apAnimPlayUnit  resultPlayUnit = playQueue.PlayQueuedAt(playData, frame, blendMethod, fadeTime, isAutoEndIfNotloop);

            if (resultPlayUnit == null)
            {
                return(null);
            }

            RefreshPlayOrders();

            return(playData);
        }
        ////1.17 추가 : 이벤트 초기화 관련하여 정밀한 처리 위해 변수 추가됨
        //[NonSerialized]
        //private int _mecanimTimeRatioLoopCount = -1;

        //[NonSerialized]
        //private bool _isMecanimLoopingFrame = false;



        // Init
        //-----------------------------------------------
        public apAnimPlayUnit(apAnimPlayQueue parentQueue, int requestedOrder, int linkKey)
        {
            _parentQueue    = parentQueue;
            _requestedOrder = requestedOrder;
            _linkKey        = linkKey;

            //_isMecanimPlayUnit = false;
        }
        /// <summary>
        /// Event : Animation is started
        /// </summary>
        /// <param name="playUnit"></param>
        /// <param name="playQueue"></param>
        public void OnAnimPlayUnitPlayStart(apAnimPlayUnit playUnit, apAnimPlayQueue playQueue)
        {
            //Play Unit이 재생을 시작했다.
            //Delay 이후에 업데이트되는 첫 프레임에 이 이벤트가 호출된다.

            // > Root Unit이 바뀔 수 있으므로 Play Manager에도 신고를 해야한다.
            SetOptRootUnit(playUnit._targetRootUnit);
        }
        public void SetCurrentPlayedUnits(apAnimPlayQueue parentAnimPlayQueue, List <apAnimPlayUnit> prevPlayUnits)
        {
            _parentAnimPlayQueue = parentAnimPlayQueue;

            _prevPlayUnits.Clear();
            for (int i = 0; i < prevPlayUnits.Count; i++)
            {
                prevPlayUnits[i]._ownerRequest = this;
                _prevPlayUnits.Add(prevPlayUnits[i]);
            }
        }
Beispiel #8
0
        /// <summary>
        /// Wait for the previous animation to finish, then play it smoothly.
        /// (If the previously playing animation is a loop animation, it will not be executed.)
        /// </summary>
        /// <param name="animClipName">Name of the Animation Clip</param>
        /// <param name="fadeTime">Fade Time</param>
        /// <param name="layer">The layer to which the animation is applied. From 0 to 20</param>
        /// <param name="blendMethod">How it is blended with the animation of the lower layers</param>
        /// <param name="isAutoEndIfNotloop">If True, animation that does not play repeatedly is automatically terminated.</param>
        /// <returns>Animation data to be played. If it fails, null is returned.</returns>
        public apAnimPlayData CrossFadeQueued(string animClipName, int layer, apAnimPlayUnit.BLEND_METHOD blendMethod, float fadeTime, bool isAutoEndIfNotloop = false)
        {
            //Debug.LogError("Start CrossFadeQueued [" + animClipName + "]");

            apAnimPlayData playData = GetAnimPlayData_Opt(animClipName);

            if (playData == null)
            {
                Debug.LogError("CrossFade Failed : No AnimClip [" + animClipName + "]");
                return(null);
            }

            if (layer < MIN_LAYER_INDEX || layer > MAX_LAYER_INDEX)
            {
                Debug.LogError("CrossFade Failed : Layer " + layer + " is invalid. Layer must be between " + MIN_LAYER_INDEX + " ~ " + MAX_LAYER_INDEX);
                return(null);
            }

            if (fadeTime < 0.0f)
            {
                fadeTime = 0.0f;
            }

            //Debug.Log("CrossFadeQueued [" + animClipName + "]");

            apAnimPlayQueue playQueue      = _animPlayQueues[layer];
            apAnimPlayUnit  resultPlayUnit = playQueue.PlayQueued(playData, blendMethod, fadeTime, isAutoEndIfNotloop);

            if (resultPlayUnit == null)
            {
                return(null);
            }

            //float delayTime = resultPlayUnit.DelayToPlayTime;
            //float delayTime = Mathf.Clamp01(resultPlayUnit.RemainPlayTime - fadeTime);

            //if (playOption == PLAY_OPTION.StopAllLayers)
            //{
            //	//다른 레이어를 모두 정지시킨다. - 단, 딜레이를 준다.
            //	for (int i = 0; i < _animPlayQueues.Count; i++)
            //	{
            //		if (i == layer)
            //		{ continue; }
            //		_animPlayQueues[i].StopAll(delayTime);
            //	}
            //}

            RefreshPlayOrders();

            return(playData);
        }
Beispiel #9
0
        /// <summary>
        /// AnimClip 이름을 인자로 받아서 애니메이션을 재생한다.
        /// Fade 타임을 받아서 다른 모든 클립에서 자연스럽게 변환된다.
        /// </summary>
        /// <param name="animClipName">Clip 이름. 맞지 않을 경우 처리 실패</param>
        /// <param name="layer">실행되는 레이어. 0부터 실행되며 최대값은 20</param>
        /// <param name="blendMethod">다른 레이어와 블렌드시 옵션</param>
        /// <param name="playOption">StopAllLayer인 경우 요청된 레이어 외의 Clip들이 다음 Clip이 실행되는 순간 같이 종료된다.</param>
        /// <param name="isAutoEndIfNotloop">[Loop 타입이 아닌 경우] True이면 재생 종료시 자동으로 처리 데이터가 삭제된다.</param>
        /// <param name="fadeTime">페이드 시간. 기본값은 0.3</param>
        /// <returns></returns>
        public apAnimPlayData CrossFade(string animClipName, int layer, apAnimPlayUnit.BLEND_METHOD blendMethod, float fadeTime, PLAY_OPTION playOption = PLAY_OPTION.StopSameLayer, bool isAutoEndIfNotloop = false)
        {
            apAnimPlayData playData = GetAnimPlayData_Opt(animClipName);

            if (playData == null)
            {
                Debug.LogError("CrossFade Failed : No AnimClip [" + animClipName + "]");
                return(null);
            }

            if (layer < MIN_LAYER_INDEX || layer > MAX_LAYER_INDEX)
            {
                Debug.LogError("CrossFade Failed : Layer " + layer + " is invalid. Layer must be between " + MIN_LAYER_INDEX + " ~ " + MAX_LAYER_INDEX);
                return(null);
            }

            if (fadeTime < 0.0f)
            {
                fadeTime = 0.0f;
            }

            apAnimPlayQueue playQueue      = _animPlayQueues[layer];
            apAnimPlayUnit  resultPlayUnit = playQueue.Play(playData, blendMethod, fadeTime, isAutoEndIfNotloop);

            if (resultPlayUnit == null)
            {
                return(null);
            }


            //float fadeInTime = resultPlayUnit.FadeInTime;

            if (playOption == PLAY_OPTION.StopAllLayers)
            {
                //다른 레이어를 모두 정지시킨다. - 단, 딜레이를 준다.
                for (int i = 0; i < _animPlayQueues.Count; i++)
                {
                    if (i == layer)
                    {
                        continue;
                    }
                    _animPlayQueues[i].StopAll(fadeTime);
                }
            }

            RefreshPlayOrders();

            return(playData);
        }
        /// <summary>
        /// Play the animation
        /// </summary>
        /// <param name="animClipName">Name of the Animation Clip</param>
        /// <param name="layer">The layer to which the animation is applied. From 0 to 20</param>
        /// <param name="blendMethod">How it is blended with the animation of the lower layers</param>
        /// <param name="playOption">How to stop which animations</param>
        /// <param name="isAutoEndIfNotloop">If True, animation that does not play repeatedly is automatically terminated.</param>
        /// <returns>Animation data to be played. If it fails, null is returned.</returns>
        public apAnimPlayData Play(apAnimPlayData playData, int layer, apAnimPlayUnit.BLEND_METHOD blendMethod, PLAY_OPTION playOption = PLAY_OPTION.StopSameLayer, bool isAutoEndIfNotloop = false, bool isDebugMsg = true)
        {
            if (playData == null)
            {
                if (isDebugMsg)
                {
                    Debug.LogError("Play Failed : Unknown AnimPlayData");
                }
                return(null);
            }

            if (layer < MIN_LAYER_INDEX || layer > MAX_LAYER_INDEX)
            {
                if (isDebugMsg)
                {
                    Debug.LogError("Play Failed : Layer " + layer + " is invalid. Layer must be between " + MIN_LAYER_INDEX + " ~ " + MAX_LAYER_INDEX);
                }
                return(null);
            }

            apAnimPlayQueue playQueue      = _animPlayQueues[layer];
            apAnimPlayUnit  resultPlayUnit = playQueue.Play(playData, blendMethod, 0.0f, isAutoEndIfNotloop);

            if (resultPlayUnit == null)
            {
                return(null);
            }



            if (playOption == PLAY_OPTION.StopAllLayers)
            {
                //다른 레이어를 모두 정지시킨다.
                for (int i = 0; i < _animPlayQueues.Count; i++)
                {
                    if (i == layer)
                    {
                        continue;
                    }
                    _animPlayQueues[i].StopAll(0.0f);
                }
            }

            RefreshPlayOrders();

            return(playData);
        }
Beispiel #11
0
        //public void SetCurrentPlayedUnits(apAnimPlayQueue parentAnimPlayQueue, List<apAnimPlayUnit> prevPlayUnits)
        public void SetCurrentPlayedUnits(apAnimPlayQueue parentAnimPlayQueue)
        {
            _parentAnimPlayQueue = parentAnimPlayQueue;

            ////리퀘스트가 들어왔는데, 대기->시작 단계를 거치기 전에 다른 Request가 들어와서 점유해버리면 재생이 되지 않는다.
            //_prevPlayUnits.Clear();

            //apAnimPlayUnit curUnit = null;


            //for (int i = 0; i < prevPlayUnits.Count; i++)
            //{
            //	curUnit = prevPlayUnits[i];
            //	curUnit.SetOwnerRequest_Prev(this);
            //		_prevPlayUnits.Add(curUnit);
            //}
            _prevPlayUnitKeys.Clear();
            _prevPlayUnitWeight.Clear();
        }
        /// <summary>
        /// Wait for the previous animation to finish, then play it.
        /// (If the previously playing animation is a loop animation, it will not be executed.)
        /// </summary>
        /// <param name="animClipName">Name of the Animation Clip</param>
        /// <param name="layer">The layer to which the animation is applied. From 0 to 20</param>
        /// <param name="blendMethod">How it is blended with the animation of the lower layers</param>
        /// <param name="isAutoEndIfNotloop">If True, animation that does not play repeatedly is automatically terminated.</param>
        /// <returns>Animation data to be played. If it fails, null is returned.</returns>
        public apAnimPlayData PlayQueued(apAnimPlayData playData, int layer, apAnimPlayUnit.BLEND_METHOD blendMethod, bool isAutoEndIfNotloop = false)
        {
            if (playData == null)
            {
                Debug.LogError("PlayQueued Failed : Unknown AnimPlayData");
                return(null);
            }

            if (layer < MIN_LAYER_INDEX || layer > MAX_LAYER_INDEX)
            {
                Debug.LogError("PlayQueued Failed : Layer " + layer + " is invalid. Layer must be between " + MIN_LAYER_INDEX + " ~ " + MAX_LAYER_INDEX);
                return(null);
            }

            apAnimPlayQueue playQueue      = _animPlayQueues[layer];
            apAnimPlayUnit  resultPlayUnit = playQueue.PlayQueued(playData, blendMethod, 0.0f, isAutoEndIfNotloop);

            if (resultPlayUnit == null)
            {
                return(null);
            }



            //if (playOption == PLAY_OPTION.StopAllLayers)
            //{
            //	//다른 레이어를 모두 정지시킨다. - 단, 딜레이를 준다.
            //	for (int i = 0; i < _animPlayQueues.Count; i++)
            //	{
            //		if (i == layer)
            //		{ continue; }
            //		_animPlayQueues[i].StopAll(delayTime);
            //	}
            //}

            RefreshPlayOrders();

            return(playData);
        }
 /// <summary>
 /// Event : Animation is ended
 /// </summary>
 /// <param name="playUnit"></param>
 /// <param name="playQueue"></param>
 public void OnAnimPlayUnitEnded(apAnimPlayUnit playUnit, apAnimPlayQueue playQueue)
 {
     //Play Unit이 재생을 종료했다
     //1. apAnimPlayUnit을 사용하고 있던 Modifier와의 연동을 해제한다.
     //??
 }
        //public float FadeInTime { get { return _fadeInTime; } }
        //public float FadeOutTime { get { return _fadeOutTime; } }
        //public float DelayToPlayTime { get { return _delayToPlayTime; } }
        //public float DelayToEndTime {  get { return _delayToEndTime; } }

        // Init
        //-----------------------------------------------
        public apAnimPlayUnit(apAnimPlayQueue parentQueue)
        {
            _parentQueue = parentQueue;
        }