Exemplo n.º 1
0
        //入る点が押されたとき登録
        private void OnClickInPoint(NodeConnectionPoint inPoint)
        {
            selectedInPoint = inPoint;

            if (selectedOutPoint != null)
            {
                //Undo処理
                if (stateMonobehaviors.Length > 0)
                {
                    Undo.RecordObject(stateMonobehaviors[nowStateMonoNuber], "StateUndo");
                }
                //現在選択中の始点終点ノードがあればノード線を作成
                if (selectedOutPoint.node != selectedInPoint.node)
                {
                    CreateConnection();
                    ClearConnectionSelection();
                }
                else
                {
                    ClearConnectionSelection();
                }
            }
            else
            {
                selectedInPoint = null;
            }
        }
Exemplo n.º 2
0
        //出る点が押されたとき登録
        private void OnClickOutPoint(NodeConnectionPoint outPoint)
        {
            if (outPoint.node.ID != Node.nodeActiveID && optionAllView == false)
            {
                return;
            }
            if (selectedOutPoint == outPoint)
            {
                ClearConnectionSelection();
                return;
            }
            selectedOutPoint = outPoint;

            if (selectedInPoint != null)
            {
                //Undo処理
                if (stateMonobehaviors.Length > 0)
                {
                    Undo.RecordObject(stateMonobehaviors[nowStateMonoNuber], "StateUndo");
                }
                //現在選択中の始点終点ノードがあればノード線を作成
                if (selectedOutPoint.node != selectedInPoint.node)
                {
                    CreateConnection();
                    ClearConnectionSelection();
                }
                else
                {
                    ClearConnectionSelection();
                }
            }
        }
Exemplo n.º 3
0
        //出る点が押されたとき登録
        private void OnClickOutPoint(NodeConnectionPoint outPoint)
        {
            if (outPoint.node.ID != Node.nodeActiveID && optionAllView == false)
            {
                return;
            }
            if (selectedOutPoint == outPoint)
            {
                ClearConnectionSelection();
                return;
            }
            selectedOutPoint = outPoint;

            if (selectedInPoint != null)
            {
                //現在選択中の始点終点ノードがあればノード線を作成
                if (selectedOutPoint.node != selectedInPoint.node)
                {
                    CreateConnection();
                    ClearConnectionSelection();
                }
                else
                {
                    ClearConnectionSelection();
                }
            }
        }
Exemplo n.º 4
0
        /// <summary>
        /// 初期化
        /// </summary>
        public Node(
            Rect recPos,
            GUIStyle inPointStyle,
            GUIStyle outPointStyle,
            Action <NodeConnectionPoint> OnClickInPoint,
            Action <NodeConnectionPoint> OnClickOutPoint,
            Action <Node> OnClickRemoveNode,
            string title,
            int id,
            NomalState nomalS,
            GameObject game,
            StateMonobehavior monobehavior
            )
        {
            rect         = recPos;                                                                              //ウィンドウの大きさ設定
            inPoint      = new NodeConnectionPoint(this, ConnectionPointType.In, inPointStyle, OnClickInPoint); //入力ポイント
            OnRemoveNode = OnClickRemoveNode;
            this.title   = title;
            ID           = id;
            myState      = nomalS;

            gameObject        = game;
            stateMonobehavior = monobehavior;
            //出力ポイント
            for (int i = 0; i < myState.nextStateJudge.Count; i++)
            {
                StateOutPoint rectOut = new StateOutPoint();
                rectOut.stateJudge = myState.nextStateJudge[i];
                rectOut.outPoint   = new NodeConnectionPoint(this, ConnectionPointType.Out, outPointStyle, OnClickOutPoint, myState.nextStateJudge[i]);
                outPoints.Add(rectOut);
            }
            //アップデート中の処理
            for (int i = 0; i < myState.playUpdateDelegate.Count; i++)
            {
                FuncList list = new FuncList();
                list.actionDelegate = myState.playUpdateDelegate[i];
                updateFuncs.Add(list);
            }
            //ステートになった時の処理
            for (int i = 0; i < myState.execDelegate.Count; i++)
            {
                FuncList list = new FuncList();
                list.actionDelegate = myState.execDelegate[i];
                startFuncs.Add(list);
            }
        }
