예제 #1
0
        private ITicker _InvestigateStrategy()
        {
            var th      = new TurnHandler(this);
            var builder = new Regulus.BehaviourTree.Builder();
            var node    = builder
                          .Sequence()
                          .Action(_NotEnemy)
                          .Action(_NeedInvestigate)

                          .Action(
                (delta) =>
            {
                var angel = Regulus.Utility.Random.Instance.NextFloat(135, 225);
                th.Input(angel);
                return(TICKRESULT.SUCCESS);
            })
                          .Action((delta) =>
            {
                if (GetTrunSpeed() > 0)
                {
                    return(th.Run(delta));
                }
                return(TICKRESULT.FAILURE);
            })
                          .Action((delta) => _Talk("?"))
                          .Action(_DoneInvestigate)
                          .End()
                          .Build();

            return(node);
        }
예제 #2
0
        private ITicker _CollisionWayfindingStrategy()
        {
            var th = new TurnHandler(this);

            var builder = new Regulus.BehaviourTree.Builder();

            return(builder
                   .Sequence()

                   .Action(
                       (delta) =>
            {
                var result = _CheckCollide();
                th.Input(Regulus.Utility.Random.Instance.NextFloat(1, 360));
                return result;
            })

                   .Action((delta) => th.Run(delta))

                   .Action(_MoveForward)

                   .Action(() => new WaitSecondStrategy(0.5f), t => t.Tick, t => t.Start, t => t.End)

                   .End()
                   .Build());
        }
예제 #3
0
        private void _BuildNode()
        {
            var th = new TurnHandler(_Behavior);

            float angle   = 0.0f;
            var   builder = new Regulus.BehaviourTree.Builder();

            _Node = builder.Sequence()
                    .Action(
                (delta) =>
            {
                var result = _Behavior.GetTargetAngle(_Target, ref angle);
                th.Input(angle);
                return(result);
            })
                    .Action((delta) => th.Run(delta))
                    .Not()
                    .Sequence()
                    .Action((delta) => _Not(_Behavior.CheckDistance(_Target, _Distance)))
                    .Action(_Behavior.MoveForward)
                    .End()
                    .End()
                    .Action((delta) => _Behavior.GetTargetAngle(_Target, ref angle))
                    .Action((delta) => _Behavior.CheckAngle(angle))
                    .Action(_Behavior.StopMove)
                    .End().Build();
        }
예제 #4
0
        private ITicker _DistanceWayfindingStrategy()
        {
            var builder = new Regulus.BehaviourTree.Builder();

            var th = new TurnHandler(this);
            var od = new ObstacleDetector();

            od.OutputEvent += th.Input;
            return(builder
                   .Sequence()
                   // 是否碰到障礙物
                   .Action((delta) => _DetectObstacle(delta, _Entiry.GetViewLength() / 2, _GetOffsetDirection(10.31f * 2)))

                   // 停止移動
                   //.Action(_StopMove)

                   // 檢查周遭障礙物
                   .Action((delta) => od.Detect(delta, _DecisionTime, _Entiry, this, _Entiry.GetViewLength(), 180))

                   // 旋轉至出口
                   .Action((delta) => th.Run(delta))
                   .End().Build());
        }