void Awake()
 {
     bulletPool = BulletPool.GetObjectPool(bullet, 5);
     animator   = GetComponent <Animator>();
     frame      = transform.parent.GetComponentInParent <Frame>();
     frame.onPlayerExitFrame.AddListener(OnPlayerExitFrame);
 }
    private void Awake()
    {
        m_HashMeleeAttackPara = Animator.StringToHash(meleeAttackTransitionName);
        m_HashShootingPara    = Animator.StringToHash(rangeAttackTransitionName);

        m_CharacterController2D = GetComponent <CharacterController2D>();
        m_Collider       = GetComponent <Collider2D>();
        m_Animator       = GetComponent <Animator>();
        m_SpriteRenderer = GetComponent <SpriteRenderer>();

        m_OriginalColor = m_SpriteRenderer.color;

        if (projectilePrefab != null)
        {
            m_BulletPool = BulletPool.GetObjectPool(projectilePrefab.gameObject, 8);
        }

        m_SpriteForward = spriteFaceLeft ? Vector2.left : Vector2.right;
        if (m_SpriteRenderer.flipX)
        {
            m_SpriteForward = -m_SpriteForward;
        }

        if (meleeDamager != null)
        {
            EndAttack();
        }
    }
    private void Awake()
    {
        characterController2D = GetComponent <CharacterController2D>();
        rigidbody2D           = GetComponent <Rigidbody2D>();
        collider       = GetComponent <Collider2D>();
        animator       = GetComponent <Animator>();
        spriteRenderer = GetComponent <SpriteRenderer>();

        originalColor = spriteRenderer.color;

        if (projectilePrefab != null)
        {
            bulletPool = BulletPool.GetObjectPool(projectilePrefab.gameObject, 8);
        }

        spriteForward = spriteFaceLeft ? Vector2.left : Vector2.right;
        if (spriteRenderer.flipX)
        {
            spriteForward = -spriteForward;
        }

        if (meleeDamager != null)
        {
            EndAttack();
        }
    }
    private const float k_GroundedStickingVelocityMultiplier = 3f;    // This is to help the character stick to vertically moving platforms.

    private void Awake()
    {
        m_SpriteRenderer        = GetComponent <SpriteRenderer>();
        m_Animator              = GetComponent <Animator>();
        m_CharacterController2D = GetComponent <CharacterController2D>();
        m_Collider2D            = GetComponent <Collider2D>();

        m_HashDeadEffect      = VFXController.StringToHash(deadEffect);
        m_HashAppearingEffect = VFXController.StringToHash(appearingEffect);
        m_HashDustEffect      = VFXController.StringToHash(dustEffect);

        m_HashFootStepAudioPlayer     = AudioPlayerController.StringToHash(footStepAudioPlayer);
        m_HashHitAudioPlayer          = AudioPlayerController.StringToHash(hitAudioPlayer);
        m_HashDeadAudioPlayer         = AudioPlayerController.StringToHash(deadAudioPlayer);
        m_HashAppearingAudioPlayer    = AudioPlayerController.StringToHash(appearingAudioPlayer);
        m_HashLandAudioPlayer         = AudioPlayerController.StringToHash(landAudioPlayer);
        m_HashStartJumpingAudioPlayer = AudioPlayerController.StringToHash(startJumpingAudioPlayer);

        m_SlashPool = BulletPool.GetObjectPool(slashPrefab, 1);

        m_SpriteRenderer.enabled = false;
        shadow.SetActive(false);

        GameManager.Instance.RegisterPlayer(this);
    }
    // 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)
                )
            );
    }
示例#6
0
 // Use this for initialization
 void Awake()
 {
     DieEffectHash             = VFXController.StringToHash("Smoke");
     shootTime                 = shootCoolDown;
     contactFilter2D.layerMask = hitLayerMask;
     rayCastPosition           = transform.position;
     bulletPool                = BulletPool.GetObjectPool(Bullet, 10);
     animator        = GetComponent <Animator>();
     shootScript     = Bullet.GetComponent <StartShooting>();
     spriteRenderer  = GetComponent <SpriteRenderer>();
     updateHealthBar = GetComponentInChildren <UpdateHealthBar>();
 }
