-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathConnection.cs
More file actions
50 lines (40 loc) · 1.52 KB
/
Copy pathConnection.cs
File metadata and controls
50 lines (40 loc) · 1.52 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
namespace ActionGraph
{
public class Connection
{
// -------------------------------------------------------------------------------
public enum ConditionRequirements
{
All,
Any
}
// -------------------------------------------------------------------------------
public ConditionRequirements ConditionRequirement;
public List<Condition> Conditions = new List<Condition>();
public Node StartNode = null;
public Node EndNode = null;
// -------------------------------------------------------------------------------
public bool CheckConditions()
{
int numChecksPassed = 0;
if (Conditions.Count > 0 )
{
foreach (var condition in Conditions)
{
var result = condition.Check();
numChecksPassed += (result) ? 1 : 0;
}
}
else
{
return true;
}
return (ConditionRequirement == ConditionRequirements.All && numChecksPassed == Conditions.Count) ||
(ConditionRequirement == ConditionRequirements.Any && numChecksPassed >= 1);
}
// -------------------------------------------------------------------------------
}
}