Exemplo n.º 1
0
    // THIS ONE IS FOR PLAYER
    public IEnumerator walkToEnemy(EnemyAttributes enemy)
    {
        bool            walkingToEnemy    = true;
        EnemyAttributes player            = this;
        Vector3         hitGroundPosition = gameManager.getPlayerBehavior().getHitGround();


        while (walkingToEnemy)
        {
            enemy.setMobIndicator(true);
            enemy.setAllIndicatorsFallsAndActivate("yellow");
            //Debug.Log("player WALKINMG to enemy");

            if (hitGroundPosition != gameManager.getPlayerBehavior().getHitGround())
            {
                //Debug.Log("new walking position");
                enemy.setMobIndicator(false);
                enemy.setAllIndicatorsFallsAndActivate("red");
                break;
            }

            if (Vector3.Distance(gameManager.getPlayerBehavior().getPlayerPosition(), enemy.getPosition()) < player.getAttackRange())
            {
                //Debug.Log("clsoe enough");
                stopMovement();
                player.setCurrentTarget(enemy);
                StartCoroutine(attackEnemy(enemy, true));

                break;
            }
            else
            {
                player.getNavMeshAgent().SetDestination(enemy.getPosition());
            }
            yield return(null);
        }
    }