feat(upserver): 保存M2客户端KV迁移至本人统计写检查点

保存独立KV用户服务、固定会话存档与原业务接线,以及C3d资料缓存和C3e本人统计写。
保留原PF/AGG路线、业务公式和时序;榜单读取、好友资料、公告、匹配及首场景闸仍待完成。

验证:ServiceHost两条件各33组646断言;Unity CLI Loop编译0错误269警告。
包含相关方案、评审裁决、测试及状态文档。未操作服务器、正式账号或打包。
This commit is contained in:
Liubing\LB
2026-09-30 19:19:05 +08:00
parent 1c0cdf7a99
commit 6813da149a
511 changed files with 151858 additions and 2376 deletions

View File

@@ -1,4 +1,4 @@
using asap.core;
using asap.core;
using cfg;
using GameCore;
using Newtonsoft.Json;
@@ -14,6 +14,8 @@ namespace Assets.Scripts.UI.AdWheel
{
public class AdWheelManager:IDisposable
{
readonly game.PlayerDataStorage.IPlayerSaveStore saveStore = GContext.container.Resolve<game.PlayerDataStorage.IPlayerSaveStore>();
public AdWheelManager()
{
@@ -97,7 +99,7 @@ namespace Assets.Scripts.UI.AdWheel
private AdWheelData GetCachedData()
{
var dataStr = PlayFabMgr.Instance.GetLocalData(nameof(AdWheelData));
var dataStr = saveStore.Read(nameof(AdWheelData)).ValueOrThrow();
#if UNITY_EDITOR
Debug.Log($"jsd AdWheelData LoadData sData {dataStr}");
#endif
@@ -117,7 +119,7 @@ namespace Assets.Scripts.UI.AdWheel
#if UNITY_EDITOR
Debug.Log($"jsd AdWheelData SaveData {JsonConvert.SerializeObject(Data)}");
#endif
PlayFabMgr.Instance.UpdateUserDataValue(nameof(AdWheelData), JsonConvert.SerializeObject(Data));
saveStore.Write(nameof(AdWheelData), JsonConvert.SerializeObject(Data)).RequireAccepted();
}
private List<IWheelReward> _rewards = new List<IWheelReward>();

View File

@@ -1,4 +1,4 @@
using System;
using System;
using asap.core;
using Assets.Scripts.UI.AdWheel;
using cfg;
@@ -19,6 +19,8 @@ public class AdvertData
}
public class AdvertPanel : MonoBehaviour
{
game.PlayerDataStorage.IPlayerSaveStore saveStore;
Button btn_close;
TMP_Text txt_energy, txt_money, txt_ticket;
ulong _curGold;
@@ -35,6 +37,7 @@ public class AdvertPanel : MonoBehaviour
private void Awake()
{
saveStore = GContext.container.Resolve<game.PlayerDataStorage.IPlayerSaveStore>();
txt_ticket = transform.Find("top_area/resource/icon_ticket/text_num").GetComponent<TMP_Text>();
txt_energy = transform.Find("top_area/resource/icon_energy/text_num").GetComponent<TMP_Text>();
txt_money = transform.Find("top_area/resource/icon_money/text_num").GetComponent<TMP_Text>();
@@ -94,7 +97,7 @@ public class AdvertPanel : MonoBehaviour
// 判断是否满足{seconds}没有充值了
private bool Condition_NoRechargeSeconds(int timeSeconds)
{
var lastPaymentStr = PlayFabMgr.Instance.GetLocalData("LastPaymentTime");
var lastPaymentStr = saveStore.Read("LastPaymentTime").ValueOrThrow();
DateTime curTime = ZZTimeHelper.UtcNow().UtcNowOffset();
DateTime endTime = curTime;
if (string.IsNullOrEmpty(lastPaymentStr) || !lastPaymentStr.Contains("__"))

View File

@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using GameCore;
using asap.core;
@@ -14,6 +14,8 @@ using Activity.Event;
public class DeBugPanel : MonoBehaviour
{
game.PlayerDataStorage.IPlayerSaveStore saveStore;
static public bool isShow = true;
private CanvasGroup _canvasGroup;
private Button btn_close;
@@ -111,6 +113,7 @@ public class DeBugPanel : MonoBehaviour
// Start is called before the first frame update
void Awake()
{
saveStore = GContext.container.Resolve<game.PlayerDataStorage.IPlayerSaveStore>();
inputField_itemId = transform.Find("root/InputField_icon").GetComponent<TMP_InputField>();
inputField_itemCount = transform.Find("root/InputField_icon_num").GetComponent<TMP_InputField>();
btn_addItem = transform.Find("root/btn_sure2/btn_green").GetComponent<Button>();
@@ -572,7 +575,7 @@ public class DeBugPanel : MonoBehaviour
data.refreshCount = 0;
data.adCount = 0;
data.refreshDay = ZZTimeHelper.UtcNow().UtcNowOffset().Date.DayOfYear;
PlayFabMgr.Instance.UpdateUserDataValue(AquariumManager.AquariumEventDataNewKey, data.Serialize());
saveStore.Write(AquariumManager.AquariumEventDataNewKey, data.Serialize()).RequireAccepted();
}
}

View File

@@ -1,4 +1,4 @@
using asap.core;
using asap.core;
using cfg;
using game;
using GameCore;

View File

@@ -1,4 +1,4 @@
using System;
using System;
using asap.core;
using cfg;
using GameCore;
@@ -12,6 +12,8 @@ namespace Assets.Scripts.UI.JigsawPuzzle
{
public class JigsawPuzzleManager:IDisposable
{
readonly game.PlayerDataStorage.IPlayerSaveStore saveStore = GContext.container.Resolve<game.PlayerDataStorage.IPlayerSaveStore>();
public const string PriceImgName = "separate_icon_eventjigsawpuzzle_piece_";
public JigsawPuzzleManager()
@@ -77,7 +79,7 @@ namespace Assets.Scripts.UI.JigsawPuzzle
}
private JigsawPuzzleData GetCacheData()
{
string dataStr = PlayFabMgr.Instance.GetLocalData(nameof(JigsawPuzzleData));
string dataStr = saveStore.Read(nameof(JigsawPuzzleData)).ValueOrThrow();
#if UNITY_EDITOR
Debug.Log($"jsd JigsawPuzzleData LoadData sData {dataStr}");
#endif
@@ -91,7 +93,7 @@ namespace Assets.Scripts.UI.JigsawPuzzle
#if UNITY_EDITOR
Debug.Log($"jsd JigsawPuzzleData SaveData {JsonConvert.SerializeObject(Data)}");
#endif
PlayFabMgr.Instance.UpdateUserDataValue(nameof(JigsawPuzzleData), JsonConvert.SerializeObject(Data));
saveStore.Write(nameof(JigsawPuzzleData), JsonConvert.SerializeObject(Data)).RequireAccepted();
}
private List<EventJigsawPuzzleReward> _rewards = new List<EventJigsawPuzzleReward>();

View File

@@ -1,4 +1,4 @@
using System.Text;
using System.Text;
using GameCore;
using cfg;
using asap.core;
@@ -10,6 +10,8 @@ namespace OfferStoryChain
{
public class Manager
{
readonly game.PlayerDataStorage.IPlayerSaveStore saveStore = GContext.container.Resolve<game.PlayerDataStorage.IPlayerSaveStore>();
#region RedPoint
public bool DoNeedRedPoint
{
@@ -86,7 +88,7 @@ namespace OfferStoryChain
public bool Load()
{
var s = PlayFabMgr.Instance.GetLocalData(PlayFabKey);
var s = saveStore.Read(PlayFabKey).ValueOrThrow();
if (string.IsNullOrEmpty(s))
{
Debug.LogWarning("[OfferStoryChain] No pf data found.");
@@ -121,7 +123,7 @@ namespace OfferStoryChain
{
var sb = new StringBuilder();
sb.AppendFormat("{0},{1},{2},{3}", _eventId, _progress, _vipOnTrigger, _roundCount);
PlayFabMgr.Instance.UpdateUserDataValue(PlayFabKey, sb.ToString());
saveStore.Write(PlayFabKey, sb.ToString()).RequireAccepted();
}
public void Reset()

View File

@@ -1,4 +1,4 @@
using System;
using System;
using asap.core;
using cfg;
using GameCore;
@@ -14,6 +14,8 @@ namespace Assets.Scripts.UI.OfferSweep
{
public class OfferSweepManager : IDisposable,IOrderReplenishment
{
readonly game.PlayerDataStorage.IPlayerSaveStore saveStore = GContext.container.Resolve<game.PlayerDataStorage.IPlayerSaveStore>();
public OfferSweepManager()
{
GContext.OnEvent<TargetEvent>().Subscribe(OnEvent_TargetEvent).AddTo(Disposables);
@@ -43,7 +45,7 @@ namespace Assets.Scripts.UI.OfferSweep
private OfferSweepPackData GetCachedData()
{
var dataStr = PlayFabMgr.Instance.GetLocalData(nameof(OfferSweepPackData));
var dataStr = saveStore.Read(nameof(OfferSweepPackData)).ValueOrThrow();
#if UNITY_EDITOR
Debug.Log($"jsd OfferSweepPackData LoadData sData {dataStr}");
#endif
@@ -99,7 +101,7 @@ namespace Assets.Scripts.UI.OfferSweep
#if UNITY_EDITOR
Debug.Log($"jsd OfferSweepPackData SaveData {JsonConvert.SerializeObject(SweepPackData)}");
#endif
PlayFabMgr.Instance.UpdateUserDataValue(nameof(OfferSweepPackData), JsonConvert.SerializeObject(SweepPackData));
saveStore.Write(nameof(OfferSweepPackData), JsonConvert.SerializeObject(SweepPackData)).RequireAccepted();
}
public FishingEvent GetCurrentLoopEvent()

View File

@@ -1,4 +1,4 @@
using System.Collections.Generic;
using System.Collections.Generic;
using GameCore;
using System.Linq;
using asap.core;
@@ -11,6 +11,8 @@ namespace OfferTreasureAscent
{
public class Manager
{
readonly game.PlayerDataStorage.IPlayerSaveStore saveStore = GContext.container.Resolve<game.PlayerDataStorage.IPlayerSaveStore>();
private int _status = 0, _eventId, _redirectId;
private List<int> _failedPurchaseRewardIndices;
private PlayerItemData _playerItemData => GContext.container.Resolve<PlayerItemData>();
@@ -78,14 +80,14 @@ namespace OfferTreasureAscent
if (_failedPurchaseRewardIndices != null && _failedPurchaseRewardIndices.Count > 0)
foreach (var i in _failedPurchaseRewardIndices)
sb.AppendFormat("{0},", i);
PlayFabMgr.Instance.UpdateUserDataValue(PfKey, sb.ToString());
saveStore.Write(PfKey, sb.ToString()).RequireAccepted();
}
public bool Load()
{
try
{
var s = PlayFabMgr.Instance.GetLocalData(PfKey);
var s = saveStore.Read(PfKey).ValueOrThrow();
if (s == null || s == "")
return false;
var tokens = s.Trim(',').Split(',');

View File

@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using asap.core;
@@ -15,6 +15,8 @@ using UniRx;
public class EventPartnerData
{
readonly game.PlayerDataStorage.IPlayerSaveStore saveStore = GContext.container.Resolve<game.PlayerDataStorage.IPlayerSaveStore>();
private bool _lock = false, _whole = false;
private MetaData _data;
private readonly Tables _tables = GContext.container.Resolve<Tables>();
@@ -201,12 +203,13 @@ public class EventPartnerData
}
Debug.Log($"Cache Done");
}
var pfString = PlayFabMgr.Instance.GetLocalData(EventPartnerPlayfabData.Key);
var pfString = saveStore.Read(EventPartnerPlayfabData.Key).ValueOrThrow();
EventPartnerPlayfabData pfData = EventPartnerPlayfabData.FromString(pfString);
Debug.Log($"<color=#2d7cee>[EventPartner] Try get response in load data:</color>");
var detailRequest = new EventBuildDetailRequest() { eventId = e.ID };
var response = await GContext.container.Resolve<ICustomServerMgr>()
.EventPartnerRequest<EventBuildDetailResp>(DetailUrl, detailRequest);
if (!saveStore.IsCurrent) throw new System.OperationCanceledException();
if (response == null)
{
response = new EventBuildDetailResp();
@@ -1362,6 +1365,8 @@ public class EventPartnerData
public class EventPartnerPlayfabData
{
readonly game.PlayerDataStorage.IPlayerSaveStore saveStore = GContext.container.Resolve<game.PlayerDataStorage.IPlayerSaveStore>();
[JsonIgnore]
public const string Key = "EventPartnerData";
public int EventId { get; set; }
@@ -1374,7 +1379,7 @@ public class EventPartnerData
public void Save()
{
var s = JsonConvert.SerializeObject(this);
PlayFabMgr.Instance.UpdateUserDataValue("EventPartnerData", s);
saveStore.Write("EventPartnerData", s).RequireAccepted();
}
public static EventPartnerPlayfabData FromString(string s)

View File

@@ -1,4 +1,4 @@
using asap.core;
using asap.core;
using TMPro;
using UnityEngine;
using UnityEngine.UI;
@@ -10,6 +10,8 @@ using System.Collections.Generic;
public class EventPartnerEntryButton : EventButtonResource
{
game.PlayerDataStorage.IPlayerSaveStore saveStore;
[SerializeField] private TMP_Text _textTimer;
[SerializeField] private Button _btn;
[SerializeField] CanvasGroup _homeCanvasGroup;
@@ -18,6 +20,7 @@ public class EventPartnerEntryButton : EventButtonResource
private void Awake()
{
saveStore = GContext.container.Resolve<game.PlayerDataStorage.IPlayerSaveStore>();
// Debug.Log($"<color=#e23f31>[EventPartner] Icon Awake</color>");
GContext.OnEvent<EventPartnerDataLoaded>().Subscribe(_ => OnDataLoaded()).AddTo(this);
}
@@ -107,12 +110,13 @@ public class EventPartnerEntryButton : EventButtonResource
var _data = GContext.container.Resolve<EventPartnerData>();
var _playerPreferenceKey = "EventPartnerRecommendCache" + _userService.UserId;
//Load Player Preferences
var pfString = PlayFabMgr.Instance.GetLocalData(EventPartnerPlayfabData.Key);
var pfString = saveStore.Read(EventPartnerPlayfabData.Key).ValueOrThrow();
EventPartnerPlayfabData pfData = EventPartnerPlayfabData.FromString(pfString);
Debug.Log($"<color=#2d7cee>[EventPartner] Try get response in load data from entrance:</color>");
var detailRequest = new EventBuildDetailRequest() { eventId = _data.EventId };
var response = await GContext.container.Resolve<ICustomServerMgr>()
.EventPartnerRequest<EventBuildDetailResp>(DetailUrl, detailRequest);
if (this == null || !saveStore.IsCurrent) return false;
if (response == null)
{
Debug.Log($"<color=red>[EventPartner] No response. </color>");

View File

@@ -1,3 +1,4 @@
using asap.core;
using System;
using System.Collections.Generic;
using System.Text;
@@ -5,6 +6,8 @@ using UnityEngine;
public class EventPartnerStatuePlayfabData
{
readonly game.PlayerDataStorage.IPlayerSaveStore saveStore = GContext.container.Resolve<game.PlayerDataStorage.IPlayerSaveStore>();
public int EventId;
public int TicketCount;
public int BuffFreeMultiplier;
@@ -96,14 +99,14 @@ public class EventPartnerStatuePlayfabData
public static EventPartnerStatuePlayfabData Load()
{
var s = PlayFabMgr.Instance.GetLocalData(Key);
var s = GContext.container.Resolve<game.PlayerDataStorage.IPlayerSaveStore>().Read(Key).ValueOrThrow();
return Deserialize(s);
}
public void Save()
{
var s = Serialized();
PlayFabMgr.Instance.UpdateUserDataValue(Key, s);
saveStore.Write(Key, s).RequireAccepted();
}
}

View File

@@ -1,4 +1,4 @@
using UnityEngine;
using UnityEngine;
using asap.core;
using System.Collections.Generic;
using UniRx;
@@ -40,6 +40,8 @@ public class EventPartnerStatueTokenExchangeFishRaid
public class EventPartnerStatueTokenExchangeData
{
readonly game.PlayerDataStorage.IPlayerSaveStore saveStore = GContext.container.Resolve<game.PlayerDataStorage.IPlayerSaveStore>();
#region State
private int _eventId = 0;
private int _tokenGiven = 0;
@@ -189,12 +191,12 @@ public class EventPartnerStatueTokenExchangeData
public void SaveData()
{
PlayFabMgr.Instance.UpdateUserDataValue(PlayfabKey, $"{_eventId}|{_tokenGiven}|{_currentScore}");
saveStore.Write(PlayfabKey, $"{_eventId}|{_tokenGiven}|{_currentScore}").RequireAccepted();
}
public bool LoadData()
{
var s = PlayFabMgr.Instance.GetLocalData(PlayfabKey);
var s = saveStore.Read(PlayfabKey).ValueOrThrow();
if (s == null)
return false;
try

View File

@@ -1,4 +1,4 @@
using System.Collections.Generic;
using System.Collections.Generic;
using asap.core;
using cfg;
using GameCore;
@@ -10,6 +10,8 @@ namespace game
{
public class EventPinataPackDataManager:IOrderReplenishment,IOrderSuccess
{
[asap.core.Inject] public game.PlayerDataStorage.IPlayerSaveStore SaveStore { get; set; }
private readonly EventPinataPackData _kvTarget;
private EventPinataPackDataManager(EventPinataPackData target) { _kvTarget=target; }
internal static EventPinataPackDataManager CreateForKVLoad()
@@ -107,7 +109,7 @@ namespace game
#if UNITY_EDITOR
Debug.Log($"jsd SaveData {JsonConvert.SerializeObject(pinataPackData)}");
#endif
PlayFabMgr.Instance.UpdateUserDataValue(nameof(EventPinataPackData), JsonConvert.SerializeObject(pinataPackData));
SaveStore.Write(nameof(EventPinataPackData), JsonConvert.SerializeObject(pinataPackData)).RequireAccepted();
}
/// <summary>
///

View File

@@ -1,4 +1,4 @@
using asap.core;
using asap.core;
using game;
using GameCore;
using System.Text;
@@ -7,6 +7,8 @@ namespace PinballUncountable
{
public class Manager : IHasMultiplier
{
readonly game.PlayerDataStorage.IPlayerSaveStore saveStore = GContext.container.Resolve<game.PlayerDataStorage.IPlayerSaveStore>();
private int _score, _ticketCount, _hitCountLeft, _hitCountRight;
private float _inflationRate = 0f;
private IEventAggregator _eventAggregator = new EventAggregator();
@@ -52,7 +54,7 @@ namespace PinballUncountable
public bool Load()
{
return Deserialize(PlayFabMgr.Instance.GetLocalData(_playfabKey));
return Deserialize(saveStore.Read(_playfabKey).ValueOrThrow());
}
public void InitTest()
@@ -258,7 +260,7 @@ namespace PinballUncountable
public void SavePlayfab()
{
// UnityEngine.Debug.Log("[PinballUncountable]Save Data.");
PlayFabMgr.Instance.UpdateUserDataValue(_playfabKey, Serialize());
saveStore.Write(_playfabKey, Serialize()).RequireAccepted();
}
public void SavePlayerPreferences(int multiplier)

View File

@@ -1,4 +1,4 @@
using System;
using System;
using System.Threading.Tasks;
using asap.core;
using cfg;
@@ -11,6 +11,8 @@ using UnityEngine.UI;
public class BindAccountPopupPanel : MonoBehaviour
{
game.PlayerDataStorage.IPlayerSaveStore saveStore;
IUserService userService;
Button btn_close;
Button btn_close1;
@@ -27,6 +29,7 @@ public class BindAccountPopupPanel : MonoBehaviour
ItemData itemData;
private void Awake()
{
saveStore = GContext.container.Resolve<game.PlayerDataStorage.IPlayerSaveStore>();
userService = GContext.container.Resolve<IUserService>();
btn_close1 = transform.Find("btn_close").GetComponent<Button>();
btn_close = transform.Find("mask").GetComponent<Button>();
@@ -203,10 +206,11 @@ public class BindAccountPopupPanel : MonoBehaviour
{
UIManager.ShowWaitingBlock("BindAccountPopupPanel::OnlinkSns");
var (code, userid) = await userService.LinkAccount(accountType);
if (this == null || !saveStore.IsCurrent) return false;
if (code == 0)
{
PlayFabMgr.Instance.UpdateUserDataValue(accountType.ToString(), "1");
saveStore.Write(accountType.ToString(), "1").RequireAccepted();
ToastPanel.Show(LocalizationMgr.GetText("UI_BindAccountPopupPanel_101007"));
}
else if (code == -1 && userid != int.Parse(userService.CustomId))
@@ -214,6 +218,7 @@ public class BindAccountPopupPanel : MonoBehaviour
var config = GContext.container.Resolve<IConfig>();
var titleId = config.Get<string>(GConstant.K_PlayFab_Title, GConstant.V_Debug_PF_Title);
var info = await PlayFabTools.GetPFPlayerInfoBySDKId(userid, titleId);
if (this == null || !saveStore.IsCurrent) return false;
if (!info.IsAccountValid || !info.IsDataValid)
{
Debug.LogWarning(
@@ -223,6 +228,7 @@ public class BindAccountPopupPanel : MonoBehaviour
}
var switchPanelGo = await UIManager.Instance.GetUIAsync(UITypes.AccountSwitchPopupPanel);
if (this == null || !saveStore.IsCurrent) return false;
switchPanelGo.GetComponent<AccountSwitchPopupPanel>()
.SetData(info.DisplayName, info.Avatar, info.Level, userid, accountType);
UIManager.Instance.DestroyUI(UITypes.BindAccountPopupPanel);

View File

@@ -1,4 +1,4 @@
using asap.core;
using asap.core;
using cfg;
using game;
using GameCore;
@@ -11,6 +11,8 @@ using UnityEngine.UI;
public class PlayerHeadPopupPanel : MonoBehaviour
{
game.PlayerDataStorage.IPlayerSaveStore saveStore;
IUserService userService;
public Button btn_mask;
public Button btn_close;
@@ -30,6 +32,7 @@ public class PlayerHeadPopupPanel : MonoBehaviour
private void Awake()
{
saveStore = GContext.container.Resolve<game.PlayerDataStorage.IPlayerSaveStore>();
userAvatars = GContext.container.Resolve<Tables>().TbUserAvatar.DataList;
userService = GContext.container.Resolve<IUserService>();
btn_mask = transform.Find("mask").GetComponent<Button>();
@@ -196,9 +199,10 @@ public class PlayerHeadPopupPanel : MonoBehaviour
}
}
var result = await userService.LinkAccount(EAccoutType.hwFacebook);
if (this == null || !saveStore.IsCurrent) return;
if (result.code == 0)
{
PlayFabMgr.Instance.UpdateUserDataValue(EAccoutType.hwFacebook.ToString(), "1");
saveStore.Write(EAccoutType.hwFacebook.ToString(), "1").RequireAccepted();
Dictionary<string, string> EAccoutUrl = userService.EAccoutUrl;
if (EAccoutUrl != null && EAccoutUrl.Count > 0)
{

View File

@@ -8,19 +8,47 @@ public class SettingNotificationsGradePopupPanel : MonoBehaviour
{
public Button btn_ok;
public Button btn_cancel;
ISettingService settings;
ILocalNotificationService notifications;
bool handling;
bool completed;
private void Start()
{
settings = GContext.container.Resolve<ISettingService>();
notifications = GContext.container.Resolve<ILocalNotificationService>();
btn_ok.onClick.AddListener(OnBtnOk);
btn_cancel.onClick.AddListener(DestroyUI);
}
private void OnBtnOk()
{
DestroyUI();
GContext.container.Resolve<ILocalNotificationService>().OpenSettings();
HandlePrompt(true);
}
void DestroyUI()
{
GContext.container.Resolve<ISettingService>().ShowNotice = true;
UIManager.Instance.DestroyUI(gameObject.name);
HandlePrompt(false);
}
async void HandlePrompt(bool openSettings)
{
if (this == null || handling || completed) return;
handling = true;
try
{
(settings as DefaultSettingService)?.RequirePromptOwner();
(notifications as LocalNotificationService)?.RequirePromptOwner(settings);
settings.ShowNotice = true;
if (openSettings && settings is DefaultSettingService bound && bound.HasKVPromptOwner)
{
await ((LocalNotificationService)notifications).OpenSettingsAsync();
if (this == null) return;
bound.RequirePromptOwner();
}
(settings as DefaultSettingService)?.RequirePromptOwner();
completed = true;
UIManager.Instance.DestroyUI(gameObject.name);
if (openSettings && !(settings is DefaultSettingService kv && kv.HasKVPromptOwner))
notifications.OpenSettings();
}
catch (System.Exception ex) { game.DefaultSettingService.LogPromptFailure(ex); }
finally { handling = false; }
}
}

View File

@@ -7,19 +7,48 @@ public class SettingNotificationsPopupPanel : MonoBehaviour
{
public Button btn_ok;
public Button btn_cancel;
ILocalNotificationService notifications;
bool handling;
bool completed;
private void Start()
{
notifications = GContext.container.Resolve<ILocalNotificationService>();
btn_ok.onClick.AddListener(OnBtnOk);
btn_cancel.onClick.AddListener(DestroyUI);
}
private void OnBtnOk()
private async void OnBtnOk()
{
DestroyUI();
ILocalNotificationService service = GContext.container.Resolve<ILocalNotificationService>();
service.OpenSettings();
if (this == null || handling || completed) return;
handling = true;
try
{
if (notifications is LocalNotificationService local && local.HasKVPromptOwner)
{
local.RequirePromptOwner();
await local.OpenSettingsAsync();
if (this == null) return;
local.RequirePromptOwner();
}
else
{
DestroyUI();
notifications.OpenSettings();
return;
}
DestroyUI();
}
catch (System.Exception ex) { game.DefaultSettingService.LogPromptFailure(ex); }
finally { handling = false; }
}
void DestroyUI()
{
UIManager.Instance.DestroyUI(gameObject.name);
if (this == null || completed) return;
try
{
(notifications as LocalNotificationService)?.RequirePromptOwner();
completed = true;
UIManager.Instance.DestroyUI(gameObject.name);
}
catch (System.Exception ex) { game.DefaultSettingService.LogPromptFailure(ex); }
}
}

View File

@@ -12,6 +12,7 @@ using UnityEngine.UI;
public class SettingPopupPanel : MonoBehaviour
{
ISettingService settingService;
ILocalNotificationService notificationService;
public Button btn_close;
public Button btn_mask;
public BtnSwitch music;
@@ -55,6 +56,7 @@ public class SettingPopupPanel : MonoBehaviour
private void Awake()
{
settingService = GContext.container.Resolve<ISettingService>();
notificationService = GContext.container.Resolve<ILocalNotificationService>();
config = GContext.container.Resolve<IConfig>();
}
@@ -214,15 +216,15 @@ public class SettingPopupPanel : MonoBehaviour
}
private void OnToggleNotification(bool isOn)
{
if (isOn)
try
{
GContext.container.Resolve<ILocalNotificationService>().OpenSettings();
// NotificationCenter.OpenNotificationSettings();
}
else
{
UIManager.Instance.ShowUI(new UIType("SettingNotificationsPopupPanel"));
if (this == null) return;
(settingService as DefaultSettingService)?.RequirePromptOwner();
(notificationService as LocalNotificationService)?.RequirePromptOwner(settingService);
if (isOn) notificationService.OpenSettings();
else UIManager.Instance.ShowUI(new UIType("SettingNotificationsPopupPanel"));
}
catch (System.Exception ex) { game.DefaultSettingService.LogPromptFailure(ex); }
}
private void OnChangeLanguage(ChangeLanguageEvent changeLanguageEvent = null)

View File

@@ -1,4 +1,4 @@
using asap.core;
using asap.core;
using GameCore;
using System;
using UnityEngine;

View File

@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using asap.core;
using cfg;
@@ -8,6 +8,8 @@ using GameCore;
public class EventShootingRangeData : IChainPackData
{
[asap.core.Inject] public game.PlayerDataStorage.IPlayerSaveStore SaveStore { get; set; }
private RawData _data = new RawData();
private bool _kvLoadPresent;
@@ -219,7 +221,7 @@ public class EventShootingRangeData : IChainPackData
{
var message = Newtonsoft.Json.JsonConvert.SerializeObject(_data);
// Debug.Log($"<color=#4d90fe>ShootingRangeDataUploaded: {message}</color>");
PlayFabMgr.Instance.UpdateUserDataValue(Key, message);
SaveStore.Write(Key, message).RequireAccepted();
}
public void AddAmmo(int count)

View File

@@ -1,10 +1,17 @@
using System;
using System;
using System.Linq;
using asap.core;
using cfg;
public class BlackFridayCouponData
{
private game.PlayerDataStorage.IPlayerSaveStore saveStore;
internal void BindSaveStore(game.PlayerDataStorage.IPlayerSaveStore store)
{
if (saveStore != null && !ReferenceEquals(saveStore, store)) throw new System.InvalidOperationException("Archive store cannot change login.");
saveStore = store;
}
private readonly Tables _tables = GContext.container.Resolve<Tables>();
private readonly TbEventCoupon _tableCoupon = GContext.container.Resolve<Tables>().TbEventCoupon;
public DateTime ActivateTime = new DateTime(1996, 11, 28);
@@ -70,7 +77,7 @@ public class BlackFridayCouponData
{
string s =
$"{ActivateTime.Year},{ActivateTime.Month},{ActivateTime.Day},{ActivateTime.Hour},{ActivateTime.Minute},{ActivateTime.Second},{EventId},{RedirectId},{(IsBought ? 1 : 0)}";
PlayFabMgr.Instance.UpdateUserDataValue(PlayFabDataKey, s);
saveStore.Write(PlayFabDataKey, s).RequireAccepted();
}
public void UpdateData(FishingEvent e)
{

View File

@@ -1,4 +1,4 @@
using asap.core;
using asap.core;
using cfg;
using GameCore;
namespace GameCore
@@ -27,7 +27,7 @@ public class ChainPackWithProgressMigrationData : ThanksGivingPackData
&& oldData.PackId == packId)
{
_data = new Data(eventId: eventId, redirectId: packId, tokenProgress: oldData.TokenProgress, chainProgress: oldData.ChainProgress);
PlayFabMgr.Instance.UpdateUserDataValue(ThanksGivingPackData.Key, "");
saveStore.Write(ThanksGivingPackData.Key, "").RequireAccepted();
}
else
_data = new Data(eventId: eventId, redirectId: packId, tokenProgress: 0, chainProgress: 0);

View File

@@ -16,10 +16,13 @@ public class GiftNoticePanel : MonoBehaviour
Button btn_watch2;
public RewardItemNew[] rewardItemNews;
private Tables _tables;
ILocalNotificationService notificationService;
bool handlingNotification;
private void Awake()
{
_tables = GContext.container.Resolve<Tables>();
notificationService = GContext.container.Resolve<ILocalNotificationService>();
btn_close = transform.Find("btn_close").GetComponent<Button>();
btn_mask = transform.Find("mask").GetComponent<Button>();
btn_watch1 = transform.Find("root/btn_watch1/btn_green").GetComponent<Button>();
@@ -58,12 +61,29 @@ public class GiftNoticePanel : MonoBehaviour
PlayerPrefs.SetInt("GiftNoticePanel", 1);
OnClose();
}
void OnClickYES()
async void OnClickYES()
{
//开启通知
OnClose();
GContext.container.Resolve<ILocalNotificationService>().OpenSettings();
// NotificationCenter.OpenNotificationSettings();
if (this == null || handlingNotification) return;
handlingNotification = true;
try
{
if (notificationService is LocalNotificationService local && local.HasKVPromptOwner)
{
local.RequirePromptOwner();
await local.OpenSettingsAsync();
if (this == null) return;
local.RequirePromptOwner();
}
else
{
OnClose();
notificationService.OpenSettings();
return;
}
OnClose();
}
catch (System.Exception ex) { game.DefaultSettingService.LogPromptFailure(ex); }
finally { handlingNotification = false; }
}
void OnClose()
{

View File

@@ -1,4 +1,4 @@
using UnityEngine;
using UnityEngine;
using System;
using System.Collections.Generic;
using System.Linq;
@@ -18,6 +18,13 @@ namespace GameCore
}
public class ThanksGivingPackData : IProgressChainPackData
{
protected game.PlayerDataStorage.IPlayerSaveStore saveStore;
internal void BindSaveStore(game.PlayerDataStorage.IPlayerSaveStore store)
{
if (saveStore != null && !ReferenceEquals(saveStore, store)) throw new System.InvalidOperationException("Archive store cannot change login.");
saveStore = store;
}
protected Data _data = new Data(0, 0, 0, 0);
internal static game.PlayerDataStorage.PlayerKVProgressPackState DecodeForKVLoad(IReadOnlyDictionary<string,string> raw,
@@ -149,7 +156,7 @@ public class ThanksGivingPackData : IProgressChainPackData
public void UploadData()
{
PlayFabMgr.Instance.UpdateUserDataValue(key, _data.Serialize());
saveStore.Write(key, _data.Serialize()).RequireAccepted();
}
public void LoadData(string s)
{

View File

@@ -20,6 +20,7 @@ public class FishingSocialPanel : BasePanel
private void Awake()
{
_socialData = GContext.container.Resolve<ClubService>();
if (!PromptOwnerIsCurrent()) return;
btn_close = transform.Find("root/btn_close").GetComponent<Button>();
for (int i = 1; i <= 3; i++)
{
@@ -36,6 +37,7 @@ public class FishingSocialPanel : BasePanel
}
protected override void Start()
{
if (!PromptOwnerIsCurrent()) return;
base.Start();
GContext.OnEvent<ClubStateChangeEvent>().Subscribe(OnChangeJoinedState).AddTo(disposables);
GContext.OnEvent<SocialFriendListChangedData>().Subscribe(OnChangeFriendListData).AddTo(disposables);
@@ -58,9 +60,10 @@ public class FishingSocialPanel : BasePanel
OnToggle();
_socialData.GetSelfClub();
_socialData.SetOpenClubRed();
try { _socialData.SetOpenClubRed(); }
catch (System.InvalidOperationException ex) { Debug.LogError(ex.Message); return; }
EventPopupData eventPopup = GContext.container.Resolve<ClubService>().eventPopupDataClub;
EventPopupData eventPopup = _socialData.eventPopupDataClub;
if (eventPopup != null && !eventPopup.IsRead)
{
eventPopup.IsRead = true;
@@ -83,6 +86,12 @@ public class FishingSocialPanel : BasePanel
}
}
bool PromptOwnerIsCurrent()
{
if (this == null || _socialData == null) return false;
try { _socialData.RequirePromptOwner(); return true; }
catch (System.InvalidOperationException ex) { Debug.LogError(ex.Message); return false; }
}
//玩家被踢出首次进入俱乐部打开提示弹窗:
// 您被会长踢出了俱乐部 You have been kicked out of the club by the club master
void KickedOut()

View File

@@ -1,4 +1,4 @@
using asap.core;
using asap.core;
using cfg;
using EnhancedUI.EnhancedScroller;
using GameCore;
@@ -14,6 +14,8 @@ namespace game
{
public class FishingFriendAddPanel : MonoBehaviour, IEnhancedScrollerDelegate
{
game.PlayerDataStorage.IPlayerSaveStore saveStore;
#region 分享
Button btn_invite;
@@ -630,6 +632,7 @@ namespace game
#region 生命周期
void Awake()
{
saveStore = GContext.container.Resolve<game.PlayerDataStorage.IPlayerSaveStore>();
loading = transform.Find("loading").gameObject;
empty = transform.Find("add").gameObject;
empty.SetActive(false);
@@ -657,7 +660,7 @@ namespace game
{
List<cfg.Invite> invites = GContext.container.Resolve<Tables>().TbInvite.DataList;
//已经领取奖励的数量
string receiveRewardCountStr = PlayFabMgr.Instance.GetLocalData(FriendService.InviteLinkRewardCountKey);
string receiveRewardCountStr = saveStore.Read(FriendService.InviteLinkRewardCountKey).ValueOrThrow();
if (receiveRewardCountStr != null)
{
int.TryParse(receiveRewardCountStr, out int InviteLinkRewardCount);

View File

@@ -1,4 +1,4 @@
using UnityEngine;
using UnityEngine;
using asap.core;
using System.Text;
using cfg;
@@ -10,6 +10,8 @@ namespace Assets.Scripts.UI.SocialRush
{
public class SocialRushArchitecture
{
readonly game.PlayerDataStorage.IPlayerSaveStore saveStore = GContext.container.Resolve<game.PlayerDataStorage.IPlayerSaveStore>();
private Model _model = new Model();
private TableContext _tableContext;
public int EventId => _tableContext.EventId;
@@ -66,14 +68,14 @@ namespace Assets.Scripts.UI.SocialRush
sb.Append(_model.ProgressDisplay).Append(Pipe);
sb.Append(_model.ProgressActual).Append(Pipe);
sb.Append(_model.InflationRate).Append(Pipe);
PlayFabMgr.Instance.UpdateUserDataValue(PfKey, sb.ToString());
saveStore.Write(PfKey, sb.ToString()).RequireAccepted();
}
public bool LoadPlayfab()
{
try
{
var dataString = PlayFabMgr.Instance.GetLocalData(PfKey);
var dataString = saveStore.Read(PfKey).ValueOrThrow();
var tokens = dataString.Trim(Pipe).Split(Pipe);
var eventId = int.Parse(tokens[0]);
var progressDisplay = int.Parse(tokens[1]);

View File

@@ -1,4 +1,4 @@
using System.Collections;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
@@ -17,6 +17,7 @@ using System.Threading.Tasks;
public class FishingTurntablePanel : BasePanel
{
game.PlayerDataStorage.IPlayerSaveStore saveStore;
Tables _tables;
FishingEventData _fishingEventData;
CanvasGroup canvasGroup;
@@ -89,6 +90,7 @@ public class FishingTurntablePanel : BasePanel
void Awake()
{
saveStore = GContext.container.Resolve<game.PlayerDataStorage.IPlayerSaveStore>();
_tables = GContext.container.Resolve<Tables>();
_fishingEventData = GContext.container.Resolve<FishingEventData>();
canvasGroup = GetComponent<CanvasGroup>();
@@ -579,8 +581,8 @@ public class FishingTurntablePanel : BasePanel
}
private async void ConsumeOnPlayfab()
{
var success = await PlayFabMgr.Instance.SyncDataImmidiate("TurntableRoll",
(_fishingEventData.TurntableCoupon - wheelLevel.CostNumber).ToString());
var success = (await saveStore.WriteAndConfirmAsync("TurntableRoll",
(_fishingEventData.TurntableCoupon - wheelLevel.CostNumber).ToString())).Confirmed;
Debug.Log($"[FishingTurntablePanel::ConsumeOnPlayfab] {success}");
isDataSynced = true;
}