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 _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()); }
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 _AttackStrategy() { Guid enemy = Guid.Empty; var skill = ACTOR_STATUS_TYPE.NORMAL_IDLE; float distance = 0; var builder = new Regulus.BehaviourTree.Builder(); var traceStrategy = new TraceStrategy(this); return(builder .Sequence() .Action((delta) => _FindEnemy(out enemy)) .Selector() .Sub(_ChangeToBattle()) .Sequence() .Action((delta) => _FindSkill(ref skill, ref distance)) .Action((delta) => traceStrategy.Reset(enemy, distance)) .Action((delta) => traceStrategy.Tick(delta)) .Action((delta) => _UseSkill(skill)) .End() .End() .End() .Build()); }
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(); }
private ITicker _ChangeToBattle() { var builder = new Regulus.BehaviourTree.Builder(); return(builder.Sequence() .Action(_InNormal) .Action(_ToBattle) .End().Build()); }
private ITicker _ListenCommandStrategy() { var builder = new Regulus.BehaviourTree.Builder(); return(builder .Sequence() .Action(_HandleCommandAction) .End() .Build()); }
protected override ITicker _Launch() { var builder = new Regulus.BehaviourTree.Builder(); var ticker = builder .Sequence() .Action(() => new WaitSecondStrategy(0.1f)) .Action(_Pass) .End().Build(); return(ticker); }
protected override ITicker _Launch() { var builder = new Regulus.BehaviourTree.Builder(); var ticker = builder .Sequence() .Action(() => new ChestIdleAction(_Chest, _Gate)) .Action(() => new ChestExcludeAction(_Gate , _Finder, _Owner , _Door , _Exit )) .End() .Build(); return ticker; }
protected override ITicker _Launch() { var builder = new Regulus.BehaviourTree.Builder(); var ticker = builder .Sequence() .Action(() => new WaitSecondStrategy(0.1f)) .Action(_Pass) .End().Build(); return ticker; }
protected override ITicker _Launch() { var builder = new Regulus.BehaviourTree.Builder(); var ticker = builder .Sequence() .Action(() => new ChestIdleAction(_Chest, _Gate), t => t.Tick, t => t.Start, t => t.End) .Action(() => new ChestExcludeAction(_Gate, _Finder, _Owner, _Door, _Exit), t => t.Tick, t => t.Start, t => t.End) .End() .Build(); return(ticker); }
private ITicker _MakeItemStrategy() { var index = 0; var builder = new Regulus.BehaviourTree.Builder(); var timeTrigger = new TimeTriggerStrategy(10f); var node = builder .Sequence() .Action(timeTrigger.Tick) .Action((delta) => timeTrigger.Reset(10f)) .Action(_ToMake) .Action(() => new WaitSecondStrategy(3), t => t.Tick, t => t.Start, t => t.End) .Action((delta) => _GetRandomIndex(0, 4, out index)) .Selector() .Sequence() .Action((delta) => _If(index == 0)) .Action((delta) => _CheckItemAmount("Axe1", (count) => count < 2)) .Action((delta) => _MakeItem("Axe1")) .Action((delta) => _Talk("Produced axe.")) .End() .Sequence() .Action((delta) => _If(index == 1)) .Action((delta) => _CheckItemAmount("Sword1", (count) => count < 2)) .Action((delta) => _MakeItem("Sword1")) .Action((delta) => _Talk("Produced sword.")) .End() .Sequence() .Action((delta) => _If(index == 2)) .Action((delta) => _CheckItemAmount("Lamp", (count) => count < 2)) .Action((delta) => _MakeItem("Lamp")) .Action((delta) => _Talk("Produced lamp.")) .End() .Sequence() .Action((delta) => _If(index == 3)) .Action((delta) => _CheckItemAmount("AidKit", (count) => count < 2)) .Action((delta) => _MakeItem("AidKit")) .Action((delta) => _Talk("Produced aid.")) .End() .Sequence() .Action((delta) => _Talk("Nothing maked.")) .End() .End() .Action(_ReleaseMake) .End() .Build(); return(node); }
protected override ITicker _Launch() { _Gate.Join(_Entity); var builder = new Regulus.BehaviourTree.Builder(); var ticker = builder .Sequence() .Action(() => new WaitSecondStrategy(0.1f), t => t.Tick, t => t.Start, t => t.End) .Action(_HandlePassing) .End() .Build(); return(ticker); }
private ITicker _BuildNode() { Guid actor = Guid.Empty; var builder = new Regulus.BehaviourTree.Builder(); var node = builder .Selector() .Sub(_ListenCommandStrategy()) .Sequence() .Action((delta) => _DetectActor(_Entiry.GetViewLength(), _GetOffsetDirection(120), out actor)) .Action((delta) => _NotSeen(actor)) .Action((delta) => _Remember(actor)) .End() .Sub(_CollisionWayfindingStrategy()) .Sub(_AttackStrategy()) .Sub(_InvestigateStrategy()) .Sequence() .Action(_NotEnemy) .Selector() .Sequence() .Action(_InBattle) .Action(_ToNormal) .End() .Sub(_RescueCompanion()) .Sub(_LootStrategy()) .Sub(_ResourceObtaionStrategy()) .Sub(_MakeItemStrategy()) .Sub(_EquipItemStrategy()) .Sub(_DiscardItemStrategy()) .End() .End() .Sub(_DistanceWayfindingStrategy()) // 沒事就前進 .Sequence() .Action(_MoveForward) .End() .End() .Build(); return(node); }
private ITicker _RescueCompanion() { var trace = new TraceStrategy(this); Guid target = Guid.Empty; var builder = new Regulus.BehaviourTree.Builder(); return(builder .Sequence() .Action((delta) => _CheckItemAmount("AidKit", (count) => count >= 1)) .Action((delta) => _FindWounded(out target)) .Action((delta) => trace.Reset(target, 1)) .Action(trace.Tick) .Action(_StopMove) .Action((dt) => _UseItem("AidKit")) .End() .Build()); }
private ITicker _EquipItemStrategy() { var timeTrigger = new TimeTriggerStrategy(1f); var builder = new Regulus.BehaviourTree.Builder(); var node = builder .Sequence() .Action(timeTrigger.Tick) .Action((delta) => timeTrigger.Reset(1)) .Selector() .Action((delta) => _Equip(EQUIP_PART.RIGHT_HAND)) .Action((delta) => _Equip(EQUIP_PART.FIXTURES)) .End() .End() .Build(); return(node); }
protected override ITicker _Launch() { var builder = new Regulus.BehaviourTree.Builder(); var ticker = builder .Sequence() .Action(() => new WaitSecondStrategy(1f), t => t.Tick, t => t.Start, t => t.End) .Selector() .Sequence() .Action(_Pass) .End() .Sequence() .Action(_NeedSpawn) .Action(_Spawn) .End() .End() .End().Build(); return(ticker); }
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); }
private ITicker _DiscardItemStrategy() { var builder = new Regulus.BehaviourTree.Builder(); var timeTrigger = new TimeTriggerStrategy(10f); var node = builder .Sequence() .Action(timeTrigger.Tick) .Action((delta) => timeTrigger.Reset(10f)) .Selector() .Sequence() .Action((delta) => _CheckItemAmount("Axe1", (count) => count >= 2)) .Action((delta) => _DiscardItem("Axe1", 1)) .Action((delta) => _Talk("Discard axe.")) .End() .Sequence() .Action((delta) => _CheckItemAmount("Sword1", (count) => count >= 2)) .Action((delta) => _DiscardItem("Sword1", 1)) .Action((delta) => _Talk("Discard sword.")) .End() .Sequence() .Action((delta) => _CheckItemAmount("Lamp", (count) => count >= 2)) .Action((delta) => _DiscardItem("Lamp", 1)) .Action((delta) => _Talk("Discard lamp.")) .End() .Sequence() .Action((delta) => _CheckItemAmount("AidKit", (count) => count >= 2)) .Action((delta) => _DiscardItem("AidKit", 1)) .Action((delta) => _Talk("Discard AidKit.")) .End() .End() .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() // 是否碰到障礙物 .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 _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; }
private ITicker _MakeItemStrategy() { var index = 0; var builder = new Regulus.BehaviourTree.Builder(); var timeTrigger = new TimeTriggerStrategy(10f); var node = builder .Sequence() .Action(timeTrigger.Tick) .Action((delta) => timeTrigger.Reset(10f)) .Action(_ToMake) .Action(()=>new WaitSecondStrategy(3)) .Action((delta) => _GetRandomIndex(0, 4 , out index)) .Selector() .Sequence() .Action((delta) => _If( index == 0) ) .Action((delta) => _CheckItemAmount("Axe" , (count) => count < 2 )) .Action((delta) => _MakeItem("Axe")) .Action((delta) => _Talk("Produced axe.")) .End() .Sequence() .Action((delta) => _If(index == 1)) .Action((delta) => _CheckItemAmount("Sword", (count) => count < 2)) .Action((delta) => _MakeItem("Sword")) .Action((delta) => _Talk("Produced sword.")) .End() .Sequence() .Action((delta) => _If(index == 2)) .Action((delta) => _CheckItemAmount("Lamp", (count) => count < 2)) .Action((delta) => _MakeItem("Lamp")) .Action((delta) => _Talk("Produced lamp.")) .End() .Sequence() .Action((delta) => _If(index == 3)) .Action((delta) => _CheckItemAmount("AidKit", (count) => count < 2)) .Action((delta) => _MakeItem("AidKit")) .Action((delta) => _Talk("Produced aid.")) .End() .Sequence() .Action((delta) => _Talk("Nothing maked.")) .End() .End() .Action(_ReleaseMake) .End() .Build(); return node; }
private ITicker _RescueCompanion() { var trace = new TraceStrategy(this); Guid target = Guid.Empty; var builder = new Regulus.BehaviourTree.Builder(); return builder .Sequence() .Action((delta) => _CheckItemAmount("AidKit", (count) => count >= 1)) .Action((delta) => _FindWounded(out target)) .Action((delta) => trace.Reset(target , 1)) .Action(trace.Tick) .Action(_StopMove) .Action((dt) => _UseItem("AidKit") ) .End() .Build(); }
private ITicker _ListenCommandStrategy() { var builder = new Regulus.BehaviourTree.Builder(); return builder .Sequence() .Action(_HandleCommandAction) .End() .Build(); }
private ITicker _DiscardItemStrategy() { var builder = new Regulus.BehaviourTree.Builder(); var timeTrigger = new TimeTriggerStrategy(10f); var node = builder .Sequence() .Action(timeTrigger.Tick) .Action((delta) => timeTrigger.Reset(10f)) .Selector() .Sequence() .Action((delta) => _CheckItemAmount("Axe", (count) => count >= 2)) .Action((delta) => _DiscardItem("Axe" , 1)) .Action((delta) => _Talk("Discard axe.")) .End() .Sequence() .Action((delta) => _CheckItemAmount("Sword", (count) => count >= 2)) .Action((delta) => _DiscardItem("Sword", 1)) .Action((delta) => _Talk("Discard sword.")) .End() .Sequence() .Action((delta) => _CheckItemAmount("Lamp", (count) => count >= 2)) .Action((delta) => _DiscardItem("Lamp", 1)) .Action((delta) => _Talk("Discard lamp.")) .End() .Sequence() .Action((delta) => _CheckItemAmount("AidKit", (count) => count >= 2)) .Action((delta) => _DiscardItem("AidKit", 1)) .Action((delta) => _Talk("Discard AidKit.")) .End() .End() .End() .Build(); return node; }
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 _BuildNode() { Guid actor = Guid.Empty; var builder = new Regulus.BehaviourTree.Builder(); var node = builder .Selector() .Sub(_ListenCommandStrategy()) .Sequence() .Action((delta) => _DetectActor(_Entiry.GetViewLength(), _GetOffsetDirection(120), out actor)) .Action((delta) => _NotSeen(actor)) .Action((delta) => _Remember(actor)) .End() .Sub(_CollisionWayfindingStrategy()) .Sub(_AttackStrategy()) .Sub(_InvestigateStrategy()) .Sequence() .Action(_NotEnemy) .Selector() .Sequence() .Action(_InBattle) .Action(_ToNormal) .End() .Sub(_RescueCompanion()) .Sub(_LootStrategy()) .Sub(_ResourceObtaionStrategy()) .Sub(_MakeItemStrategy()) .Sub(_EquipItemStrategy()) .Sub(_DiscardItemStrategy()) .End() .End() .Sub(_DistanceWayfindingStrategy()) // �S�ƴN�e�i .Sequence() .Action(_MoveForward) .End() .End() .Build(); return node; }
private ITicker _EquipItemStrategy() { var timeTrigger = new TimeTriggerStrategy(1f); var builder = new Regulus.BehaviourTree.Builder(); var node = builder .Sequence() .Action(timeTrigger.Tick) .Action((delta) => timeTrigger.Reset(1)) .Selector() .Action((delta) => _Equip(EQUIP_PART.RIGHT_HAND)) .Action((delta) => _Equip(EQUIP_PART.FIXTURES)) .End() .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 _AttackStrategy() { Guid enemy = Guid.Empty; var skill = ACTOR_STATUS_TYPE.NORMAL_IDLE; float distance = 0; var builder = new Regulus.BehaviourTree.Builder(); var traceStrategy = new TraceStrategy(this); return builder .Sequence() .Action((delta) => _FindEnemy(out enemy)) .Selector() .Sub(_ChangeToBattle()) .Sequence() .Action((delta) => _FindSkill(ref skill, ref distance)) .Action((delta) => traceStrategy.Reset(enemy, distance)) .Action((delta) => traceStrategy.Tick(delta)) .Action((delta) => _UseSkill(skill)) .End() .End() .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 _ChangeToBattle() { var builder = new Regulus.BehaviourTree.Builder(); return builder.Sequence() .Action(_InNormal) .Action(_ToBattle) .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; }