// Start is called before the first frame update void Start() { Debug.Log("생성"); m_Slime = gameObject.GetComponent <GreenSlime>(); root.AddChild(selector); selector.AddChild(seqDead); selector.AddChild(selectPattern); //노드 m_Dead.Enemy = m_Slime; m_Attack.Enemy = m_Slime; m_MonsterMove.Enemy = m_Slime; m_Patrol.Enemy = m_Slime; m_GetHit.Enemy = m_Slime; seqDead.AddChild(m_Dead); selectPattern.AddChild(seqMove); selectPattern.AddChild(seqAttack); selectPattern.AddChild(seqPatrol); selectPattern.AddChild(seqGetHit); seqMove.AddChild(m_MonsterMove); seqAttack.AddChild(m_Attack); seqPatrol.AddChild(m_Patrol); seqGetHit.AddChild(m_GetHit); behaviorProcess = BehaviorProcess(); StartCoroutine(behaviorProcess); }
private void Start() { agent = this.GetComponent <NavMeshAgent>(); tree = new BehaviourTree(); Sequence steal = new Sequence("Steal Something"); // Node goToPoint = new Leaf("Go To Point", GoToPoint); Node goToFrontDoor = new Leaf("Go To FrontDoor", GoToFrontDoor); Node goToBackDoor = new Leaf("Go To BackDoor", GoToBackDoor); Node goToDiamond = new Leaf("Go To Diamond", GoToDiamond); Node goToVan = new Leaf("Go To Van", GoToVan); Selector openDoor = new Selector("Open Door"); openDoor.AddChild(goToFrontDoor); openDoor.AddChild(goToBackDoor); //steal.AddChild(goToPoint); steal.AddChild(openDoor); steal.AddChild(goToFrontDoor); //steal.AddChild(goToBackDoor); steal.AddChild(goToDiamond); //steal.AddChild(goToBackDoor); steal.AddChild(goToVan); tree.AddChild(steal); tree.PrintTree(); }
public FireSlime1AI() : base() { SetMoveState(new MoveState_FireSlime1()); moveState.SetCharacterAI(this); SetMoveToEnemyState(new MoveToEnemyState_FireSlime1()); moveToEnemyState.SetCharacterAI(this); SetAttackState(new AttackState_FireSlime1()); attackState.SetCharacterAI(this); SetThrowMeltedBombState(new ThrowMeltedBombState_FireSlime1()); throwMeltedBombState.SetCharacterAI(this); SetMoveToEnemy(new MoveToEnemy_FireSlime1()); moveToEnemy.SetCharacterAI(this); SetThrowMeltedBomb(new ThrowMeltedBomb_FireSlime1()); throwMeltedBomb.SetCharacterAI(this); SetConditionHaveEnemy(new ConditionHaveEnemy_FireSlime1()); conditionHaveEnemy.SetCharacterAI(this); SetDistanceCondition(new DistanceCondition_FireSlime1()); distanceCondition.SetCharacterAI(this); root_Node = new Selector(); root_Node.AddChild(attackState); root_Node.AddChild(moveState); root_Node.currentState = State.NONE; }
public BTEnemy(Agent ownerBrain) : base(ownerBrain) { rootSelector = new Selector(); enemyCheck = new Sequence(); patrolSequence = new Sequence(); suspiciousSequence = new Sequence(); ChaseSequence = new Sequence(); DistractionSequence = new Sequence(); parallelDetection = new Parallel(); checkInverter = new Inverter(); turnToPoint = new TurnToPoint(GetOwner()); patrol = new Patrol(GetOwner()); wait = new Wait(GetOwner()); detection = new Detection(GetOwner()); distraction = new Distraction(GetOwner()); suspicious = new Suspicious(GetOwner()); suspiciousAlert = new SuspiciousAlert(GetOwner()); moveToLKP = new MoveToLKP(GetOwner()); seen = new Seen(GetOwner()); chase = new Chase(GetOwner()); //Root -> Patrol and Check rootSelector.AddChild(parallelDetection); parallelDetection.AddChild(checkInverter); //A parallel to check for the player checkInverter.AddChild(detection); //Patrol alongside checking for the player parallelDetection.AddChild(patrolSequence); patrolSequence.AddChild(patrol); patrolSequence.AddChild(wait); patrolSequence.AddChild(turnToPoint); //Root -> Adding sequences rootSelector.AddChild(suspiciousSequence); rootSelector.AddChild(ChaseSequence); rootSelector.AddChild(DistractionSequence); //Distraction State DistractionSequence.AddChild(distraction); DistractionSequence.AddChild(wait); //Suspicious state suspiciousSequence.AddChild(suspicious); suspiciousSequence.AddChild(suspiciousAlert); suspiciousSequence.AddChild(moveToLKP); suspiciousSequence.AddChild(wait); //Chase state ChaseSequence.AddChild(seen); ChaseSequence.AddChild(chase); ChaseSequence.AddChild(wait); }
// Start is called before the first frame update void Start() { Debug.Log("Start Tree"); m_Sonny = gameObject.GetComponent <SonnyMove>(); root.AddChild(selector); selector.AddChild(seqDead); // seqDead 노드를 selector의 자식 노드로 연결 selector.AddChild(seqMovingAttack); // seqMovingAttack 노드를 selector의 자식 노드로 연결 moveinmap.Enemy = m_Sonny; // m_Enemy를 넣어 초기화시킴 m_OnAttack.Enemy = m_Sonny; isCollision.Enemy = m_Sonny; detectPos.Enemy = m_Sonny; m_IsDead.Enemy = m_Sonny; seqMovingAttack.AddChild(m_OnAttack); seqMovingAttack.AddChild(moveinmap); //seqMovingAttack 노드에 클래스 변수들을 자식으로 추가 seqMovingAttack.AddChild(isCollision); seqMovingAttack.AddChild(detectPos); seqDead.AddChild(m_IsDead); //seqDead 노드에 클래스 변수를 자식으로 추가 behaviorProcess = BehaviorProcess(); StartCoroutine(behaviorProcess); }
private void BuildTree() { root = new Selector(); Sequencer seq1 = new Sequencer(); Randomizer rand1 = new Randomizer(); root.AddChild(rand1); root.AddChild(seq1); Condition con1 = new Condition(nearDogs); BAction pact = new BAction(Play); BAction wact = new BAction(Wander); BAction ract = new BAction(Run); BAction sact = new BAction(Sleep); seq1.AddChild(con1); seq1.AddChild(pact); rand1.AddChild(wact); rand1.AddChild(ract); // rand1.AddChild(sact); root.AddChild(new BAction(Wander)); }
IEnumerator Start() { Sequence root = new Sequence(); Selector selector = new Selector(); Sequence attackSequence = new Sequence(); Node isAlivedBehavior = new IsAlivedBehavior(this); Node detectBehavior = new DetectBehavior(this); Node attackBehavior = new AttackBehavior(this); Node patrolBehavior = new PatrolBehavior(this); root.AddChild(selector); root.AddChild(isAlivedBehavior); selector.AddChild(attackSequence); attackSequence.AddChild(detectBehavior); attackSequence.AddChild(attackBehavior); selector.AddChild(patrolBehavior); while (root.Invoke()) { yield return(null); } }
private void Init() { //Patrol //Chase selChase.AddChild(inSight); selChase.AddChild(isDamaged); seqChase.AddChild(chase); seqChase.AddChild(selChase); //Attack seqAttack.AddChild(attack); seqAttack.AddChild(inAttackRange); selMove.AddChild(patrol); selMove.AddChild(seqChase); selMove.AddChild(seqAttack); //Death seqDeath.AddChild(death); seqDeath.AddChild(isDead); root.AddChild(seqDeath); root.AddChild(selMove); }
public FireSlime2AI() : base() { SetMoveState(new MoveState_FireSlime2()); moveState.SetCharacterAI(this); SetRushState(new RushState_FireSlime2()); rushState.SetCharacterAI(this); SetConditionHaveEnemy(new ConditionHaveEnemy_FireSlime2()); conditionHaveEnemy.SetCharacterAI(this); SetRush(new Rush_FireSlime2()); rush.SetCharacterAI(this); SetVertigoState(new VertigoState_FireSlime2()); vertigoState.SetCharacterAI(this); SetConditionHavaBumpInToTheWall(new ConditionHaveBumpIntoTheWall_FireSlime2()); conditionHaveBumpIntoTheWall.SetCharacterAI(this); SetVertigo(new Vertigo_FireSlime2()); vertigo.SetCharacterAI(this); root_Node = new Selector(); root_Node.AddChild(moveState); root_Node.AddChild(vertigoState); }
public MiddleBT() { Selector selector = ScriptableObject.CreateInstance <Selector>(); Sequence sequence = ScriptableObject.CreateInstance <Sequence>(); ParallelSelector ps = ScriptableObject.CreateInstance <ParallelSelector>(); CanISeePlayer c1 = ScriptableObject.CreateInstance <CanISeePlayer>(); CanISeePlayer c2 = ScriptableObject.CreateInstance <CanISeePlayer>(); TranslatetoARandomPosition t1 = ScriptableObject.CreateInstance <TranslatetoARandomPosition>(); UntilSuccess untilSuccess = ScriptableObject.CreateInstance <UntilSuccess>(); RotateByY r1 = ScriptableObject.CreateInstance <RotateByY>(); selector.AddChild(sequence, 0); selector.AddChild(ps, 1); sequence.AddChild(c1, 0); sequence.AddChild(t1, 1); ps.AddChild(untilSuccess, 0); ps.AddChild(r1, 1); untilSuccess.AddChild(c2, 0); InitalBTStructureData(selector); }
void BuildTree() { Sequencer idleSeq = new Sequencer(); Sequencer pathSeq = new Sequencer(); Sequencer shootSeq = new Sequencer(); InverterGadget invCon = new InverterGadget(); invCon.SetChild(new Condition(ShouldTgt)); idleSeq.AddChild(invCon); idleSeq.AddChild(new BAction(Idle)); invCon = new InverterGadget(); invCon.SetChild(new Condition(InTgtDist)); pathSeq.AddChild(invCon); pathSeq.AddChild(new BAction(Path)); shootSeq.AddChild(new Condition(InSights)); shootSeq.AddChild(new BAction(Shoot)); root.AddChild(idleSeq); root.AddChild(pathSeq); root.AddChild(shootSeq); root.AddChild(new BAction(Idle)); }
// Start is called before the first frame update void Start() { m_Shooter = gameObject.GetComponent <Shooter_Move>(); //슈터무브 컴포넌트 받기 root.AddChild(selector); //트리 구성 selector.AddChild(seqDead); selector.AddChild(seqMovingAttack); moveForTarget.Shooter = m_Shooter; changeGun.Shooter = m_Shooter; isCollision.Shooter = m_Shooter; //isCollision Shooter추가 detectPos.Shooter = m_Shooter; m_OnAttack.Shooter = m_Shooter; m_IsDead.Shooter = m_Shooter; seqMovingAttack.AddChild(moveForTarget); //자식 seqMovingAttack.AddChild(m_OnAttack); seqMovingAttack.AddChild(changeGun); seqMovingAttack.AddChild(isCollision); //IsCollision 자식 노드 추가 seqMovingAttack.AddChild(detectPos); //detectPos 자식노드 seqDead.AddChild(m_IsDead); behaviorProcess = BehaviorProcess(); StartCoroutine(behaviorProcess); }
public IceSlimeAI() : base() { //移动状态 SetMoveState(new MoveState_IceSlime()); moveState.SetCharacterAI(this); SetMoveToEnemyState(new MoveToEnemyState_IceSlime()); moveToEnemyState.SetCharacterAI(this); SetMoveToEnemy(new MoveToEnemy_IceSlime()); moveToEnemy.SetCharacterAI(this); SetConditionHaveEnemy(new ConditionHaveEnemy_IceSlime()); conditionHaveEnemy.SetCharacterAI(this); SetDistanceCondition(new DistanceCondition_IceSlime()); distanceCondition.SetCharacterAI(this); SetAttackState(new AttackState_IceSlime()); attackState.SetCharacterAI(this); SetLaunchIceState(new LaunchIceState_IceSlime()); launchIceState.SetCharacterAI(this); SetLaunchIce(new LaunchIce_IceSlime()); launchIce.SetCharacterAI(this); root_Node = new Selector(); root_Node.AddChild(attackState); root_Node.AddChild(moveState); root_Node.currentState = State.NONE; }
public void TestSelectorIsSequential() { var selector = new Selector("", 0, 1); selector.AddChild(new RunRunFail("", 0, 0)); selector.AddChild(new RunRunSuccess("", 0, 0)); Assert.AreEqual(selector.Start(), Observable.Concat(Running, Success)); }
public MiddleBTRandom() { Selector selector = ScriptableObject.CreateInstance <Selector>(); Sequence sequence = ScriptableObject.CreateInstance <Sequence>(); ParallelSelector ps = ScriptableObject.CreateInstance <ParallelSelector>(); CanISeePlayer c1 = ScriptableObject.CreateInstance <CanISeePlayer>(); CanISeePlayer c2 = ScriptableObject.CreateInstance <CanISeePlayer>(); TranslatetoARandomPosition t1 = ScriptableObject.CreateInstance <TranslatetoARandomPosition>(); UntilSuccess untilSuccess = ScriptableObject.CreateInstance <UntilSuccess>(); RotateByY r1 = ScriptableObject.CreateInstance <RotateByY>(); // 包含0,不包含3 int randomChoice = Random.Range(0, 3); string color = ""; switch (randomChoice) { case 0: RedAction redTask = ScriptableObject.CreateInstance <RedAction>(); color = "red"; sequence.AddChild(redTask, 0); break; case 1: BlueAction blueTask = ScriptableObject.CreateInstance <BlueAction>(); color = "blue"; sequence.AddChild(blueTask, 0); break; case 2: YellowAction yellowTask = ScriptableObject.CreateInstance <YellowAction>(); color = "yellow"; sequence.AddChild(yellowTask, 0); break; default: break; } if (null == UIBTInformationNotifier.instance) { UIBTInformationNotifier notifier = new UIBTInformationNotifier(); } UIBTInformationNotifier.instance.NotifyColorInfoChangeEvent(color); selector.AddChild(sequence, 0); selector.AddChild(ps, 1); sequence.AddChild(c1, 1); sequence.AddChild(t1, 2); ps.AddChild(untilSuccess, 0); ps.AddChild(r1, 1); untilSuccess.AddChild(c2, 0); InitalBTStructureData(selector); }
public BTEnemy(Agent ownerBrain) : base(ownerBrain) { rootSelector = new Selector(); charging = new Sequence(); parallelDetection = new Parallel(); //checkInverter = new Inverter(); randomJob = new SelectorRandom(); recharge = new Recharge(GetOwner()); needsCharging = new NeedsCharging(GetOwner()); collectWood = new CollectWood(GetOwner()); collectRocks = new CollectRocks(GetOwner()); collectPower = new CollectPower(GetOwner()); //////////////////////////////// rootSelector.AddChild(charging); rootSelector.AddChild(randomJob); charging.AddChild(needsCharging); charging.AddChild(recharge); randomJob.AddChild(collectWood); randomJob.AddChild(collectRocks); randomJob.AddChild(collectPower); //A parallel to check for the player //checkInverter.AddChild(detection); //Patrol alongside checking for the player //parallelDetection.AddChild(patrolSequence); //patrolSequence.AddChild(patrol); //patrolSequence.AddChild(wait); //patrolSequence.AddChild(turnToPoint); // ////Root -> Adding sequences //rootSelector.AddChild(suspiciousSequence); //rootSelector.AddChild(ChaseSequence); //rootSelector.AddChild(DistractionSequence); // ////Distraction State ////DistractionSequence.AddChild(distraction); //DistractionSequence.AddChild(wait); // ////Suspicious state ////suspiciousSequence.AddChild(suspicious); //suspiciousSequence.AddChild(suspiciousAlert); ////suspiciousSequence.AddChild(moveToLKP); //suspiciousSequence.AddChild(wait); // ////Chase state ////ChaseSequence.AddChild(seen); ////ChaseSequence.AddChild(chase); //ChaseSequence.AddChild(wait); }
public IceSlimeBossAI() : base() { SetAttackState(new AttackState_IceSlimeBoss()); attackState.SetCharacterAI(this); SetMoveState(new MoveState_IceSlimeBoss()); moveState.SetCharacterAI(this); SetPassiveSkillState(new PassiveSkillState_IceSlimeBoss()); passiveSkillState.SetCharacterAI(this); root_Node = new Selector(); // root_Node.AddChild(passiveSkillState); root_Node.AddChild(attackState); root_Node.AddChild(moveState); }
// Start is called before the first frame update void Start() { agent = this.GetComponent <NavMeshAgent>(); tree = new BehaviorTree(); Sequence steal = new Sequence("Steal Something"); Leaf goToBackDoor = new Leaf("Go To Back Door", () => GoToDoor(backDoor)); Leaf goToFrontDoor = new Leaf("Go To Front Door", () => GoToDoor(frontDoor)); Leaf goToDiamond = new Leaf("Go To Diamond", () => { Node.Status s = GoToLocation(diamond.transform.position); if (s == Node.Status.SUCCESS) { diamond.transform.parent = this.gameObject.transform; } return(s); }); Leaf needsMoney = new Leaf("Needs Money", () => { if (money >= 500) { return(Node.Status.FAILURE); } else { return(Node.Status.SUCCESS); } }); Leaf goToVan = new Leaf("Go To Van", () => { Node.Status s = GoToLocation(van.transform.position); if (s == Node.Status.SUCCESS) { money += 300; Destroy(diamond); } return(s); }); Selector openDoor = new Selector("Open Door"); openDoor.AddChild(goToBackDoor); openDoor.AddChild(goToFrontDoor); steal.AddChild(needsMoney); steal.AddChild(openDoor); steal.AddChild(goToDiamond); steal.AddChild(goToVan); tree.AddChild(steal); tree.PrintTree(); Time.timeScale = 5; }
// Use this for initialization void Start() { MoveLocation = transform.position; //CREATING OUR ZOMBIE BEHAVIOUR TREE //Get reference to Zombie Blackboard ZombieBB bb = GetComponent <ZombieBB>(); //Create our root selector Selector rootChild = new Selector(bb); // selectors will execute it's children 1 by 1 until one of them succeeds BTRootNode = rootChild; //Flee Sequence CompositeNode fleeSequence = new Sequence(bb); // The sequence of actions to take when Fleeing FleeDecorator fleeRoot = new FleeDecorator(fleeSequence, bb); // defines the condition required to enter the flee sequence (see FleeDecorator) fleeSequence.AddChild(new CalculateFleeLocation(bb)); // calculate a destination to flee to (just random atm) fleeSequence.AddChild(new ZombieMoveTo(bb, this)); // move to the calculated destination fleeSequence.AddChild(new ZombieWaitTillAtLocation(bb, this)); // wait till we reached destination fleeSequence.AddChild(new ZombieStopMovement(bb, this)); // stop movement fleeSequence.AddChild(new DelayNode(bb, 2.0f)); // wait for 2 seconds //Fight sequence CompositeNode FightSequence = new Sequence(bb); // The sequence of actions to take when Fighting FightDecorator fightRoot = new FightDecorator(FightSequence, bb); //defines the condition required to enter the fight sequence(see FightDecorator) //Defining a sequence for when the Zombie is to do it's combo attack, this is a nested within our FightSequence Sequence ZombieCombo = new Sequence(bb); ZombieCombo.AddChild(new ZombieClawPlayer(bb)); // claw the player ZombieCombo.AddChild(new DelayNode(bb, 0.8f)); // wait for 0.8 seconds ZombieCombo.AddChild(new ZombieBitePlayer(bb)); // bite the player ZombieCombo.AddChild(new DelayNode(bb, 1.5f)); // wait for 1.5 seconds FightSequence.AddChild(new ZombieMoveToPlayer(bb, this)); // constantly move to player until within range FightSequence.AddChild(new ZombieStopMovement(bb, this)); // stop movement FightSequence.AddChild(ZombieCombo); // perform combo sequence //Adding to root selector rootChild.AddChild(fleeRoot); rootChild.AddChild(fightRoot); //Execute our BT every 0.1 seconds InvokeRepeating("ExecuteBT", 0.1f, 0.1f); }
// Start is called before the first frame update void Start() { Debug.Log("Start Tree"); m_tiger = gameObject.GetComponent <Tiger_Move>(); root.AddChild(selector); selector.AddChild(seqInTheFarm); hungry.tiger = m_tiger; poop.tiger = m_tiger; play.tiger = m_tiger; followMouse.tiger = m_tiger; follow_Food.tiger = m_tiger; follow_Egg.tiger = m_tiger; follow_Milk.tiger = m_tiger; eat.tiger = m_tiger; basicMove.tiger = m_tiger; quarrel.tiger = m_tiger; seqInTheFarm.AddChild(hungry); seqInTheFarm.AddChild(poop); seqInTheFarm.AddChild(play); seqInTheFarm.AddChild(followMouse); seqInTheFarm.AddChild(follow_Food); seqInTheFarm.AddChild(follow_Milk); seqInTheFarm.AddChild(follow_Egg); seqInTheFarm.AddChild(eat); seqInTheFarm.AddChild(basicMove); seqInTheFarm.AddChild(quarrel); behaviorProcess = BehaviorProcess(); StartCoroutine(behaviorProcess); }
private void DefineBehaviorTree() { // Behavior Tree definition m_behaviorTree = new Sequencor(); var findPlayer = new Action(FindPlayer); m_behaviorTree.AddChild(findPlayer); var actionNode = new Selector(); var attackNode = new Action(Attack); var moveNode = new Action(Move); actionNode.AddChild(attackNode); actionNode.AddChild(moveNode); m_behaviorTree.AddChild(actionNode); }
// Use this for initialization void Start() { bt = GetComponent <BehaviorTree>(); m = GetComponent <Renderer>().material; Debug.Log(bt); root = bt.root; root.AddChild(new Condition(RadiusCheck)); root.AddChild(new BAction(() => { Status s = RandomColor(); Debug.Log("CURRENT CUBE STATUS: " + s); return(s); })); m.color = Random.ColorHSV(); startC = m.color; nextC = Random.ColorHSV(); }
public void TestSelectorFailsIfNoneSucceed() { var selector = new Selector("", 1, 1); selector.AddChild(TestingResources.GetRunRunFail()); //should be "running" selector.AddChild(TestingResources.GetRunRunFail()); //should be "running" var actual = new List <BehaviorState>(); var expected = new List <BehaviorState>(); expected.Add(BehaviorState.Running); expected.Add(BehaviorState.Running); expected.Add(BehaviorState.Fail); selector.Start().Subscribe((x) => actual.Add(x)); Assert.AreEqual(expected, actual); }
public override void Init() { bossController = GetComponent <BossMonsterController>(); bossController.Init(); idle.Controller = bossController; detectTarget.Controller = bossController; chaseTarget.Controller = bossController; checkCloseTarget.Controller = bossController; checkPossibleAttack.Controller = bossController; startAttack.Controller = bossController; checkPossibleSkill.Controller = bossController; skillAction.Controller = bossController; deadAction.Controller = bossController; isDie.Controller = bossController; //Node 추가 aiRoot.AddChild(seqNormal); seqNormal.AddChild(idle); seqNormal.AddChild(detectTarget); aiRoot.AddChild(selector); selector.AddChild(seqchaseAttack); selector.AddChild(seqSkill); selector.AddChild(seqDead); seqchaseAttack.AddChild(chaseTarget); seqchaseAttack.AddChild(checkCloseTarget); seqchaseAttack.AddChild(checkPossibleAttack); seqchaseAttack.AddChild(startAttack); seqSkill.AddChild(checkPossibleSkill); seqSkill.AddChild(skillAction); seqDead.AddChild(isDie); seqDead.AddChild(deadAction); behaviorProcess = BehaviorProcess(); }
public SimpleBT() { Sequence s1 = new Sequence(); Parallel p1 = new Parallel(); Selector selector1 = new Selector(); ParallelSelector ps1 = new ParallelSelector(); RedAction a1 = new RedAction(); //SimpleAction2 a2 = new SimpleAction2(); YellowAction a2 = new YellowAction(); s1.AddChild(a1, 0); s1.AddChild(a2, 1); p1.AddChild(a1, 0); p1.AddChild(a2, 1); selector1.AddChild(a1, 0); selector1.AddChild(a2, 1); ps1.AddChild(a1, 0); ps1.AddChild(a2, 1); // just test sequence // this.taskList.Add(s1); // just test parallel //this.taskList.Add(p1); // just test selector //this.taskList.Add(selector1); // just test ParallelSelecotr this.taskList.Add(ps1); this.taskList.Add(a1); this.taskList.Add(a2); this.parentIndexList.Add(0); // 其实组装一个action的东西是不是应该是AddTask方法封装好的呀,而用户只是传进来一个Type //SimpleAction2 a3 = new SimpleAction2(); //this.AddTask(0, 0, a3); for (int i = 0; i < taskList.Count; i++) { NodeData nd = new NodeData(); nd.ExecutionStatus = TaskStatus.Inactive; taskList[i].NodeData = nd; taskList[i].OnAwake(); } }
public void TestSelectorCompletesOnFirstSucceed() { var selector = new Selector("", 1, 1); selector.AddChild(TestingResources.GetRunRunFail()); selector.AddChild(TestingResources.GetRunRunSuccess()); //all of these should be ignored //TODO: Should probably check if these are run anyways // through the Concat operation selector.AddChild(TestingResources.GetRunRunFail()); selector.AddChild(TestingResources.GetRunRunFail()); selector.AddChild(TestingResources.GetRunRunFail()); selector.AddChild(TestingResources.GetRunRunFail()); var actual = new List <BehaviorState>(); var expected = new List <BehaviorState>(); expected.Add(BehaviorState.Running); expected.Add(BehaviorState.Success); selector.Start().Subscribe((x) => actual.Add(x)); Assert.AreEqual(expected, actual); }
// Start is called before the first frame update void Start() { Debug.Log("Start Tree"); m_Healer = gameObject.GetComponent <HealerMove>(); root.AddChild(selector); selector.AddChild(seqDead); // seqDead 노드를 selector의 자식 노드로 연결 selector.AddChild(seqMoving); // seqMoving 노드를 selector의 자식 노드로 연결 moveHealer.Healer = m_Healer; // m_Enemy를 넣어 초기화시킴 healerteamHpDetect.Healer = m_Healer; healermyHpDetect.Healer = m_Healer; healerIsDead.Healer = m_Healer; seqMoving.AddChild(moveHealer); //seqMoving 노드에 클래스 변수들을 자식으로 추가 seqMoving.AddChild(healerteamHpDetect); seqMoving.AddChild(healermyHpDetect); seqDead.AddChild(healerIsDead); //seqDead 노드에 클래스 변수를 자식으로 추가 behaviorProcess = BehaviorProcess(); StartCoroutine(behaviorProcess); }
// Start is called before the first frame update void Start() { Debug.Log("Start Tree"); m_Booster = gameObject.GetComponent <BoosterMove>(); root.AddChild(selector); selector.AddChild(seqDead); // seqDead 노드를 selector의 자식 노드로 연결 selector.AddChild(seqMoving); // seqMoving 노드를 selector의 자식 노드로 연결 moveBooster.Booster = m_Booster; // m_Enemy를 넣어 초기화시킴 boosterTeamPosDetect.Booster = m_Booster; boosterEnemyPosDetect.Booster = m_Booster; boosterIsDead.Booster = m_Booster; seqMoving.AddChild(moveBooster); //seqMoving 노드에 클래스 변수들을 자식으로 추가 seqMoving.AddChild(boosterTeamPosDetect); seqMoving.AddChild(boosterEnemyPosDetect); seqDead.AddChild(boosterIsDead); //seqDead 노드에 클래스 변수를 자식으로 추가 behaviorProcess = BehaviorProcess(); StartCoroutine(behaviorProcess); }
// Start is called before the first frame update void Start() { Debug.Log("Start Tree"); m_Enemy = gameObject.GetComponent <BastionMove>(); //BastionMove 객체 root.AddChild(selector); //노드추가 selector.AddChild(seqDead); //seqDead노드 추가 selector.AddChild(seqMovingAttack); //seqMovingAttack노드 추가 moveForTarget.Enemy = m_Enemy; bastionfindEnemy.Enemy = m_Enemy; m_OnAttack.Enemy = m_Enemy; isBastion_Col.Enemy = m_Enemy; m_IsDead.Enemy = m_Enemy; seqMovingAttack.AddChild(moveForTarget); //seqMovingAttack에 노드추가 seqMovingAttack.AddChild(m_OnAttack); //seqMovingAttack에 노드추가 seqMovingAttack.AddChild(bastionfindEnemy); //seqMovingAttack에 노드추가 seqMovingAttack.AddChild(isBastion_Col); //seqMovingAttack에 노드추가 seqDead.AddChild(m_IsDead); //seqDead에 노드추가 behaviorProcess = BehaviorProcess(); StartCoroutine(behaviorProcess); }
public FireSlimeBossAI() : base() { SetConditionHaveEnemy(new ConditionHaveEnemy_FireSlimeBoss()); conditionHaveEnemy.SetCharacterAI(this); SetDistanceCondition(new DistanceCondition_FireSlimeBoss()); distanceCondition.SetCharacterAI(this); SetMoveState(new MoveState_FireSlimeBoss()); moveState.SetCharacterAI(this); SetMoveToEnemyState(new MoveToEnemyState_FireSlimeBoss()); moveToEnemyState.SetCharacterAI(this); SetMoveToEnemy(new MoveToEnemy_FireSlimeBoss()); moveToEnemy.SetCharacterAI(this); SetAttackState(new AttackState_FireSlimeBoss()); attackState.SetCharacterAI(this); SetSkill1State(new Skill1State_FireSlimeBoss()); skill1State.SetCharacterAI(this); SetSkill2State(new Skill2State_FireSlimeBoss()); skill2State.SetCharacterAI(this); SetSkill3State(new Skill3State_FireSlimeBoss()); skill3State.SetCharacterAI(this); SetNormalAttackState(new NormalAttackState_FireSlimeBoss()); normalAttackState.SetCharacterAI(this); root_Node = new Selector(); root_Node.AddChild(attackState); root_Node.AddChild(moveState); root_Node.currentState = State.NONE; }