Files
ft/Client/Assets/Scripts/Event1v1Battle/Data/Event1v1BattleSlapDataEx.cs
2026-06-29 21:18:33 +08:00

125 lines
3.9 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using System.Collections.Generic;
using asap.core;
using cfg;
using GameCore;
using UnityEngine;
namespace Event1v1Battle.Data
{
/// <summary>
/// 1v1扇耳光大赛数据扩展方法仅包含纯数据查询
/// </summary>
public static class Event1v1BattleSlapDataEx
{
#region
/// <summary>
/// 获取下次NPC攻击的时间间隔对 <see cref="TbEventStageRobotAttackInterval"/> 全表按 Weight 加权随机
/// </summary>
public static int GetNextAttackInterval(this Event1v1BattleSlapData data)
{
return data.Tables.TbEventStageRobotAttackInterval.PickRandomAttackInterval();
}
#endregion
#region
/// <summary>
/// 获取下一关ID
/// </summary>
public static int GetNextStageID(this Event1v1BattleSlapData data)
{
return data.StageConfig?.NextStage ?? data.InitConfig.InitialStage;
}
public static int GetAllStageCount(this Event1v1BattleSlapData data)
{
return data.GetAllStage().Count;
}
public static int GetStageIndex(this Event1v1BattleSlapData data, EventSlapStage stage)
{
return data.GetAllStage().IndexOf(stage);
}
public static int GetCurrentStageIndex(this Event1v1BattleSlapData data)
{
return data.GetStageIndex(data.StageConfig);
}
public static List<EventSlapStage> GetAllStage(this Event1v1BattleSlapData data)
{
var stages = new List<EventSlapStage>();
var stageIds = new HashSet<int>();
EventSlapStage stageConfig = data.Tables.TbEventSlapStage.GetOrDefault(data.InitConfig.InitialStage);
if (stageConfig == null)
{
Debug.LogError($"[EventSlap] Initial stage {data.InitConfig.InitialStage} not found");
return stages;
}
stages.Add(stageConfig);
stageIds.Add(stageConfig.ID);
while (!stageIds.Contains(stageConfig.NextStage))
{
stageConfig = data.Tables.TbEventSlapStage.GetOrDefault(stageConfig.NextStage);
stages.Add(stageConfig);
stageIds.Add(stageConfig.ID);
}
return stages;
}
#endregion
#region
public static List<ItemData> GetStageRewards(this Event1v1BattleSlapData data, EventSlapStage stage)
{
if (stage != null && stage.DropId != 0)
return GContext.container.Resolve<PlayerItemData>()
.GetItemDataByDropIdAndTypeLureInflation(data.InflationRate, stage.DropId);
Debug.LogWarning($"stage is null");
return new List<ItemData>();
}
/// <summary>
/// 获取当前关卡的奖励
/// </summary>
public static List<ItemData> GetCurrentStageRewards(this Event1v1BattleSlapData data)
{
return data.GetStageRewards(data.StageConfig);
}
public static List<List<ItemData>> GetAllStageRewards(this Event1v1BattleSlapData data)
{
var rewards = new List<List<ItemData>>();
foreach (var stage in data.GetAllStage())
rewards.Add(data.GetStageRewards(stage));
return rewards;
}
#endregion
#region
/// <summary>
/// 获取菠菜配置
/// </summary>
public static EventSlapSpinach GetSpinachConfig(this Event1v1BattleSlapData data, int spinachID)
{
var spinachConfig = data.Tables.TbEventSlapSpinach.GetOrDefault(spinachID);
if (spinachConfig == null)
{
Debug.LogError($"[EventSlap] Spinach config not found for ID: {spinachID}");
return null;
}
return spinachConfig;
}
#endregion
}
}