public IEnumerator GetAd(int id) { BusinessCard = null; adReady = false; hasAd = false; BusinessID = id; string adURL = serverURL + "getAd?b=" + id; string bcURL = serverURL + "bizcard?id=" + id; WWW card = new WWW(bcURL); yield return card; BusinessCard = new Texture2D(Convert.ToInt32(card.texture.width), Convert.ToInt32(card.texture.height), TextureFormat.ARGB32, false); BusinessCard.SetPixels(card.texture.GetPixels()); BusinessCard.Apply(); WWW page = new WWW(adURL); yield return page; if (page.error == null && page.text[0] == '{') { Debug.Log(page.text); // Get the ad as a Dictionary object. hasAd = true; Dictionary<string, object> ad = Json.Deserialize(page.text) as Dictionary<string, object>; AdImages(ad); AdInfo = new AdData(ad); } adReady = true; }
public void Initialize(AdData data, GameManager.WindowCallback callback, bool startMinimized = false) { m_name.text = data.name; m_icon.sprite = data.icon; GetComponent <AnimatedSprite>().Load(data.frames, data.fps); m_function = data.func; if (ProgramManager.instance.ResizeActive) { Resize(Settings.SmallWindowSize); } else { Resize(data.imageSize); } gameObject.SetActive(!startMinimized); m_miniIcon.isOn = !startMinimized; m_miniIcon.GetComponentInChildren <MinimizedButton>().Initialize(data.name, data.icon); m_onClose += callback; transform.SetAsLastSibling(); if (programWindow) { ProgramManager.instance.Trigger(m_function, true); } else { if (data.sfx != null) { AudioManager.PlaySfx(data.sfx); } } }
private void IncSlotChar(int jsonFileId, int wantedSlotInt) { AdSlotData wantedSlotData = GetAdSlotData(jsonFileId, wantedSlotInt); bool isValidAd = false; AdData curAdData = null; int adSlotCount = wantedSlotData.advert.Count; for (int i = 0; !isValidAd && i < (adSlotCount * 2); i++) { wantedSlotData.lastSlotId = wantedSlotData.lastSlotId + 1 >= adSlotCount ? 0 : wantedSlotData.lastSlotId + 1; curAdData = GetAdData(jsonFileId, wantedSlotInt, GetSlotChar(jsonFileId, wantedSlotInt)); // Never display any self ads or inactive ads if (!curAdData.isSelf && curAdData.isActive) { // Only apps which are not already installed are valid UNLESS we iterated through all ads and could not find a valid one if (!curAdData.isInstalled || i >= adSlotCount) { isValidAd = true; } } } if (isValidAd) { StartCoroutine(DownloadAdTexture(curAdData)); } }
// Use this for initialization public void Init(AdData admobData) { _admobData = admobData; _interstitialAdFactory = new InterstitialAdFactory(); if (_admobData != null) { MobileAds.Initialize(_admobData.AppId); } }
public void InitComponents(AdData adInfo) { Description.GetComponent<UILabel>().text = adInfo.Mega.Description; End.GetComponent<UILabel>().text = "Hurry! Deal ends " + adInfo.Mega.End; List.GetComponent<UILabel>().text = adInfo.Mega.List.ToString(); Price.GetComponent<UILabel>().text = adInfo.Mega.Price.ToString(); Title.GetComponent<UILabel>().text = adInfo.Mega.Title; //GetComponent<Page>().narratorTexture = adInfo.Expert.Image; megaDealColor = adInfo.Background.TopColor; }
// Use this for initialization public void Init(AdData adData) { _adData = adData; // debugState 0 : DEFAULT // debugState 1 : DEBUG (InEEA) ADXGDPRManager.InitializeWithShowADXConsent(adData.BannerAdInfo[0].AdUnitId, 0); ADXGDPR.OnADXConsentCompleted += onADXConsentCompleted; //Google _googleMobileAdsCtrl = gameObject.AddComponent <GoogleMobileAdsCtrl>(); _googleMobileAdsCtrl.Init(_adData); }
/// <summary> /// Returns the Texture of the current active advert from the requested JSON file and slot int /// </summary> /// <returns>The advert texture</returns> /// <param name="jsonFileId">JSON file ID</param> /// <param name="wantedSlotInt">Slot int</param> public static Texture GetAdTexture(int jsonFileId, int wantedSlotInt) { #if ias AdData returnValue = staticRef.GetAdData(jsonFileId, wantedSlotInt); if (returnValue != null) { return(staticRef.advertTextures[returnValue.adTextureId]); } else { return(null); } #else return(null); #endif }
/// <summary> /// Returns the package name of the current active advert from the requested JSON file and slot int /// </summary> /// <returns>The advert package name</returns> /// <param name="jsonFileId">JSON file ID</param> /// <param name="wantedSlotInt">Slot int</param> public static string GetAdPackageName(int jsonFileId, int wantedSlotInt) { #if ias AdData returnValue = staticRef.GetAdData(jsonFileId, wantedSlotInt); if (returnValue != null) { return(returnValue.packageName); } else { return(string.Empty); } #else return(string.Empty); #endif }
/// <summary> /// Returns whether the ad texture has downloaded or not /// </summary> /// <returns><c>true</c> if is ad ready the specified jsonFileId wantedSlotInt; otherwise, <c>false</c>.</returns> /// <param name="jsonFileId">JSON file ID</param> /// <param name="wantedSlotInt">Slot int</param> public static bool IsAdReady(int jsonFileId, int wantedSlotInt) { #if ias AdData returnValue = staticRef.GetAdData(jsonFileId, wantedSlotInt); if (returnValue != null) { return(returnValue.isTextureReady); } else { return(false); } #else return(false); #endif }
public void RegisterAdWatch(AdPlacementType type, MetaDataStateBase playerState, Action getAdRewardForTypeMethod) { AdData adData = AdData.GetAdDataForPlacementType(type); AdStateItem adStateItem = GetStateItem(adData.PlacementType); if (adData != null && (adStateItem.UseCount < adData.DailyMaxUse || adData.DailyMaxUse == 0)) { adStateItem.UseCount++; if (getAdRewardForTypeMethod != null) { getAdRewardForTypeMethod.Invoke(); } playerState.TotalAdWatchedCount++; } }
private void DomainUserDiscovery() { Mq.Info("Getting interesting users from AD."); // We do this single threaded cos it's fast and not easily divisible. // The AdData class set/get semantics have gotten wonky here. Leaving as-is to minimize breakage/changes, but needs another look. AdData adData = new AdData(); adData.SetDomainUsers(); foreach (string user in adData.GetDomainUsers()) { MyOptions.DomainUsersToMatch.Add(user); } // build the regexes for use in the file scans PrepDomainUserRules(); }
private int GetAdIndex(int jsonFileId, int wantedSlotInt, char wantedSlotChar) { AdSlotData slotData = GetAdSlotData(jsonFileId, wantedSlotInt); if (slotData.advert != null) { for (int i = 0; i < slotData.advert.Count; i++) { AdData curAdData = slotData.advert[i]; if (wantedSlotChar == curAdData.slotChar) { return(i); } } } return(-1); }
private void DomainDfsDiscovery() { Dictionary <string, string> dfsSharesDict = null; AdData adData = null; Mq.Info("Getting DFS paths from AD."); adData = new AdData(); adData.SetDfsPaths(); dfsSharesDict = adData.GetDfsSharesDict(); // if we found some actual dfsshares if (dfsSharesDict.Count >= 1) { MyOptions.DfsSharesDict = dfsSharesDict; MyOptions.DfsNamespacePaths = adData.GetDfsNamespacePaths(); } }
void RegistAdSdk(Type _type, IAD _iAd, AdType _adType = AdType.Third) { if (!adSdkDic.ContainsKey(_type)) { AdData adData = new AdData(); adData.type = _type; adData.Ad = _iAd; adData.adType = _adType; adSdkDic.Add(_type, adData); if (_adType == AdType.Third) { adSdkList.Add(adData); } AllSDKManager.SDKDebug(Name + "/" + adSdkDic[_type].Ad.Name + "注册成功"); } else { AllSDKManager.SDKDebug(Name + " 已经注册过这个平台" + adSdkDic[_type].Ad.Name); } }
private void AddPopUp() { WindowController window = Instantiate(m_window, m_windowContainer).GetComponent <WindowController>(); AdData data = m_adb.RequestRandom(); window.Initialize(data, CloseWindow); if (ProgramManager.instance.ConsolidateActive) { RectTransform winRect = window.GetComponent <RectTransform>(); winRect.anchoredPosition = Settings.ConsolodatePosition; if (ProgramManager.instance.PredictionActive) { ProgramManager.instance.Predict(); } } else { if (ProgramManager.instance.PredictionActive) { Vector2 pos = ProgramManager.instance.PredictionPos; RectTransform winRect = window.GetComponent <RectTransform>(); if (pos.y + (winRect.rect.height / 2) > Screen.height / 2) { pos.y = (Screen.height / 2) - (winRect.rect.height / 2); } winRect.anchoredPosition = pos; ProgramManager.instance.Predict(); } else { Vector2 pos = UnityEngine.Random.insideUnitCircle * (new Vector2(Screen.width, Screen.height) / 2); RectTransform winRect = window.GetComponent <RectTransform>(); if (pos.y + (winRect.rect.height / 2) > Screen.height / 2) { pos.y = (Screen.height / 2) - (winRect.rect.height / 2); } winRect.anchoredPosition = pos; } } m_currentWindows.Add(window); }
public IEnumerator Init() { AnalyticsManager.Instance.Init(); #if UNITY_ANDROID AdData adData = _adDataForAndroid; _mobilePlatform = gameObject.AddComponent <GooglePlayServiceCtrl>(); #elif UNITY_IOS AdData adData = _adDataForIos; _mobilePlatform = gameObject.AddComponent <GameCenterServiceCtrl>(); #endif _mobilePlatform.Init(); // if (adData.adAdaptorType == AdAdaptorType.ADMOB){ // _adsCtrl = gameObject.AddComponent<GoogleMobileAdsCtrl>(); // } // if(adData.adAdaptorType == AdAdaptorType.ADAX){ // _adsCtrl = gameObject.AddComponent<AdxAdsCtrl>(); // } // _adsCtrl.Init(adData); yield return(null); }
public void Play() { if (!crossp.IsReady) { return; } currentAd = crossp.GetRandomAvailableAd(); switch (currentAd.Type) { case AdData.FileType.Image: rawImage.texture = crossp.GetTexture2DFrom(currentAd); break; case AdData.FileType.Video: rawImage.texture = crossp.CrosspSettings.RenderTexture; videoPlayer.Stop(); videoPlayer.url = crossp.GetVideoFilePathFrom(currentAd); videoPlayer.Prepare(); break; } }
private IEnumerator DownloadAdTexture(AdData curAdData) { // Download the texture for the newly selected IAS advert // Only bother re-downloading the image if the timestamp has changed or the texture isn't marked as ready if (!curAdData.isTextureReady || curAdData.lastUpdated < curAdData.newUpdateTime) { // Check if this is an advert we may be using in this game // Note: We still download installed ads because we might need them if there's no ads to display if (!curAdData.isSelf && curAdData.isActive) { // Whilst we still have wwwImage write the bytes to disk to save on needing extra operations string filePath = Application.persistentDataPath + Path.AltDirectorySeparatorChar; string fileName = "IAS_" + curAdData.fileName; // Check to see if we have this advert locally cached if (curAdData.isTextureFileCached) { // Make sure the cache file actually exists (unexpected write fails or manual deletion) if (File.Exists(filePath + fileName)) { try { // Read the saved texture from disk byte[] imageData = File.ReadAllBytes(filePath + fileName); // We need to create a template texture, we're also setting the compression type here Texture2D imageTexture = new Texture2D(2, 2, TextureFormat.ETC2_RGBA1, false); // Load the image data, this will also resize the texture imageTexture.LoadImage(imageData); advertTextures.Add(imageTexture); } catch (IOException e) { Analytics.LogError("IAS", "Failed to load cached file! " + e.Message); curAdData.isTextureFileCached = false; throw; } } else { Analytics.LogError("IAS", "Saved cached image was missing!"); curAdData.isTextureFileCached = false; yield break; } } else { // The advert is not yet locally cached, WWW wwwImage = new WWW(curAdData.imgUrl); // Wait for the image data to be downloaded yield return(wwwImage); // Check for any errors if (!string.IsNullOrEmpty(wwwImage.error)) { Analytics.LogError("IAS", "Image download error! " + wwwImage.error); yield break; } else if (wwwImage.text.Contains("There was an error")) { Analytics.LogError("IAS", "Image download error! Serverside system error!"); yield break; } else if (string.IsNullOrEmpty(wwwImage.text)) { Analytics.LogError("IAS", "Image download error! Empty JSON!"); yield break; } advertTextures.Add(wwwImage.texture); try { File.WriteAllBytes(filePath + fileName, wwwImage.bytes); curAdData.isTextureFileCached = true; } catch (IOException e) { Analytics.LogError("IAS", "Failed to create cache file! " + e.Message); throw; } // Dispose of the wwwImage data as soon as we no longer need it (clear it from memory) wwwImage.Dispose(); } curAdData.adTextureId = advertTextures.Count - 1; curAdData.lastUpdated = curAdData.newUpdateTime; curAdData.isTextureReady = true; } } OnIASImageDownloaded(); }
private void DomainTargetDiscovery() { AdData adData = null; List <string> targetComputers; // Give preference to explicit targets in the options file over LDAP computer discovery if (MyOptions.ComputerTargets != null) { Mq.Info("Using computer list from user-specified options."); targetComputers = new List <string>(); foreach (string t in MyOptions.ComputerTargets) { targetComputers.Add(t); } Mq.Info(string.Format("Took {0} computers specified in options file.", targetComputers.Count)); } else { // We do this single threaded cos it's fast and not easily divisible. Mq.Info("Getting computers from AD."); // The AdData class set/get semantics have gotten wonky here. Leaving as-is to minimize breakage/changes, but needs another look. // initialize it if we didn't already if (adData == null) { adData = new AdData(); } adData.SetDomainComputers(MyOptions.ComputerTargetsLdapFilter); targetComputers = adData.GetDomainComputers(); Mq.Info(string.Format("Got {0} computers from AD.", targetComputers.Count)); // if we're only scanning DFS shares then we can skip the SMB sharefinder and work from the list in AD, then jump to FileDiscovery(). if (MyOptions.DfsOnly) { FileDiscovery(MyOptions.DfsNamespacePaths.ToArray()); } } if (targetComputers == null && MyOptions.DfsNamespacePaths == null) { Mq.Error( "Something f****d out finding stuff in the domain. You must be holding it wrong."); while (true) { Mq.Terminate(); } } if (targetComputers.Count == 0 && MyOptions.DfsNamespacePaths.Count == 0) { Mq.Error("Didn't find any domain computers. Seems weird. Try pouring water on it."); while (true) { Mq.Terminate(); } } // call ShareDisco which should handle the rest. ShareDiscovery(targetComputers.ToArray()); // ShareDiscovery(targetComputers.ToArray(), dfsShares); }
private IEnumerator DownloadIASData(bool cachedDataLoaded = false) { // Wait for an active internet connection while (Application.internetReachability == NetworkReachability.NotReachable) { yield return(null); } ProjectManager.AdvLog("IAS downloading data.."); // Iterate through each JSON file for (int jsonFileId = 0; jsonFileId < jsonUrls.Length; jsonFileId++) { // Download the JSON file WWW wwwJSON = new WWW(jsonUrls[jsonFileId]); // Wait for the JSON data to be downloaded yield return(wwwJSON); // Check for any errors if (!string.IsNullOrEmpty(wwwJSON.error)) { Analytics.LogError("IAS", "JSON download error! " + wwwJSON.error); yield break; } else if (wwwJSON.text.Contains("There was an error")) { Analytics.LogError("IAS", "JSON download error! Serverside system error!"); yield break; } else if (string.IsNullOrEmpty(wwwJSON.text)) { Analytics.LogError("IAS", "JSON download error! Empty JSON!"); yield break; } JsonFileData tempAdvertData = JsonUtility.FromJson <JsonFileData>(wwwJSON.text); // Dispose of the wwwJSON data (clear it from memory) wwwJSON.Dispose(); if (tempAdvertData == null) { Analytics.LogError("IAS", "Temp advert data was null!"); yield break; } if (!DoesSlotFileIdExist(jsonFileId)) { advertData.Add(new AdJsonFileData()); } bool needToReloadAdSlots = !cachedDataLoaded; bool needToRandomizeSlot = false; // We're currently only using the slots, not containers for (int i = 0; i < tempAdvertData.slots.Count; i++) { JsonSlotData curSlot = tempAdvertData.slots[i]; // We'll be converting the slot id (e.g 1a, 1c or 2f) into just number and just character values int slotInt; char slotChar; // Attempt to extract the slot int from the slot id if (!int.TryParse(Regex.Replace(curSlot.slotid, "[^0-9]", ""), out slotInt)) { Analytics.LogError("IAS", "Failed to parse slot int from '" + curSlot.slotid + "'"); yield break; } // Attempt to extract the slot character from the slot id if (!char.TryParse(Regex.Replace(curSlot.slotid, "[^a-z]", ""), out slotChar)) { Analytics.LogError("IAS", "Failed to parse slot char from '" + curSlot.slotid + "'"); yield break; } // If this slot doesn't exist yet create a new slot for it if (!DoesSlotIntExist(jsonFileId, slotInt)) { advertData[jsonFileId].slotInts.Add(new AdSlotData(slotInt, new List <AdData>())); } // Get the index in the list for slotInt int slotDataIndex = GetSlotIndex(jsonFileId, slotInt); if (slotDataIndex < 0) { Analytics.LogError("IAS", "Failed to get slotDataIndex!"); yield break; } // Make sure this slot char isn't repeated in the json file within this slot int for some reason if (!DoesSlotCharExist(jsonFileId, slotInt, slotChar)) { advertData[jsonFileId].slotInts[slotDataIndex].advert.Add(new AdData(slotChar)); needToRandomizeSlot = true; } int slotAdIndex = GetAdIndex(jsonFileId, slotInt, slotChar); if (slotAdIndex < 0) { Analytics.LogError("IAS", "Failed to get slotAdIndex! Could not find " + slotInt + ", " + slotChar.ToString()); yield break; } AdData curAdData = advertData[jsonFileId].slotInts[slotDataIndex].advert[slotAdIndex]; // Extract the bundleId of the advert #if UNITY_ANDROID // Regex extracts the id GET request from the URL which is the package name of the game // (replaces everything that does NOT match id=blahblah END or NOT match id=blahblah AMERPERSAND string packageName = Regex.Match(curSlot.adurl, "(?<=id=)((?!(&|\\?)).)*").Value; #elif UNITY_IOS // IOS we just need to grab the name after the hash in the URL string packageName = Regex.Match(curSlot.adurl, "(?<=.*#).*").Value; #else // For other platforms we should be fine to just use the full URL for package name comparisons as we'll be using .Compare // And other platforms won't include any other referral bundle ids in their URLs string packageName = curSlot.adurl; #endif string imageFileType = Regex.Match(curSlot.imgurl, "(?<=/uploads/adverts/.*)\\.[A-z]*[^(\\?|\")]").Value; curAdData.fileName = curSlot.slotid + imageFileType; curAdData.isSelf = packageName.Contains(bundleId); curAdData.isActive = curSlot.active; curAdData.isInstalled = IsPackageInstalled(packageName); curAdData.adUrl = curSlot.adurl; curAdData.packageName = packageName; curAdData.imgUrl = curSlot.imgurl; if (curAdData.newUpdateTime < curSlot.updatetime || curAdData.newUpdateTime == 0L) { needToReloadAdSlots = true; } curAdData.newUpdateTime = curSlot.updatetime; // I'm not pre-downloading all the images here because it takes quite a long time to download even on our fast ethernet connection (~15 seconds) // So I think it's best to download the images (if needed) when the ads are called to be refreshed } if (needToRandomizeSlot) { RandomizeAdSlots(jsonFileId); } if (needToReloadAdSlots) { RefreshActiveAdSlots(jsonFileId); } } SaveIASData(); ProjectManager.AdvLog("IAS Done"); }
private void SetUpMegaDeal(AdData adInfo) { MegaDealPage.GetComponent<Page>().businessAd = this; hasMegaDeal = true; MegaDealBtn.SetActive(true); MegaDealBtn.GetComponent<UIButton>().isEnabled = true; MegaDeal megaDeal = MegaDealPage.GetComponent<MegaDeal>(); megaDeal.InitComponents(adInfo); MegaDealPage.GetComponent<Page>().pageBtn = MegaDealBtn; }