示例#7
0
    //protected readonly int m_HashTargetLostPara = Animator.StringToHash("TargetLost");
    //protected readonly int m_HashGroundedPara = Animator.StringToHash("Grounded");



    private void Awake()
    {
        HashMeleeAttackPara = Animator.StringToHash(meleeAttackTransitionName);
        HashShootingPara    = Animator.StringToHash(rangeAttackTransitionName);
        HashPatrollingPara  = Animator.StringToHash(patrollingTransitionName);
        HashRunPara         = Animator.StringToHash(runTransitionName);
        HashDeathPara       = Animator.StringToHash(deathTransitionName);
        HashHitPara         = Animator.StringToHash(hitTransitionName);

        //if (deadEffectName != null)
        {
            hashDeadEffect = VFXController.StringToHash(deadEffectName);
        }
        //if (hitEffectName != null)
        {
            hashHitEffect = VFXController.StringToHash(hitEffectName);
        }
        m_CharacterController2D = GetComponent <SimpleCharacterController2D>();
        m_Collider = GetComponent <Collider2D>();

        m_Animator = GetComponent <Animator>();
        if (m_Animator == null)
        {
            m_Animator = GetComponentInChildren <Animator>();
        }

        m_SpriteRenderer = GetComponent <SpriteRenderer>();
        if (m_SpriteRenderer == null)
        {
            m_SpriteRenderer = GetComponentInChildren <SpriteRenderer>();
        }

        m_OriginalColor = m_SpriteRenderer.color;

        if (projectilePrefab != null)
        {
            m_BulletPool = BulletPool.GetObjectPool(projectilePrefab.gameObject, 8);
        }

        m_SpriteForward = spriteFaceLeft ? Vector2.left : Vector2.right;
        if (m_SpriteRenderer.flipX)
        {
            m_SpriteForward = -m_SpriteForward;
        }

        if (meleeDamager != null)
        {
            EndAttack();
        }
    }
        void Start()
        {
            playGrid = GetComponent <FlexGrid2D> ();
            if (!string.IsNullOrEmpty(corePath))
            {
                GameObject core = ResourcesMgr.GetInstance().LoadAsset(corePath, false);
                SetGridItem(core, Vector2Int.zero);
            }
            screenSpaceZ = Camera.main.WorldToScreenPoint(transform.position).z;
            //选择效果
            selectEffect = ResourcesMgr.GetInstance().LoadAsset(ShipConst.selectPath, false);
            MyTools.SetObjActive(selectEffect, false);
            srShowGrid = traShowGrid.GetComponent <SpriteRenderer> ();
            SetSize(1, 2, 4, 3);
            bulletPool = BulletPool.GetObjectPool(preBullet, bulletCount);

            path = Application.streamingAssetsPath + @"/Config/PlayerShip.json";
        }
