// 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))
                )
            );
    }
    // Use this for initialization
    void Awake()
    {
        m_Animator       = GetComponent <Animator>();
        m_EnemyBehaviour = GetComponentInParent <SimpleEnemyBehaviour>();
        m_RigidBody2D    = GetComponentInParent <Rigidbody2D>();

        m_AI.OpenBranch(
            BT.If(() => { return(m_EnemyBehaviour.CurrentTarget != null); }).OpenBranch(
                BT.Call(m_EnemyBehaviour.CheckTargetStillVisible),
                //BT.If(() => { return !m_EnemyBehaviour.CheckMeleeAttack(); }).OpenBranch(
                //    BT.If(() => { return !m_EnemyBehaviour.CheckForObstacle(0.3f); }).OpenBranch(
                //        BT.Call(() => m_EnemyBehaviour.RunToTarget(0.2f)),
                //        BT.WaitUntil(() => { return m_EnemyBehaviour.CheckForObstacle(0.3f); }),
                //        BT.Call(m_EnemyBehaviour.StopRunning)
                //    )
                //),
                //Attack
                //BT.If(() => { return m_EnemyBehaviour.CheckMeleeAttack(); }).OpenBranch(
                BT.Call(m_EnemyBehaviour.OrientToTarget),
                BT.Call(m_EnemyBehaviour.StopPatrolling),
                BT.Call(() => m_Animator.SetTrigger(m_EnemyBehaviour.HashMeleeAttackPara)),
                BT.Wait(0.5f),
                BT.WaitForAnimatorState(m_Animator, "BoneKnight_Idle"),
                BT.Wait(1f),
                BT.Call(m_EnemyBehaviour.ForgetTarget)
                //)
                ),

            //Patrolling Around
            BT.If(() => { return(m_EnemyBehaviour.CurrentTarget == null); }).OpenBranch(
                BT.Call(m_EnemyBehaviour.ScanForTarget),
                BT.Call(() => m_EnemyBehaviour.Patrolling(0.3f))
                )

            );
    }