protected void UpdateUIAsAdState() { if (m_AdHandler == null) { HideAdUI(); SetLoadingAnimState(true); } else { AdState state = m_AdHandler.adState; switch (state) { case AdState.Loaded: case AdState.Showing: UpdateText(); UpdateIcon(); UpdateCoverImage(); SetLoadingAnimState(false); break; case AdState.Loading: case AdState.NONE: HideAdUI(); SetLoadingAnimState(true); break; default: break; } } }
public Ad(Guid id, Guid userId, string header, string content, IEnumerable <string> tags, AdState state, DateTime from, DateTime to, DateTime createdAt) { if (string.IsNullOrWhiteSpace(header)) { throw new InvalidHeaderException(); } if (string.IsNullOrWhiteSpace(content)) { throw new InvalidContentException(); } if (from >= to) { throw new InvalidPeriodException(from, to); } Id = id; UserId = userId; Header = header; Content = content; Tags = tags; State = state; From = from; To = to; CreatedAt = createdAt; Amount = (int)Math.Floor((To - From).TotalDays) * 100; }
public void OnUnityAdsDidFinish(string placementId, ShowResult showResult) { Time.timeScale = 1f; if (placementId == afterDeathAd && adState != AdState.ShowingNewLifeRewardAd) { adState = AdState.NotShowingAd; } if (showResult == ShowResult.Finished && placementId == newLifeRewardedAd) { adState = AdState.NotShowingAd; isAskingAboutRewardAd = false; shipController.SetIsRewardedNewLife(true); ReloadLevel(); } else if (showResult == ShowResult.Skipped && placementId == newLifeRewardedAd) { adState = AdState.NotShowingAd; isAskingAboutRewardAd = false; ReloadLevel(); } else if (showResult == ShowResult.Failed) { Debug.LogError(placementId + " Failed to Play."); adState = AdState.NotShowingAd; isAskingAboutRewardAd = false; } }
protected void OnTextLoadFinish() { m_AdState = AdState.Loaded; if (On_AdTextLoadFinish != null) { On_AdTextLoadFinish(this); } }
protected void ResetAdState(int count) { m_ResetTimer = -1; if (m_AdState == AdState.Failed) { m_AdState = AdState.NONE; } m_AdInterface.PreLoadAd(); }
public void SetAdStateFailed() { m_AdState = AdState.Failed; if (m_ResetTimer > 0) { Timer.S.Cancel(m_ResetTimer); m_ResetTimer = -1; } m_ResetTimer = Timer.S.Post2Really(ResetAdState, m_FailedWaitDuration); }
private string AdStateToString(AdState s) { switch (s) { case AdState.Available: return("published"); case AdState.SaleAgreed: return("sale-agreed"); } return(string.Empty); }
//Initialize the ad with its given ad image public void Initialize(Sprite adImage, Sprite gameBackground, AdManager adManager, AdShape shape, float adImageWidth, float adImageLength) { this.adImage = adImage; this.gameBackground = gameBackground; this.adManager = adManager; this.shape = shape; this.adImageLength = adImageLength; this.adImageWidth = adImageWidth; renderer = GetComponent <SpriteRenderer>(); renderer.sprite = adImage; currState = AdState.Unclicked; }
private static string GetKey(AdState adKey) { switch (adKey) { case AdState.Video: return(videoKeys); case AdState.RewardVideo: return(rewardKeys); } return(rewardKeys); }
public static void ShowAd(AdState adKey, float probability = 1f) { #if UNITY_ADS if (!Advertisement.IsReady()) { return; } if (Random.value < probability) { Advertisement.Show(GetKey(adKey)); } #endif }
static AdvertisingState ConvertAdState(AdState adState) { switch (adState) { case AdState.Linear: return(AdvertisingState.Linear); case AdState.NonLinear: return(AdvertisingState.NonLinear); case AdState.Loading: return(AdvertisingState.Loading); case AdState.None: return(AdvertisingState.None); default: throw new NotImplementedException(); } }
protected void ProcessAdFailedLoadAction() { if (m_ResetTimer > 0) { Timer.S.Cancel(m_ResetTimer); m_ResetTimer = -1; } m_ResetTimer = Timer.S.Post2Really(ResetAdState, m_FailedWaitDuration); m_FailedWaitDuration += failedWaitAddOffset; m_AdState = AdState.Failed; DoCleanAd(); m_AdInterface.OnAdLoadFailed(); }
public AdState GetStateByAdIdAndVideoId(int adId, int videoId, string stateName) { AdState state = null; try { state = context.AdStates.SingleOrDefault(a => a.AdId == adId && a.VideoUnitId == videoId && a.Name.Equals(stateName)); } catch (Exception ex) { throw new FaultException <MultiplyAdStatesFoundException>(new MultiplyAdStatesFoundException(Models.Properties.ExceptionText.AdStateMultiply)); } if (state == null) { throw new FaultException <AdStateNotFoundException>(new AdStateNotFoundException(Models.Properties.ExceptionText.AdStateNotFound)); } return(state); }
public void ShowAd(string placmentID) { int attemptsBetweenAds = 8; if (attemptCounter % attemptsBetweenAds == 0 && placmentID == afterDeathAd) { Advertisement.Show(placmentID); adState = AdState.ShwowingBasicAd; Time.timeScale = 0f; } else if (placmentID == newLifeRewardedAd) { Advertisement.Show(placmentID); adState = AdState.ShowingNewLifeRewardAd; } else if (attemptCounter % attemptsBetweenAds == 0) { Debug.LogError(placmentID + " is incorrect. Double check for typo."); } }
/// <summary> /// OnMouseDown is called when the user has pressed the mouse button while /// over the GUIElement or Collider. /// </summary> protected void OnMouseDown() { Animator animator = gameObject.GetComponent <Animator>(); if (animator != null) { gameObject.GetComponent <Animator>().runtimeAnimatorController = null; } renderer.sprite = gameBackground; currState = AdState.Clicked; gameObject.GetComponent <Renderer>().sortingLayerName = "GameElement"; gameObject.GetComponent <Renderer>().sortingOrder = 2; if (topMostGame != null) { topMostGame.GetComponent <Renderer>().sortingOrder = 0; topMostGame.UpdateSortingOrder(); topMostGame.GetComponent <BoxCollider2D>().enabled = true; } topMostGame = this; gameObject.GetComponent <BoxCollider2D>().enabled = false; }
private string AdState2Name(AdState state) { switch (state) { case AdState.Loaded: return("Loaded"); case AdState.Loading: return("Loading"); case AdState.Showing: return("Showing"); case AdState.NONE: return("NONE"); default: break; } return(string.Empty); }
protected void ProcessAdLoadedAction() { m_FailedWaitDuration = failedWaitDuration; m_AdState = AdState.Loaded; m_AdInterface.OnAdLoad(); }
public void LoadAd() { CleanCurrentAD(); m_AdState = AdState.Loading; LoadAdInner(); }
internal AdStateEventArgs(AdState adState) { AdState = adState; }
static AdvertisingState ConvertAdState(AdState adState) { switch (adState) { case AdState.Linear: return AdvertisingState.Linear; case AdState.NonLinear: return AdvertisingState.NonLinear; case AdState.Loading: return AdvertisingState.Loading; case AdState.None: return AdvertisingState.None; default: throw new NotImplementedException(); } }
protected void ProcessAdClosedAction() { m_AdState = AdState.NONE; m_AdInterface.OnAdClose(); DoCleanAd(); }
void controller_AdStateChanged(object sender, object e) { state = controller.AdState; }
/// <inheritdoc /> protected override void SetAdvertisingState(AdState adState)
/// <inheritdoc /> protected override void SetAdvertisingState(AdState adState) #endif { var newValue = ConvertAdState(adState); var oldValue = MediaPlayer.AdvertisingState; if (newValue != oldValue) { #if WINDOWS_PHONE7 if (MediaPlayer.PlayerState == PlayerState.Started || playerState != null) #else if (MediaPlayer.PlayerState == PlayerState.Started) #endif { // pause the MediaPlayer if we're playing a linear ad or loading an ad, resume if the opposite if ((newValue == AdvertisingState.Loading || newValue == AdvertisingState.Linear) && (oldValue == AdvertisingState.None || oldValue == AdvertisingState.NonLinear)) { #if WINDOWS_PHONE7 playerState = MediaPlayer.GetMediaState(); MediaPlayer.Close(); #else MediaPlayer.Pause(); #endif } else if ((oldValue == AdvertisingState.Loading || oldValue == AdvertisingState.Linear) && (newValue == AdvertisingState.None || newValue == AdvertisingState.NonLinear)) { #if WINDOWS_PHONE7 MediaPlayer.RestoreMediaState(playerState); playerState = null; #else MediaPlayer.Play(); #endif } } if (newValue == AdvertisingState.Loading) { AdContainer.Visibility = Visibility.Visible; } else if (newValue == AdvertisingState.None) { AdContainer.Visibility = Visibility.Collapsed; } // let the MediaPlayer update its visualstate MediaPlayer.AdvertisingState = newValue; } switch (newValue) { case AdvertisingState.Linear: MediaPlayer.InteractiveViewModel = new VpaidLinearAdViewModel(ActiveAdPlayer, MediaPlayer); break; case AdvertisingState.NonLinear: MediaPlayer.InteractiveViewModel = new VpaidNonLinearAdViewModel(ActiveAdPlayer, MediaPlayer); break; default: MediaPlayer.InteractiveViewModel = MediaPlayer.DefaultInteractiveViewModel; break; } }
/// <summary> /// Called when the advertising state has changed. /// Allows the subclass to change the UI or allowed behaviors appropriately. /// </summary> /// <param name="adState"></param> protected virtual void SetAdvertisingState(AdState adState) { // only here to support overriding. Not abstract in order to prevent it from being mandatory. }