using System; using System.Collections.Generic; using SUISS.Core; using UnityEngine; namespace CIG { public class AdWaterfall { public AdWaterfall(params AdProviderType[] adProviderSequence) { this._adProviderSequence = new List(adProviderSequence); List list = new List(); int count = this._adProviderSequence.Count; for (int i = 0; i < count; i++) { AdProviderType item = this._adProviderSequence[i]; if (!list.Contains(item)) { list.Add(item); } } count = list.Count; for (int j = 0; j < count; j++) { AdProviderType providerType = list[j]; if (!SingletonMonobehaviour.Instance.AdProviderExists(providerType)) { this._adProviderSequence.RemoveAll((AdProviderType x) => x == providerType); UnityEngine.Debug.LogWarningFormat("[AdWaterfall] AdProvider '{0}' doesn't exist. -> Removing all occurances from the provider sequence list.", new object[] { providerType }); } } } public bool ContainsAdProvider(AdProviderType providerType) { return this._adProviderSequence.Contains(providerType); } public bool ShowAd(Action callback) { //TODODO չʾ¼¤ÀøÊÓÆµ callback(true, true); return true; if (!this.IsReady) { return false; } int count = this._adProviderSequence.Count; int i = 0; while (i < count) { AdProviderType adProviderType = this._adProviderSequence[i]; if (SingletonMonobehaviour.Instance.IsReady(adProviderType)) { if (SingletonMonobehaviour.Instance.ShowAd(adProviderType, callback)) { this._adProviderSequence.RemoveAt(i); this._adProviderSequence.Add(adProviderType); return true; } UnityEngine.Debug.LogErrorFormat("[AdWaterfall] Failed to ShowAd for '{0}'", new object[] { adProviderType }); return false; } else { i++; } } return false; } public virtual bool IsReady { get { int count = this._adProviderSequence.Count; if (count == 0) { return false; } for (int i = 0; i < count; i++) { if (SingletonMonobehaviour.Instance.IsReady(this._adProviderSequence[i])) { return true; } } return false; } } private List _adProviderSequence; } }