Skip to content

Commit

Permalink
Merge pull request #45 from VirtueSky/dev
Browse files Browse the repository at this point in the history
Dev
  • Loading branch information
VirtueSky authored Dec 24, 2024
2 parents 93dda2c + 14e62f8 commit e3a08ba
Show file tree
Hide file tree
Showing 8 changed files with 156 additions and 122 deletions.
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,9 @@
### 1: Download the repo and drop it into folder `Assets`
### 2: Add the line below to `Packages/manifest.json`

for version `3.2.4`
for version `3.2.5`
```csharp
"com.virtuesky.sunflower":"https://github.com/VirtueSky/sunflower.git#3.2.4",
"com.virtuesky.sunflower":"https://github.com/VirtueSky/sunflower.git#3.2.5",
```

## Includes modules
Expand Down
37 changes: 37 additions & 0 deletions VirtueSky/Advertising/Runtime/Admob/AdmobAdClient.cs
Original file line number Diff line number Diff line change
Expand Up @@ -42,9 +42,11 @@ public override void Initialize()
LoadRewarded();
LoadRewardedInterstitial();
LoadAppOpen();
LoadBanner();
#endif
}


#if VIRTUESKY_ADS && VIRTUESKY_ADMOB
void RegisterAppStateChange()
{
Expand All @@ -60,5 +62,40 @@ void OnAppStateChanged(GoogleMobileAds.Common.AppState state)
}
}
#endif
public override void LoadBanner()
{
if (adSetting.AdmobBannerVariable == null) return;
adSetting.AdmobBannerVariable.Load();
}

public override void LoadInterstitial()
{
if (adSetting.AdmobInterVariable == null) return;
if (!adSetting.AdmobInterVariable.IsReady()) adSetting.AdmobInterVariable.Load();
}

public override void LoadRewarded()
{
if (adSetting.AdmobRewardVariable == null) return;
if (!adSetting.AdmobRewardVariable.IsReady()) adSetting.AdmobRewardVariable.Load();
}

public override void LoadRewardedInterstitial()
{
if (adSetting.AdmobRewardInterVariable == null) return;
if (!adSetting.AdmobRewardInterVariable.IsReady()) adSetting.AdmobRewardInterVariable.Load();
}

public override void LoadAppOpen()
{
if (adSetting.AdmobAppOpenVariable == null) return;
if (!adSetting.AdmobAppOpenVariable.IsReady()) adSetting.AdmobAppOpenVariable.Load();
}

public override void ShowAppOpen()
{
if (statusAppOpenFirstIgnore) adSetting.AdmobAppOpenVariable.Show();
statusAppOpenFirstIgnore = true;
}
}
}
117 changes: 7 additions & 110 deletions VirtueSky/Advertising/Runtime/General/AdClient.cs
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();
}
}
34 changes: 33 additions & 1 deletion VirtueSky/Advertising/Runtime/IronSource/IronSourceAdClient.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using UnityEngine;
using VirtueSky.Core;
using VirtueSky.Tracking;

Expand All @@ -7,6 +6,7 @@ namespace VirtueSky.Ads
public class IronSourceAdClient : AdClient
{
public bool SdkInitializationCompleted { get; private set; }

public override void Initialize()
{
SdkInitializationCompleted = false;
Expand All @@ -27,7 +27,9 @@ public override void Initialize()
#endif
LoadInterstitial();
LoadRewarded();
LoadBanner();
}

#if VIRTUESKY_ADS && VIRTUESKY_IRONSOURCE
private void ImpressionDataReadyEvent(IronSourceImpressionData impressionData)
{
Expand All @@ -48,5 +50,35 @@ void SdkInitializationCompletedEvent()
{
SdkInitializationCompleted = true;
}

public override void LoadBanner()
{
if (adSetting.IronSourceBannerVariable == null) return;
adSetting.IronSourceBannerVariable.Load();
}

public override void LoadInterstitial()
{
if (adSetting.IronSourceInterVariable == null) return;
if (!adSetting.IronSourceInterVariable.IsReady()) adSetting.IronSourceInterVariable.Load();
}

public override void LoadRewarded()
{
if (adSetting.IronSourceRewardVariable == null) return;
if (!adSetting.IronSourceRewardVariable.IsReady()) adSetting.IronSourceRewardVariable.Load();
}

public override void LoadRewardedInterstitial()
{
}

public override void LoadAppOpen()
{
}

public override void ShowAppOpen()
{
}
}
}
39 changes: 38 additions & 1 deletion VirtueSky/Advertising/Runtime/Max/MaxAdClient.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
using UnityEngine;
using VirtueSky.Core;

namespace VirtueSky.Ads
Expand All @@ -20,9 +19,11 @@ public override void Initialize()
LoadRewarded();
LoadRewardedInterstitial();
LoadAppOpen();
LoadBanner();
#endif
}