示例#9
0
    // Use this for initialization
    void Awake()
    {
        m_HashHitEffect  = VFXController.StringToHash(hitEffect);
        m_HashDeadEffect = VFXController.StringToHash(deadEffect);

        m_Animator = GetComponent <Animator>();

        m_BulletPool = BulletPool.GetObjectPool(bullet, 2);


        m_AI.OpenBranch(
            BT.Call(() => m_ShootingTimer = fireTime),
            BT.Call(() => m_Animator.SetBool(m_HashAttackPara, true)),
            BT.WaitUntil(() => m_ShootingTimer <= 0),
            BT.Call(() => m_Animator.SetBool(m_HashAttackPara, false)),
            BT.WaitForAnimatorState(m_Animator, "ExoticPlant_Idle"),
            BT.Wait(timeBetweenShooting)
            );
    }
    private const float k_GroundedStickingVelocityMultiplier = 3f;    // This is to help the character stick to vertically moving platforms.

    private void Awake()
    {
        //m_Rigidbody2D = GetComponent<Rigidbody2D>();
        m_SpriteRenderer        = GetComponentInChildren <SpriteRenderer>();
        m_AlessiaGraphics       = m_SpriteRenderer.gameObject.transform;
        m_Animator              = GetComponent <Animator>();
        m_CharacterController2D = GetComponent <CharacterController2D>();
        m_CharacterInput        = GetComponent <CharacterInput>();
        m_Flicker                        = m_SpriteRenderer.gameObject.AddComponent <Flicker>();
        m_SlashContactEffect             = slashContactTransform.GetComponentInChildren <ParticleSystem>();
        m_OffsetFromSlashEffectToAlessia = slashContactTransform.position - transform.position;
        m_Damageable                     = GetComponent <Damageable>();

        m_platformEffector2D = FindObjectOfType <PlatformEffector2D>();

        m_HashSlashHitEffect = VFXController.StringToHash(slashHitEffectName);

        m_MiniCollectableHealthPool = BulletPool.GetObjectPool(miniCollectableHealthPrefab, 5);
    }
    // Use this for initialization
    void Start()
    {
        bulletPool1        = BulletPool.GetObjectPool(bulletAttack1, 5);
        bulletPool3        = BulletPool.GetObjectPool(attack3Soldier, 7);
        vortexGroundEffect = BulletPool.GetObjectPool(spawnSoldierEffect, 7);
        explodingHash      = VFXController.StringToHash("ExplodingHitEffect");

        animator       = GetComponentInChildren <Animator>();
        rigidbody2D    = GetComponent <Rigidbody2D>();
        spriteRenderer = GetComponentInChildren <SpriteRenderer>();
        boxCollider2D  = GetComponent <BoxCollider2D>();

        AliciaBT.OpenBranch(
            BT.Sequence().OpenBranch(
                BT.Wait(3),
                BT.Call(OrientToTarget),
                BT.SetBool(animator, "attack1", true),
                BT.WaitForAnimatorState(animator, "attack1"),
                BT.SetBool(animator, "attack1", false),
                BT.Call(Attack1),
                BT.WaitForAnimatorState(animator, "Idle"),
                BT.Call(() => Debug.Log("Finish Dash"))
                ),
            BT.Sequence().OpenBranch(
                BT.Wait(2f),
                BT.Call(OrientToTarget),
                BT.SetBool(animator, "dash", true),
                BT.WaitForAnimatorState(animator, "beforeDash"),
                BT.WaitForAnimatorState(animator, "dash"),
                BT.Call(MoveToTarget),
                BT.WaitUntil(MoveCheck),
                BT.SetBool(animator, "dash", false)
                ),
            BT.Sequence().OpenBranch(
                BT.Call(OrientToTarget),
                BT.SetBool(animator, "attack2", true),
                BT.WaitForAnimatorState(animator, "attack2"),
                BT.SetBool(animator, "attack2", false),
                BT.Call(Attack2)
                ),
            BT.Sequence().OpenBranch(
                BT.Wait(2f),
                BT.SetBool(animator, "backward", true),
                BT.WaitForAnimatorState(animator, "backward"),
                BT.Call(MoveBackWard),
                BT.WaitUntil(CheckMoveBackWard),
                BT.SetBool(animator, "attack3", true),
                BT.SetBool(animator, "backward", false),
                BT.WaitForAnimatorState(animator, "attack3"),
                BT.Call(() => fireShield.Play()),
                BT.Call(() => shieldDamager.EnableDamage()),
                BT.Call(PopVortex),
                BT.Call(SpawnSoldier),
                BT.Wait(2f),
                BT.Call(Attack3),
                BT.WaitUntil(Attack3Check),
                BT.SetBool(animator, "attack3", false),
                BT.Call(() => rigidbody2D.position = new Vector2(rigidbody2D.position.x, rigidbody2D.position.y - 0.55f)),
                BT.Call(() => fireShield.Stop()),
                BT.Call(() => shieldDamager.DisableDamage()),
                BT.Call(() => Debug.Log("after attack3"))
                )
            );
    }
