示例#1
0
        private ITicker _LootStrategy()
        {
            var th = new TurnHandler(this);


            var  traceStrategy = new TraceStrategy(this);
            Guid target        = Guid.Empty;
            var  builder       = new Regulus.BehaviourTree.Builder();
            var  distance      = 1f;
            var  node          = builder
                                 .Sequence()
                                 .Action(_NotEnemy)
                                 .Action((delta) => _FindLootTarget(out target))
                                 .Action((delta) => traceStrategy.Reset(target, distance))
                                 .Action((delta) => traceStrategy.Tick(delta))
                                 .Action((delta) => _Loot(target))
                                 .End()
                                 .Build();

            return(node);
        }
示例#2
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());
        }
        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;
        }
        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()
                    // �O�_�I����
                    .Action((delta) => _DetectObstacle(delta, _Entiry.GetViewLength() / 2, _GetOffsetDirection(10.31f * 2)))

                    // �����
                    //.Action(_StopMove)

                    // �ˬd�P�D��ê��
                    .Action((delta) => od.Detect(delta , _DecisionTime, _Entiry, this, _Entiry.GetViewLength(), 180) )

                    // ����ܥX�f
                    .Action((delta) => th.Run(delta) )
                .End().Build();
        }
        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))

                    .End()
                .Build();
        }
        private ITicker _ResourceObtaionStrategy()
        {
            var th = new TurnHandler(this);

            var traceStrategy = new TraceStrategy(this);
            Guid target = Guid.Empty;
            var builder = new Regulus.BehaviourTree.Builder();
            var distance = 1f;
            var node = builder
                    .Sequence()
                        .Action(_NotEnemy)
                        .Action((delta) => _FindResourceTarget(out target))
                        .Action((delta) => _GetDistance(target , out distance))
                        //.Action((delta) => _Talk(string.Format("Mining Target. Distance:{0}", distance)))
                        .Sequence()
                                .Action((delta) => traceStrategy.Reset(target, distance))
                                .Action((delta) => traceStrategy.Tick(delta))
                                //.Action((delta) => _Talk("Begin Mining ."))
                                .Action((delta) => _Loot(target))
                                //.Action((delta) => _Talk("Mining Done."))
                        .End()
                    .End()
                .Build();
            return node;
        }
        private ITicker _LootStrategy()
        {
            var th = new TurnHandler(this);

            var traceStrategy = new TraceStrategy(this);
            Guid target = Guid.Empty;
            var builder = new Regulus.BehaviourTree.Builder();
            var distance = 1f;
            var node = builder
                    .Sequence()
                        .Action(_NotEnemy)
                        .Action((delta) => _FindLootTarget(out target) )
                        .Action((delta) => traceStrategy.Reset(target , distance ) )
                        .Action((delta) => traceStrategy.Tick(delta))
                        .Action((delta) => _Loot(target))
                    .End()
                .Build();
            return node;
        }