Exemplo n.º 1
0
    /**
     *  Helper method that calculates the point where the enemy should shoot at
     *
     *  @param targetPosition The current position of the target
     *  @param barrel "right" or "left"
     *
     *  @return A random vector3 in between the target position and the predicted intercept position. Accuracy of shot can be modified in inaccurateInterceptPoint
     */
    private Vector3 CalculateInterceptPosition(Vector3 targetPosition, Transform barrel)
    {
        Vector3 interceptPoint = ShootScript.FirstOrderIntercept(
            barrel.position, _rb.velocity, _bulletSpeed, new Vector3(targetPosition.x, targetPosition.y - 0.7f, targetPosition.z), player.getVelocity());
        Vector3 inaccurateInterceptPoint = new Vector3(Random.Range(targetPosition.x, interceptPoint.x), interceptPoint.y, Random.Range(targetPosition.z, interceptPoint.z));

        if (player.timeSinceLastDodge > 8)
        {
            return(interceptPoint);
        }
        return(interceptPoint);
    }
    /**
     *  Helper method that calculates the point where the enemy should shoot at
     *
     *  @param targetPosition The current position of the target
     *
     *  @return A random vector3 in between the target position and the predicted intercept position. Accuracy of shot can be modified in inaccurateInterceptPoint
     */
    private Vector3 CalculateInterceptPosition(Vector3 targetPosition)
    {
        Vector3 interceptPoint = ShootScript.FirstOrderIntercept(
            this.transform.position, _rb.velocity, _bulletSpeed, new Vector3(targetPosition.x, targetPosition.y - 1.5f, targetPosition.z), hero1.getVelocity());
        Vector3 inaccurateInterceptPoint = new Vector3(Random.Range(targetPosition.x, interceptPoint.x), interceptPoint.y, Random.Range(targetPosition.z, interceptPoint.z));

        if (hero1.timeSinceLastDodge > 8)
        {
            return(interceptPoint);
        }
        return(inaccurateInterceptPoint);
    }