예제 #1
0
    private void OnEnable()
    {
        agentBehaviour = GetComponent <AgentBehaviour>();
        aiBehaviour    = GetComponent <AIBehaviour>();
        layerMask      = LayerMask.NameToLayer("Elemnet");
        m_Ai.AddBehaviours(
            BT.Selector().AddBehaviours(
                BT.Sequence().AddBehaviours(
                    BT.Condition(() => { return(aiBehaviour.getCircleElementsNum() > 2); }),
                    //如果没有发现敌人和方块则自由移动
                    BT.Sequence().AddBehaviours(
                        //如果没有发现
                        BT.If(() => { return(!isFindElement && !isFindPlayer); }).AddBehaviours(
                            //进行随机移动
                            BT.Call(agentBehaviour.RandomWalk)
                            //进行随搜
                            //BT.Call(CheckForAround)
                            ),
                        //如果有发现
                        BT.If(() => { return(isFindElement); }).AddBehaviours(

                            BT.Call(agentBehaviour.Pursue)

                            )

                        )
                    )
                )

            );
    }
예제 #2
0
파일: Frog.cs 프로젝트: chickening/TeemoRPG
    protected override void Start()
    {
        base.Start();
        skillReaderList.Add(new SkillReader(SkillManager.FindSkill("FrogGeneralAttack")));
        BT BTAttack = BT.Sequence
                      (
            BT.Call(GeneralAttack)
                      );
        BT BTPatrol = BT.Sequence
                      (
            BT.Success(BT.Call(RandomWayPoint)),
            BT.Success(BT.Call(FindAroundEnemy)),
            BT.Condition(() => { return(!isFoundEnemy); }, BT.Call(Move))
                      );

        AI = BT.Root
             (
            BT.Sequence
            (
                BT.Success(BT.Call(FindAroundEnemy)),
                BT.Selector
                (
                    BT.Condition(() => { return(isFoundEnemy); }, BTAttack),
                    BT.Probability(0.3f * Time.fixedDeltaTime, BTPatrol)
                )
            )
             );
        moveMaxDelay = new Delay();
    }
예제 #3
0
파일: Arrest.cs 프로젝트: mxmstr/neo
    IEnumerator LateStart()
    {
        yield return(new WaitUntil(delegate()
        {
            m_Player = Array.Find(
                GameObject.FindGameObjectsWithTag("Character"),
                delegate(GameObject go) { return go.GetComponent <Character>().GetID() == 0; }
                );

            return m_Player != null;
        }));

        m_PlayerInitPos = m_Player.transform.position;
        m_Character     = GetComponent <Character>();
        m_AI            = GetComponent <AI>();
        m_Tree          = BT.Root();

        m_Tree.OpenBranch(

            BT.If(m_AI.InRange).OpenBranch(
                BT.Sequence().OpenBranch(
                    BT.Call(m_AI.Punch),
                    BT.While(m_AI.ActionPlaying).OpenBranch(
                        BT.Call(m_AI.RotateTo)
                        )
                    )
                ),
            BT.If(m_AI.OutOfRange).OpenBranch(
                BT.Call(m_AI.Walk),
                BT.Call(m_AI.RotateTo)
                )

            );
    }
예제 #4
0
 protected override void Awake()
 {
     base.Awake();
     this.contoller = new BTContoller
                      (
         BT.Root
         (
             BT.Selector
             (
                 BT.Sequence
                 (
                     BT.Call(SearchEnemy),
                     BT.Call(WaypointToTarget),
                     BT.Call(Move),
                     BT.Call(Attack)
                 )
                 ,
                 BT.Sequence
                 (
                     BT.Call(FindWayPoint),
                     BT.Call(Move)
                 )
             )
         )
                      );
 }