#if VIRTUESKY_ADS && VIRTUESKY_APPLOVIN
private void OnAppStateChange(bool pauseStatus)
{
Expand All @@ -32,5 +33,41 @@ private void OnAppStateChange(bool pauseStatus)
}
}
#endif

public override void LoadBanner()
{
if (adSetting.MaxBannerVariable == null) return;
adSetting.MaxBannerVariable.Load();
}

public override void LoadInterstitial()
{
if (adSetting.MaxInterVariable == null) return;
if (!adSetting.MaxInterVariable.IsReady()) adSetting.MaxInterVariable.Load();
}

public override void LoadRewarded()
{
if (adSetting.MaxRewardVariable == null) return;
if (!adSetting.MaxRewardVariable.IsReady()) adSetting.MaxRewardVariable.Load();
}

public override void LoadRewardedInterstitial()
{
if (adSetting.MaxRewardInterVariable == null) return;
if (!adSetting.MaxRewardInterVariable.IsReady()) adSetting.MaxRewardInterVariable.Load();
}

public override void LoadAppOpen()
{
if (adSetting.MaxAppOpenVariable == null) return;
if (!adSetting.MaxAppOpenVariable.IsReady()) adSetting.MaxAppOpenVariable.Load();
}

public override void ShowAppOpen()
{
if (statusAppOpenFirstIgnore) adSetting.MaxAppOpenVariable.Show();
statusAppOpenFirstIgnore = true;
}
}
}
8 changes: 3 additions & 5 deletions VirtueSky/ControlPanel/ConstantPackage.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
{
public class ConstantPackage
{
public const string VersionSunflower = "3.2.4";
public const string VersionSunflower = "3.2.5";
public const string PackageNameInAppPurchase = "com.unity.purchasing";
public const string MaxVersionInAppPurchase = "4.12.2";
public const string PackageNameNewtonsoftJson = "com.unity.nuget.newtonsoft-json";
Expand Down Expand Up @@ -97,18 +97,16 @@ public class ConstantPackage
public const string PackageNameCoffeeUIEffect = "com.coffee.ui-effect";

public const string MaxVersionCoffeeUIEffect =
"https://github.com/mob-sakai/UIEffect.git?path=Packages/src#5.0.1";
"https://github.com/mob-sakai/UIEffect.git?path=Packages/src#5.0.2";

public const string PackageNameCoffeeUIParticle = "com.coffee.ui-particle";

public const string MaxVersionCoffeeUIParticle =
"https://github.com/mob-sakai/ParticleEffectForUGUI.git#4.10.3";
"https://github.com/mob-sakai/ParticleEffectForUGUI.git#4.10.5";

public const string PackageNameAppleSignIn = "com.lupidan.apple-signin-unity";

public const string MaxVersionAppleSignIn = "https://github.com/lupidan/apple-signin-unity.git#v1.4.3";
//public const string PackageNameAnimancer = "com.virtuesky.animancer";
//public const string MaxVersionAnimancer = "https://github.com/VirtueSky/animancer-unity.git#7.0.0";

#region Spine

Expand Down
34 changes: 33 additions & 1 deletion VirtueSky/Iap/Runtime/IapDataVariable.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,9 @@ public class IapDataVariable : ScriptableObject
[ReadOnly] public string id;
[ReadOnly] public ProductType productType;

[Space] public float price;
[Tooltip("Price config used for UI"), Space]
public float priceConfig;

[SerializeField] private IapPurchaseSuccess onPurchaseSuccess;
[SerializeField] private IapPurchaseFailed onPurchaseFailed;
internal IapPurchaseSuccess OnPurchaseSuccess => onPurchaseSuccess;
Expand Down Expand Up @@ -54,6 +56,36 @@ public bool IsPurchased()
if (iapManager == null) return false;
return iapManager.IsPurchasedProduct(this);
}

public string GetLocalizedPriceString()
{
if (GetProduct() == null) return String.Empty;
return GetProduct().metadata.localizedPriceString;
}

public string GetIsoCurrencyCode()
{
if (GetProduct() == null) return String.Empty;
return GetProduct().metadata.isoCurrencyCode;
}

public string GetLocalizedDescription()
{
if (GetProduct() == null) return String.Empty;
return GetProduct().metadata.localizedDescription;
}

public string GetLocalizedTitle()
{
if (GetProduct() == null) return String.Empty;
return GetProduct().metadata.localizedTitle;
}

public decimal GetLocalizedPrice()
{
if (GetProduct() == null) return 0;
return GetProduct().metadata.localizedPrice;
}
}
}
#endif
Loading

0 comments on commit e3a08ba

Please sign in to comment.