NLDClient-yudde/ProjectNLD/Assets/Code/Scripts/Gameplay/Condition/Conditions/ConditionLevelStar.cs

34 lines
1.2 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

using System.Collections.Generic;
using Framework;
using Gameplay.Level;
using Framework.Condition;
/// <summary>
/// 关卡星级是否满足
/// </summary>
public class ConditionLevelStar : ICondition
{
public EventManager.EventName SignalName => EventManager.EventName.LevelInfoChanged;
public bool Check(List<float> args)
{
if (args.Count < 2)
throw new ConditionException($"{nameof(ConditionLevelStar)}条件(关卡星级是否满足),需要两个参数,当前只有{args.Count}个参数参数1关卡id参数2星级数量");
int id = (int)args[0];
int star = (int)args[1];
if (!LevelManager.Instance.TryGetLevelInfoByID(id, out LevelInfo levelInfo))
return false;
return levelInfo.Score >= star;
}
public string[] GetArgLocalizations(List<float> args)
{
if (args.Count < 2)
throw new ConditionException($"{nameof(ConditionLevelStar)}条件(关卡星级是否满足),需要两个参数,当前只有{args.Count}个参数参数1关卡id参数2星级数量");
return new string[2] { ((int)args[0]).ToString(), ((int)args[1]).ToString() };
}
}