Ejemplo n.º 1
0
    public void Update()
    {
        if (GameManager.Instance.IsGamePaused())
        {
            return;
        }

        switch (state)
        {
        default:
        case State.Roaming:
            pathfindingMovement.MoveToTimer(roamPosition);

            float reachedPositionDistance = 1f;
            if (Vector3.Distance(transform.position, roamPosition) < reachedPositionDistance)
            {
                roamPosition = GetRoamingPosition();
            }
            FindTarget();
            break;

        case State.ChaseTarget:
            pathfindingMovement.MoveToTimer(PlayerManager.Instance.GetPlayerPosition());
            if (Vector3.Distance(transform.position, PlayerManager.Instance.GetPlayerPosition()) < attackRange)
            {
                pathfindingMovement.StopMoving();
                shoot.FireWeapon((PlayerManager.Instance.GetPlayerPosition() - transform.position));
            }
            break;
        }
    }
Ejemplo n.º 2
0
 public void FireWeapon(Vector2 d)
 {
     shoot.FireWeapon(d);
     lastDir = d;
 }