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

59 lines
1.6 KiB
C#

using Framework;
namespace Gameplay.Condition
{
public interface IUnlock
{
uint Check(cfg.ActorCfg.DataUnlock cfg);
}
public sealed class ConditionManager
{
private IUnlock[] m_Unlocks;
public void Init()
{
m_Unlocks = new IUnlock[(int)cfg.ActorCfg.UnlockType.Max];
m_Unlocks[(int)cfg.ActorCfg.UnlockType.LevelStar] = new UnlockLevelStar();
m_Unlocks[(int)cfg.ActorCfg.UnlockType.Character] = new UnlockCharacter();
m_Unlocks[(int)cfg.ActorCfg.UnlockType.LevelPass] = new UnlockLevelPass();
}
public uint IsUnlock(uint nUnlockID)
{
var scpUnlock = TableManager.Instance.Tables.Unlock.Get((int)nUnlockID);
if(scpUnlock == null)
{
return (uint)NLDPB.OpResult.UnlockSchemaNotfound;
}
if(scpUnlock.Type >= cfg.ActorCfg.UnlockType.Max)
{
return (uint)NLDPB.OpResult.UnlockTypeError;
}
if(m_Unlocks[(int)scpUnlock.Type] == null)
{
return (uint)NLDPB.OpResult.UnlockCheckNotHandler;
}
return m_Unlocks[(int)scpUnlock.Type].Check(scpUnlock);
}
public static uint GetUnlockParam(cfg.ActorCfg.DataUnlock cfg, cfg.ActorCfg.UnlockParam param)
{
switch((int)param)
{
case 1:
return (uint)cfg.Param1;
case 2:
return (uint)cfg.Param2;
default:
return (uint)cfg.Param3;
}
}
}
}