Beispiel #1
0
    private bool Scan(EnemyStateController controller)
    {
        // Vector3 tempScanPos = new Vector3(Random.Range(-1f, 1f), Random.Range(-1f, 1f), Random.Range(-1f, 1f));

        controller.agent.isStopped = true;

        // controller.transform.Translate(controller.transform.position + tempScanPos * controller.enemyStats.moveSpeed * Time.deltaTime);

        return(controller.CheckIfTimeElapsed(controller.enemyStats.searchDuration));
    }
Beispiel #2
0
    private void Attack(EnemyStateController controller)
    {
        RaycastHit hit;

        Debug.DrawRay(controller.eyes.position, controller.eyes.forward.normalized * controller.enemyStats.attackRange, Color.red);

        if (Physics.SphereCast(controller.eyes.position, controller.enemyStats.lookSphereCastRadius, controller.eyes.forward,
                               out hit, controller.enemyStats.attackRange) && hit.collider.CompareTag("Player"))
        {
            // controller.enemyAnim.SetTrigger("Attack");
            if (controller.CheckIfTimeElapsed(controller.enemyStats.attackRate))
            {
                Debug.Log("Enemy Attacks...");
                controller.enemyAnim.SetTrigger("Attack");
                GameController.Instance.TakeDamage(controller.enemyStats.attackDamage);
                if (GameController.Instance.currentHealth <= 0)
                {
                    controller.enemyAnim.SetTrigger("Walk");
                }
            }
        }
    }