예제 #5
0
    // Use this for initialization
    void Awake()
    {
        m_TargetToTrack = GameObject.FindGameObjectWithTag("Player").transform;

        m_HashHitEffect = VFXController.StringToHash("CFX_Hit_Red");
        m_HashDieEffect = VFXController.StringToHash("ExplodingHitEffectDark");

        m_Animator       = GetComponent <Animator>();
        m_RigidBody2D    = GetComponent <Rigidbody2D>();
        m_SpriteRenderer = GetComponent <SpriteRenderer>();
        //m_Damageable = GetComponent<Damageable>();

        m_TargetPosition = m_TargetToTrack.transform.position;

        //Behaviour tree
        m_Ai.OpenBranch(
            BT.If(() => { return((m_TargetPosition - transform.position).sqrMagnitude < 0.9f); }).OpenBranch(
                BT.Call(() => m_Animator.ResetTrigger(m_HashWalkPara)),
                BT.Call(() => SetHorizontalSpeed(0f)),
                BT.Call(() => m_Animator.SetTrigger(m_HashAttackPara)),
                BT.Wait(0.5f),
                BT.WaitForAnimatorState(m_Animator, "MiniSoldier_Idle")
                ),
            BT.If(() => { return((m_TargetPosition - transform.position).sqrMagnitude >= 0.9f); }).OpenBranch(
                BT.Call(() => m_Animator.SetTrigger(m_HashWalkPara)),
                BT.Call(() => SetHorizontalSpeed(1f))
                ),
            BT.Call(() => m_TargetPosition = m_TargetToTrack.transform.position),
            BT.Wait(0.5f),
            BT.Call(OrientToTarget)
            );
    }
예제 #6
0
    private void OnEnable()
    {
        m_Dead             = false;
        m_Collider.enabled = true;

        bossAudio.PlayAudio(end, 1);

        m_Ai.OpenBranch(
            BT.RandomSequence(new int[] { 2, 6, 1 }).OpenBranch(
                BT.Root().OpenBranch(
                    BT.SetBool(m_Animator, "Walk 1", true),
                    BT.Wait(Random.Range(1f, 2f)),
                    BT.SetBool(m_Animator, "Walk 1", false),
                    BT.WaitForAnimatorState(m_Animator, "Idle 1")
                    ),
                BT.Root().OpenBranch(
                    BT.If(() => { return(CheckMeleeAttack()); }).OpenBranch(
                        BT.Wait(0.2f),
                        BT.WaitForAnimatorState(m_Animator, "Idle 1")
                        )
                    ),
                BT.Repeat(stage1StrafeTimes).OpenBranch(
                    BT.Call(OrientToTarget),
                    BT.Trigger(m_Animator, "RangeAttack 1"),
                    BT.Wait(0.2f),
                    BT.WaitForAnimatorState(m_Animator, "Idle 1"),
                    BT.Wait(strafeInterval)
                    )
                )
            );

        tick = true;
    }
예제 #7
0
        /// <summary>
        /// AI 小怪智能 行为树模式
        /// </summary>
        /// <param name="self"></param>
        void TreeMonsterInit(MonsterBehaviorTreeComponent self)
        {
            self.root = BT.Root();

            self.root.OpenBranch(
                BT.Selector().OpenBranch(
                    BT.Sequence().OpenBranch(
                        BT.Call(self.GetParent <Unit>().GetComponent <AttackComponent>().CheckDeath),
                        BT.Send(self.GetParent <Unit>().GetComponent <AttackComponent>().GetExpAndCoin),
                        BT.Send(self.GetParent <Unit>().GetComponent <AttackComponent>().RemoveUnit)
                        ),
                    BT.Selector().OpenBranch(
                        BT.Sequence().OpenBranch(
                            BT.Call(self.GetParent <Unit>().GetComponent <SeekComponent>().CheckSeekTarget),
                            BT.Selector().OpenBranch(
                                BT.Sequence().OpenBranch(
                                    BT.Call(self.GetParent <Unit>().GetComponent <AttackComponent>().MonsterCheckAttackTarget),
                                    BT.Send(self.GetParent <Unit>().GetComponent <AttackComponent>().AttackTarget)
                                    ),
                                BT.Send(self.GetParent <Unit>().GetComponent <SeekComponent>().SeekTarget)
                                )
                            ),
                        BT.Sequence().OpenBranch(
                            BT.Send(self.GetParent <Unit>().GetComponent <RecoverComponent>().RecoverHp),
                            BT.Send(self.GetParent <Unit>().GetComponent <PatrolComponent>().UpdatePatrol)
                            )
                        )
                    )
                );
        }