示例#12
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))
                    )
                )
            );
    }
示例#13
0
    private void Awake()
    {
        m_Animator       = GetComponent <Animator>();
        m_RigidBody2D    = GetComponent <Rigidbody2D>();
        m_Damageable     = GetComponent <Damageable>();
        m_SpriteRenderer = GetComponent <SpriteRenderer>();
        m_Flicker        = gameObject.AddComponent <Flicker>();

        m_OriginalPosition = transform.position;

        shortDamager.DisableDamage();
        longDamager.DisableDamage();
        jumpDamager.DisableDamage();

        m_DeathEffectHash = VFXController.StringToHash(deathEffectName);
        m_HitEffectHash   = VFXController.StringToHash(hitEffectName);

        m_JumpAttackSpellPool = BulletPool.GetObjectPool(jumpAttackSpell, 4);
        m_DarkMatterPool      = BulletPool.GetObjectPool(darkBallSpell, 2);
        m_SoldierPool         = BulletPool.GetObjectPool(miniSoldier, 4);


        //Behaviour tree
        m_Ai.OpenBranch(
            BT.If(() => { return(m_Damageable.CurrentHealth == m_Damageable.startingHealth && m_SoldierCount == 2); }).OpenBranch(

                //Summon
                BT.Sequence().OpenBranch(
                    BT.Call(() => TeleportTo(summonTeleportPosition.position)),
                    BT.Wait(4.5f),
                    BT.Call(() => m_SpriteRenderer.flipX = true),
                    BT.Call(() => SetConcetratingEffectLocalPosition(new Vector2(-0.15f, 1.5f))),
                    BT.Call(() => m_Animator.SetTrigger(m_HashSummonPara)),
                    BT.Wait(1f),
                    BT.WaitForAnimatorState(m_Animator, "PrincessFury_Idle"),
                    BT.WaitUntil(SummonActionEndCheck),
                    BT.Wait(0.5f),
                    BT.Call(() => TeleportToRandom()),
                    BT.Wait(5f)
                    )

                ),

            BT.If(() => { return(m_Damageable.CurrentHealth <= m_Damageable.startingHealth * 2 / 3 && m_SoldierCount == 3); }).OpenBranch(

                //Summon
                BT.Sequence().OpenBranch(
                    BT.Call(() => TeleportTo(summonTeleportPosition.position)),
                    BT.Wait(4.5f),
                    BT.Call(() => m_SpriteRenderer.flipX = true),
                    BT.Call(() => SetConcetratingEffectLocalPosition(new Vector2(-0.15f, 1.5f))),
                    BT.Call(() => m_Animator.SetTrigger(m_HashSummonPara)),
                    BT.Wait(1f),
                    BT.WaitForAnimatorState(m_Animator, "PrincessFury_Idle"),
                    BT.WaitUntil(SummonActionEndCheck),
                    BT.Wait(0.5f),
                    BT.Call(() => TeleportToRandom()),
                    BT.Wait(5f)
                    )

                ),

            BT.If(() => { return(m_Damageable.CurrentHealth <= m_Damageable.startingHealth / 3 && m_SoldierCount == 4); }).OpenBranch(

                //Summon
                BT.Sequence().OpenBranch(
                    BT.Call(() => TeleportTo(summonTeleportPosition.position)),
                    BT.Wait(4.5f),
                    BT.Call(() => m_SpriteRenderer.flipX = true),
                    BT.Call(() => SetConcetratingEffectLocalPosition(new Vector2(-0.15f, 1.5f))),
                    BT.Call(() => m_Animator.SetTrigger(m_HashSummonPara)),
                    BT.Wait(1f),
                    BT.WaitForAnimatorState(m_Animator, "PrincessFury_Idle"),
                    BT.WaitUntil(SummonActionEndCheck),
                    BT.Wait(0.5f),
                    BT.Call(() => TeleportToRandom()),
                    BT.Wait(5f)
                    )

                ),


            BT.RandomSequence(new int[] { 3, 2, 2, 2 }, 1).OpenBranch(
                //Walk
                BT.Sequence().OpenBranch(
                    BT.Call(OrientToTarget),
                    BT.Call(() => m_Animator.SetBool(m_HashWalkPara, true)),
                    BT.Call(() => SetHorizontalSpeed(1f)),
                    BT.Wait(2.5f),
                    BT.Call(() => SetHorizontalSpeed(0)),
                    BT.Call(() => m_Animator.SetBool(m_HashWalkPara, false)),
                    BT.Wait(0.5f)
                    ),
                ////Teleport
                //BT.Sequence().OpenBranch(
                //    BT.Call(() => TeleportToRandom()),
                //    BT.Wait(4.5f)
                //),
                //Top to bottom Attack
                BT.Sequence().OpenBranch(
                    BT.Call(() => SetConcetratingEffectLocalPosition(new Vector2(-1.3f, 1f))),
                    BT.Call(() => m_Animator.SetTrigger(m_HashTopToDowmAttackPara)),
                    BT.Wait(0.5f),
                    BT.Call(OrientToTarget),
                    BT.WaitForAnimatorState(m_Animator, "PrincessFury_Idle"),
                    BT.Wait(1f)
                    ),
                //Combo Attack
                BT.If(() => { return((targetToTrack.position - transform.position).sqrMagnitude < 4f); }).OpenBranch(
                    BT.Sequence().OpenBranch(
                        BT.Call(() => m_Animator.SetTrigger(m_HashTopAttackPara)),
                        BT.Wait(0.5f),
                        BT.WaitForAnimatorState(m_Animator, "PrincessFury_Idle"),
                        BT.Call(OrientToTarget),
                        BT.Call(() => m_Animator.SetTrigger(m_HashBottomAttackPara)),
                        BT.Wait(0.5f),
                        BT.WaitForAnimatorState(m_Animator, "PrincessFury_Idle"),
                        BT.Call(OrientToTarget),
                        BT.Call(() => m_Animator.SetTrigger(m_HashTopAttackPara)),
                        BT.Wait(0.5f),
                        BT.WaitForAnimatorState(m_Animator, "PrincessFury_Idle"),
                        BT.Wait(1f)
                        )
                    ),
                //JumpAttack
                BT.Sequence().OpenBranch(
                    BT.Call(() => SetConcetratingEffectLocalPosition(new Vector2(-0.85f, -0.75f))),
                    BT.Call(() => m_Animator.SetTrigger(m_HashJumpAttackPara)),
                    BT.Call(OrientToTarget),
                    BT.WaitForAnimatorState(m_Animator, "PrincessFury_Idle"),
                    BT.Wait(1f)
                    )


                ),

            BT.Call(OrientToTarget),

            BT.Wait(1f)
            );
    }
