Files
zeling_v2/Assets/_Game/Scripts/Progression/Achievement/TimedBossKillCondition.cs

24 lines
944 B
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 UnityEngine;
using BaseGames.Core.Save;
namespace BaseGames.Progression
{
/// <summary>在指定时间内击败 Boss 的成就条件(使用 ChallengeRooms.Records 的 BestTime。</summary>
[CreateAssetMenu(menuName = "BaseGames/Achievement/Condition/TimedBossKill", fileName = "COND_TimedBossKill_")]
public class TimedBossKillCondition : AchievementCondition
{
[Tooltip("Boss 的 ChallengeRoom 记录 ID与 ChallengeRoomRecord key 匹配)")]
public string bossRoomId;
[Tooltip("需要在此秒数内完成击败(含)")]
public float maxSeconds = 60f;
public override bool IsMet(SaveData save)
{
if (save?.ChallengeRooms?.Records == null) return false;
if (!save.ChallengeRooms.Records.TryGetValue(bossRoomId, out var record)) return false;
return record.BestTime > 0f && record.BestTime <= maxSeconds;
}
}
}