|
@@ -4,6 +4,7 @@ using Excel2Json;
|
|
|
using Fort23.UTool;
|
|
|
using GameLogic.Bag;
|
|
|
using UnityEngine;
|
|
|
+using UnityEngine.UIElements;
|
|
|
using Utility;
|
|
|
|
|
|
namespace GameLogic.Player
|
|
@@ -12,6 +13,9 @@ namespace GameLogic.Player
|
|
|
{
|
|
|
public Map<int, AccountFileInfo.SummonData> summonDataMap = new Map<int, AccountFileInfo.SummonData>();
|
|
|
|
|
|
+ //积分规则
|
|
|
+ public Map<int, List<OpenBoxScoreRule>> openBoxScoreRuleMap = new Map<int, List<OpenBoxScoreRule>>();
|
|
|
+
|
|
|
public void CustomInit()
|
|
|
{
|
|
|
OpenBoxConfig[] openBoxConfigs = ConfigComponent.Instance.GetAll<OpenBoxConfig>();
|
|
@@ -27,6 +31,21 @@ namespace GameLogic.Player
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ OpenBoxScoreRule[] openBoxScoreRules = ConfigComponent.Instance.GetAll<OpenBoxScoreRule>();
|
|
|
+ foreach (var openBoxScoreRule in openBoxScoreRules)
|
|
|
+ {
|
|
|
+ List<OpenBoxScoreRule> openBoxScoreRuleList;
|
|
|
+ if (!openBoxScoreRuleMap.ContainsKey(openBoxScoreRule.openBoxID))
|
|
|
+ {
|
|
|
+ openBoxScoreRuleList = new List<OpenBoxScoreRule>();
|
|
|
+ openBoxScoreRuleMap[openBoxScoreRule.openBoxID] = openBoxScoreRuleList;
|
|
|
+ }
|
|
|
+
|
|
|
+ openBoxScoreRuleList = openBoxScoreRuleMap[openBoxScoreRule.openBoxID];
|
|
|
+ openBoxScoreRuleList.Add(openBoxScoreRule);
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
foreach (var playerDataSummonData in AccountFileInfo.Instance.playerData.SummonDatas)
|
|
|
{
|
|
|
if (!summonDataMap.ContainsKey(playerDataSummonData.id))
|
|
@@ -62,6 +81,7 @@ namespace GameLogic.Player
|
|
|
{
|
|
|
PlayerManager.Instance.BagController.DeductCoin(openBoxConfig.oneConsume);
|
|
|
allIitem = Summon(summonData, 1);
|
|
|
+
|
|
|
summonData.onePayCount++;
|
|
|
summonData.nextOneFreeTime = PlayerManager.Instance.serverTime + openBoxConfig.oneConsumeFreePara[0] * 1000;
|
|
|
}
|
|
@@ -78,7 +98,14 @@ namespace GameLogic.Player
|
|
|
if (summonData.tenFreeCount < openBoxConfig.oneConsumeFreePara_1[1] && PlayerManager.Instance.serverTime >= summonData.nextTenFreeTime)
|
|
|
{
|
|
|
allIitem = Summon(summonData, 10);
|
|
|
+ //记录抽卡道具 用于成就检测
|
|
|
+ List<int> drawHistory = new List<int>();
|
|
|
+ foreach (var itemInfo in allIitem)
|
|
|
+ {
|
|
|
+ drawHistory.Add(itemInfo.itemID);
|
|
|
+ }
|
|
|
|
|
|
+ summonData.drawHistory.Add(drawHistory);
|
|
|
summonData.tenFreeCount++;
|
|
|
summonData.tenPayCount++;
|
|
|
summonData.nextTenFreeTime = PlayerManager.Instance.serverTime + openBoxConfig.oneConsumeChargePara[0] * 1000;
|
|
@@ -90,8 +117,18 @@ namespace GameLogic.Player
|
|
|
{
|
|
|
PlayerManager.Instance.BagController.DeductCoin(openBoxConfig.tenConsume);
|
|
|
allIitem = Summon(summonData, 10);
|
|
|
+ //记录抽卡道具 用于成就检测
|
|
|
+ List<int> drawHistory = new List<int>();
|
|
|
+ foreach (var itemInfo in allIitem)
|
|
|
+ {
|
|
|
+ drawHistory.Add(itemInfo.itemID);
|
|
|
+ }
|
|
|
+
|
|
|
+ summonData.drawHistory.Add(drawHistory);
|
|
|
summonData.tenPayCount++;
|
|
|
summonData.nextTenFreeTime = PlayerManager.Instance.serverTime + openBoxConfig.oneConsumeChargePara[0] * 1000;
|
|
|
+
|
|
|
+ CheckAchievements(summonData);
|
|
|
}
|
|
|
else
|
|
|
{
|
|
@@ -100,6 +137,7 @@ namespace GameLogic.Player
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ AccountFileInfo.Instance.SavePlayerData();
|
|
|
return allIitem;
|
|
|
}
|
|
|
|
|
@@ -187,5 +225,77 @@ namespace GameLogic.Player
|
|
|
AccountFileInfo.Instance.SavePlayerData();
|
|
|
return allIitem;
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
+ // 检查成就匹配
|
|
|
+ private void CheckAchievements(AccountFileInfo.SummonData summonData)
|
|
|
+ {
|
|
|
+ List<OpenBoxScoreRule> openBoxScoreRuleList = openBoxScoreRuleMap[summonData.id];
|
|
|
+
|
|
|
+ List<OpenBoxScoreRule> daChengOpenBoxScoreRuleList = new List<OpenBoxScoreRule>();
|
|
|
+ foreach (var openBoxScoreRule in openBoxScoreRuleList)
|
|
|
+ {
|
|
|
+ // 检查连续 Para0 次十连
|
|
|
+ if (summonData.drawHistory.Count < openBoxScoreRule.para0) continue;
|
|
|
+
|
|
|
+ bool allDrawsSatisfy = true;
|
|
|
+ // 检查最近 Para0 次十连是否都满足条件
|
|
|
+ for (int i = summonData.drawHistory.Count - openBoxScoreRule.para0; i < summonData.drawHistory.Count; i++)
|
|
|
+ {
|
|
|
+ if (!CheckSingleDraw(openBoxScoreRule, summonData.drawHistory[i]))
|
|
|
+ {
|
|
|
+ allDrawsSatisfy = false;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (allDrawsSatisfy)
|
|
|
+ {
|
|
|
+ daChengOpenBoxScoreRuleList.Add(openBoxScoreRule);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (daChengOpenBoxScoreRuleList.Count > 0)
|
|
|
+ {
|
|
|
+ int id = daChengOpenBoxScoreRuleList.Max(obsr => obsr.ID);
|
|
|
+ OpenBoxScoreRule openBoxScoreRule = ConfigComponent.Instance.Get<OpenBoxScoreRule>(id);
|
|
|
+ summonData.score += openBoxScoreRule.score;
|
|
|
+ LogTool.Log($"达成成就 ID: {openBoxScoreRule.ID}, 分数: {openBoxScoreRule.score}, 描述: 连续{openBoxScoreRule.para0}次十连获得{openBoxScoreRule.para1}个品质{openBoxScoreRule.para3}的道具");
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
+ // 检查单次十连是否满足成就条件
|
|
|
+ private bool CheckSingleDraw(OpenBoxScoreRule openBoxScoreRule, List<int> drawResult)
|
|
|
+ {
|
|
|
+ // 统计符合条件的道具数量
|
|
|
+ int validItemCount = 0;
|
|
|
+ foreach (var item in drawResult)
|
|
|
+ {
|
|
|
+ ItemConfig itemConfig = ConfigComponent.Instance.Get<ItemConfig>(item);
|
|
|
+ // 检查道具标签
|
|
|
+ if (!openBoxScoreRule.para4.Contains(itemConfig.itemTag)) continue;
|
|
|
+
|
|
|
+ // 检查品质是否符合
|
|
|
+ bool qualityMatch = false;
|
|
|
+ switch (openBoxScoreRule.para2)
|
|
|
+ {
|
|
|
+ case 1: // 等于
|
|
|
+ qualityMatch = itemConfig.quality == openBoxScoreRule.para3;
|
|
|
+ break;
|
|
|
+ case 2: // 大于等于
|
|
|
+ qualityMatch = itemConfig.quality >= openBoxScoreRule.para3;
|
|
|
+ break;
|
|
|
+ case 3: // 小于等于
|
|
|
+ qualityMatch = itemConfig.quality <= openBoxScoreRule.para3;
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ if (qualityMatch) validItemCount++;
|
|
|
+ }
|
|
|
+
|
|
|
+ // 根据 Para1 判断是否满足数量要求
|
|
|
+ return validItemCount >= openBoxScoreRule.para1;
|
|
|
+ }
|
|
|
}
|
|
|
}
|