public void PlayAnimation(ActorActions inAction, Action inCallback = null, float inDelay = 0f)
 {
     // --------------------------------------------------------------------------------
     // Play the given animation and prevent over calling
     // --------------------------------------------------------------------------------
     if (inAction == _currentAction)
     {
         Log("return " + inAction);
         return;
     }
     _lastAction    = _currentAction;
     _currentAction = inAction;
     _animator.RemoveEventsListener();
     if (inCallback != null)
     {
         _animator.OnCompleteEvent += inData =>
         {
             if (inDelay > 0f)
             {
                 _delayAmount   = inDelay;
                 _delayCallback = inCallback;
                 _delayCounter  = 0f;
                 _isDelay       = true;
             }
             else
             {
                 inCallback?.Invoke();
             }
         };
     }
     _animator.PLay(_view.Profile.GetAnimationData(inAction));
 }
Example #2
0
        public void PlayAnimation(ActorActions inAction, Action inCallback = null, float inDelay = 0f)
        {
            // --------------------------------------------------------------------------------
            // Play the given animation and prevent over calling
            // --------------------------------------------------------------------------------

            if (inAction == _currentAction)
            {
                return;
            }
            _lastAction    = _currentAction;
            _currentAction = inAction;
            if (profile == null)
            {
                throw new Exception($"Player profile must not null");
            }
            if (_animator == null)
            {
                throw new Exception($"Player needs GameAnimator Component to do this action !");
            }
            _animator.RemoveEventsListener();
            if (inCallback != null)
            {
                _animator.OnCompleteEvent += inData =>
                {
                    if (inDelay > 0f)
                    {
                        _delayAmount   = inDelay;
                        _delayCallback = inCallback;
                        _delayCounter  = 0f;
                        _isDelay       = true;
                    }
                    else
                    {
                        inCallback?.Invoke();
                    }
                };
            }
            _animator.PLay(profile.GetAnimationData(inAction));
        }