update: 删除无用的属性

main
胡宇飞 2024-08-11 21:31:25 +08:00
parent 0870e71cf9
commit 018fb2c35b
3 changed files with 14 additions and 45 deletions

View File

@ -3,7 +3,6 @@ namespace Guru
using System; using System;
using UnityEngine; using UnityEngine;
using System.Collections.Generic; using System.Collections.Generic;
using Newtonsoft.Json;
using System.Linq; using System.Linq;
@ -38,8 +37,8 @@ namespace Guru
private DateTime _lastSavedTime = new DateTime(1970,1,1); private DateTime _lastSavedTime = new DateTime(1970,1,1);
private bool _noAds = false; private bool _noAds = false;
private readonly BindableProperty<int> _bLevel; private int _bLevel;
private readonly BindableProperty<int> _bPlay; private int _bPlay;
private string _uid; private string _uid;
private List<PurchasedProduct> _purchased; private List<PurchasedProduct> _purchased;
@ -60,33 +59,33 @@ namespace Guru
GuruSDKSerializedModel model = LoadModel(); GuruSDKSerializedModel model = LoadModel();
_uid = model.uid; _uid = model.uid;
_noAds = model.no_ads; _noAds = model.no_ads;
_bLevel = new BindableProperty<int>(model.b_level); _bLevel = model.b_level;
_bPlay = new BindableProperty<int>(model.b_play); _bPlay = model.b_play;
_purchased = model.purchased; _purchased = model.purchased;
} }
public int BLevel public int BLevel
{ {
get => _bLevel.Value; get => _bLevel;
set set
{ {
if (value < _bLevel.Value) if (value < _bLevel)
{ {
// b_level 必须比上一次的值大 // b_level 必须比上一次的值大
Debug.LogWarning($"[SDK] :: Set b_level [{value}] should not be less than original value [{_bLevel.Value}]"); Debug.LogWarning($"[SDK] :: Set b_level [{value}] should not be less than original value [{_bLevel}]");
return; return;
} }
_bLevel.Value = value; _bLevel = value;
Save(); Save();
} }
} }
public int BPlay public int BPlay
{ {
get => _bPlay.Value; get => _bPlay;
set set
{ {
_bPlay.Value = value; _bPlay = value;
Save(); Save();
} }
} }
@ -114,17 +113,6 @@ namespace Guru
} }
} }
public void SetOnBLevelChanged(Action<int> action)
{
_bLevel.OnValueChanged += action;
}
public void SetOnBPlayChanged(Action<int> action)
{
_bPlay.OnValueChanged += action;
}
#region 初始化 #region 初始化
@ -153,14 +141,13 @@ namespace Guru
/// <summary> /// <summary>
/// 保存至 PlayerPrefs 数据 /// 保存至 PlayerPrefs 数据
/// </summary> /// </summary>
/// <param name="writeToDisk"></param>
private void SetToMemory() private void SetToMemory()
{ {
var model = new GuruSDKSerializedModel() var model = new GuruSDKSerializedModel()
{ {
uid = _uid, uid = _uid,
b_level = _bLevel.Value, b_level = _bLevel,
b_play = _bPlay.Value, b_play = _bPlay,
no_ads = _noAds, no_ads = _noAds,
purchased = _purchased, purchased = _purchased,
}; };

View File

@ -57,11 +57,13 @@ namespace Guru
public static void SetUserBLevel(int bLevel) public static void SetUserBLevel(int bLevel)
{ {
Analytics.SetBLevel(bLevel);
Model.BLevel = bLevel; Model.BLevel = bLevel;
} }
public static void SetUserBPlay(int bPlay) public static void SetUserBPlay(int bPlay)
{ {
Analytics.SetBPlay(bPlay);
Model.BPlay = bPlay; Model.BPlay = bPlay;
} }

View File

@ -111,9 +111,6 @@ namespace Guru
/// <param name="onComplete"></param> /// <param name="onComplete"></param>
private void StartWithConfig(GuruSDKInitConfig config, Action<bool> onComplete) private void StartWithConfig(GuruSDKInitConfig config, Action<bool> onComplete)
{ {
Model.SetOnBLevelChanged(OnBLevelChanged);
Model.SetOnBPlayChanged(OnBPlayChanged);
IsInitialSuccess = false; IsInitialSuccess = false;
_initConfig = config; _initConfig = config;
_isDebugEnabled = config.DebugMode; _isDebugEnabled = config.DebugMode;
@ -416,23 +413,6 @@ namespace Guru
CheckAttStatus(); CheckAttStatus();
} }
#endif #endif
#endregion
#region 数据
private void OnBLevelChanged(int bLevel)
{
Debug.Log($"[ANU][SDK] --- OnBLevelChanged: {bLevel}");
Analytics.SetBLevel(bLevel);
}
private void OnBPlayChanged(int bPlay)
{
Debug.Log($"[ANU][SDK] --- OnBPlayChanged: {bPlay}");
Analytics.SetBPlay(bPlay);
}
#endregion #endregion
#region Logging #region Logging