예제 #8
0
    private void OnEnable()
    {
        m_EnemyBehaviour = GetComponent <SupportBot>();
        m_Animator       = GetComponent <Animator>();

        m_Ai.OpenBranch(
            //BT.If(() => { return m_EnemyBehaviour.Target != null; }).OpenBranch(
            //    BT.Call(m_EnemyBehaviour.CheckTargetStillVisible),
            //    BT.Call(m_EnemyBehaviour.OrientToTarget),
            //    BT.If(() => { return m_EnemyBehaviour.CheckLaunchMode() == true; }).OpenBranch(
            //        BT.Call(() => { m_EnemyBehaviour.StartLaunch(true); })
            //    ),
            //    BT.If(() => { return m_EnemyBehaviour.CheckLaunchMode() == false; }).OpenBranch(
            //        BT.Call(() => { m_EnemyBehaviour.StartLaunch(false); })
            //    ),
            //    BT.Call(m_EnemyBehaviour.RememberTargetPos)
            //),
            BT.If(() => { return(m_EnemyBehaviour.Target == null); }).OpenBranch(
                BT.RandomSequence().OpenBranch(
                    BT.Sequence().OpenBranch(
                        BT.SetBool(m_Animator, "Patrol", true),
                        BT.Call(() => m_EnemyBehaviour.SetFacingData(Random.Range(0f, 1f) > 0.5f ? -1 : 1))
                        ),
                    BT.SetBool(m_Animator, "Patrol", false)
                    ),
                BT.Wait(Random.Range(3f, 5f))
                )
            );
    }
예제 #9
0
    private void OnEnable()
    {
        points         = GameObject.FindGameObjectsWithTag("WanderPoints"); //wander function
        randomwaittime = UnityEngine.Random.Range(1, 5);

        aiRoot.OpenBranch(BT.If(Playerisvisible).OpenBranch(BT.Call(Chase)), BT.If(Playerisnotvisible).OpenBranch(BT.Call(Walk)));
    }
예제 #10
0
    // Use this for initialization
    void Awake()
    {
        DieEffectHash = VFXController.StringToHash("Smoke");
        rigidbody2D   = GetComponent <Rigidbody2D>();
        animator      = GetComponent <Animator>();
        rmx6Moving    = GetComponent <rmx6Moving>();
        oldVelocity   = new Vector2(0, 0);
        die           = false;
        rmx6_BT.OpenBranch(
            BT.If(() => { return(targetInRange); }).OpenBranch(
                BT.Call(() => animator.SetBool("walk", true)),
                BT.WaitForAnimatorState(animator, "rmx6_walking"),
                //BT.Wait(0.3f),
                BT.Call(() => { if (!die)
                                {
                                    rmx6Moving.canWalk = true;
                                }
                        })
                ),
            BT.If(() => { return(!targetInRange); }).OpenBranch(
                BT.Call(() => animator.SetBool("walk", false)),
                BT.Call(() => animator.SetBool("hide", true)),
                BT.WaitForAnimatorState(animator, "rmx6_hiding"),
                //BT.Wait(0.3f),
                BT.Call(() => rmx6Moving.canWalk = false)

                )
            );
    }
    // Use this for initialization
    void Start()
    {
        m_Animator       = GetComponent <Animator>();
        m_EnemyBehaviour = GetComponent <SimpleEnemyBehaviour>();

        m_AI.OpenBranch(

            BT.If(() => { return(m_EnemyBehaviour.CurrentTarget != null); }).OpenBranch(
                BT.Call(m_EnemyBehaviour.CheckTargetStillVisible),
                //Run to target
                BT.If(() => { return(!m_EnemyBehaviour.CheckMeleeAttack()); }).OpenBranch(
                    BT.Call(() => m_EnemyBehaviour.RunToTarget(0.2f))
                    ),
                //Attack
                BT.If(() => { return(m_EnemyBehaviour.CheckMeleeAttack()); }).OpenBranch(
                    BT.Call(m_EnemyBehaviour.StopPatrolling),
                    BT.Call(m_EnemyBehaviour.StopRunning),
                    BT.Call(m_EnemyBehaviour.PerformMeleeAttack),
                    BT.Wait(0.5f),
                    BT.WaitForAnimatorState(m_Animator, "MiniSoldier_Idle")
                    )
                ),

            //Patrolling Around
            BT.If(() => { return(m_EnemyBehaviour.CurrentTarget == null); }).OpenBranch(
                BT.Call(m_EnemyBehaviour.ScanForTarget),
                BT.Call(() => m_EnemyBehaviour.Patrolling(0.2f))
                )
            );
    }
