Example #1
0
        public void PLay(AnimationData inData)
        {
            if (_animationData == inData)
            {
                throw new Exception($"Animation Data must be not null !");
            }

            _animationData = inData;
            _currentFrame  = _animationData.GetRange().x;
            _frameDuration = _animationData.duration / _animationData.spriteSource.Length;
            _timeCounter   = 0f;

            DrawFrame();

            // --------------------------------------------------------------------------------
            // Play sfx (per loop)
            // --------------------------------------------------------------------------------
            if (!_animationData.perFrame && _animationData.concreteFrame == 0 && _animationData.sfx != SoundList.None)
            {
                SystemFacade.Sounds.PlaySfx(_animationData.sfx);
            }

            _isRun = true;
            OnPlayEvent?.Invoke(this._animationData);
        }
Example #2
0
    void Update()
    {
        switch (currentState)
        {
        case States.Start:
            OnStartEvent.Invoke();
            break;

        case States.Playing:
            OnPlayEvent.Invoke();
            break;

        case States.End:
            OnEndEvent.Invoke();
            break;

        default:
            throw new ArgumentOutOfRangeException();
        }
    }
 private void PlayEvent(EventData eventInfo)
 {
     OnPlayEvent?.Invoke(eventInfo.Type, eventInfo);
 }