Пример #1
0
        private void AddTransition(StateNode endState, Transition transition)
        {
            if (!connectedStates.Contains(endState.state))
            {
                connectedStates.Add(endState.state);
                TransitionDataHolder t = ScriptableObject.CreateInstance <TransitionDataHolder>();
                t.Init(RemoveTransition, RemoveTransitionFromInspector);
                t.TransitionsForState = new List <Transition>();
                t.TransitionsForState.Add(transition);

                // If the other state transitions to this one, it needs to be two ways
                if (endState.connectedStates.Contains(state))
                {
                    t.TwoWayTransition = true;
                    endState.stateTransitionInfo[state].TwoWayTransition = true;
                    t.OtherWayTransition = endState.stateTransitionInfo[state];
                    endState.stateTransitionInfo[state].OtherWayTransition = t;
                    endState.UpdateTriangleRotation(state);
                }

                stateTransitionInfo.Add(endState.state, t);
            }
            else
            {
                stateTransitionInfo[endState.state].TransitionsForState.Add(transition);
            }

            UpdateTriangleRotation(endState.state);
        }
        /// <summary>
        /// Handles dragging of the nodes
        /// </summary>
        /// <param name="delta"></param>
        private void OnDrag(Vector2 delta)
        {
            drag = delta;


            for (int i = 0; i < states.Count; i++)
            {
                states[i].DragState(delta);
            }


            for (int i = 0; i < states.Count; i++)
            {
                states[i].UpdateTriangleRotation(states[i].NodeState);
            }

            if (anyStateNode != null)
            {
                anyStateNode.DragState(delta);
                anyStateNode.UpdateTriangleRotation(anyStateNode.NodeState);
            }
        }