Exemplo n.º 5
0
        //入る点が押されたとき登録
        private void OnClickInPoint(NodeConnectionPoint inPoint)
        {
            selectedInPoint = inPoint;

            if (selectedOutPoint != null)
            {
                //現在選択中の始点終点ノードがあればノード線を作成
                if (selectedOutPoint.node != selectedInPoint.node)
                {
                    CreateConnection();
                    ClearConnectionSelection();
                }
                else
                {
                    ClearConnectionSelection();
                }
            }
            else
            {
                selectedInPoint = null;
            }
        }
Exemplo n.º 6
0
 //選択中のノード矩形のリセット
 private void ClearConnectionSelection()
 {
     selectedInPoint  = null;
     selectedOutPoint = null;
 }
Exemplo n.º 7
0
        /// <summary>
        /// 初期化処理
        /// </summary>
        public void InitState()
        {
            EditorApplication.playModeStateChanged += OnChangedPlayMode;//プレイモードの変更時の処理
            //フラグがtrueなら起動
            if (initFlag == false)
            {
                return;
            }

            Undo.undoRedoPerformed += UndoCall;
            nowId = 0; //windowIDを初期化
                       //ノードがあればノードを一度初期化する
            if (nodes != null)
            {
                nodes.Clear();
                nodes = null;
            }
            if (connections != null)
            {
                connections.Clear();
                connections = null;
            }
            //クラスを格納してそのクラスのステートを現在管理するステートに
            var cla = gameObject.GetComponent <StateMonobehavior>();

            Array.Resize(ref stateMonoOption, 0);
            stateMonobehaviors = gameObject.GetComponents <StateMonobehavior>();
            for (int i = 0; i < stateMonobehaviors.Length; i++)
            {
                Array.Resize(ref stateMonoOption, stateMonoOption.Length + 1);
                stateMonoOption[i] = stateMonobehaviors[i].stateBody.stateName;
            }
            if (isSubStateEditor == true)
            {
                states = subStates.states;
            }
            else
            {
                states = stateMonobehaviors[nowStateMonoNuber].stateBody.states;
            }
            if (nodes == null)
            {
                nodes = new List <Node>();
            }
            //ステートの分ノードを追加
            foreach (NomalState st in states)
            {
                //ノードの追加
                nodes.Add(new Node(new Rect(st.nodePosition.x, st.nodePosition.y, 250, 150), inPointStyle, outPointStyle, OnClickInPoint, OnClickOutPoint, OnClickRemoveNode, st.getStateName(), nowId, st, gameObject, stateMonobehaviors[nowStateMonoNuber]));
                nowId++;
            }
            //nextStateの線を描く
            if (nodes.Count > 0)
            {
                foreach (Node n in nodes)
                {
                    if (n.outPoints.Count <= 0)
                    {
                        continue;
                    }
                    foreach (Node.StateOutPoint point in n.outPoints)
                    {
                        selectedOutPoint = point.outPoint;
                        foreach (Node a in nodes)
                        {
                            if (point.stateJudge.nextID.number == 0)
                            {
                                break;
                            }

                            if (a.myState.ID.number == point.stateJudge.nextID.number)
                            {
                                selectedInPoint = a.inPoint;
                                break;
                            }
                        }
                        if (selectedOutPoint != null && selectedInPoint != null)
                        {
                            if (selectedOutPoint.node != selectedInPoint.node)
                            {
                                CreateConnection();
                            }
                        }
                        ClearConnectionSelection();
                    }
                }
            }
            //IDを振り分け
            int countOne = 1;

            foreach (NomalState nomal in states)
            {
                nomal.ID.number = countOne;
                countOne++;
            }
            initFlag = false;
        }
Exemplo n.º 8
0
 //初期化
 public NodeConnection(NodeConnectionPoint inPoint, NodeConnectionPoint outPoint, Action <NodeConnection> onClickRemove)
 {
     this.inPoint            = inPoint;
     this.outPoint           = outPoint;
     OnClickRemoveConnection = onClickRemove;
 }