예제 #12
0
 private void Start()
 {
     aiRoot = BT.Root();
     aiRoot.OpenBranch(
         BT.If(HasTarget).OpenBranch(
             BT.If(tankController.IsBusy).OpenBranch(
                 BT.Call(() => { Debug.Log("Busy"); }),
                 BT.Wait(1f)
                 ),
             BT.If(CanTakeBehind).OpenBranch(
                 BT.Call(() => { Debug.Log("Taking your six"); }),
                 BT.Wait(5f),
                 BT.Call(FireAtTarget),
                 BT.Wait(1f)
                 ),
             BT.If(CanFireAtTarget).OpenBranch(
                 BT.Call(FireAtTarget),
                 BT.Wait(1f)
                 ),
             BT.If(CanMoveToTarget).OpenBranch(
                 BT.Call(MoveToTarget),
                 BT.Wait(1f)
                 ),
             BT.If(IsNotMoving).OpenBranch(
                 BT.Wait(1f),
                 BT.Call(EndTurn)
                 )
             ),
         BT.If(HasNoTarget).OpenBranch(
             BT.Call(() => { Debug.Log("Honestly, this should not happen"); }),
             BT.Call(EndTurn)
             )
         );
 }
예제 #13
0
    void OnEnable()
    {
        players          = GameObject.FindGameObjectsWithTag("Player");
        gameObject.layer = 8;
        gameObject.tag   = "Enemy";

        aiRoot.OpenBranch(
            BT.If(IsAlive).OpenBranch(
                BT.If(IsNotDamaging).OpenBranch(
                    BT.Selector().OpenBranch(
                        BT.If(PlayerInRange).OpenBranch(
                            BT.Call(PrepareForAttack),
                            BT.If(CanAttack).OpenBranch(
                                BT.Call(Attack)
                                )
                            ),
                        BT.If(PlayerInTerritory).OpenBranch(
                            BT.Call(Follow)
                            ),
                        BT.If(AwayFromHome).OpenBranch(
                            BT.Call(ReturnHome)
                            ),
                        BT.Sequence().OpenBranch(
                            BT.Call(Rest),
                            BT.Wait(2.0f),
                            BT.Call(Turn)
                            )
                        )
                    )
                )
            );
    }
예제 #14
0
파일: WaitForArrest.cs 프로젝트: mxmstr/neo
    IEnumerator LateStart()
    {
        yield return(new WaitUntil(delegate()
        {
            m_Arrester = Array.Find(
                GameObject.FindGameObjectsWithTag("Character"),
                delegate(GameObject go) { return go.GetComponent <Character>().GetID() == m_ArresterID; }
                );

            return m_Arrester != null;
        }));

        yield return(new WaitUntil(delegate()
        {
            m_Player = Array.Find(
                GameObject.FindGameObjectsWithTag("Character"),
                delegate(GameObject go) { return go.GetComponent <Character>().GetID() == 0; }
                );

            return m_Player != null;
        }));

        m_PlayerInitPos = m_Player.transform.position;
        m_AI            = GetComponent <AI>();
        m_Tree          = BT.Root();

        m_Tree.OpenBranch(

            BT.Call(m_AI.Stand),
            BT.Call(m_AI.RotateTo)

            );
    }
