39 lines
1001 B
C#
39 lines
1001 B
C#
|
|
using UnityEngine;
|
||
|
|
|
||
|
|
namespace Rokojori
|
||
|
|
{
|
||
|
|
|
||
|
|
public enum CompareOperator
|
||
|
|
{
|
||
|
|
Equal,
|
||
|
|
NotEqual,
|
||
|
|
GreaterThan,
|
||
|
|
GreaterOrEqual,
|
||
|
|
LessThan,
|
||
|
|
LessOrEqual
|
||
|
|
}
|
||
|
|
|
||
|
|
[CreateAssetMenu( menuName = "Rokojori/Dialog/Conditions/Compare Int" )]
|
||
|
|
public class CompareInt : GameStateCondition
|
||
|
|
{
|
||
|
|
public GameStateNumberVariable variable = null;
|
||
|
|
public CompareOperator comparison = CompareOperator.Equal;
|
||
|
|
public int value = 0;
|
||
|
|
|
||
|
|
public override bool Evaluate()
|
||
|
|
{
|
||
|
|
var current = GameStateManager.instance.GetValue( variable );
|
||
|
|
|
||
|
|
if ( CompareOperator.Equal == comparison ) return value == current;
|
||
|
|
if ( CompareOperator.NotEqual == comparison ) return value != current;
|
||
|
|
if ( CompareOperator.GreaterThan == comparison ) return current > value;
|
||
|
|
if ( CompareOperator.GreaterOrEqual == comparison ) return current >= value;
|
||
|
|
if ( CompareOperator.LessThan == comparison ) return current < value;
|
||
|
|
if ( CompareOperator.LessOrEqual == comparison ) return current <= value;
|
||
|
|
|
||
|
|
return false;
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
}
|