public ICharacterState Step() { behaviour.Idle(); findTargetCooldown.Update(); idleDoneCooldown.Update(); // If there's target, attack if (findTargetCooldown.Ready()) { var target = behaviour.FindTarget(); if (target != null) { return(new AttackState(behaviour, character, target)); } } // If havn't done idling, idle if (!idleDoneCooldown.Ready()) { return(this); } // Otherwise patrol return(new PatrolState(behaviour, character)); }
public ICharacterState Step() { findTargetCooldown.Update(); // Attack if there is target if (findTargetCooldown.Ready()) { var target = behaviour.FindTarget(); if (target != null) { return(new AttackState(behaviour, character, target)); } } // Keep patrolling var finished = behaviour.Patrol(); if (!finished) { return(this); } return(new IdleState(behaviour, character)); }