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

23 lines
908 B
C#
Raw Permalink 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>收集指定数量魅饰Charm的成就条件。</summary>
[CreateAssetMenu(menuName = "BaseGames/Achievement/Condition/CollectedAllCharms", fileName = "COND_CollectedAllCharms")]
public class CollectedAllCharmsCondition : AchievementCondition
{
[Tooltip("需要收集的魅饰总数(游戏设计时确定)")]
[Min(1)] public int totalCharmsCount = 45;
public override bool IsMet(SaveData save)
=> save?.Equipment != null && save.Equipment.OwnedCharmIds.Count >= totalCharmsCount;
public override float GetProgress(SaveData save)
{
if (save?.Equipment == null || totalCharmsCount <= 0) return 0f;
return UnityEngine.Mathf.Clamp01((float)save.Equipment.OwnedCharmIds.Count / totalCharmsCount);
}
}
}