Forums › 💬 NodeCanvas › 🗨️ General Discussion › JRPG Battle System › Reply To: JRPG Battle System
Hello,
No worries at all.
Here is the ‘Graph Owner Control’ code revamped, so that you can wait for the behaviour to finish like you describe. Simply replace the GraphOwnerControl.cs code with the following:
|
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 51 52 53 |
using UnityEngine; using System.Collections; namespace NodeCanvas.Actions{ [Category("✫ Utility")] [Description("Start, Resume, Pause, Stop a GraphOwner's behaviour")] [AgentType(typeof(GraphOwner))] public class GraphOwnerControl : ActionTask { public enum Control { StartBehaviour, StopBehaviour, PauseBehaviour } public Control control = Control.StartBehaviour; public bool waitUntilFinish = true; protected override string info{ get {return agentInfo + "." + control.ToString();} } protected override void OnExecute(){ if (control == Control.StartBehaviour){ if (waitUntilFinish){ (agent as GraphOwner).StartBehaviour( delegate{EndAction();} ); } else { (agent as GraphOwner).StartBehaviour(); EndAction(); } } } //These should take place here to be called 1 frame later, in case target is the same agent. protected override void OnUpdate(){ if (control == Control.StopBehaviour){ (agent as GraphOwner).StopBehaviour(); EndAction(); } else if (control == Control.PauseBehaviour){ (agent as GraphOwner).PauseBehaviour(); EndAction(); } } } } |
Iterating all enemies as you describe can certainly be one way of doing this, so that enemies take turns in order.
Let me know if you have any further questions 🙂
Cheers!
