Ejemplo n.º 1
0
        private void HandleAnimationFadeinEvent(AnimationEventArg eventArgs)
        {
            SetBlockInput(eventArgs._animation.blockInputOnStart);
            SetDelayInput(eventArgs._animation.delayInputOnStart);
            SetFrozen(eventArgs._animation.frozenOnStart);
            _mover.AirAttacking = eventArgs._animation.airAttack;

            switch (eventArgs._animation.name)
            {
            case PlayerFSMData.Anim.ATK_Charge_Ground_ATK:
            case PlayerFSMData.Anim.ATK_Melee_Air_1:
            case PlayerFSMData.Anim.ATK_Melee_Air_2:
            case PlayerFSMData.Anim.ATK_Melee_Air_3:
            case PlayerFSMData.Anim.ATK_Melee_Ground_1:
            case PlayerFSMData.Anim.ATK_Melee_Ground_2:
            case PlayerFSMData.Anim.ATK_Melee_Ground_3:
                _state._attacking = true;
                break;

            default:
                _state._attacking = false;
                break;
            }

            switch (eventArgs._animation.name)
            {
            case PlayerFSMData.Anim.Healing:
                _state._stamina -= _healingStaminaCost;
                break;
            }
        }
        private void RemoveConflictedTimerPairs(AnimationEventArg eventArgs)
        {
            var list = _timerPairList.FindAll((x) =>
            {
                return(x.Key._animationName == eventArgs._animation.name);
            });

            foreach (var item in list)
            {
                var timerBegin =
                    item.Key._state == Animation.AnimationState.FadingIn ||
                    item.Key._state == Animation.AnimationState.FadeInComplete;
                var timerEnd =
                    item.Key._state == Animation.AnimationState.FadingOut ||
                    item.Key._state == Animation.AnimationState.FadeOutComplete;
                var animBegin =
                    eventArgs._state == Animation.AnimationState.FadingIn ||
                    eventArgs._state == Animation.AnimationState.FadeInComplete;
                var animEnd =
                    eventArgs._state == Animation.AnimationState.FadingOut ||
                    eventArgs._state == Animation.AnimationState.FadeOutComplete;

                if ((timerBegin && animEnd) || (timerEnd && animBegin))
                {
                    _timerPairList.Remove(item);
                    item.Value.Abort();
                    item.Value.Dispose();
                }
            }
        }
        private void HandleFadeInAnimation(AnimationEventArg eventArgs)
        {
            SetFrozen(eventArgs._animation.frozenOnStart);
            SetBlockInput(eventArgs._animation.blockInputOnStart);
            SetDelayInput(eventArgs._animation.delayInputOnStart);

            var aim           = _input.GetAimingDirection();
            var moveDirection = NormalizeHorizonalDirection(aim);

            switch (eventArgs._animation.name)
            {
            case BossFSMData.Anim.Slash1:
            case BossFSMData.Anim.Slash2:
                UpdateFacingDirection(aim);
                _mover.InvokeConstantMovement(moveDirection, _slashSpeed, _slashTime);
                break;

            case BossFSMData.Anim.Combo2_1:
                UpdateFacingDirection(aim);
                _mover.InvokeConstantMovement(Vector2.up, _combo2RaiseSpeed, _combo2RaiseTime);
                _stalkTracker.Initialize(transform.position);
                _stalking = true;
                break;

            case BossFSMData.Anim.Combo2_2:
                UpdateFacingDirection(aim);
                _mover.InvokeConstantMovement(Vector2.up, _combo2PauseSpeed, _combo2PauseTime);
                break;

            case BossFSMData.Anim.Combo2_3:
                var     player   = GameManager.PlayerInstance;
                Vector2 toPlayer = player.transform.position - transform.position;

                UpdateFacingDirection(toPlayer);
                toPlayer += _state._facingRight ? _combo2CrushOffset : -_combo2CrushOffset;
                var speed = (toPlayer.magnitude / _combo2CrushTime) * _combo2SpeedScaler;

                speed = Mathf.Clamp(speed, _minCrushSpeed, _maxCrushSpeed);

                _combo2CrushSpeed.constant        = speed;
                _combo2CrushSpeed.curveMultiplier = speed;
                _mover.InvokeConstantMovement(toPlayer, _combo2CrushSpeed, _combo2CrushTime);

                _stalking = false;
                break;

            case BossFSMData.Anim.Combo3_2:
                UpdateFacingDirection(aim);
                _mover.InvokeConstantMovement(moveDirection, _thrustSpeed, _thrustTime);
                break;

            case BossFSMData.Anim.Retreat:
                UpdateFacingDirection(aim);
                _mover.InvokeConstantMovement(-moveDirection, _retreatSpeed, _retreatTime);

                break;
            }
        }
Ejemplo n.º 4
0
        private void HandleAnimationEvent(AnimationEventArg eventArgs)
        {
            if (eventArgs._animation.name != "Monster1_Death_Ground")
            {
                return;
            }

            Destroy(this.gameObject);
        }
Ejemplo n.º 5
0
 private void HandleAnimationCompletedEvent(AnimationEventArg eventArgs)
 {
     if (eventArgs._animation.name == PlayerFSMData.Anim.Death)
     {
         foreach (var handler in GetComponents <ICanHandleDeath>())
         {
             handler.OnDeath(_state);
         }
     }
 }
 private void HandleAnimationFadeInEvent(AnimationEventArg eventArgs)
 {
     if (eventArgs._animation.name == PlayerFSMData.Anim.Healing)
     {
         _particles["Regenerate"].Play();
         _playerAudioSource.clip   = _audios["Regenerate"];
         _playerAudioSource.volume = _volume["Regenerate"];
         _playerAudioSource.pitch  = _pitch["Regenerate"];
         _playerAudioSource.Play();
     }
 }
 private void HandleCompletedAnimation(AnimationEventArg eventArgs)
 {
     if (eventArgs._animation.name != BossFSMData.Anim.Death)
     {
         return;
     }
     foreach (var handler in GetComponents <ICanHandleDeath>())
     {
         handler.OnDeath(_state);
     }
 }
Ejemplo n.º 8
0
 private void HandleFadeInAnimation(AnimationEventArg eventArgs)
 {
     if (eventArgs._animation.name == BossFSMData.Anim.Combo2_1)
     {
         bossAudioSource.clip   = _audios["Combo2"];
         bossAudioSource.volume = _audiosVolume["Combo2"];
         bossAudioSource.pitch  = _pitch["Combo2"];
         bossAudioSource.Play();
     }
     if (eventArgs._animation.name == BossFSMData.Anim.Combo3_1)
     {
         bossAudioSource.clip   = _audios["Combo3"];
         bossAudioSource.volume = _audiosVolume["Combo3"];
         bossAudioSource.pitch  = _pitch["Combo3"];
         bossAudioSource.Play();
     }
 }
        private void HandleAnimationStateEvent(AnimationEventArg eventArgs)
        {
            RemoveConflictedTimerPairs(eventArgs);

            foreach (var formation in _formationList)
            {
                if (formation.Value._state != eventArgs._state ||
                    eventArgs._animation.name != formation.Value._animationName)
                {
                    continue;
                }

                Timer timer = new Timer();
                timer.Start(formation.Value._delay);
                _timerPairList.Add(new PairedValue <WeakpointFormation, Timer>(formation.Value, timer));
            }
        }