37 lines
1.1 KiB
C#
37 lines
1.1 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)}条件,参数数量错误,需要2个参数,只有{args.Count}参数");
|
||
|
||
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)}条件,参数数量错误,需要2个参数,只有{args.Count}参数");
|
||
|
||
int id = (int)args[0];
|
||
int star = (int)args[1];
|
||
|
||
return new string[2] { id.ToString(), star.ToString() };
|
||
}
|
||
} |