public void RemoveState(CharacterState state)
 {
     if (states.Contains(state))
     {
         state.Deactivate();
         states.Remove(state);
     }
 }
 private void AddStateToHistory(CharacterState state)
 {
     stateHistory.Enqueue(state);
     if (stateHistory.Count > 10)
     {
         stateHistory.Dequeue();
     }
 }
 public SpriteAnimationSequence GetTransitionAnimationSequence(CharacterState lastStateAnimation)
 {
     if (lastStateAnimation == null || !SpriteTransitionAnimationSequences.ContainsKey(lastStateAnimation))
     {
         throw new SpriteAnimationNotAvailableException();
     }
     return SpriteTransitionAnimationSequences[lastStateAnimation];
 }
 private void ChangeAnimation(CharacterState newState)
 {
     if (currentStateAnimation != newState)
     {
         lastStateAnimation = currentStateAnimation;
         currentStateAnimation = newState;
         spriteAnimator.Reset();
     }
 }
 public void AddState(CharacterState state, bool overwrite = false) {
     if (states.Contains(state) && overwrite)
     {
         RemoveState(state);
     }
     if (!states.Contains(state))
     {
         states.Add(state);
         AddStateToHistory(state); 
     }
 }
        private void InitializeStates()
        {
            SpriteAnimationSettings defaultAnimationSettings = new SpriteAnimationSettings(true);

            hitMissState = new CharacterState("Hit Miss", HIT_MISS_STATE_PRIORITY, HIT_MISS_STATE_ANIMATION_PRIORITY, defaultAnimationSettings);
            hitMissState.SpriteAnimationSequences = new List<SpriteAnimationSequence> { hitMissSequence };
            hitState = new CharacterState("Hit", HIT_STATE_PRIORITY, HIT_STATE_ANIMATION_PRIORITY, defaultAnimationSettings);
            hitState.SpriteAnimationSequences = new List<SpriteAnimationSequence> { hitSequence1, hitSequence2, hitSequence3 };
            comboHitState = new CharacterState("Combo Hit", COMBO_HIT_STATE_PRIORITY, COMBO_HIT_STATE_ANIMATION_PRIORITY, defaultAnimationSettings);
            comboHitState.SpriteAnimationSequences = new List<SpriteAnimationSequence> { comboHitSequence1, comboHitSequence2 };
            comboHitState.AddIncompatibleStates(new CharacterState[] { hitState, hitMissState });
            hypeAttackState = new CharacterState("Hype Attack State", HYPE_ATTACK_STATE_PRIORITY, HYPE_ATTACK_STATE_ANIMATION_PRIORITY, defaultAnimationSettings);
            hypeAttackState.SpriteAnimationSequences = new List<SpriteAnimationSequence> { hypeAttackSequence };
            hypeAttackState.AddIncompatibleStates(new CharacterState[] { hitState, hitMissState });
            deadState = new CharacterState("Dead", DEAD_STATE_PRIORITY, DEAD_STATE_ANIMATION_PRIORITY, defaultAnimationSettings);
            deadState.SpriteAnimationSequences = new List<SpriteAnimationSequence> { deathSequence };
            deadState.AddIncompatibleStates(new CharacterState[] { hitState, hitMissState , comboHitState, hypeAttackState });
            idleState = new CharacterState("Idle", IDLE_STATE_PRIORITY, IDLE_STATE_ANIMATION_PRIORITY, defaultAnimationSettings);
            idleState.SpriteAnimationSequences = new List<SpriteAnimationSequence> { idleSequence1, idleSequence2 };
            bossStateController.AddState(idleState);
        }
        private void AnimateState(CharacterState state)
        {
            try {
                spriteAnimator.Sequences = state.GetSpriteAnimationSequences();
            }
            catch (SpriteAnimationNotAvailableException)
            {
                return;
            }

            try
            {
                spriteAnimator.TransitionSequence = state.GetTransitionAnimationSequence(lastStateAnimation);
            }
            catch (SpriteAnimationNotAvailableException)
            {
                spriteAnimator.TransitionSequence = null;
            }

            spriteAnimator.Settings = state.SpriteAnimationSettings;
            spriteAnimator.OnAnimationSequenceComplete -= AnimationSequenceCompleteEventHandler;
            spriteAnimator.OnAnimationSequenceComplete += AnimationSequenceCompleteEventHandler;
            spriteAnimator.Animate();
        }
 public void AddTransitionAnimationSequence(CharacterState lastState, SpriteAnimationSequence spriteAnimationSequence)
 {
     SpriteTransitionAnimationSequences.Add(lastState, spriteAnimationSequence);
 }
 private void HitStateActivateEventHandler(CharacterState sender)
 {
     DecreaseBossLifeDefault();
     StaminaController.DecreaseStamina();
     HypeController.IncreaseHype();
     playerPropertyService.IncreaseExperiencePoints();
 }
 private void HypeAttackStateActivateEventHandler(CharacterState sender)
 {
     BossDeathExplosionController.Explode();
 }
 public bool HasPriority(CharacterState state)
 {
     return Priority <= state.Priority;
 }
 public bool HasActiveState(CharacterState state)
 {
     return HasState(state) && state.IsActive;
 }
 private void HitMissStateActivateEventHandler(CharacterState sender)
 {
     BossAttackFeedbackController.ShowHitMissFeedback();
 }
 public void SetState(CharacterState state)
 {
     AddState(state);
     RemoveAllStates(state);
 }
 public bool HasState(CharacterState state)
 {
     return states.Contains(state);
 }
 public bool HitMissAnimationSequenceCompleteEventHandler(CharacterState sender)
 {
     bossStateController.RemoveState(hitMissState);
     return false;
 }
 private void ComboHitStateActivateEventHandler(CharacterState sender)
 {
     GetComponents<AudioSource>()[KnockOutFallAudioClipIndex].Play();
     GetComponents<AudioSource>()[KnockOutVoiceAudioClipIndex].Play();
 }
 private void DeadStateActivateEventHandler(CharacterState sender)
 {
     BossDeathAnimationController.BeginDeathAnimation();
 }
 private void DeadStateUpdateEventHandler(CharacterState sender)
 {
     BossDeathAnimationController.Animate();
 }
 private bool DeathAnimationSequenceCompleteEventHandler(CharacterState sender)
 {
     GameSceneController.ShowVictoryScene();
     return false;
 }