Example #1
0
 public NodeConnection(NodeConnectionPoint inPoint, NodeConnectionPoint outPoint,
                       Action <NodeConnection> RemoveConnection)
 {
     this.inPoint          = inPoint;
     this.outPoint         = outPoint;
     this.RemoveConnection = RemoveConnection;
 }
    //出る点が押されたとき登録
    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();
            }
        }
    }
Example #3
0
    public Rect window;                  //このノードの大きさ


    //初期化
    public Node(Vector2 position, float width, float height, GUIStyle nodeStyle, GUIStyle selectedStyle, GUIStyle inPointStyle, GUIStyle outPointStyle, Action <NodeConnectionPoint> OnClickInPoint, Action <NodeConnectionPoint> OnClickOutPoint, Action <Node> OnClickRemoveNode)
    {
        rect              = new Rect(position.x, position.y, width, height);
        inPoint           = new NodeConnectionPoint(this, ConnectionPointType.In, inPointStyle, OnClickInPoint);
        outPoint          = new NodeConnectionPoint(this, ConnectionPointType.Out, outPointStyle, OnClickOutPoint);
        style             = nodeStyle;
        defaultNodeStyle  = nodeStyle;
        selectedNodeStyle = selectedStyle;
        OnRemoveNode      = OnClickRemoveNode;
    }
    private void OnClickOutPoint(NodeConnectionPoint outPoint)
    {
        selectedOutPoint = outPoint;

        if (selectedInPoint != null)
        {
            if (selectedOutPoint.Node != selectedInPoint.Node)
            {
                CreateConnection();
                ClearConnectionSelection();
            }
            else
            {
                ClearConnectionSelection();
            }
        }
    }
    public void OnClickOutPoint(NodeConnectionPoint iOutPoint)
    {
        SelectedOutPoint = iOutPoint;

        if (SelectedInPoint != null)
        {
            if (SelectedOutPoint.Node != SelectedInPoint.Node)
            {
                CreateConnection();
                ClearConnectionSelection();
            }
            else
            {
                ClearConnectionSelection();
            }
        }
    }
Example #6
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);
     }
 }
    //終点が押されたとき登録
    private void OnClickOutPoint(NodeConnectionPoint outPoint)
    {
        selectedOutPoint = outPoint;

        if (selectedInPoint != null)
        {
            //現在選択中の始点終点ノードがあればノード線を作成
            if (selectedOutPoint.node != selectedInPoint.node)
            {
                CreateConnection();
                ClearConnectionSelection();
            }
            else
            {
                ClearConnectionSelection();
            }
        }
    }
 private void ClearConnectionSelection()
 {
     //Clear
     selectedInPoint  = null;
     selectedOutPoint = null;
 }
Example #9
0
 //初期化
 public NodeConnection(NodeConnectionPoint inPoint, NodeConnectionPoint outPoint, Action <NodeConnection> onClickRemove)
 {
     this.inPoint            = inPoint;
     this.outPoint           = outPoint;
     OnClickRemoveConnection = onClickRemove;
 }
    /// <summary>
    /// 初期化処理
    /// </summary>
    private void InitState()
    {
        EditorApplication.playModeStateChanged += OnChangedPlayMode;        //プレイモードの変更時の処理
        //フラグがtrueなら起動
        if (initFlag == false)
        {
            return;
        }


        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].stateName;
        }
        states = stateMonobehaviors[nowStateMonoNuber].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;
    }
Example #11
0
 public NodeConnection(NodeConnectionPoint inPoint, NodeConnectionPoint outPoint, Action <NodeConnection> OnClickRemoveConnection)
 {
     this.inPoint  = inPoint;
     this.outPoint = outPoint;
     this.OnClickRemoveConnection = OnClickRemoveConnection;
 }