Ejemplo n.º 1
0
        private void DisplayNodeOptionsAtPosition(TransitionConnection transition)
        {
            GenericMenu genericMenu = new GenericMenu();

            genericMenu.AddItem(new GUIContent("Remove transition"), false, () => _window.RemoveTransition(transition));
            genericMenu.ShowAsContext();
        }
Ejemplo n.º 2
0
        public void RemoveTransition(TransitionConnection transition)
        {
            if (_transitions.Remove(transition))
            {
                if (IsSelected(transition))
                {
                    DeselectAll();
                }

                RecordAndRebuild();
            }
        }
Ejemplo n.º 3
0
        public void AddTransitionFrom(TransitionInfo transitionInfo)
        {
            var source = StateNodeOf(transitionInfo.StateFrom);
            var target = StateNodeOf(transitionInfo.StateTo);

            var newTransition = new TransitionConnection(source, target, _builder.TriggerType, transitionInfo.Trigger, transitionInfo.GuardConditions);

            newTransition.OnTriggerChanged         += (connection, previousTrigger, currentTrigger) => RecordAndRebuild();
            newTransition.OnGuardConditionsChanged += (connection, currentGuardConditions) => RecordAndRebuild();

            _transitions.Add(newTransition);
        }
Ejemplo n.º 4
0
        public void SelectTransition(TransitionConnection transition)
        {
            DeselectAll();

            for (int i = 0; i < _transitions.Count; i++)
            {
                var currentTransition = _transitions[i];

                if (currentTransition == transition)
                {
                    GUI.FocusControl(null);
                    _selectedObject = currentTransition;
                }
            }

            Repaint();
        }
Ejemplo n.º 5
0
        public void AddTransition(StateNode source, StateNode target)
        {
            DoWithUndoAndDirtyFlag(() =>
            {
                if (ContainsTransitionWithSourceAndTarget(source, target))
                {
                    return;
                }

                var newTransition = new TransitionConnection(source, target, _builder.TriggerType);

                newTransition.OnTriggerChanged         += (connection, previousTrigger, currentTrigger) => RecordAndRebuild();
                newTransition.OnGuardConditionsChanged += (connection, currentGuardConditions) => RecordAndRebuild();

                _transitions.Add(newTransition);
            });
        }
Ejemplo n.º 6
0
        public void HandleEventFor(TransitionConnection transition, Event nodeEvent)
        {
            switch (nodeEvent.type)
            {
            case EventType.MouseDown:

                if (IsLeftMouseClick(nodeEvent.button))
                {
                    if (transition.IsPointOverConnection(nodeEvent.mousePosition))
                    {
                        _window.SelectTransition(transition);
                        nodeEvent.Use();
                    }
                }
                else if (IsRightMouseClick(nodeEvent.button) && _window.IsSelected(transition))
                {
                    DisplayNodeOptionsAtPosition(transition);
                    nodeEvent.Use();
                }

                break;
            }
        }
Ejemplo n.º 7
0
 public bool IsSelected(TransitionConnection transition)
 {
     return(object.ReferenceEquals(_selectedObject, transition));
 }