예제 #15
0
        void Start()
        {
            m_Character = GetComponent <Character>();
            m_AI        = GetComponent <AI>();
            m_Tree      = BT.Root();
            int[] attackWeights = { m_AttackPunchWeight, m_AttackKickWeight, m_AttackJumpRightWeight, m_AttackJumpLeftWeight };
            int[] jumpWeights   = { m_RunWeight, m_RunJumpWeight };

            m_Tree.OpenBranch(

                BT.Call(m_AI.DecrementRangeTime),

                BT.If(m_AI.InRangeOrRangeTimeIn).OpenBranch(

                    BT.If(m_AI.TargetHasHealth).OpenBranch(

                        BT.If(m_AI.InRange).OpenBranch(
                            BT.Call(m_AI.ResetRangeDelay)
                            ),
                        BT.RandomSequence(attackWeights).OpenBranch(
                            BT.Sequence().OpenBranch(
                                BT.Call(m_AI.Punch),
                                BT.While(m_AI.ActionPlaying).OpenBranch(
                                    BT.Call(m_AI.Run),
                                    BT.Call(m_AI.RotateTo)
                                    )
                                ),
                            BT.Sequence().OpenBranch(
                                BT.Call(m_AI.Kick),
                                BT.While(m_AI.ActionPlaying).OpenBranch(
                                    BT.Call(m_AI.RotateTo)
                                    )
                                ),
                            BT.Sequence().OpenBranch(
                                BT.Call(m_AI.JumpLeft)
                                ),
                            BT.Sequence().OpenBranch(
                                BT.Call(m_AI.JumpRight)
                                )
                            )

                        )

                    ),

                BT.If(m_AI.OutOfRangeAndRangeTimeOut).OpenBranch(
                    BT.RandomSequence(jumpWeights).OpenBranch(
                        BT.Sequence().OpenBranch(
                            BT.Call(m_AI.Run),
                            BT.Call(m_AI.RotateTo)
                            ),
                        BT.Call(m_AI.JumpForward)
                        )
                    )

                );
        }
    // Use this for initialization
    private void Awake()
    {
        spriteRenderer = GetComponent <SpriteRenderer>();
        animator       = GetComponent <Animator>();
        rigidbody2D    = GetComponent <Rigidbody2D>();
        damageable     = GetComponent <Damageable>();
        activeBound    = GetComponentInParent <ActiveBound>();
        boxCollider2D  = GetComponent <BoxCollider2D>();

        sphereBulletPool    = BulletPool.GetObjectPool(Sphere, 5);
        thornLoadBulletPool = BulletPool.GetObjectPool(LoadThorn, 4);
        thornBulletPool     = BulletPool.GetObjectPool(ThornBullet, 20);

        innerRangeBT.OpenBranch(
            BT.Sequence().OpenBranch(
                BT.SetBool(animator, "move", true),
                BT.WaitForAnimatorState(animator, "move"),
                BT.WaitUntil(CheckMoveToTarget),
                BT.SetBool(animator, "attack1", true),
                BT.SetBool(animator, "move", false),
                BT.WaitForAnimatorState(animator, "attack1"),
                BT.SetBool(animator, "attack1", false),
                BT.WaitForAnimatorState(animator, "stand")
                ),
            BT.Sequence().OpenBranch(
                BT.Call(() => spawnSphereEffect.Play()),
                BT.Wait(0.5f),
                BT.Call(PopSphere),
                BT.Wait(1.5f),
                BT.Call(SetSphereVelocity),
                BT.Wait(2f),
                BT.Call(() => spawnSphereEffect.Stop())
                ),
            BT.Sequence().OpenBranch(
                BT.SetBool(animator, "move", true),
                BT.WaitForAnimatorState(animator, "move"),
                BT.WaitUntil(CheckMoveToTarget),
                //BT.Call(MoveToAttack2Pos),
                BT.Call(ResetVelocity),
                BT.SetBool(animator, "attack2", true),
                BT.SetBool(animator, "move", false),
                BT.WaitForAnimatorState(animator, "attack2"),
                BT.SetBool(animator, "attack2", false),
                BT.WaitForAnimatorState(animator, "stand")
                ),
            BT.Sequence().OpenBranch(
                BT.Call(MoveToAttack2Pos),
                BT.Wait(1),
                BT.Call(ResetVelocity),
                BT.Call(PopLoadThorn),
                BT.Wait(1.5f),
                BT.Call(ShootThorns)
                )
            );
    }
    void Start()
    {
        mainCameraTransform           = Camera.main.transform;
        playerTransform               = GameObject.FindWithTag("Player").transform;
        rikishiController             = GetComponent <RikishiController>();
        zeFlabben                     = GetComponent <ParameterizedFlabbiness>();
        scoreboard                    = FindObjectOfType <Scoreboard>();
        animator                      = GetComponent <Animator>();
        zeFlabben.Flabbiness          = scoreboard.GetEnemyScore() * 34f;
        rikishiController.shoveForce += zeFlabben.Flabbiness * 3;

        trackingTransform          = new GameObject().transform;
        trackingTransform.position = playerTransform.position;
        trackingTransformStartY    = trackingTransform.position.y;

        // BT class from the 2D Game Kit
        // https://learn.unity.com/tutorial/2d-game-kit-advanced-topics#5c7f8528edbc2a002053b77a
        //behaviorTree.OpenBranch(

        //    //BT.If(() => { return m_EnemyBehaviour.Target != null; }).OpenBranch(
        //    //    BT.Call(m_EnemyBehaviour.CheckTargetStillVisible),
        //    //    BT.Call(m_EnemyBehaviour.OrientToTarget),
        //    //    BT.Trigger(m_Animator, "Shooting"),
        //    //    BT.Call(m_EnemyBehaviour.RememberTargetPos),
        //    //    BT.WaitForAnimatorState(m_Animator, "Attack")
        //    //),

        //    BT.If(TestPlayerInStrikingDistance).OpenBranch(
        //        BT.Trigger(animator, "Stop Dancing"),
        //        BT.Call(Attack),
        //        BT.Wait(StrikeDelay)
        //    ),

        //    BT.Call(LockOntoTarget)
        //);

        behaviorTree.OpenBranch(
            BT.RandomSequence(new int[] { 3, 1 }).OpenBranch(
                BT.Sequence().OpenBranch(
                    //BT.Log("Chasing Player"),
                    BT.RunCoroutine(GetWithinStrikingDistanceOfThePlayer),
                    BT.Call(Attack),
                    BT.RunCoroutine(GetReadyForNextAttack)
                    ),
                BT.Sequence().OpenBranch(
                    BT.While(() => PlayerIsInStrikingDistance() == false).OpenBranch(
                        //BT.Log("Avoiding Player"),
                        BT.Call(() => ImOnTheEdgeOfTheDohyo()),
                        BT.Call(SitStill),
                        BT.Call(LockOntoTarget)
                        )
                    )
                )
            );
    }
