private void CreateFlowState(Vector2 position)
        {
            var flowState = FlowState.WithEnterUpdateExit();

            if (!graph.states.Any())
            {
                flowState.isStart          = true;
                flowState.nest.embed.title = "Start";
            }

            AddState(flowState, position);
        }
Exemplo n.º 2
0
        public static StateGraph WithStart()
        {
            var stateGraph = new StateGraph();

            var startState = FlowState.WithEnterUpdateExit();

            startState.isStart          = true;
            startState.nest.embed.title = "Start";
            startState.position         = new Vector2(-86, -15);

            stateGraph.states.Add(startState);

            return(stateGraph);
        }
        public void CompleteTransitionToNewState()
        {
            var startRect = this.Widget(transitionSource).position;
            var end       = mousePosition;

            GraphGUI.GetConnectionEdge
            (
                startRect.center,
                end,
                out var startEdge,
                out var endEdge
            );

            var destination = FlowState.WithEnterUpdateExit();

            graph.states.Add(destination);

            Vector2 offset;

            var size = this.Widget(destination).position.size;

            switch (endEdge)
            {
            case Edge.Left:
                offset = new Vector2(0, -size.y / 2);
                break;

            case Edge.Right:
                offset = new Vector2(-size.x, -size.y / 2);
                break;

            case Edge.Top:
                offset = new Vector2(-size.x / 2, 0);
                break;

            case Edge.Bottom:
                offset = new Vector2(-size.x / 2, -size.y);
                break;

            default:
                throw new UnexpectedEnumValueException <Edge>(endEdge);
            }

            destination.position = mousePosition + offset;

            destination.position = destination.position.PixelPerfect();

            EndTransition(destination);
        }
 public override void PerformDragAndDrop()
 {
     if (DragAndDropUtility.Is <ScriptGraphAsset>())
     {
         var flowMacro = DragAndDropUtility.Get <ScriptGraphAsset>();
         var flowState = new FlowState(flowMacro);
         AddState(flowState, DragAndDropUtility.position);
     }
     else if (DragAndDropUtility.Is <StateGraphAsset>())
     {
         var asset      = DragAndDropUtility.Get <StateGraphAsset>();
         var superState = new SuperState(asset);
         AddState(superState, DragAndDropUtility.position);
     }
 }