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,259 @@
|
||||
using asap.core;
|
||||
using cfg;
|
||||
using game;
|
||||
using GameCore;
|
||||
using System.Collections.Generic;
|
||||
using UnityEngine;
|
||||
|
||||
public class LuckyTaskPanel : LuckyTaskPanelBase
|
||||
{
|
||||
protected override void Awake()
|
||||
{
|
||||
saveStore = GContext.container.Resolve<game.PlayerDataStorage.IPlayerSaveStore>();
|
||||
base.Awake();
|
||||
}
|
||||
|
||||
game.PlayerDataStorage.IPlayerSaveStore saveStore;
|
||||
|
||||
/// <summary>
|
||||
/// luckyModel 也作为是否自动全部领奖的标志
|
||||
/// </summary>
|
||||
List<LuckyTaskItem> taskItems = new List<LuckyTaskItem>();
|
||||
protected override void SetItem()
|
||||
{
|
||||
string adData = saveStore.Read(LuckyTaskData.ADTaskADKey).ValueOrThrow();
|
||||
int curDay = ZZTimeHelper.UtcNow().UtcNowOffset().DayOfYear;
|
||||
if (!string.IsNullOrEmpty(adData))
|
||||
{
|
||||
string[] strings = adData.Split("|");
|
||||
int day = -1;
|
||||
if (strings.Length != 2 || !int.TryParse(strings[1], out day) || day != curDay)
|
||||
{
|
||||
adData = $"{0}|{curDay}";
|
||||
saveStore.Write(LuckyTaskData.ADTaskADKey, adData).RequireAccepted();
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
adData = $"{0}|{curDay}";
|
||||
saveStore.Write(LuckyTaskData.ADTaskADKey, adData).RequireAccepted();
|
||||
}
|
||||
List<LuckyTaskItemData> taskList = new List<LuckyTaskItemData>();
|
||||
int level = taskData.GetValueOrDefault(-2, 0);
|
||||
float inflationRate = taskData.GetValueOrDefault(-3, 0) / 100f;
|
||||
foreach (var item in taskData)
|
||||
{
|
||||
if (item.Key <= 0)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
CommonTask commonTask = tables.TbCommonTask.Get(item.Key);
|
||||
if (commonTask != null)
|
||||
{
|
||||
LuckyTaskItemData luckyTaskData = new LuckyTaskItemData();
|
||||
luckyTaskData.id = item.Key;
|
||||
int dropID = commonTask.TaskReward[level];
|
||||
|
||||
luckyTaskData.reward = dropID;
|
||||
|
||||
luckyTaskData.inflationRate = inflationRate;
|
||||
string desc = LocalizationMgr.GetText(commonTask.TaskDesc_l10n_key);
|
||||
string progressText;
|
||||
if (commonTask.TaskType == ConditionType.RechargeAmount)
|
||||
{
|
||||
//sku.ProdPrice
|
||||
int iapid = commonTask.TaskParam[level];
|
||||
var iap = tables.TbIAPItemList.GetOrDefault(iapid);
|
||||
SKUDetailDataEvent sKUDetailDataEvent = new SKUDetailDataEvent(iap);
|
||||
GContext.Publish(sKUDetailDataEvent);
|
||||
desc = desc.SafeFormat(sKUDetailDataEvent.price);
|
||||
float TaskParam = iap.VIPPoint;
|
||||
float value = item.Value;
|
||||
float ratio = value / TaskParam;
|
||||
float ProdPrice = sKUDetailDataEvent.prodPrice;
|
||||
float truncatedPrice = (float)Mathf.Ceil(ratio * ProdPrice * 100) / 100;
|
||||
progressText = $"({truncatedPrice:F2}/{ProdPrice})";
|
||||
if (item.Value == -1)
|
||||
{
|
||||
progressText = $"({ProdPrice}/{ProdPrice})";
|
||||
luckyTaskData.state = -1;
|
||||
}
|
||||
else if (value >= TaskParam)
|
||||
{
|
||||
luckyTaskData.state = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
luckyTaskData.state = 0;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
int taskParam = commonTask.TaskParam[level];
|
||||
if (commonTask.TaskType == ConditionType.ConsumeEnergy)
|
||||
{
|
||||
taskParam = GContext.container.Resolve<PlayerItemData>().IntInflation(taskParam, inflationRate);
|
||||
}
|
||||
progressText = $"({item.Value}/{taskParam})";
|
||||
if (item.Value == -1)
|
||||
{
|
||||
progressText = $"({taskParam}/{taskParam})";
|
||||
luckyTaskData.state = -1;
|
||||
}
|
||||
else if (item.Value >= taskParam)
|
||||
{
|
||||
luckyTaskData.state = 1;
|
||||
}
|
||||
else
|
||||
{
|
||||
luckyTaskData.state = 0;
|
||||
}
|
||||
desc = desc.SafeFormat(taskParam);
|
||||
}
|
||||
luckyTaskData.desc = desc + progressText;
|
||||
taskList.Add(luckyTaskData);
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.LogError($"Task ID {item.Key} not found in CommonTask table.");
|
||||
}
|
||||
}
|
||||
taskList.Sort((a, b) => b.state.CompareTo(a.state)); // 按state排序
|
||||
for (int i = 0; i < taskList.Count; i++)
|
||||
{
|
||||
LuckyTaskItem luckyTaskItem = Instantiate(itemPrefab, content).AddComponent<LuckyTaskItem>();
|
||||
luckyTaskItem.gameObject.SetActive(true);
|
||||
luckyTaskItem.Init(taskList[i], OnClickLuckyTaskItem);
|
||||
taskItems.Add(luckyTaskItem);
|
||||
}
|
||||
}
|
||||
|
||||
public void TaskItemPlay(LuckyTaskItem luckyTaskItem)
|
||||
{
|
||||
canvasGroup.blocksRaycasts = false;
|
||||
try
|
||||
{
|
||||
luckyTaskItem.data.state = -1; // 更新状态为已领取
|
||||
luckyTaskItem.Refresh();
|
||||
luckyTaskItem.Play();
|
||||
}
|
||||
catch (System.Exception ex)
|
||||
{
|
||||
Debug.LogError($"Error during TaskItemPlay: {ex.Message}");
|
||||
}
|
||||
canvasGroup.blocksRaycasts = true;
|
||||
GContext.Publish(new ShowData());
|
||||
}
|
||||
|
||||
void OnClickLuckyTaskItem(LuckyTaskItem luckyTaskItem)
|
||||
{
|
||||
if (IsOpen)
|
||||
{
|
||||
//奖励补领
|
||||
OnClickLuckyTaskItem1(luckyTaskItem);
|
||||
return;
|
||||
}
|
||||
if (luckyTaskItem.data.state == 1)
|
||||
{
|
||||
bool result = luckyModel.OnGetTaskReward(luckyTaskItem.data.id);
|
||||
if (result)
|
||||
{
|
||||
CommonTask commonTask = tables.TbCommonTask.GetOrDefault(luckyTaskItem.data.id);
|
||||
if (commonTask != null)
|
||||
{
|
||||
// 任务奖励
|
||||
int level = taskData.GetValueOrDefault(-2, 0);
|
||||
int dropID = commonTask.TaskReward[level];
|
||||
|
||||
ChangeSource changeSource = new ChangeSource(EventId, "Event_Minigame3", "Event_Minigame3_LuckMagic", "TaskReward");
|
||||
if (fishingEvent.SubType == 4)
|
||||
{
|
||||
changeSource.Source_Type = "Event_Minigame3_LuckyCards";
|
||||
}
|
||||
List<ItemData> rewardItem = GContext.container.Resolve<PlayerItemData>().AddItemByDropLureInflation(luckyTaskItem.data.inflationRate, dropID, changeSource, false);
|
||||
if (rewardItem != null)
|
||||
{
|
||||
TaskItemPlay(luckyTaskItem);
|
||||
}
|
||||
#if AGG
|
||||
using (var e = GEvent.GameEvent("event_lucky_task"))
|
||||
{
|
||||
int round = luckyModel.DicTasks.GetValueOrDefault(-1, 0);
|
||||
e.AddContent("task_id", luckyTaskItem.data.id)
|
||||
.AddContent("round", round)
|
||||
.AddContent("combine_id", round * 100000 + luckyTaskItem.data.id % 10000)
|
||||
.AddContent("task_reward", dropID);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
Debug.Log("任务奖励领取失败");
|
||||
}
|
||||
}
|
||||
else if (luckyTaskItem.data.state == 0)
|
||||
{
|
||||
OnClickGo(luckyTaskItem.data.id);
|
||||
Debug.Log("任务未完成,无法领取奖励");
|
||||
}
|
||||
else if (luckyTaskItem.data.state == -1)
|
||||
{
|
||||
Debug.Log("任务已领取,无法重复领取");
|
||||
}
|
||||
}
|
||||
|
||||
void OnClickLuckyTaskItem1(LuckyTaskItem luckyTaskItem)
|
||||
{
|
||||
if (luckyTaskItem.data.state == 1)
|
||||
{
|
||||
CommonTask commonTask = tables.TbCommonTask.GetOrDefault(luckyTaskItem.data.id);
|
||||
taskData[luckyTaskItem.data.id] = -1; // 标记为已领取
|
||||
if (commonTask != null)
|
||||
{
|
||||
// 任务奖励
|
||||
int level = taskData.GetValueOrDefault(-2, 0);
|
||||
int dropID = commonTask.TaskReward[level];
|
||||
ChangeSource changeSource = new ChangeSource(EventId, "Event_Minigame3", "Event_Minigame3_LuckMagic", "TaskReward");
|
||||
if (fishingEvent.SubType == 4)
|
||||
{
|
||||
changeSource.Source_Type = "Event_Minigame3_LuckyCards";
|
||||
}
|
||||
|
||||
List<ItemData> rewardItem = GContext.container.Resolve<PlayerItemData>().AddItemByDropLureInflation(luckyTaskItem.data.inflationRate, dropID, changeSource, false);
|
||||
if (rewardItem != null)
|
||||
{
|
||||
TaskItemPlay(luckyTaskItem);
|
||||
}
|
||||
#if AGG
|
||||
using (var e = GEvent.GameEvent("event_lucky_task"))
|
||||
{
|
||||
int round = luckyModel.DicTasks.GetValueOrDefault(-1, 0);
|
||||
e.AddContent("task_id", luckyTaskItem.data.id)
|
||||
.AddContent("round", round)
|
||||
.AddContent("combine_id", round * 100000 + luckyTaskItem.data.id % 10000)
|
||||
.AddContent("task_reward", dropID);
|
||||
}
|
||||
#endif
|
||||
}
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
UIManager.Instance.DestroyUI(gameObject.name);
|
||||
}
|
||||
}
|
||||
}
|
||||
public class LuckyTaskItemData
|
||||
{
|
||||
public int id;
|
||||
public string desc;
|
||||
public int target;
|
||||
public int reward;
|
||||
public int progress;
|
||||
/// <summary>
|
||||
/// // 0:未完成 1:可领取 -1:已领取
|
||||
/// </summary>
|
||||
public int state;
|
||||
public float inflationRate;
|
||||
}
|
||||
Reference in New Issue
Block a user