コード例 #1
0
    public void Render()
    {
        ProcessDrag();


        if (DraggedState != null)
        {
            FSMEditorState hoverState = MyFSMStatesControl.FindStateUnderMouse();
            if (hoverState != null)
            {
                FSMLineRender.DrawTransition(DraggedState.GetEventRect(DraggedTransitionIndex, null), hoverState.GetHeaderRect(DraggedState));
            }
            else
            {
                Vector2 position = FSMEditorEvent.Instance.MousePosition;
                position.y += MyFSMStatesControl.ScrollPos.y - MyFSMStatesControl.Position.y;
                position.x += MyFSMStatesControl.ScrollPos.x;
                FSMLineRender.DrawTransition(DraggedState.GetEventRect(DraggedTransitionIndex, null), new Rect(position.x, position.y, 1, 1));
            }

            if (FSMEditorEvent.Instance.EditorEventType == FSMEditorEventType.MouseUp)
            {
                if (hoverState != null && hoverState != DraggedState)
                {
                    DraggedState.State.Transitions[DraggedTransitionIndex].ToState = hoverState.State.StateName;
                }
                DraggedState = null;
            }
        }
    }
コード例 #2
0
 public Rect GetEventRect(int index, FSMEditorState destinationState)
 {
     if (destinationState != null && destinationState.State.Frame.x < State.Frame.x)
     {
         return(new Rect(State.Frame.x - 5, State.Frame.y + GetEventRectYOffset(index), 5, 20));
     }
     else
     {
         return(new Rect(State.Frame.x, State.Frame.y + GetEventRectYOffset(index), width, 20));
     }
 }
コード例 #3
0
 public Rect GetHeaderRect(FSMEditorState sourceState)
 {
     if (sourceState.State.Frame.x < State.Frame.x)
     {
         return(new Rect(State.Frame.x, State.Frame.y, width, 20));
     }
     else
     {
         return(new Rect(State.Frame.x + State.Frame.width, State.Frame.y, 5, 20));
     }
 }
コード例 #4
0
    public void Start()
    {
        this.title = "Xtudio 16 FSM Editor";
        FSMState [] states = MyFSM.GetComponentsInChildren <FSMState>();
        EditorStates      = new FSMEditorState[states.Length];
        EditorStatesIndex = new Dictionary <string, FSMEditorState>();
        int id = 0;

        foreach (var state in states)
        {
            var editorState = new FSMEditorState(state, id);
            EditorStates[id] = editorState;
            EditorStatesIndex.Add(state.StateName, editorState);
            id++;
        }
        FSMStatesControl      = new FSMStatesControl(this);
        FSMCreateStateControl = new FSMCreateStateControl(this);
    }
コード例 #5
0
    void ProcessDrag()
    {
        var editorStates = MyFSMStatesControl.MyFSMEditor.EditorStates;

        if (FSMEditorEvent.Instance.EditorEventType == FSMEditorEventType.MouseDown)
        {
            foreach (var editorState in editorStates)
            {
                int index = 0;
                foreach (var transition in editorState.State.Transitions)
                {
                    Rect transitionRect = editorState.GetTransitionRect(index);
                    transitionRect.y += MyFSMStatesControl.Position.y + editorState.State.Frame.y - MyFSMStatesControl.ScrollPos.y;
                    transitionRect.x += editorState.State.Frame.x - MyFSMStatesControl.ScrollPos.x;
                    if (transitionRect.Contains(FSMEditorEvent.Instance.MousePosition))
                    {
                        DraggedTransitionIndex = index;
                        DraggedState           = editorState;
                    }
                    index++;
                }
            }
        }
    }