Exemple #1
0
        protected override void CheckConditions()
        {
            // Store the active state because we want to evaluate all conditions, not just the first one
            bool activeCache = active;

            for (int i = 0; i < conditions.Length; i++)
            {
                // We evaluate first because we want the lastState in the condition to update regardless of 'active'
                if (conditions[i].Evaluate(value) && activeCache)
                {
                    NodePort triggerPort = GetOutputPort("conditions " + i);
                    if (triggerPort.IsConnected)
                    {
                        for (int k = 0; k < triggerPort.ConnectionCount; k++)
                        {
                            StateNodeBase nextNode = triggerPort.GetConnection(k).node as StateNodeBase;
                            active = false;
                            if (nextNode != null)
                            {
                                nextNode.Enter();
                            }
                        }
                    }
                }
            }
        }
        public void Exit()
        {
            if (active != this)
            {
                Debug.LogWarning("Exiting from a non-active node. Aborted.");
                return;
            }

            active = false;

            OnExit();
            NodePort exitPort = GetOutputPort("exit");

            if (exitPort.IsConnected)
            {
                for (int i = 0; i < exitPort.ConnectionCount; i++)
                {
                    StateNodeBase nextNode = exitPort.GetConnection(i).node as StateNodeBase;
                    if (nextNode != null)
                    {
                        nextNode.Enter();
                    }
                }
            }
        }
 /// <summary> Enumerate through all StatNodeBase nodes where active == true </summary>
 public IEnumerator <StateNodeBase> ActiveNodes()
 {
     for (int i = 0; i < nodes.Count; i++)
     {
         StateNodeBase node = nodes[i] as StateNodeBase;
         if (node != null && node.active)
         {
             yield return(node);
         }
     }
 }
        public override void OnHeaderGUI()
        {
            // Draw info icon
            GUI.color = new Color(1, 1, 1, 0.2f);
            GUI.Label(new Rect(GetWidth() - 22, 8, 14, 14), new GUIContent("i", description), DelftStyles.infoIcon);

            // Draw header name
            GUI.color = Color.white;
            StateNodeBase node = target as StateNodeBase;

            if (node.active)
            {
                GUI.color = Color.green;
            }
            base.OnHeaderGUI();
            GUI.color = Color.white;
        }
Exemple #5
0
        protected override void OnEnter()
        {
            NodePort triggerPort = GetOutputPort("out" + nextOutletNum);

            if (triggerPort.IsConnected)
            {
                for (int k = 0; k < triggerPort.ConnectionCount; k++)
                {
                    StateNodeBase nextNode = triggerPort.GetConnection(k).node as StateNodeBase;
                    active = false;
                    if (nextNode != null)
                    {
                        nextNode.Enter();
                    }
                }
            }
            nextOutlet();
        }