protected override int GetRandom() { BehaviorRandom.Check(); _totalPriotity = 0; IEnumerable <int> ie = BehaviorRandom.GetRemainder(); foreach (var index in ie) { _totalPriotity += nodeChildList[index].Priority; } int randomValue = _random.Next(0, _totalPriotity + 1); int priority = 0; int result = 0; ie = BehaviorRandom.GetRemainder(); foreach (var index in ie) { priority += nodeChildList[index].Priority; if (priority >= randomValue) { result = index; BehaviorRandom.Remove(index); break; } } return(result); }
public override void OnEnter() { base.OnEnter(); BehaviorRandom.Init(); }