コード例 #1
0
        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++;
        }
コード例 #2
0
ファイル: NodeWindow.cs プロジェクト: kazu0928/StateEditor
 //再生中ノードの色を変える
 private void NodeColorChange()
 {
     color = new Color(1, 1, 1, 0.8f);
     if (EditorApplication.isPlaying == true)
     {
         if (stateMonobehavior.nowPlayStateBody.stateMove)
         {
             NodeBaseEditor.initFlag = true;
         }
         if (stateMonobehavior.nowPlayStateBody.stateProcessor.State == myState)
         {
             color = new Color(1, 0, 0, 0.8f);
             return;
         }
         else
         {
             color = new Color(1, 1, 1, 0.8f);
         }
         StateBody body = stateMonobehavior.nowPlayStateBody.parant;
         while (body != null)
         {
             if (body.stateProcessor.State == myState)
             {
                 color = new Color(0, 1, 0, 0.8f);
                 return;
             }
             body = body.parant;
         }
     }
 }
コード例 #3
0
        private void SubStateSet()
        {
            for (int i = 0; i < stateMonobehavior.stateBody.Count; i++)
            {
                if (stateMonobehavior.stateBody[i].ID.number == myState.subStateID.number)
                {
                    NodeBaseEditorParameter.instance.window.subStates = stateMonobehavior.stateBody[i];
                    return;
                }
            }
            StateBody s = new StateBody();

            myState.subStateID = s.ID;
            stateMonobehavior.stateBody.Add(s);
        }
コード例 #4
0
        /// <summary>
        /// 判定処理、現在のステートの中身から判定処理を実行(delegate)
        /// </summary>
        public void NomalStateJudge()
        {
            //優先度順にジャッジ(ソートは別)
            foreach (NextStateJudge judge in stateProcessor.State.nextStateJudge)
            {
                //次のステートが登録されていなければ移行しない
                if (judge.nextState == null)
                {
                    continue;
                }

                if (judge.judgeFunc.Invoke())
                {
                    if (mono.nowPlayStateBody != this)
                    {
                        mono.nowPlayStateBody = this;
                    }
                    stateProcessor.State = judge.nextState;
                    stateMove            = true;
                    //サブステート有の場合
                    if (judge.nextState.stateMode == StateMode.SubState)
                    {
                        mono.nowPlayStateBody = judge.nextState.stateBody;
                        judge.nextState.stateBody.stateProcessor.State = judge.nextState.stateBody.states[0];
                        judge.nextState.stateBody.stateMove            = true;
                        mono.nowPlayStateBody.stateProcessor.Execute();
                    }
                    else if (judge.nextState.stateMode == StateMode.EndState)
                    {
                        if (parant != null)
                        {
                            mono.nowPlayStateBody = parant;
                            mono.nowPlayStateBody.stateProcessor.PlayUpdate();
                        }
                    }
                }
            }
            StateBody pa = parant;

            while (pa != null)
            {
                pa.stateProcessor.PlayUpdate();
                pa = pa.parant;
            }
        }
コード例 #5
0
 protected virtual void Awake()
 {
     foreach (StateBody s in stateBody)
     {
         bodyDic.Add(s.ID.number, s);
     }
     foreach (StateBody s in stateBody)
     {
         foreach (NomalState sb in s.states)
         {
             if (sb.stateMode == StateMode.SubState)
             {
                 sb.stateBody = bodyDic[sb.subStateID.number];
             }
         }
     }
     nowPlayStateBody = stateBody[0];
     nowPlayStateBody.AwakeInit();
     bodyDic.Clear();
 }
コード例 #6
0
 //親のセット
 public void SetParant(StateBody parant)
 {
     this.parant = parant;
 }
コード例 #7
0
        /// <summary>
        /// 判定処理、現在のステートの中身から判定処理を実行(delegate)
        /// </summary>
        public void NomalStateJudge()
        {
            //優先度順にジャッジ(ソートは別)
            foreach (NextStateJudge judge in stateProcessor.State.nextStateJudge)
            {
                //次のステートが登録されていなければ移行しない
                if (judge.nextState == null)
                {
                    continue;
                }

                if (judge.judgeFunc.Invoke())
                {
                    if (mono.nowPlayStateBody != this)
                    {
                        mono.nowPlayStateBody = this;
                    }
                    stateProcessor.State = judge.nextState;
                    stateMove            = true;
                    bool subState = false;
                    //サブステート有の場合
                    if (judge.nextState.stateMode == StateMode.SubState)
                    {
                        mono.nowPlayStateBody = judge.nextState.stateBody;
                        judge.nextState.stateBody.stateProcessor.State = judge.nextState.stateBody.states[0];
                        judge.nextState.stateBody.stateMove            = true;
                        mono.nowPlayStateBody.stateProcessor.Execute();
                        subState = true;
                    }
                    else if (judge.nextState.stateMode == StateMode.EndState)
                    {
                        if (parant != null)
                        {
                            mono.nowPlayStateBody = parant;
                            mono.nowPlayStateBody.stateProcessor.PlayUpdate();
                        }
                    }
                    if (stateProcessor.State != null)
                    {
                        stateProcessor.Execute();
                    }
                    if (subState)
                    {
                        if (judge.nextState.stateBody.states[0].isSkipState)
                        {
                            mono.nowPlayStateBody._frag = true;
                            mono.nowPlayStateBody.NomalStateJudge();
                        }
                    }
                    else if (judge.nextState.isSkipState)
                    {
                        mono.nowPlayStateBody._frag = true;
                        mono.nowPlayStateBody.NomalStateJudge();
                    }
                    //ステートの値が変更されたら実行処理を行う
                    if (stateProcessor.State == null)
                    {
                        return;
                    }
                    if (stateMove)
                    {
                        _beforeStateName = stateProcessor.State.getStateName();
                    }
                    break;
                }
            }
            StateBody pa = parant;

            //親のジャッジ処理も行う
            while ((pa != null) && (_frag == false))
            {
                pa.UpdateGame();
                pa = pa.parant;
            }
            _frag = false;
        }
コード例 #8
0
 protected virtual void Awake()
 {
     nowPlayStateBody = stateBody;
     nowPlayStateBody.AwakeInit();
 }