Ejemplo n.º 1
0
        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;
                }
            }
        }
Ejemplo n.º 2
0
        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;
        }
Ejemplo n.º 3
0
    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;
        }
    }
Ejemplo n.º 4
0
        protected void OnTextLoadFinish()
        {
            m_AdState = AdState.Loaded;

            if (On_AdTextLoadFinish != null)
            {
                On_AdTextLoadFinish(this);
            }
        }
Ejemplo n.º 5
0
        protected void ResetAdState(int count)
        {
            m_ResetTimer = -1;
            if (m_AdState == AdState.Failed)
            {
                m_AdState = AdState.NONE;
            }

            m_AdInterface.PreLoadAd();
        }
Ejemplo n.º 6
0
        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);
        }
Ejemplo n.º 7
0
        private string AdStateToString(AdState s)
        {
            switch (s)
            {
            case AdState.Available:
                return("published");

            case AdState.SaleAgreed:
                return("sale-agreed");
            }
            return(string.Empty);
        }
Ejemplo n.º 8
0
    //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;
    }
Ejemplo n.º 9
0
    private static string GetKey(AdState adKey)
    {
        switch (adKey)
        {
        case AdState.Video:
            return(videoKeys);

        case AdState.RewardVideo:
            return(rewardKeys);
        }

        return(rewardKeys);
    }
Ejemplo n.º 10
0
    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
    }
Ejemplo n.º 11
0
        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();
            }
        }
Ejemplo n.º 12
0
        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();
        }
Ejemplo n.º 13
0
        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);
        }
Ejemplo n.º 14
0
    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.");
        }
    }
Ejemplo n.º 15
0
    /// <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;
    }
Ejemplo n.º 16
0
        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);
        }
Ejemplo n.º 17
0
 protected void ProcessAdLoadedAction()
 {
     m_FailedWaitDuration = failedWaitDuration;
     m_AdState            = AdState.Loaded;
     m_AdInterface.OnAdLoad();
 }
Ejemplo n.º 18
0
 public void LoadAd()
 {
     CleanCurrentAD();
     m_AdState = AdState.Loading;
     LoadAdInner();
 }
 internal AdStateEventArgs(AdState adState)
 {
     AdState = adState;
 }
Ejemplo n.º 20
0
 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();
     }
 }
Ejemplo n.º 22
0
 protected void ProcessAdClosedAction()
 {
     m_AdState = AdState.NONE;
     m_AdInterface.OnAdClose();
     DoCleanAd();
 }
Ejemplo n.º 23
0
 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;
            }
        }
Ejemplo n.º 26
0
 /// <inheritdoc />
 protected override void SetAdvertisingState(AdState adState)
Ejemplo n.º 27
0
 /// <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.
 }
Ejemplo n.º 28
0
        /// <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;
            }
        }
Ejemplo n.º 29
0
 void controller_AdStateChanged(object sender, object e)
 {
     state = controller.AdState;
 }
 /// <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.
 }