86 lines
2.7 KiB
C#
86 lines
2.7 KiB
C#
using System;
|
|
using UnityEngine;
|
|
|
|
namespace AibisDream.FixSystem
|
|
{
|
|
[CreateAssetMenu(fileName = "CheckRule", menuName = "Level Data/CheckRule")]
|
|
public class CheckRule : ScriptableObject
|
|
{
|
|
public Vector2 duration;
|
|
|
|
public bool isColorLimited;
|
|
public string colorName;
|
|
|
|
public CompareSign borderCountSign;
|
|
public int borderCount;
|
|
|
|
public CompareSign roundSign;
|
|
public bool isRound;
|
|
|
|
public int productNum;
|
|
|
|
public bool Match(CheckData data)
|
|
{
|
|
// 色彩
|
|
if (isColorLimited)
|
|
{
|
|
if (colorName != data.colorName)
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
|
|
// 圆角和直角
|
|
if (roundSign != CompareSign.Ignore)
|
|
{
|
|
if (isRound != data.isRound)
|
|
{
|
|
return false;
|
|
}
|
|
}
|
|
|
|
// 边数
|
|
return borderCountSign switch
|
|
{
|
|
CompareSign.Ignore => true,
|
|
CompareSign.Equal => borderCount == data.borderCount,
|
|
CompareSign.NotEqual => borderCount != data.borderCount,
|
|
CompareSign.GreaterThan => data.borderCount > borderCount,
|
|
CompareSign.LessThan => data.borderCount < borderCount,
|
|
CompareSign.GreaterThanOrEqual => data.borderCount >= borderCount,
|
|
CompareSign.LessThanOrEqual => data.borderCount <= borderCount,
|
|
_ => true,
|
|
};
|
|
}
|
|
|
|
public string GetRuleText()
|
|
{
|
|
var res = string.Empty;
|
|
// 颜色限制
|
|
if (isColorLimited)
|
|
{
|
|
res += $"颜色: <color={colorName}>{colorName}</color><br>";
|
|
}
|
|
// 圆角或非圆角
|
|
if (roundSign != CompareSign.Ignore)
|
|
{
|
|
var roundText = isRound ? "圆角" : "非圆角";
|
|
res += $"{roundText}<br>";
|
|
}
|
|
// 边数关系
|
|
res += borderCountSign switch
|
|
{
|
|
CompareSign.Ignore => string.Empty,
|
|
CompareSign.Equal => $"边数: {borderCount}<br>",
|
|
CompareSign.NotEqual => $"边数: 不等于{borderCount}<br>",
|
|
CompareSign.GreaterThan => $"边数: 大于{borderCount}<br>",
|
|
CompareSign.LessThan => $"边数: 小于{borderCount}<br>",
|
|
CompareSign.GreaterThanOrEqual => $"边数: 大于等于{borderCount}",
|
|
CompareSign.LessThanOrEqual => $"边数: 小于等于{borderCount}",
|
|
_ => throw new ArgumentOutOfRangeException()
|
|
};
|
|
|
|
return res;
|
|
}
|
|
}
|
|
} |