示例#14
0
    private void Awake()
    {
        //Get references
        m_Animator    = GetComponent <Animator>();
        m_RigidBody2D = GetComponentInParent <Rigidbody2D>();
        m_Damageable  = GetComponentInParent <Damageable>();
        m_OriginalGraphicsLocalScale = transform.localScale;
        m_ParentTransform            = transform.parent;
        m_SpriteRenderers            = transform.GetComponentsInChildren <SpriteRenderer>();
        m_OriginalSpriteColors       = new Color[m_SpriteRenderers.Length];
        for (int i = 0; i < m_SpriteRenderers.Length; i++)
        {
            m_OriginalSpriteColors[i] = m_SpriteRenderers[i].color;
        }

        //Pools
        m_SlashPool = BulletPool.GetObjectPool(slash, 3);
        //m_FireBallPool = BulletPool.GetObjectPool(fireBall, 10);
        m_ChaserPool   = BulletPool.GetObjectPool(chaser, 5);
        m_PortalPool   = BulletPool.GetObjectPool(portal, 3);
        m_DarkVoidPool = BulletPool.GetObjectPool(darkVoid, 1);

        //Effect
        m_DarkVoidHash     = VFXController.StringToHash(darkVoidEffectName);
        m_PortalImpactHash = VFXController.StringToHash("ImpactEffect");

        m_PortalObjects = new List <BulletObject>();

        //Behaviour tree
        m_Ai.OpenBranch(
            BT.RandomSequence(new int[] { 1, 2, 3, 2, 3 }, 1).OpenBranch(
                //Walk
                BT.If(() => { return(!MoveOutOfBoundCheck()); }).OpenBranch(
                    BT.Sequence().OpenBranch(
                        BT.Call(() => m_Animator.SetBool(m_HashWalkPara, true)),
                        BT.Call(() => SetHorizontalSpeed(1f)),
                        BT.Wait(2f),
                        BT.Call(() => SetHorizontalSpeed(0)),
                        BT.Call(() => m_Animator.SetBool(m_HashWalkPara, false)),
                        BT.Wait(0.5f)
                        )
                    ),
                BT.If(() => { return(!MoveOutOfBoundCheck()); }).OpenBranch(
                    //Run
                    BT.Sequence().OpenBranch(
                        BT.Call(() => m_Animator.SetTrigger(m_HashIdle2Para)),
                        BT.Wait(0.5f),
                        BT.WaitForAnimatorState(m_Animator, "idle_1"),
                        BT.Call(OrientToTarget),
                        BT.Call(() => m_Animator.SetBool(m_HashRunPara, true)),
                        BT.Call(() => SetHorizontalSpeed(5f)),
                        BT.Wait(2f),
                        BT.Call(() => SetHorizontalSpeed(0)),
                        BT.Call(() => m_Animator.SetBool(m_HashRunPara, false)),
                        BT.Wait(0.5f)
                        )
                    ),

                //Slash
                BT.Sequence().OpenBranch(
                    BT.Call(() => m_Animator.SetTrigger(m_HashSkill1Para)),
                    BT.Wait(0.5f),
                    BT.WaitForAnimatorState(m_Animator, "idle_1"),
                    BT.Wait(0.5f)
                    ),
                ////DarkVoid
                //BT.Sequence().OpenBranch(
                //    BT.Call(() => m_Animator.SetTrigger(m_HashSkill2Para)),
                //    BT.Wait(0.5f),
                //    BT.Call(SpawnRandomDarkVoid),
                //    BT.Wait(1.5f),
                //    BT.Repeat(5).OpenBranch(
                //        BT.Call(SpawnChaserAttack),
                //        BT.Wait(0.5f)
                //    )
                //),
                //DarkVoid Attacking
                BT.Sequence().OpenBranch(
                    BT.Call(() => m_Animator.SetTrigger(m_HashSkill2Para)),
                    BT.Wait(0.5f),
                    BT.Call(StartDarkVoidAttacking),
                    BT.Wait(3f)
                    ),
                //Portal
                BT.If(() => { return(m_Damageable.CurrentHealth < m_Damageable.startingHealth / 1.5f && m_PortalObjects.Count <= 0); }).OpenBranch(
                    BT.Sequence().OpenBranch(
                        BT.Call(() => m_Animator.SetTrigger(m_HashSkill2Para)),
                        BT.Wait(0.5f),
                        BT.Call(SpawnPortal),
                        BT.WaitForAnimatorState(m_Animator, "idle_1")
                        )
                    )
                ////Fireball
                //BT.Sequence().OpenBranch(
                //    BT.Call(() => m_Animator.SetTrigger(m_HashIdle2Para)),
                //    BT.Wait(0.5f),
                //    BT.WaitForAnimatorState(m_Animator, "idle_1"),
                //    BT.Wait(1f)
                //)

                ),

            BT.Call(OrientToTarget)

            //BT.Wait(0.5f)

            );
    }
