// 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)
                )
            );
    }
Example #2
0
    // Use this for initialization
    void Start()
    {
        bulletPool          = BulletPool.GetObjectPool(bullet, 5);
        skill3BulletPool    = BulletPool.GetObjectPool(skill3Bullet, 4);
        skill3BulletObjects = new BulletObject[4];
        bulletObjects       = new BulletObject[shootPoints.Length];
        timeToCoolDown      = 0;
        currentAmount       = 0;
        turn              = 1;
        damageable        = GetComponent <Damageable>();
        activeBound       = GetComponentInParent <ActiveBound>();
        capsuleCollider2D = GetComponent <CapsuleCollider2D>();

        animator       = GetComponent <Animator>();
        spriteRenderer = GetComponent <SpriteRenderer>();

        BlackKnightBT.OpenBranch(
            BT.If(() => turn <= 2).OpenBranch(
                BT.Sequence().OpenBranch(
                    BT.Wait(3f),
                    BT.SetBool(animator, "attack1", true),
                    BT.WaitForAnimatorState(animator, "attack1"),
                    BT.Call(() => attack1Effect.Play()),
                    BT.Call(() => Casting.Play()),
                    BT.WaitUntil(Attack1),
                    BT.Wait(1.5f),
                    BT.SetBool(animator, "attack1", false),
                    BT.Call(() => attack1Effect.Stop()),
                    BT.Call(() => Casting.Stop())
                    )
                ),
            BT.If(() => turn <= 1).OpenBranch(
                BT.Sequence().OpenBranch(
                    BT.Wait(2f),
                    BT.SetBool(animator, "attack2", true),
                    BT.WaitForAnimatorState(animator, "attack2"),
                    BT.Call(ActiveAlicia),
                    BT.WaitUntil(() => aliciaDied),
                    BT.Call(DeactiveAlicia),
                    BT.SetBool(animator, "attack2", false)
                    )
                ),
            BT.If(() => turn == 3).OpenBranch(
                BT.Sequence().OpenBranch(
                    BT.Wait(2f),
                    BT.Call(() => Flying_Upward_Effect.Play()),
                    BT.Wait(0.5f),
                    BT.SetBool(animator, "move", true),
                    BT.WaitForAnimatorState(animator, "move"),
                    BT.Call(MoveToNewPos),
                    BT.WaitUntil(MoveCheck),
                    BT.SetBool(animator, "move", false)
                    )
                ),
            BT.If(() => turn++ >= 3 && damageable.CurrentHealth > 0).OpenBranch(
                BT.Sequence().OpenBranch(
                    BT.Wait(1f),
                    BT.Call(PopBlackKnightBullet),
                    BT.Wait(3f),
                    BT.Call(BulletFollowTarget),
                    BT.Call(() => Debug.Log(skill3NumberOfButllet))
                    )
                ),
            BT.If(() => skill3NumberOfButllet <= 3).OpenBranch(
                BT.Sequence().OpenBranch(
                    BT.Wait(4f),
                    BT.Call(() => Debug.Log("wait 4: " + skill3NumberOfButllet))
                    )
                ),
            BT.If(() => skill3NumberOfButllet > 3).OpenBranch(
                BT.Sequence().OpenBranch(
                    BT.Wait(6f),
                    BT.Call(() => Debug.Log("wait 6: " + skill3NumberOfButllet))
                    )
                )
            );
    }