예제 #18
0
 public BTContoller(BT bt = null)
 {
     if (bt == null)
     {
         this.bt = BT.Call(() => BTState.FAILURE);
     }
     else
     {
         this.bt = bt;
     }
 }
예제 #19
0
    public IEnumerator Switch()
    {
        tick = false;
        bossAudio.PlayAudio(end, 2);
        m_Animator.ResetTrigger(m_HashMeleeAttack1Para);
        m_Animator.ResetTrigger(m_HashRangeAttack1Para);
        m_Animator.ResetTrigger(m_HashWalk1Para);
        m_Animator.SetTrigger(m_HashSwitchPara);
        yield return(new WaitForAnimatorState(m_Animator, "Idle 2"));

        m_Ai = BT.Root();
        m_Ai.OpenBranch(
            BT.RandomSequence(new int[] { 2, 15, 6, 6 }).OpenBranch(
                BT.Root().OpenBranch(
                    BT.Log("mmp1-1"),
                    BT.SetBool(m_Animator, "Walk 2", true),
                    BT.Wait(Random.Range(1f, 2f)),
                    BT.SetBool(m_Animator, "Walk 2", false),
                    BT.Log("mmp1-2"),
                    BT.WaitForAnimatorState(m_Animator, "Idle 2")
                    ),
                BT.Root().OpenBranch(
                    BT.Repeat(stage2MeleeTimes).OpenBranch(
                        BT.Log("mmp2-1"),
                        BT.If(() => { return(CheckMeleeAttack()); }).OpenBranch(
                            //BT.Wait(0.1f),
                            BT.Log("mmp2-2"),
                            BT.WaitForAnimatorState(m_Animator, "Idle 2")
                            )
                        )
                    ),
                BT.Root().OpenBranch(
                    BT.Repeat(stage2MeleeTimes).OpenBranch(
                        //BT.Call(OrientToTarget),
                        BT.Log("mmp3-1"),
                        BT.Trigger(m_Animator, "Launch"),
                        BT.Wait(0.1f),
                        BT.Log("mmp3-2"),
                        BT.WaitForAnimatorState(m_Animator, "Idle 2")
                        )
                    ),
                BT.Repeat(stage1StrafeTimes).OpenBranch(
                    BT.Log("mmp4-1"),
                    BT.Call(OrientToTarget),
                    BT.Trigger(m_Animator, "RangeAttack 2"),
                    BT.Wait(0.1f),
                    BT.Log("mmp4-2"),
                    BT.WaitForAnimatorState(m_Animator, "Idle 2"),
                    BT.Wait(strafeInterval)
                    )
                )
            );
        tick = true;
    }
