Gameplay Ingredients是一组用于 Unity 游戏的运行时和编辑器工具:一组脚本的集合,可在制作游戏和原型时简化简单的任务。
您最多选择25个主题 主题必须以中文或者字母或数字开头,可以包含连字符 (-),并且长度不得超过35个字符

52 行
1.3 KiB

using NaughtyAttributes;
using System;
using UnityEngine.Events;
namespace GameplayIngredients.Logic
{
public abstract class ConditionalLogic : LogicBase
{
[ReorderableList]
public Callable[] OnConditionValid;
[ReorderableList]
public Callable[] OnConditionInvalid;
public override void Execute()
{
if (GetCondition())
Callable.Call(OnConditionValid);
else
Callable.Call(OnConditionInvalid);
}
public abstract bool GetCondition();
protected static bool Compare<T>(T A, T B, Comparison c) where T : IComparable
{
int comp = A.CompareTo(B);
switch (c)
{
case Comparison.Equal: return comp == 0;
case Comparison.NotEqual: return comp != 0;
case Comparison.Greater: return comp > 0;
case Comparison.GreaterOrEqual: return comp >= 0;
case Comparison.Less: return comp < 0;
case Comparison.LessOrEqual: return comp <= 0;
}
return false;
}
public enum Comparison
{
Equal,
NotEqual,
Greater,
GreaterOrEqual,
Less,
LessOrEqual
}
}
}