private IEnumerable AttackResolver(BossActor actor, int count) { BossBehaviour.Log(Time.frameCount + " " + actor + " attacks " + count + " times", actor); for (var i = count; i > 0; i--) { foreach (var unused in _controller.WaitForStateEnter <AttackState>(actor)) { BossBehaviour.Log(Time.frameCount + " waiting attack state enter", actor); actor.DesiredAttack = true; yield return(null); } } BossBehaviour.Log(Time.frameCount + " attack state entered", actor); foreach (var unused in _controller.WaitForStateExit <AttackState>(actor)) { BossBehaviour.Log(Time.frameCount + " waiting attack state exit", actor); yield return(null); } }
public IEnumerable GetResolver(CompoundBehaviourNode node) { var actor = _controller.GetComponent <BossActor>(); _behaviours = new List <string>(); if (node.Randomize) { _behaviours.AddRange(node.GetChildNodes().Zip(node.GetChildMultiplicators(), Enumerable.Repeat) .SelectMany(enumerable => enumerable)); } else { _behaviours.AddRange(node.GetChildNodes()); } BossBehaviour.Log(actor + " starts behaviour " + node.Name, actor); do { foreach (var unused in GetOneLoopResolver(node)) { if (node.UseHealthEndCondition) { var currentHealth = actor.GetComponent <ActorHealth>().CurrentHitCount; if (!_actorCriticalHurtFlagSet && currentHealth <= node.HealthEndConditionLimit + 1) { _actorCriticalHurtFlagSet = true; actor.SetNextHurtIsCritical(); } if (currentHealth <= node.HealthEndConditionLimit) { // wait for actor to go out of next hurt state foreach (var unused1 in _controller.WaitForStateExit <CriticalHurtState>(actor)) { yield return(null); } yield break; } } yield return(null); } } while (node.LoopRepeat); }