示例#15
0
 // Use this for initialization
 void Awake()
 {
     m_BulletPool = BulletPool.GetObjectPool(bullet, 2);
 }
示例#16
0
 // Use this for initialization
 void Awake()
 {
     m_DarkMatterPool = BulletPool.GetObjectPool(darkMatter, 2);
 }
    private void Awake()
    {
        m_Animator             = GetComponentInChildren <Animator>();
        m_RigidBody2D          = GetComponent <Rigidbody2D>();
        m_Damageable           = GetComponent <Damageable>();
        m_SpriteRenderer       = GetComponentInChildren <SpriteRenderer>();
        m_LineRenderer         = GetComponentInChildren <LineRenderer>();
        m_Flicker              = m_Animator.gameObject.AddComponent <Flicker>();
        m_LaserFollowComponent = laserFollower.GetComponent <FollowTarget>();
        m_trailRenderer        = GetComponentInChildren <TrailRenderer>();

        m_OriginalPosition = transform.position;

        m_DeathEffectHash = VFXController.StringToHash(deathEffectName);
        m_HitEffectHash   = VFXController.StringToHash(hitEffectName);

        //Pool
        m_ConcentratingAttackPool = BulletPool.GetObjectPool(concentratingAttack, 5);
        m_LaserAttackPool         = BulletPool.GetObjectPool(laserAttackBullet, 20);


        m_OffsetFromLaserToShardKnight = laserStartingPosition.position - m_SpriteRenderer.transform.position;

        //Behaviour tree
        m_Ai.OpenBranch(
            BT.If(() => { return(m_Damageable.CurrentHealth >= m_Damageable.startingHealth / 2); }).OpenBranch(

                BT.RandomSequence(new int[] { 3, 2, 4 }, 2).OpenBranch(
                    //Laser follow attack
                    BT.Sequence().OpenBranch(
                        BT.Call(() => laserAttackType = 1),
                        BT.Call(() => m_LineRenderer.colorGradient = laserFollowAttackGradient),
                        BT.Call(StartLaserAttack),
                        BT.Wait(1.5f),
                        BT.Call(() => m_LaserFollowComponent.speed = 1f),
                        BT.Call(() => m_LineRenderer.enabled       = false),
                        BT.Repeat(15).OpenBranch(
                            BT.Call(LaserFollowAttack),
                            BT.Wait(0.1f)
                            ),
                        BT.Call(() => m_LaserFollowComponent.speed = 2f),
                        BT.Call(EndLaserAttack),
                        BT.Wait(1f)
                        ),
                    //Cicle laser Attack
                    BT.Sequence().OpenBranch(
                        BT.Call(() => laserAttackType = Random.Range(2, 4)),
                        BT.Call(() => m_LineRenderer.colorGradient = circleLaserAttackGradient),
                        BT.Call(StartLaserAttack),
                        BT.WaitUntil(() => Mathf.Abs(m_LaserSweptAngle) >= 360),
                        BT.Call(() => m_LineRenderer.enabled = false),
                        BT.Repeat(19).OpenBranch(
                            BT.Call(CircleLaserAttack),
                            BT.Wait(0.1f)
                            ),
                        BT.Call(EndLaserAttack),
                        BT.Wait(1f)
                        ),
                    //Dash
                    BT.Sequence().OpenBranch(
                        BT.Call(() => tornadoEffect.Play()),
                        BT.Wait(1.5f),
                        BT.Call(DashToLower, 3f, false),
                        BT.WaitUntil(MoveCheck),
                        BT.Wait(0.5f),
                        BT.Call(StartDashing),
                        BT.Call(DashToLower, 10f, true),
                        BT.Call(RotateTowardsFuturePosition),
                        BT.WaitUntil(MoveCheck),
                        BT.Call(EndDashing),
                        BT.Wait(0.5f),
                        BT.Call(FlipSpriteBasedOnSide),
                        BT.Call(DashToUpper, 3f, false),
                        BT.WaitUntil(MoveCheck),
                        BT.Call(() => tornadoEffect.Stop()),
                        BT.Wait(1.5f)
                        )

                    )
                ),

            BT.If(() => { return(m_Damageable.CurrentHealth < m_Damageable.startingHealth / 2); }).OpenBranch(
                //Change form animation
                BT.If(() => { return(!m_FormChanged); }).OpenBranch(
                    BT.Call(ChangeForm),
                    BT.WaitForAnimatorState(m_Animator, "ShardKnightAfterTransform"),
                    BT.Wait(1f)
                    ),

                BT.RandomSequence(new int[] { 3, 3, 2, 2 }, 2).OpenBranch(
                    //Dash
                    BT.Sequence().OpenBranch(
                        BT.Call(() => tornadoEffect.Play()),
                        BT.Wait(1.5f),
                        BT.Call(StartDashing),
                        BT.Call(DashToLower, 10f, true),
                        BT.Call(RotateTowardsFuturePosition),
                        BT.WaitUntil(MoveCheck),
                        BT.Wait(0.2f),
                        BT.Call(FlipSpriteBasedOnSide),
                        BT.Call(DashToLower, 12f, true),
                        BT.Call(RotateTowardsFuturePosition),
                        BT.WaitUntil(MoveCheck),
                        BT.Wait(0.2f),
                        BT.Call(FlipSpriteBasedOnSide),
                        BT.Call(DashToUpper, 10f, true),
                        BT.Call(RotateTowardsFuturePosition),
                        BT.WaitUntil(MoveCheck),
                        BT.Call(EndDashing),
                        BT.Call(FlipSpriteBasedOnSide),
                        BT.Call(() => tornadoEffect.Stop()),
                        BT.Wait(1.5f)

                        ),
                    //Exploding Attack
                    BT.Sequence().OpenBranch(
                        BT.Call(() => m_Animator.SetTrigger(m_HashExplodingAttackPara)),
                        BT.Repeat(5).OpenBranch(
                            BT.Call(SpawnConcentratingAttack),
                            BT.Wait(0.5f),
                            BT.Call(EnableConcentratingAttackDamager),
                            BT.Wait(0.8f)
                            ),
                        BT.Call(() => m_Animator.SetTrigger(m_HashEndAnimationPara)),
                        BT.Wait(2f)
                        ),
                    //Cicle laser Attack
                    BT.Sequence().OpenBranch(
                        BT.Call(() => laserAttackType = Random.Range(2, 4)),
                        BT.Call(() => m_LineRenderer.colorGradient = circleLaserAttackGradient),
                        BT.Call(StartLaserAttack),
                        BT.WaitUntil(() => Mathf.Abs(m_LaserSweptAngle) >= 360),
                        BT.Call(() => m_LineRenderer.enabled = false),
                        BT.Repeat(19).OpenBranch(
                            BT.Call(CircleLaserAttack),
                            BT.Wait(0.1f)
                            ),
                        BT.Call(EndLaserAttack),
                        BT.Wait(1f)
                        ),
                    //Meteor shower
                    BT.Sequence().OpenBranch(
                        BT.Call(() => m_Animator.SetTrigger(m_HashMeteorShowerAttackPara)),
                        BT.Wait(0.5f),
                        BT.Call(() => concentratingStateEffect.Play()),
                        BT.Wait(1f),
                        BT.Repeat(30).OpenBranch(
                            BT.Call(MeteorShowerAttack),
                            BT.Wait(0.2f)
                            ),
                        BT.Call(() => m_Animator.SetTrigger(m_HashEndAnimationPara)),
                        BT.Call(() => concentratingStateEffect.Stop()),
                        BT.Wait(1f)
                        )
                    ),

                BT.Call(OrientToTarget)
                )


            );
    }