Exemplo n.º 1
0
    // Se a API de Advertisement realmente esta sendo utilizada
    //
    // Quando o metodo retorna false:
    // - Se a Prefab "AdvertisementManager" (inserida dentro da Prefab "#Configuration#") for nula
    // - Se a bool isActive do "AdvertisementManager" estiver como false
    // - Se nenhum Advertisement conseguir ser instanciado
    //
    // Ex: if (Advertisement.IsRunning())
    //	      Debug.log("Advertisement API esta funcionando");
    public static bool IsRunning()
    {
#if !UNITY_WEBPLAYER
        return(AdvertisementManager.isEnabled());
#else
        return(false);
#endif
    }
    // Mostra o video
    public static void fetchVideo()
    {
        if (!AdvertisementManager.isEnabled())
        {
            return;
        }

        if (Info.IsEditor() || AdvertisementManager.manager.video == null)
        {
            return;
        }

        foreach (AdvertisementBase ad in AdvertisementManager.manager.video)
        {
            ad.fetchVideo();
        }
    }
    public static bool isVideoAvailable()
    {
        if (!AdvertisementManager.isEnabled())
        {
            return(false);
        }

        if (Info.IsEditor() || AdvertisementManager.manager.video == null)
        {
            return(false);
        }

        foreach (AdvertisementBase ad in AdvertisementManager.manager.video)
        {
            if (ad.isVideoAvailable())
            {
                return(true);
            }
        }
        return(false);
    }
    // Mostra o video
    public static bool showVideo(VideoDelegate methodToCall)
    {
        if (!AdvertisementManager.isEnabled())
        {
            return(false);
        }

        if (Info.IsEditor() || AdvertisementManager.manager.video == null)
        {
            return(false);
        }

        foreach (AdvertisementBase ad in AdvertisementManager.manager.video)
        {
            if (ad.showVideo(methodToCall))
            {
                return(true);
            }
        }
        return(false);
    }
    // Obtem a lista de ads com o servidor
    protected static void getAdList()
    {
        if (!AdvertisementManager.isEnabled())
        {
            return;
        }

        GameConnection conn = new GameConnection(Flow.URL_BASE + "login/ads.php", AdvertisementManager.manager.handleGetAdList);

        WWWForm form = new WWWForm();

        form.AddField("app", Info.appId);

#if UNITY_ANDROID
        form.AddField("os", "android");
#elif UNITY_IPHONE
        form.AddField("os", "ios");
#else
        form.AddField("os", "web");
#endif

        AdvertisementManager.manager.StartCoroutine(conn.startConnection(form));
    }