Пример #1
0
        // =============================================================
        // Enemy Logic


        private void Update()
        {
            if (enemy.CharacterDamage.IsDead == true)
            {
                InterruptBehavior();
                return;
            }
            if (enemy.CharacterDamage.IsKnockback == true)
            {
                InterruptBehavior();
                EnemyPause();
                return;
            }
            else if (enemy.CharacterAction.isAttacking() == true || timeData.TimeFlow == false)
            {
                EnemyPause();
                return;
            }
            else if (timeData.TimeFlow == true && pause == true)
            {
                if (currentBehavior != null)
                    currentBehavior.ResumeBehavior();
                pause = false;
                return;
            }

            if (currentBehavior == null) // Pas d'attaque donc on va en chercher une 
            {
                SelectAttack();
                return;
            }

            if (timeData.TimeFlow == true)
            {
                AimTime += (currentBehavior.UpdateBehavior(enemy, target, out updateInterruption) * Time.deltaTime) * enemy.CharacterAnimation.GetMotionSpeed();
                if (updateInterruption == true && aimTime < 1f)
                {
                    updateInterruption = false;
                    InterruptBehavior();
                    //ResetBehavior();
                    SelectAttack();
                }

                if (aimTime >= 1f && attackCharged == false)
                {
                    attackCharged = true;
                    if (OnAttackCharged != null) OnAttackCharged.Invoke(this, currentBehavior.CanInterruptPlayer());
                }
                else if (aimTime < 1f && attackCharged == true)
                {
                    attackCharged = false;
                    if (OnAttackInterrupted != null) OnAttackInterrupted.Invoke(this, currentBehavior.CanInterruptPlayer());
                }
            }
        }
Пример #2
0
        public void InterruptBehavior()
        {
            if (currentBehavior != null)
            {
                AimTime = 0;
                enemy.CharacterStatController.RemoveStat(currentBehavior.GetWeaponData().BaseStat, StatModifierType.Flat);
                currentBehavior.InterruptBehavior();
                if (OnAttackInterrupted != null) OnAttackInterrupted.Invoke(this, currentBehavior.CanInterruptPlayer());
                currentBehavior = null;
                attackCharged = false;
            }

        }