34 lines
1.2 KiB
C#
34 lines
1.2 KiB
C#
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() };
|
||
}
|
||
} |