예제 #1
0
 public override Result Excute(NodeInstanse instanse)
 {
     instanse.nodeStateDic[Key] = NodeState.Ready;
     instanse.nodeStateDic.ObserveReplace()
     .Where(x => x.Key == actions.Current.Key)
     .Subscribe(x => NextState(x.NewValue, instanse));
     actions.MoveNext();
     actions.Current.Excute(instanse);
     return(new Result(true));
 }
예제 #2
0
 private void NextState(NodeState state, NodeInstanse instanse)
 {
     Debug.Log("ねくすと");
     if (state == NodeState.Failed)
     {
         instanse.nodeStateDic[Key] = NodeState.Failed;
     }
     else if (state == NodeState.Success)
     {
         instanse.nodeStateDic[Key] = NodeState.Success;
     }
 }
예제 #3
0
 private void NextState(NodeState state, NodeInstanse instanse)
 {
     if (state == NodeState.Failed)
     {
         instanse.nodeStateDic[Key] = NodeState.Failed;
     }
     else if (state == NodeState.Success)
     {
         actions.Current.Excute(instanse);
     }
     else
     {
         instanse.nodeStateDic[Key] = NodeState.Success;
     }
 }
예제 #4
0
        private Result IsHpLessThan(NodeInstanse instanse)
        {
            var hp = Random.Range(0, 10);

            Debug.Log(hp);
            if (hp <= 4)
            {
                Debug.Log("体力が4以下だ。突撃―ッ!");
                return(new Result(true));
            }
            else
            {
                Debug.Log("体力が4より大きい。警戒を怠るな!");
                return(new Result(false));
            }
        }
예제 #5
0
        void Start()
        {
            var attack = new DecoratorNode(IsHpLessThan, new ActionNode(Attack));

            var move = new SequencerNode(new Node[] { new ActionNode(MoveNearEnemy), new ActionNode(Wait) });

            var root = new SelectorNode(new Node[] { attack, move });

            nodeInstanse = new NodeInstanse(root);
            nodeInstanse
            .endRP
            .Where(x => x != NodeState.Ready)
            .Do(x => Debug.Log("処理が終わった模様"))
            .Subscribe(_ => CoroutineStart());
            nodeInstanse.Excute();
        }
예제 #6
0
 public override Result Excute(NodeInstanse instanse)
 {
     Debug.Log("ノードキー" + node.Key);
     if (func(instanse).result)
     {
         Debug.Log("あ");
         instanse.nodeStateDic.ObserveReplace()
         .Where(x => x.Key == node.Key)
         .Subscribe(x => NextState(x.NewValue, instanse));
         Debug.Log("い");
         node.Excute(instanse);
         Debug.Log("う");
     }
     else
     {
         Debug.Log("え");
         instanse.nodeStateDic[Key] = NodeState.Failed;
         Debug.Log("お");
     }
     return(new Result(true));
 }
예제 #7
0
        /// <summary>
        /// 処理を実行しその結果を返す
        /// </summary>
        /// <param name="instanse"></param>
        /// <returns></returns>
        public override Result Excute(NodeInstanse instanse)
        {
            Debug.Log(1);
            instanse.nodeStateDic[Key] = NodeState.Ready;
            Debug.Log(2);
            var result = func(instanse);

            Debug.Log(3);
            if (result.result)
            {
                Debug.Log(4);
                instanse.nodeStateDic[Key] = NodeState.Success;
                Debug.Log(5);
            }
            else
            {
                Debug.Log(6);
                instanse.nodeStateDic[Key] = NodeState.Failed;
                Debug.Log(7);
            }
            Debug.Log(8);
            return(result);
        }
예제 #8
0
 private Result Wait(NodeInstanse instanse)
 {
     Debug.Log("待機");
     return(new Result(true));
 }
예제 #9
0
 private Result MoveNearEnemy(NodeInstanse instanse)
 {
     Debug.Log("最も近い敵へ向かう!");
     return(new Result(true));
 }
예제 #10
0
 private Result Attack(NodeInstanse instanse)
 {
     Debug.Log("攻撃!");
     return(new Result(true));
 }
예제 #11
0
 /// <summary>
 /// 実行
 /// </summary>
 /// <returns></returns>
 public abstract Result Excute(NodeInstanse instanse);