feat(upserver): 保存M2客户端KV迁移至本人统计写检查点
保存独立KV用户服务、固定会话存档与原业务接线,以及C3d资料缓存和C3e本人统计写。 保留原PF/AGG路线、业务公式和时序;榜单读取、好友资料、公告、匹配及首场景闸仍待完成。 验证:ServiceHost两条件各33组646断言;Unity CLI Loop编译0错误269警告。 包含相关方案、评审裁决、测试及状态文档。未操作服务器、正式账号或打包。
This commit is contained in:
@@ -0,0 +1,182 @@
|
||||
using System;
|
||||
using asap.core;
|
||||
using Assets.Scripts.UI.AdWheel;
|
||||
using cfg;
|
||||
using DG.Tweening;
|
||||
using game;
|
||||
using GameCore;
|
||||
using TMPro;
|
||||
using UniRx;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
public class AdvertData
|
||||
{
|
||||
public int ID;
|
||||
public int index;
|
||||
public int day;
|
||||
public string cdTime;
|
||||
public bool isOpen;
|
||||
}
|
||||
public class AdvertPanel : MonoBehaviour
|
||||
{
|
||||
game.PlayerDataStorage.IPlayerSaveStore saveStore;
|
||||
|
||||
Button btn_close;
|
||||
TMP_Text txt_energy, txt_money, txt_ticket;
|
||||
ulong _curGold;
|
||||
int _curEnergy;
|
||||
int _curTicket;
|
||||
protected CompositeDisposable disposables = new CompositeDisposable();
|
||||
|
||||
|
||||
private Transform panel_gift1;
|
||||
private Transform panel_gift2;
|
||||
private Transform panel_gift3;
|
||||
|
||||
|
||||
|
||||
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>();
|
||||
btn_close = transform.Find("root/btn_close").GetComponent<Button>();
|
||||
|
||||
//
|
||||
panel_gift1 = transform.Find("root/ScrollView/Viewport/Content/Item/panel_gift1");
|
||||
panel_gift2 = transform.Find("root/ScrollView/Viewport/Content/Item/panel_gift2");
|
||||
panel_gift3 = transform.Find("root/ScrollView/Viewport/Content/Item/panel_gift3");
|
||||
|
||||
}
|
||||
private void Start()
|
||||
{
|
||||
var playerData = GContext.container.Resolve<PlayerData>();
|
||||
_curGold = playerData.gold;
|
||||
_curEnergy = playerData.Energy;
|
||||
_curTicket = GContext.container.Resolve<PlayerShopData>().GetAdticketCount();
|
||||
txt_money.text = ConvertTools.GetNumberString2(_curGold);
|
||||
txt_energy.text = ConvertTools.GetNumberString2(_curEnergy);
|
||||
txt_ticket.text = ConvertTools.GetNumberString2(_curTicket);
|
||||
btn_close.onClick.AddListener(() =>
|
||||
{
|
||||
GContext.Publish(new RestartShowHomeUIEvent());
|
||||
UIManager.Instance.DestroyUI(UITypes.AdvertPanel);
|
||||
});
|
||||
GContext.OnEvent<ResAddEvent>().Where(x => x.id == 1002).Subscribe(x =>
|
||||
{
|
||||
GoldAddAnim();
|
||||
}).AddTo(disposables);
|
||||
GContext.OnEvent<ResAddEvent>().Where(x => x.id == 1001).Subscribe(x =>
|
||||
{
|
||||
EnergyAddAnim();
|
||||
}).AddTo(disposables);
|
||||
GContext.OnEvent<ResAddEvent>().Where(x => x.id == 1006).Subscribe(x =>
|
||||
{
|
||||
TicketAddAnim();
|
||||
}).AddTo(disposables);
|
||||
|
||||
GContext.OnEvent<ResAddEvent>().Where(x => x.id == 1007).Subscribe(x =>
|
||||
{
|
||||
TicketAddAnim();
|
||||
}).AddTo(disposables);
|
||||
|
||||
// panel_gift3.gameObject.SetActive(false);
|
||||
#if UNITY_IOS || UNITY_IPHONE
|
||||
panel_gift2?.gameObject.SetActive(true);
|
||||
panel_gift3?.gameObject.SetActive(false);
|
||||
#else
|
||||
CheckTapJoyOpen();
|
||||
#endif
|
||||
|
||||
}
|
||||
|
||||
// 7天
|
||||
private readonly int _conditionSeconds = 604800; // 7 * 24 * 60 * 60;
|
||||
|
||||
// 判断是否满足{seconds}没有充值了
|
||||
private bool Condition_NoRechargeSeconds(int timeSeconds)
|
||||
{
|
||||
var lastPaymentStr = saveStore.Read("LastPaymentTime").ValueOrThrow();
|
||||
DateTime curTime = ZZTimeHelper.UtcNow().UtcNowOffset();
|
||||
DateTime endTime = curTime;
|
||||
if (string.IsNullOrEmpty(lastPaymentStr) || !lastPaymentStr.Contains("__"))
|
||||
endTime = GContext.container.Resolve<IUserService>().CreateTime.UtcNowOffset();
|
||||
|
||||
var curTimeSecond = new DateTimeOffset(curTime).ToUnixTimeSeconds();
|
||||
var endTimeSecond = new DateTimeOffset(endTime).ToUnixTimeSeconds();
|
||||
if (curTimeSecond - endTimeSecond >= timeSeconds)
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
|
||||
private void CheckTapJoyOpen()
|
||||
{
|
||||
var tables = GContext.container.Resolve<Tables>();
|
||||
var tapjoyWakeParam = tables.TbGlobalConfig.TapjoyWakeParam * 24 * 60 * 60;
|
||||
var config = GContext.container.Resolve<IConfig>();
|
||||
// bool isTapJoyOpen = !(config != null && string.IsNullOrEmpty(config.Get(GConstant.K_TAPJOY, string.Empty)));
|
||||
bool isTapJoyOpen = config == null || string.IsNullOrEmpty(config.Get(GConstant.K_TAPJOY_BAN, string.Empty)) ;
|
||||
|
||||
#if UNITY_ANDROID
|
||||
if (Condition_NoRechargeSeconds(tapjoyWakeParam) && isTapJoyOpen)
|
||||
{
|
||||
panel_gift2?.gameObject.SetActive(false);
|
||||
panel_gift3?.gameObject.SetActive(true);
|
||||
}
|
||||
else
|
||||
{
|
||||
panel_gift2?.gameObject.SetActive(true);
|
||||
panel_gift3?.gameObject.SetActive(false);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
//private async System.Threading.Tasks.Task WaitForRewardPanel()
|
||||
//{
|
||||
// await new WaitForSeconds(0.5f);
|
||||
// var rewardPanelTask = new RewardPopupData();
|
||||
// GContext.Publish(rewardPanelTask);
|
||||
// if (rewardPanelTask.tcs != null)
|
||||
// {
|
||||
// await rewardPanelTask.tcs.Task;
|
||||
// }
|
||||
|
||||
//}
|
||||
void GoldAddAnim()
|
||||
{
|
||||
//await WaitForRewardPanel();
|
||||
DOTween.Kill("txt_money");
|
||||
txt_money.text = ConvertTools.GetNumberString2(_curGold);
|
||||
var EndDiamond = GContext.container.Resolve<PlayerData>().gold;
|
||||
DOTween.To(() => _curGold, x => _curGold = x, EndDiamond, 1f).OnUpdate(() =>
|
||||
{
|
||||
txt_money.text = ConvertTools.GetNumberString2(_curGold);
|
||||
}).SetId("txt_money");
|
||||
}
|
||||
void EnergyAddAnim()
|
||||
{
|
||||
//await WaitForRewardPanel();
|
||||
DOTween.Kill("advert_text_energy");
|
||||
txt_energy.text = ConvertTools.GetNumberString2(_curEnergy);
|
||||
var EndEnergy = GContext.container.Resolve<PlayerData>().Energy;
|
||||
DOTween.To(() => _curEnergy, x => _curEnergy = x, EndEnergy, 1f).OnUpdate(() =>
|
||||
{
|
||||
txt_energy.text = ConvertTools.GetNumberString2(_curEnergy);
|
||||
}).SetId("advert_text_energy");
|
||||
}
|
||||
void TicketAddAnim()
|
||||
{
|
||||
//await WaitForRewardPanel();
|
||||
DOTween.Kill("text_ticket");
|
||||
txt_ticket.text = ConvertTools.GetNumberString2(_curTicket);
|
||||
var Ticket = GContext.container.Resolve<PlayerShopData>().GetAdticketCount();
|
||||
DOTween.To(() => _curTicket, x => _curTicket = x, Ticket, 1f).OnUpdate(() =>
|
||||
{
|
||||
txt_ticket.text = ConvertTools.GetNumberString2(_curTicket);
|
||||
}).SetId("text_ticket");
|
||||
}
|
||||
private void OnDestroy()
|
||||
{
|
||||
disposables.Dispose();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user