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

39 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 ConditionLevelPass : ICondition
{
public EventManager.EventName SignalName => EventManager.EventName.LevelInfoChanged;
public bool Check(List<float> args)
{
if (args.Count < 1)
throw new ConditionException($"{nameof(ConditionLevelPass)}条件参数数量错误需要1个参数只有{args.Count}参数");
int id = (int)args[0];
if (!LevelManager.Instance.TryGetLevelInfoByID(id, out LevelInfo levelInfo))
return false;
return levelInfo.IsPass;
}
public string[] GetArgLocalizations(List<float> args)
{
if (args.Count < 1)
throw new ConditionException($"{nameof(ConditionLevelPass)}条件参数数量错误需要1个参数只有{args.Count}参数");
int id = (int)args[0];
if (LevelManager.Instance.TryGetLevelInfoByID(id, out LevelInfo levelInfo))
return new string[1] { levelInfo.Name };
else
return new string[1] { id.ToString() };
}
}