private void OnClickAddSubState(Vector2 mousePosition) { //Undo処理 if (stateMonobehaviors.Length > 0) { Undo.RecordObject(stateMonobehaviors[nowStateMonoNuber], "StateUndo"); } //ノード、ステート追加 NomalState statePlus = new NomalState(); statePlus.stateMode = StateMode.SubState; StateBody s = new StateBody(); stateMonobehaviors[nowStateMonoNuber].stateBody.Add(s); statePlus.subStateID = s.ID; states.Add(statePlus); initFlag = true; if (nodes == null) { nodes = new List <Node>(); } //マウスの場所に追加 nodes.Add(new Node(new Rect(mousePosition.x, mousePosition.y, 200, 50), inPointStyle, outPointStyle, OnClickInPoint, OnClickOutPoint, OnClickRemoveNode, " ", nowId, statePlus, gameObject, stateMonobehaviors[nowStateMonoNuber])); nowId++; }
//ノードの追加 private void OnClickAddNode(Vector2 mousePosition) { //ノード、ステート追加 NomalState statePlus = new NomalState(); states.Add(statePlus); if (nodes == null) { nodes = new List <Node>(); } //マウスの場所に追加 nodes.Add(new Node(new Rect(mousePosition.x, mousePosition.y, 200, 50), inPointStyle, outPointStyle, OnClickInPoint, OnClickOutPoint, OnClickRemoveNode, " ", nowId, statePlus, gameObject, stateMonobehaviors[nowStateMonoNuber])); nowId++; }
/// <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 OnClickPasteNodeAll(Vector2 mousePosition) { //Undo処理 if (stateMonobehaviors.Length > 0) { Undo.RecordObject(stateMonobehaviors[nowStateMonoNuber], "StateUndo"); } if (copyNode == null) { return; } NomalState statePlus = new NomalState(); statePlus.execDelegate = new List <StateBase.ActionDelegate>(copyNode.myState.execDelegate); statePlus.stateName = copyNode.myState.stateName + "(Clone)"; statePlus.nextStateJudge = new List <NextStateJudge>(); statePlus.stateMode = copyNode.myState.stateMode; statePlus.stateBody = copyNode.myState.stateBody; for (int i = 0; i < copyNode.myState.nextStateJudge.Count; i++) { NextStateJudge next = new NextStateJudge(); next.nextID = new InstanceID(); next.nextID = copyNode.myState.nextStateJudge[i].nextID; next.nextState = copyNode.myState.nextStateJudge[i].nextState; next.nextStateName = copyNode.myState.nextStateJudge[i].nextStateName; next.priority = copyNode.myState.nextStateJudge[i].priority; next.comment = copyNode.myState.nextStateJudge[i].comment; next.judgeFunc = copyNode.myState.nextStateJudge[i].judgeFunc; next.judgeFuncName = copyNode.myState.nextStateJudge[i].judgeFuncName; next.judgeFuncInstance = copyNode.myState.nextStateJudge[i].judgeFuncInstance; statePlus.nextStateJudge.Add(next); } statePlus.playUpdateDelegate = new List <StateBase.ActionDelegate>(copyNode.myState.playUpdateDelegate); states.Add(statePlus); if (nodes == null) { nodes = new List <Node>(); } //マウスの場所に追加 nodes.Add(new Node(new Rect(mousePosition.x, mousePosition.y, 200, 50), inPointStyle, outPointStyle, OnClickInPoint, OnClickOutPoint, OnClickRemoveNode, " ", nowId, statePlus, gameObject, stateMonobehaviors[nowStateMonoNuber])); nowId++; initFlag = true; }