private static void MouseSelectObject()
        {
            Event e = Event.current;

            if (e.button == 0 && e.type == EventType.MouseDown)
            {
                if (StateMachineBGGUI.controlWindowRange.Contains(e.mousePosition))
                {
                    bool isSelect = false;
                    foreach (var item in MachineStateGUIDataControl.allMachineStateGUI)
                    {
                        if (StateMachineUtils.MachineGridRectContainsMousePos(e.mousePosition, item.GUIRect))
                        {
                            isSelect = true;
                            SelectObjectController.SelectItemObject(item);
                            break;
                        }
                    }
                    if (!isSelect)
                    {
                        StateTransitionArrowLine line = StateTransitionArrowLineDataControl.FindClosestStateTransitionArrowLine(e.mousePosition);
                        if (line)
                        {
                            isSelect = true;
                            SelectObjectController.SelectItemObject(line);
                        }
                    }
                    if (isSelect == false)
                    {
                        SelectObjectController.SelectObjectCancel();
                    }
                    e.Use();
                }
            }
        }
Beispiel #2
0
        public static void AddNewTransitionGUI(MachineState from, MachineState to)
        {
            StateTransition st = StateTransitionDataControl.AddNewStateTransition(from, to);

            StateTransitionArrowLineDataControl.AddStateTransitionToCreateArrowLine(st);
            if (StateMachineEditorWindow.OnAddStateTransition != null)
            {
                StateMachineEditorWindow.OnAddStateTransition(st);
            }
        }
Beispiel #3
0
        public static void DeleteStateTransitionArrowLine(StateTransitionArrowLine line)
        {
            bool res = StateTransitionArrowLineDataControl.DeleteStateTransitionArrowLine(line);

            if (res)
            {
                if (StateMachineEditorWindow.OnDeleteStateTransitionArrowLine != null)
                {
                    StateMachineEditorWindow.OnDeleteStateTransitionArrowLine(line);
                }
            }
        }
Beispiel #4
0
        public static void OnGUI()
        {
            Dictionary <StateTransitionArrowLine, StateTransitionArrowLine> dic = StateTransitionArrowLineDataControl.StateTransitionArrowLinesToGrouping();

            //Debug.Log(dic.Count);
            foreach (var item in dic.Keys)
            {
                if (item.IsLineSelf)
                {
                    DrawLine(item, 0);
                }
                else
                {
                    DrawLine(item, 0);
                    //Debug.Log(" dic:" + item.FormLinePosition[1] + " ||" + item.ToLinePosition[1]);
                    if (dic[item] != null)
                    {
                        //Debug.LogWarning("   dic[item]:" + dic[item].FormLinePosition[1] + " ||" + dic[item].ToLinePosition[1]);
                        DrawLine(dic[item], 1);
                    }
                }
            }


            //Debug.Log(state.showContent.text + ":" + state.stateTransitions.Count);
            //  StateTransitionArrowLine[] lines = StateTransitionArrowLine.CreateStateTransitionArrowLines(state.stateTransitions);
            ////  if (state.stateTransitions.Count > 0)
            //      //Debug.Log(state.showContent.text+"  lines: " + lines.Length);

            //  for (int i = 0; i < lines.Length; i++)
            //  {
            //      StateTransitionArrowLine line = lines[i];
            //      if (line.transitions.Count > 1)
            //      {
            //          DrawArrowCenterThreeTriangle(line.FormLinePosition, line.ToLinePosition, lineSize, triangleSize, line.color);
            //      }
            //      else
            //      {
            //          DrawArrowCenterOneTriangle(line.FormLinePosition, line.ToLinePosition, lineSize, triangleSize, line.color);
            //      }
            //Texture2D tex = (Texture2D)Styles.connectionTexture.image;
            //      //DrawEdge(line.FormLinePosition, line.ToLinePosition, tex, line.color, EdgeGUI.EdgeStyle.Curvy);
            //  }
            //DrawArrowCenter(st.fromState.position, st.toState.position, 12, Color.white);
        }
 public static bool DeleteMachineStateGUI(MachineStateGUI state)
 {
     if (allMachineStateGUI.Contains(state))
     {
         List <StateTransitionArrowLine> lineList = new List <StateTransitionArrowLine>();
         lineList.AddRange(state.FromArrowLines);
         lineList.AddRange(state.ToArrowLines);
         foreach (var item in lineList)
         {
             StateTransitionArrowLineDataControl.DeleteStateTransitionArrowLine(item);
         }
         lineList.Clear();
         StateMachineDataControl.DeleteMachineState(state.state);
         allMachineStateGUI.Remove(state);
         return(true);
     }
     return(false);
 }
Beispiel #6
0
 public static void DeleteStateTransition(StateTransitionArrowLine line, StateTransition st)
 {
     if (line.transitions.Contains(st))
     {
         if (line.transitions.Count == 1)
         {
             StateTransitionArrowLineDataControl.DeleteStateTransitionArrowLine(line);
         }
         else
         {
             StateTransitionDataControl.DeleteStateTransition(st);
             line.transitions.Remove(st);
         }
         if (StateMachineEditorWindow.OnDeleteStateTransition != null)
         {
             StateMachineEditorWindow.OnDeleteStateTransition(st);
         }
     }
 }