Exemplo n.º 1
0
        public override void SetData(params object[] data)
        {
            if (data.Length > 0 && data[0] != null && data[0] is Node)
            {
                _selectedNode = data[0] as Node;
            }

            if (data.Length > 1 && data[1] != null && data[1] is StateGraph)
            {
                _stateGraph = data[1] as StateGraph;
            }

            if (data.Length > 2 && data[2] != null && data[2] is GenericMenu)
            {
                addConditionGenericMenu = data[2] as GenericMenu;
            }
        }
Exemplo n.º 2
0
        public void Initialize(StateGraph stateGraph)
        {
            _stateGraph = stateGraph;

            _addStateContextMenu = GenerateAddMenu(StatesAssemblyExtension.GetDerivedTypes <BaseState>(), "Add state/{0}", AddState, GetNameFromType);
            //_addStateContextMenu = GenerateAddMenu(_stateGraph.NodeInfo.ToArray(), "Add state reference/{0}", AddStateReference, GetNameFromNode, _addStateContextMenu);
            _addContitionContextMenu = GenerateAddMenu(StatesAssemblyExtension.GetDerivedTypes <BaseStateTransitionCondition>(), "{0}", AddCondition, GetNameFromType);

            _transitionConditionsInspector.SetData(null, null, _addContitionContextMenu);

            _selectedNodeContextMenu.AddItem(new GUIContent("Remove state"), false, RemoveState);
            _selectedTransitionContextMenu.AddItem(new GUIContent("Remove transition"), false, RemoveTransition);

            _stateInspecotr.SetData(_selectedNode, _stateGraph, _addContitionContextMenu);

            _connector             = new Connector(SetDirty);
            _formAnyStateConnector = new Connector(SetDirty, _stateGraph);

            _nodes.AddRange(_stateGraph.NodeInfo);
            _nodes.Add(_stateGraph.FromAnyStateNode);

            _stateGraph.FromAnyStateNode.OnConnectionPointClicked += _formAnyStateConnector.Connect;

            foreach (var item in _nodes)
            {
                if (item.State != null)
                {
                    List <Node> nodeList = null;
                    if (_statesDictionary.ContainsKey(item.State))
                    {
                        nodeList = _statesDictionary[item.State];
                    }
                    else
                    {
                        nodeList = new List <Node>();
                        _statesDictionary.Add(item.State, nodeList);
                    }

                    nodeList.Add(item);
                }

                item.IsSelected = false;
                item.OnConnectionPointClicked += _formAnyStateConnector.Connect;
                item.OnConnectionPointClicked += _connector.Connect;
            }
        }
Exemplo n.º 3
0
 public Connector(Action <MonoBehaviour> setDirty, StateGraph graph) : this(setDirty)
 {
     SetDirty = setDirty;
     _graph   = graph;
 }