//初期化処理 public void StartInit(StateMonobehavior mono) { this.mono = mono; //ステートがあれば処理 if (states.Count > 0) { //0がスタートステート stateProcessor.State = states[0]; //ステート0をスタートステートに //ステートの中身のアップデートデリゲートに登録 //最初がSubStateだったら if (states[0].stateMode == StateMode.SubState) { mono.nowPlayStateBody = states[0].stateBody; } foreach (NomalState ns in states) { //サブステートの処理 if (ns.stateMode == StateMode.SubState) { ns.stateBody.StartInit(mono); ns.stateBody.SetParant(this); } ns.updateJudgeDelegate = NomalStateJudge; //判定 stateDictionary.Add(ns.ID.number, ns); //辞書追加 ns.nextStateJudge.Sort((a, b) => b.priority - a.priority); //優先度順にソート(高ければ高い、降順) } } //ステートの格納 foreach (NomalState state in states) { if (state.nextStateJudge.Count > 0) { foreach (NextStateJudge judge in state.nextStateJudge) { //TODO:同じ名前のステートでもできるようにする if (judge.nextStateName == null) { judge.nextState = null; continue; } judge.nextState = stateDictionary[judge.nextID.number]; } } } //入った時の処理 if ((stateProcessor.State != null) && (mono.nowPlayStateBody == this)) { stateProcessor.Execute(); } }
/// <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); } }