-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #45 from VirtueSky/dev
Dev
- Loading branch information
Showing
8 changed files
with
156 additions
and
122 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,124 +1,21 @@ | ||
using UnityEngine; | ||
using VirtueSky.Inspector; | ||
|
||
namespace VirtueSky.Ads | ||
{ | ||
public abstract class AdClient | ||
{ | ||
protected AdSetting adSetting; | ||
private bool _statusAppOpenFirstIgnore; | ||
protected bool statusAppOpenFirstIgnore; | ||
|
||
public void SetupAdSetting(AdSetting _adSetting) | ||
{ | ||
this.adSetting = _adSetting; | ||
} | ||
|
||
public abstract void Initialize(); | ||
|
||
#region Inter Ad | ||
|
||
private AdUnitVariable InterstitialAdUnit() | ||
{ | ||
return adSetting.CurrentAdNetwork switch | ||
{ | ||
AdNetwork.Max => adSetting.MaxInterVariable, | ||
AdNetwork.Admob => adSetting.AdmobInterVariable, | ||
_ => adSetting.IronSourceInterVariable, | ||
}; | ||
} | ||
|
||
protected virtual bool IsInterstitialReady() | ||
{ | ||
return InterstitialAdUnit().IsReady(); | ||
} | ||
|
||
public virtual void LoadInterstitial() | ||
{ | ||
if (InterstitialAdUnit() == null) return; | ||
if (!IsInterstitialReady()) InterstitialAdUnit().Load(); | ||
} | ||
|
||
#endregion | ||
|
||
#region Reward Ad | ||
|
||
private AdUnitVariable RewardAdUnit() | ||
{ | ||
return adSetting.CurrentAdNetwork switch | ||
{ | ||
AdNetwork.Max => adSetting.MaxRewardVariable, | ||
AdNetwork.Admob => adSetting.AdmobRewardVariable, | ||
_ => adSetting.IronSourceRewardVariable, | ||
}; | ||
} | ||
|
||
protected virtual bool IsRewardedReady() | ||
{ | ||
return RewardAdUnit().IsReady(); | ||
} | ||
|
||
public virtual void LoadRewarded() | ||
{ | ||
if (RewardAdUnit() == null) return; | ||
if (!IsRewardedReady()) RewardAdUnit().Load(); | ||
} | ||
|
||
#endregion | ||
|
||
#region Reward Inter Ad | ||
|
||
private AdUnitVariable RewardedInterstitialAdUnit() | ||
{ | ||
return adSetting.CurrentAdNetwork switch | ||
{ | ||
AdNetwork.Max => adSetting.MaxRewardInterVariable, | ||
AdNetwork.Admob => adSetting.AdmobRewardInterVariable, | ||
_ => null, | ||
}; | ||
} | ||
|
||
protected virtual bool IsRewardedInterstitialReady() | ||
{ | ||
return RewardedInterstitialAdUnit().IsReady(); | ||
} | ||
|
||
public virtual void LoadRewardedInterstitial() | ||
{ | ||
if (RewardedInterstitialAdUnit() == null) return; | ||
if (!IsRewardedInterstitialReady()) RewardedInterstitialAdUnit().Load(); | ||
} | ||
|
||
#endregion | ||
|
||
#region AppOpen Ad | ||
|
||
private AdUnitVariable AppOpenAdUnit() | ||
{ | ||
return adSetting.CurrentAdNetwork switch | ||
{ | ||
AdNetwork.Max => adSetting.MaxAppOpenVariable, | ||
AdNetwork.Admob => adSetting.AdmobAppOpenVariable, | ||
_ => null | ||
}; | ||
} | ||
|
||
protected virtual bool IsAppOpenReady() | ||
{ | ||
return AppOpenAdUnit().IsReady(); | ||
} | ||
|
||
public virtual void LoadAppOpen() | ||
{ | ||
if (AppOpenAdUnit() == null) return; | ||
if (!IsAppOpenReady()) AppOpenAdUnit().Load(); | ||
} | ||
|
||
public virtual void ShowAppOpen() | ||
{ | ||
if (_statusAppOpenFirstIgnore) AppOpenAdUnit().Show(); | ||
_statusAppOpenFirstIgnore = true; | ||
} | ||
|
||
#endregion | ||
public abstract void LoadBanner(); | ||
public abstract void LoadInterstitial(); | ||
public abstract void LoadRewarded(); | ||
public abstract void LoadRewardedInterstitial(); | ||
public abstract void LoadAppOpen(); | ||
public abstract void ShowAppOpen(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.