Exemplo n.º 1
0
 public Transition AddTransition(BaseNode b)
 {
     return b.stateRef.currentState.AddTransition();
 }
Exemplo n.º 2
0
        public override void DrawWindow(BaseNode b)
        {
            if(b.stateRef.currentState == null)
            {
                EditorGUILayout.LabelField("Add state to modify:");
            }
            else
            {
                if(!b.collapse)
                {
                 
                }
                else
                {
                    b.windowRect.height = 100;
                }

                b.collapse = EditorGUILayout.Toggle(" ", b.collapse);
            }

            b.stateRef.currentState = (State)EditorGUILayout.ObjectField(b.stateRef.currentState, typeof(State), false);

            if(b.previousCollapse != b.collapse)
            {
                b.previousCollapse = b.collapse;
            }

            if(b.stateRef.previousState != b.stateRef.currentState)
            {
                //b.serializedState = null;
                b.isDuplicate = BehaviorEditor.settings.currentGraph.IsStateDuplicate(b);
				b.stateRef.previousState = b.stateRef.currentState;

				if (!b.isDuplicate)
				{
					Vector3 pos = new Vector3(b.windowRect.x,b.windowRect.y,0);
					pos.x += b.windowRect.width * 2;

					SetupReordableLists(b);

					//Load transtions
					for (int i = 0; i < b.stateRef.currentState.transitions.Count; i++)
					{
						pos.y += i * 100;
						BehaviorEditor.AddTransitionNodeFromTransition(b.stateRef.currentState.transitions[i], b, pos);
					}

					BehaviorEditor.forceSetDirty = true;
				}
				
			}

			if (b.isDuplicate)
            {
                EditorGUILayout.LabelField("State is a duplicate!");
                b.windowRect.height = 100;
				return;
            }

            if (b.stateRef.currentState != null)
            {
                b.isAssigned = true;
                
                if (!b.collapse)
                {
					if (b.stateRef.serializedState == null)
					{
						SetupReordableLists(b);

					//	SerializedObject serializedState = new SerializedObject(b.stateRef.currentState);
					}

					float standard = 150;
					b.stateRef.serializedState.Update();
					b.showActions = EditorGUILayout.Toggle("Show Actions ", b.showActions);
					if (b.showActions)
					{
						EditorGUILayout.LabelField("");
						b.stateRef.onFixedList.DoLayoutList();
						EditorGUILayout.LabelField("");
						b.stateRef.onUpdateList.DoLayoutList();
						standard += 100 + 40 + (b.stateRef.onUpdateList.count + b.stateRef.onFixedList.count) * 20;
					}
					b.showEnterExit = EditorGUILayout.Toggle("Show Enter/Exit ", b.showEnterExit);
					if (b.showEnterExit)
					{
						EditorGUILayout.LabelField("");
						b.stateRef.onEnterList.DoLayoutList();
						EditorGUILayout.LabelField("");
						b.stateRef.onExitList.DoLayoutList();
						standard += 100 + 40 + (b.stateRef.onEnterList.count + b.stateRef.onExitList.count) * 20;
					}

					b.stateRef.serializedState.ApplyModifiedProperties();
                    b.windowRect.height = standard;
                }   
            }
            else
            {
                b.isAssigned = false;
            }
		}
Exemplo n.º 3
0
        public override void DrawCurve(BaseNode b)
        {

        }
Exemplo n.º 4
0
 public abstract void DrawCurve(BaseNode n);
Exemplo n.º 5
0
 public abstract void DrawWindow(BaseNode n);
Exemplo n.º 6
0
        public static BaseNode AddTransitionNodeFromTransition(Transition transition, BaseNode enterNode, Vector3 pos)
        {
            BaseNode transNode = settings.AddNodeOnGraph(settings.transitionNode, 200, 100, "Condition", pos);

            transNode.enterNode             = enterNode.id;
            transNode.transRef.transitionId = transition.id;
            return(transNode);
        }
Exemplo n.º 7
0
        public override void DrawCurve(BaseNode b)
        {
            Rect rect = b.windowRect;

            rect.y     += b.windowRect.height * .5f;
            rect.width  = 1;
            rect.height = 1;

            BaseNode e = BehaviorEditor.settings.currentGraph.GetNodeWithIndex(b.enterNode);

            if (e == null)
            {
                BehaviorEditor.settings.currentGraph.DeleteNode(b.id);
            }
            else
            {
                Color targetColor = Color.green;
                if (!b.isAssigned || b.isDuplicate)
                {
                    targetColor = Color.red;
                }

                Rect r = e.windowRect;
                BehaviorEditor.DrawNodeCurve(r, rect, true, targetColor);
            }

            if (b.isDuplicate)
            {
                return;
            }

            if (b.targetNode > 0)
            {
                BaseNode t = BehaviorEditor.settings.currentGraph.GetNodeWithIndex(b.targetNode);
                if (t == null)
                {
                    b.targetNode = -1;
                }
                else
                {
                    rect    = b.windowRect;
                    rect.x += rect.width;
                    Rect endRect = t.windowRect;
                    endRect.x -= endRect.width * .5f;

                    Color targetColor = Color.green;

                    if (t.drawNode is StateNode)
                    {
                        if (!t.isAssigned || t.isDuplicate)
                        {
                            targetColor = Color.red;
                        }
                    }
                    else
                    {
                        if (!t.isAssigned)
                        {
                            targetColor = Color.red;
                        }
                        else
                        {
                            targetColor = Color.yellow;
                        }
                    }

                    BehaviorEditor.DrawNodeCurve(rect, endRect, false, targetColor);
                }
            }
        }
Exemplo n.º 8
0
        public override void DrawWindow(BaseNode b)
        {
            EditorGUILayout.LabelField("");
            BaseNode enterNode = BehaviorEditor.settings.currentGraph.GetNodeWithIndex(b.enterNode);

            if (enterNode == null)
            {
                return;
            }

            if (enterNode.stateRef.currentState == null)
            {
                BehaviorEditor.settings.currentGraph.DeleteNode(b.id);
                return;
            }

            Transition transition = enterNode.stateRef.currentState.GetTransition(b.transRef.transitionId);

            if (transition == null)
            {
                return;
            }


            transition.condition =
                (Condition)EditorGUILayout.ObjectField(transition.condition
                                                       , typeof(Condition), false);

            if (transition.condition == null)
            {
                EditorGUILayout.LabelField("No Condition!");
                b.isAssigned = false;
            }
            else
            {
                b.isAssigned = true;
                if (b.isDuplicate)
                {
                    EditorGUILayout.LabelField("Duplicate Condition!");
                }
                else
                {
                    GUILayout.Label(transition.condition.description);

                    BaseNode targetNode = BehaviorEditor.settings.currentGraph.GetNodeWithIndex(b.targetNode);
                    if (targetNode != null)
                    {
                        if (!targetNode.isDuplicate)
                        {
                            transition.targetState = targetNode.stateRef.currentState;
                        }
                        else
                        {
                            transition.targetState = null;
                        }
                    }
                    else
                    {
                        transition.targetState = null;
                    }
                }
            }

            if (b.transRef.previousCondition != transition.condition)
            {
                b.transRef.previousCondition = transition.condition;
                b.isDuplicate = BehaviorEditor.settings.currentGraph.IsTransitionDuplicate(b);

                if (!b.isDuplicate)
                {
                    BehaviorEditor.forceSetDirty = true;
                    // BehaviorEditor.settings.currentGraph.SetNode(this);
                }
            }
        }