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

37 lines
1.1 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)}条件参数数量错误需要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() };
}
}