예제 #1
0
 public SimplePatrolAI(LevelObjectView view, SimplePatrolAIModel aiModel, SpriteAnimatorConfig animator)
 {
     _view     = view != null ? view : throw new ArgumentException(nameof(view));
     _aiModel  = aiModel != null ? aiModel : throw new ArgumentException(nameof(aiModel));
     _animator = animator != null ? new SpriteAnimator(animator) : throw new ArgumentException(nameof(animator));
     _animator.StartAnimation(_view.SpriteRenderer, AnimState.Run, true, _animationSpeed);
 }
예제 #2
0
 public PlayerAnimation(SpriteRenderer sprite, PlayerConfig config)
 {
     _playerAnimator = new SpriteAnimator(config.KnightAnimeCnf);
     _animationSpeed = config.AnimationSpeed;
     _spriteRenderer = sprite;
     _animationState = AnimState.Idle;
     _playerAnimator.StartAnimation(_spriteRenderer, _animationState, true, _animationSpeed);
 }
예제 #3
0
        public void OnChangeState(PlayerState state)
        {
            switch (state)
            {
            case PlayerState.Stay:
                _animationState = AnimState.Idle;
                break;

            case PlayerState.Walk:
                _animationState = AnimState.Run;
                break;

            case PlayerState.JumpUp:
                _animationState = AnimState.JumpUp;
                break;

            case PlayerState.JumpDown:
                _animationState = AnimState.JumpDown;
                break;

            case PlayerState.SwordAttack:
                _animationState = AnimState.Attack;
                break;

            case PlayerState.FireAttack:
                _animationState = AnimState.FireAttack;
                break;

            case PlayerState.Block:
                _animationState = AnimState.Block;
                break;

            case PlayerState.Win:
                _animationState = AnimState.Victory;
                break;

            default:
                throw new ArgumentOutOfRangeException(nameof(state), state, null);
            }

            _playerAnimator.StartAnimation(_spriteRenderer, _animationState, true, _animationSpeed);
        }
예제 #4
0
 public CoinAnimation(Transform coin, ItemConfig config)
 {
     _coinsAnimator  = new SpriteAnimator(config.ItemAnimatorCnf);
     _spriteRenderer = coin.GetComponentInChildren <SpriteRenderer>();
     _coinsAnimator.StartAnimation(_spriteRenderer, AnimState.Idle, true, config.ItemAnimationSpeed);
 }