update: 添加 IsIapUser 的属性

deeplink
胡宇飞 2024-05-17 10:28:35 +08:00
parent e4f51978d1
commit 777ac87b18
3 changed files with 27 additions and 6 deletions

View File

@ -30,7 +30,8 @@ namespace Guru
public int b_level = 0; public int b_level = 0;
public int b_play = 0; public int b_play = 0;
public int buy_count = 0; public int buy_count = 0;
public bool is_iap_user = false;
public List<PurchasedProduct> purchased; public List<PurchasedProduct> purchased;
//-------------- data --------------- //-------------- data ---------------
@ -91,14 +92,27 @@ namespace Guru
_uid.Value = value; _uid.Value = value;
} }
} }
public bool IsIAPUser => PurchasedCount > 0; public bool IsIapUser
{
get
{
if(_isIapUser == null) InitProperties();
return _isIapUser.Value;
}
set
{
if(_isIapUser == null) InitProperties();
_isIapUser.Value = value;
}
}
private BindableProperty<int> _successLevel; private BindableProperty<int> _successLevel;
private BindableProperty<int> _totalPlayed; private BindableProperty<int> _totalPlayed;
private BindableProperty<int> _purchasedCount; private BindableProperty<int> _purchasedCount;
private BindableProperty<string> _uid; private BindableProperty<string> _uid;
private BindableProperty<bool> _isIapUser;
public BindableProperty<int> PropBLevel => _successLevel; public BindableProperty<int> PropBLevel => _successLevel;
public BindableProperty<int> PropBPlay => _totalPlayed; public BindableProperty<int> PropBPlay => _totalPlayed;
@ -146,6 +160,7 @@ namespace Guru
_totalPlayed = new BindableProperty<int>(b_play, OnPlayedChanged); _totalPlayed = new BindableProperty<int>(b_play, OnPlayedChanged);
_purchasedCount = new BindableProperty<int>(buy_count, OnPurchasedNumChanged); _purchasedCount = new BindableProperty<int>(buy_count, OnPurchasedNumChanged);
_uid = new BindableProperty<string>(uid, OnUidChanged); _uid = new BindableProperty<string>(uid, OnUidChanged);
_isIapUser = new BindableProperty<bool>(is_iap_user, OnIsIapUserChanged);
purchased = new List<PurchasedProduct>(20); purchased = new List<PurchasedProduct>(20);
} }
@ -190,6 +205,12 @@ namespace Guru
uid = value; uid = value;
Save(); Save();
} }
private void OnIsIapUserChanged(bool value)
{
is_iap_user = value;
Save();
}
#endregion #endregion
#region 启动配置 #region 启动配置

View File

@ -243,7 +243,7 @@ namespace Guru
return; return;
} }
SetUserIsIAP(Model.IsIAPUser); // 预先设置用户的 IAP User 属性 SetUserIsIAP(Model.IsIapUser); // 预先设置用户的 IAP User 属性
SetUserBLevel(Model.SuccessLevelId); // 预先设置用户的 BLevel 属性 SetUserBLevel(Model.SuccessLevelId); // 预先设置用户的 BLevel 属性
SetUserBPlay(Model.TotalPlayedCount); // 预先设置用户的 BPlay 属性 SetUserBPlay(Model.TotalPlayedCount); // 预先设置用户的 BPlay 属性
} }

View File

@ -368,7 +368,7 @@ namespace Guru
Try(() => Try(() =>
{ {
LogI($"#4.4 --- Start Keywords ---"); LogI($"#4.4 --- Start Keywords ---");
KeywordsManager.Install(Model.IsIAPUser, Model.SuccessLevelId); // 启动Keyword管理器 KeywordsManager.Install(Model.IsIapUser, Model.SuccessLevelId); // 启动Keyword管理器
}, ex => }, ex =>
{ {
UnityEngine.Debug.LogError($"--- ERROR on Keywords: {ex.Message}"); UnityEngine.Debug.LogError($"--- ERROR on Keywords: {ex.Message}");