Example #1
0
    void Updating()
    {
        if (!soundsStarted)
        {
            soundsStarted = true;
            StartCoroutine("EngardeSound");
        }
        if (!enemy.GetAttackTimer())
        {
            enemy.TimeBeforeAttackStart();
        }
        enemy.Engarde();

        //TRANSITIONS GO HERE
        if (enemy.GetTimerSetOff())
        {
            enemy.SetTimerSetOff(false);
            enemy.ResetAnimatorBools(enemy.anim);
            enemy.anim.SetBool("attack", true);
            ToAttackState();
        }
        else if (enemy.EnemyIsTooClose())
        {
            GetComponent <Rigidbody>().AddForce(-transform.forward * 5, ForceMode.Impulse);
        }
        else if ((enemy.PlayerInFieldOfView() || enemy.PlayerDetected()) && enemy.EnemyIsOutsideEngardeDistance())
        {
            enemy.ResetAnimatorBools(enemy.anim);
            enemy.anim.SetBool("chase", true);
            ToChaseState();
        }
        else if (!enemy.PlayerInFieldOfView() && !enemy.PlayerDetected() && !enemy.PlayerIsWithinStrikingDistance())
        {
            enemy.ResetAnimatorBools(enemy.anim);
            enemy.anim.SetBool("patrol", true);
            ToPatrolState();
        }
        else if (enemy.PlayerIsAttacking() && enemy.WillAttemptToCounter() && enemy.PlayerIsWithinStrikingDistance())
        {
            enemy.ResetAnimatorBools(enemy.anim);
            enemy.anim.SetBool("block", true);
            ToBlockSwordState();
        }
        else
        {
            ToEngardeState();
        }
    }
    void Updating()
    {
        //aim enemy sword/projectile at player and attack

        if (!startedAttack)
        {
            enemy.PlaySound(enemy.enemyAudio, enemy.attackSound);
            startedAttack = true;
            enemy.Attack();
        }

        if (enemy.GetRigidBody().velocity.magnitude >= 0 && enemy.GetRigidBody().velocity.magnitude <= 0.1f)
        {
            endedAttack = true;
        }


        //TRANSITIONS GO HERE
        if ((enemy.PlayerInFieldOfView() || enemy.PlayerDetected()) && !enemy.PlayerIsWithinStrikingDistance() && (endedAttack || (enemy.GetRigidBody().velocity.magnitude >= 0 && enemy.GetRigidBody().velocity.magnitude <= 0.1f)))
        {
            startedAttack = false;
            endedAttack   = false;
            enemy.ResetAnimatorBools(enemy.anim);
            enemy.anim.SetBool("chase", true);
            ToChaseState();
        }
        else if (enemy.PlayerInFieldOfView() && enemy.PlayerIsWithinStrikingDistance() && (endedAttack || (enemy.GetRigidBody().velocity.magnitude >= 0 && enemy.GetRigidBody().velocity.magnitude <= 0.1f)))
        {
            startedAttack = false;
            endedAttack   = false;
            enemy.ResetAnimatorBools(enemy.anim);
            enemy.anim.SetBool("engarde", true);
            ToEngardeState();
        }
        else
        {
            startedAttack = false;
            endedAttack   = false;
            enemy.ResetAnimatorBools(enemy.anim);
            enemy.anim.SetBool("patrol", true);
            ToPatrolState();
        }
    }
Example #3
0
    void Updating()
    {
        if (!soundsStarted)
        {
            soundsStarted = true;
            StartCoroutine("ChaseSound");
        }
        enemy.ChasePlayer();

        if (enemy.gameObject.name == "Enemy (1)")
        {
            Debug.Log("this should be called");
        }

        //TRANSITIONS GO HERE
        if (!enemy.PlayerDetected() && !enemy.PlayerInFieldOfView())
        {
            enemy.SetPriorityPatrol(true);
            enemy.ResetAnimatorBools(enemy.anim);
            enemy.anim.SetBool("patrol", true);
            ToPatrolState();
        }
        else if (enemy.EnemyIsTooClose())
        {
            GetComponent <Rigidbody>().AddForce(-transform.forward * 5, ForceMode.Impulse);
        }
        else if (enemy.EnemyIsWithinAllowableBounds() && enemy.PlayerInFieldOfView())
        {
            enemy.ResetAnimatorBools(enemy.anim);
            enemy.anim.SetBool("engarde", true);
            ToEngardeState();
        }
        else
        {
            ToChaseState();
        }
    }
    void Updating()
    {
        /*if (!soundsStarted)
         * {
         *  soundsStarted = true;
         *  enemy.PlaySound(enemy.enemyAudio, enemy.patrolSound);
         *  enemy.enemyAudio.loop = true;
         * }*/
        //randomly move around
        if (enemy.GetPriorityPatrol())
        {
            enemy.PriorityPatrol();
        }
        else
        {
            enemy.Patrol();
        }

        //TRANSITIONS GO HERE
        if ((enemy.PlayerDetected() || enemy.PlayerInFieldOfView()))
        {
            enemy.ResetAnimatorBools(enemy.anim);
            enemy.anim.SetBool("investigate", true);
            ToInvestigateState();
        }
        else if (enemy.PlayerIsAttacking() && enemy.WillAttemptToCounter() && enemy.PlayerIsWithinStrikingDistance() && enemy.PlayerInFieldOfView())
        {
            enemy.ResetAnimatorBools(enemy.anim);
            enemy.anim.SetBool("block", true);
            ToBlockSwordState();
        }
        else
        {
            ToPatrolState();
        }
    }
Example #5
0
 void Updating()
 {
     //dodge sword
     enemy.PlaySound(enemy.enemyAudio, enemy.attackSound);
     enemy.AvoidSword();
     //TRANSITIONS GO HERE
     if (!enemy.PlayerInFieldOfView() && !enemy.PlayerIsWithinStrikingDistance() && !enemy.PlayerDetected())
     {
         enemy.ResetAnimatorBools(enemy.anim);
         enemy.anim.SetBool("patrol", true);
         ToPatrolState();
     }
     else
     {
         enemy.ResetAnimatorBools(enemy.anim);
         enemy.anim.SetBool("chase", true);
         ToChaseState();
     }
 }