//protected override bool CheckFinish() { // if (base.CheckFinish()) { // return true; // } // if (_primary != null) { // PlayAnimation(_primary.IdleAnimation, false); // return true; // } // if (IsSecondary) { // PlayAnimation(_otherAnimator.CurrentAnimationClipState); // //StopCurrentAnimation(); // //Controller.GetLayer(Layer).StartFade(0, FadeDuration); // } // else { // PlayAnimation(PlayerAnimationIds.Idle, false); // } // return false; //} protected override void PlayAnimation(AnimationClipState clip) { //bool syncClipState = !IsSecondary;// && _otherAnimator.CurrentAnimationClipState == CurrentAnimationClipState; base.PlayAnimation(clip); if (!IsSecondary) { _otherAnimator.PlayAnimation(clip); } //if (IsSecondary) { // Controller.GetLayer(Layer).SetWeight(1); //} }
private IEnumerator PlayAnimation(ClipAnimator animator, AnimationClipState state) { if (!Application.isPlaying) { AnimationMode.StartAnimationMode(); } int limiter = 0; _animationTime = 0; _canPlay = true; _currentAnimation = state; _currentFrame = 0; UnscaledTimer normalLimited = null; int lastFrame = 999; var weaponTrails = animator.GetComponentInChildren <WeaponModel>(true); while (limiter < 99999) { limiter++; if (_currentAnimation == null || !_canPlay) { break; } switch (_playType) { case PlayType.Percent: _animationTime = _forceTime; break; case PlayType.Normal: case PlayType.Limited: case PlayType.NormalLimited: _animationTime += TimeManager.DeltaUnscaled * state.PlaySpeedMultiplier; break; case PlayType.Frame: //_animationTime = state.ConvertFrameToAnimationTime(_currentFrame); _currentFrame = _forceFrame; break; } switch (_playType) { case PlayType.Limited: case PlayType.Percent: case PlayType.Normal: case PlayType.NormalLimited: if (_animationTime > state.ClipLength) { _animationTime -= state.ClipLength; } _currentFrame = _currentAnimation.CalculateCurrentFrame(_animationTime); switch (_playType) { case PlayType.Percent: case PlayType.Limited: if (_currentFrame < 0) { _animationTime = 0; continue; } break; } break; } switch (_playType) { default: if (_currentFrame != lastFrame) { _currentAnimation.Play(animator.Animator, _currentAnimation.ConvertFrameToAnimationTime(_currentFrame)); if (weaponTrails != null) { if (state.Events[_currentFrame] == AnimationEvents.FxOn) { weaponTrails.SetFx(true); } else if (state.Events[_currentFrame] == AnimationEvents.FxOff) { weaponTrails.SetFx(false); } } } break; case PlayType.Normal: _currentAnimation.Play(animator.Animator, _animationTime); break; case PlayType.NormalLimited: if (normalLimited == null) { normalLimited = new UnscaledTimer(1 / state.Fps); } if (!normalLimited.IsActive) { _currentAnimation.Play(animator.Animator, _animationTime); normalLimited.StartNewTime(1 / state.Fps); } break; } lastFrame = _currentFrame; SceneView.RepaintAll(); yield return(null); } if (!Application.isPlaying) { AnimationMode.StopAnimationMode(); } _currentAnimation = null; }