예제 #20
0
        private void OnEnable()
        {
            m_EnemyBehaviour = GetComponent <SentryEnemyBehavior>();
            m_Animator       = GetComponent <Animator>();

            m_Ai.OpenBranch(
                BT.Trigger(m_Animator, "Shooting"),
                BT.Call(m_EnemyBehaviour.RememberTargetPos),
                BT.WaitForAnimatorState(m_Animator, "Attack")
                );
        }
예제 #21
0
 //AI邏輯:
 //IF(怪物血量歸零) => 死亡function(放特效、音效,死亡時攻擊之類的)
 //ELSE IF(可以攻擊) => 攻擊
 //ELSE => 跟隨玩家
 private void OnEnable()
 {
     aiRoot.OpenBranch(
         BT.If(() => hp <= 0).OpenBranch(
             BT.Call(OnDead)
             ),
         BT.If(CanAttack).OpenBranch(
             BT.Call(Attack)
             ),
         BT.Call(Follow)
         );
 }
예제 #22
0
        private void OnEnable()
        {
            _behave = GetComponent <BossBehave>();

            _AI.OpenBranch(
                BT.Selector().OpenBranch(
                    BT.While(_behave.Opening).OpenBranch(
                        BT.Call(_behave.MoveToTarget),
                        BT.Wait(0.5f),
                        BT.Call(_behave.DashAttack),
                        BT.Wait(2f),
                        BT.Call(_behave.TurnToTarget),
                        BT.Call(_behave.AfterOpening)
                        ),

                    BT.If(_behave.Moving).OpenBranch(
                        BT.Wait(Time.deltaTime),
                        BT.Call(_behave.Initialization)
                        ),

                    BT.Sequence().OpenBranch(
                        BT.Condition(_behave.TooFar),
                        BT.Call(_behave.Charge)
                        ),

                    BT.Sequence().OpenBranch(
                        BT.Condition(_behave.NeedDodge),
                        BT.Call(_behave.Dodge),
                        BT.Wait(0.5f),
                        BT.RandomSequence().OpenBranch(
                            BT.Call(_behave.Slash),
                            BT.Call(_behave.DashAttack)
                            ),
                        BT.Call(_behave.TurnToTarget)
                        ),

                    BT.Sequence().OpenBranch(
                        BT.Condition(_behave.InAttackRange),
                        BT.RandomSequence().OpenBranch(
                            BT.Call(_behave.Slash),
                            BT.Call(_behave.JumpAttack),
                            BT.Call(_behave.DashAttack)
                            ),
                        BT.Call(_behave.TurnToTarget)
                        ),

                    BT.Sequence().OpenBranch(
                        BT.Call(_behave.Charge),
                        BT.Wait(0.5f)
                        )
                    )
                );
        }
예제 #23
0
    public void Awake()
    {
        Monster = GetComponent <MonsterSetting>();

        AI = BT.Root();

        AI.OpenBranch(
            BT.Selector().OpenBranch(

                BT.Sequence().OpenBranch(BT.Condition(Monster.CanAttack), BT.Call(Monster.Attack)),

                BT.Call(Monster.Idle))

            );
    }
예제 #24
0
 void OnEnable()
 {
     aiRoot.OpenBranch(
         BT.While(TestVisibleTarget).OpenBranch(
             BT.Call(Aim),
             BT.Call(Shoot)
             ),
         BT.Sequence().OpenBranch(
             BT.Call(Walk),
             BT.Wait(5.0f),
             BT.Call(Turn),
             BT.Wait(1.0f)
             )
         );
 }
예제 #25
0
 protected override void Awake()
 {
     base.Awake();
     this.contoller = new BTContoller
                      (
         BT.Root
         (
             BT.Sequence
             (
                 BT.Call(SearchEnemy),
                 BT.Call(Fire)
             )
         )
                      );
 }
예제 #26
0
파일: TestBT.cs 프로젝트: Venbb/VGame
 private void OnEnable()
 {
     aiRoot.OpenBranch(
         BT.If(TestVisibleTarget).OpenBranch(
             BT.Call(Aim),
             BT.Call(Shoot)
             ),
         BT.Sequence().OpenBranch(
             BT.Call(Walk),
             BT.Wait(5.0f),
             BT.Call(Turn),
             BT.Wait(1.0f),
             BT.Call(Turn)
             )
         );
     BT.RunCoroutine(RunCoroutine);
 }
