2023-11-03 14:46:27 +08:00
|
|
|
|
using System.Collections.Generic;
|
2023-11-01 13:33:20 +08:00
|
|
|
|
using Framework;
|
|
|
|
|
|
using Gameplay.Level;
|
|
|
|
|
|
using Framework.Condition;
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
|
/// 关卡星级是否满足
|
|
|
|
|
|
/// </summary>
|
|
|
|
|
|
public class ConditionLevelStar : ICondition
|
|
|
|
|
|
{
|
|
|
|
|
|
public EventManager.EventName SignalName => EventManager.EventName.LevelInfoChanged;
|
|
|
|
|
|
|
2023-11-03 14:46:27 +08:00
|
|
|
|
public bool Check(List<float> args)
|
2023-11-01 13:33:20 +08:00
|
|
|
|
{
|
2024-10-11 16:51:50 +08:00
|
|
|
|
if (args.Count < 2)
|
2024-10-12 12:46:58 +08:00
|
|
|
|
throw new ConditionException($"{nameof(ConditionLevelStar)}条件(关卡星级是否满足),需要两个参数,当前只有{args.Count}个参数,参数1:关卡id,参数2:星级数量");
|
2024-10-11 16:51:50 +08:00
|
|
|
|
|
2024-09-05 13:41:39 +08:00
|
|
|
|
int id = (int)args[0];
|
|
|
|
|
|
int star = (int)args[1];
|
|
|
|
|
|
|
|
|
|
|
|
if (!LevelManager.Instance.TryGetLevelInfoByID(id, out LevelInfo levelInfo))
|
|
|
|
|
|
return false;
|
2023-11-01 13:33:20 +08:00
|
|
|
|
|
2024-09-05 14:17:27 +08:00
|
|
|
|
return levelInfo.Score >= star;
|
2023-11-01 13:33:20 +08:00
|
|
|
|
}
|
2024-04-15 17:59:58 +08:00
|
|
|
|
|
|
|
|
|
|
public string[] GetArgLocalizations(List<float> args)
|
|
|
|
|
|
{
|
2024-10-11 16:51:50 +08:00
|
|
|
|
if (args.Count < 2)
|
2024-10-12 12:46:58 +08:00
|
|
|
|
throw new ConditionException($"{nameof(ConditionLevelStar)}条件(关卡星级是否满足),需要两个参数,当前只有{args.Count}个参数,参数1:关卡id,参数2:星级数量");
|
2024-10-11 16:51:50 +08:00
|
|
|
|
|
2024-10-12 12:46:58 +08:00
|
|
|
|
return new string[2] { ((int)args[0]).ToString(), ((int)args[1]).ToString() };
|
2024-04-15 17:59:58 +08:00
|
|
|
|
}
|
2023-11-01 13:33:20 +08:00
|
|
|
|
}
|