예제 #27
0
    public override void PreEnter(string characterID, Action <float> updateSpeed)
    {
        base.PreEnter(characterID, updateSpeed);

        string path = string.Format("ScriptableObjects/AIBrain/{0}", characterID);

        brain = (AIBrain)Resources.Load(path);

        character = GetComponent <Character>();
        animator  = GetComponent <Animator>();

        player = CharacterManager.Instance.player.GetComponent <Character>();

        currentTime = 0;

        ai.OpenBranch
        (
            // 1) Sleeper Part. 일종의 대기 상태.
            BT.While(character.IsSleeper).OpenBranch
            (
                BT.Wait(brain.tickRate)
            ),

            // 2) MainAction - 이 부분만 AIBrain 로 옮길 수 있을지도?
            // BT도 너무 난잡하게 제어하지 말고, IsAlive 부분만 제어가능하게 만들면 된다.
            // 사실 이정도 단순함이면 BT 말고 그냥 로직짜도 될듯... 이건 다른 프로그래머와 상의 해 보도록 하자.
            BT.While(character.IsAlive).OpenBranch
            (
                BT.RandomSequence(new int[] { 1, 6 /*, 2*/ }).OpenBranch
                (
                    BT.Call(DoTeleportToPlayer),
                    BT.Call(TrackPlayer)/*,
                                         * BT.Root().OpenBranch
                                         * (
                                         * BT.Call(character.TestJump),
                                         * BT.Wait(0.5f)
                                         * )
                                         */
                )
            ),

            BT.Wait(0.2f),
            BT.Call(LeaveWorld)
        );
        // MainAction End
    }
예제 #28
0
 // Start is called before the first frame update
 void Start()
 {
     Debug.Log("ai start");
     ai = BT.Root();
     ai.OpenBranch(
         BT.Call(this.getDistance),
         BT.While(this.check).OpenBranch(
             BT.Selector(true).OpenBranch(
                 BT.Call(() => people1.Move(new Vector3(1, 0, 0))),
                 BT.Call(() => people2.Move(new Vector3(-1, 0, 0))),
                 BT.Call(() => people2.Move(new Vector3(-2, 0, 0))),
                 BT.Call(() => people2.Move(new Vector3(-3, 0, 0)))
                 ),
             BT.Call(this.getDistance)
             ),
         BT.Terminate()
         );
 }
예제 #29
0
    private void OnEnable()
    {
        m_RangeEnemyBase = GetComponent <RangeEnemyBase>();
        m_Animator       = GetComponent <Animator>();

        m_Ai.OpenBranch(
            BT.If(() => { return(m_RangeEnemyBase.Target == null); }).OpenBranch(
                BT.RandomSequence().OpenBranch(
                    BT.Sequence().OpenBranch(
                        BT.SetBool(m_Animator, "Patrol", true),
                        BT.Call(() => m_RangeEnemyBase.SetFacingData(Random.Range(0f, 1f) > 0.5f ? -1 : 1))
                        ),
                    BT.SetBool(m_Animator, "Patrol", false)
                    ),
                BT.Wait(Random.Range(3f, 5f))
                )
            );
    }
예제 #30
0
        private void OnEnable()
        {
            m_EnemyBehaviour = GetComponent <EnemyBehaviour>();
            m_Animator       = GetComponent <Animator>();

            m_Ai.OpenBranch(
                BT.If(() => { return(m_EnemyBehaviour.Target != null); }).OpenBranch(
                    BT.Call(m_EnemyBehaviour.CheckTargetStillVisible),
                    BT.Call(m_EnemyBehaviour.OrientToTarget),
                    BT.Trigger(m_Animator, "Shooting"),
                    BT.Call(m_EnemyBehaviour.RememberTargetPos),
                    BT.WaitForAnimatorState(m_Animator, "Attack")
                    ),
                BT.If(() => { return(m_EnemyBehaviour.Target == null); }).OpenBranch(
                    BT.Call(m_EnemyBehaviour.ScanForPlayer)
                    )
                );
        }