Example #1
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)

                )
            );
    }
Example #2
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)
            );
    }
    protected void Awake()
    {
        HashMeleeAttackPara = Animator.StringToHash(meleeAttackTransitionName);
        HashDeathPara       = Animator.StringToHash(deathTransitionName);
        HashHitPara         = Animator.StringToHash(hitTransitionName);

        m_HashDeadEffect = VFXController.StringToHash(deadEffectName);
        m_HashHitEffect  = VFXController.StringToHash(hitEffectName);

        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_SpriteForward = spriteFaceLeft ? Vector2.left : Vector2.right;
        if (m_SpriteRenderer.flipX)
        {
            m_SpriteForward = -m_SpriteForward;
        }
    }
    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);
    }
Example #5
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>();
 }
Example #6
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();
        }
    }
    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);
    }
Example #8
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)
            );
    }
 // Use this for initialization
 void Awake()
 {
     //currentExistsTime = 0;
     DieEffectHash = VFXController.StringToHash("Smoke");
     Direction     = Vector2.right;
     shootTime     = shootCoolDown;
     //Shooted = false;
     contactFilter2D.layerMask = hitLayerMask;
     RoBotHandPostion          = RobotHand.GetComponent <Transform>();
     RobotHandShootingScript   = RobotHand.GetComponent <StartShooting>();
     //RoBotHandPostion.position = shootOrigin.position;
     animator                = GetComponent <Animator>();
     robotSpriteRenderer     = GetComponent <SpriteRenderer>();
     robotHandSpriteRenderer = RobotHand.GetComponent <SpriteRenderer>();
     capsuleCollider2D       = GetComponent <CapsuleCollider2D>();
     rigidbody2D             = GetComponent <Rigidbody2D>();
     movingInRange           = GetComponent <MovingInRange>();
     Offset = new Vector2(capsuleCollider2D.size.x, 0);
 }
    private void Awake()
    {
        m_Ai.OpenBranch(
            BT.Sequence().OpenBranch(
                BT.Wait(2f),
                BT.Call(SetNewPosition),
                BT.Wait(1f),
                BT.Call(MoveToNewPosition),
                BT.Wait(1.5f),
                BT.Call(SetAttackPlayer),
                BT.Wait(1f),
                BT.WaitUntil(AttackPlayer),
                BT.Wait(0.5f),
                BT.Call(() => m_Rigidbody2D.velocity = Vector2.zero)
                )
            );

        m_Rigidbody2D            = GetComponent <Rigidbody2D>();
        m_Animator               = GetComponent <Animator>();
        m_SpriteRenderer         = GetComponent <SpriteRenderer>();
        m_SpriteRenderer.enabled = false;
        glowCircle.enabled       = false;
        m_HashDeadEffect         = VFXController.StringToHash(deadEffect);
    }
Example #11
0
 private void Awake()
 {
     m_Animator        = GetComponent <Animator>();
     m_HashSavedEffect = VFXController.StringToHash(saveEffect);
 }
 private void Awake()
 {
     VFX_HASH = VFXController.StringToHash(vfxName);
 }
Example #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)
            );
    }
Example #14
0
 private void InternalWakeUp()
 {
     m_Animator.SetTrigger(m_WakeUpPara);
     VFXController.Instance.Trigger(VFXController.StringToHash("Implode"), transform.position, 0, false, null);
 }
Example #15
0
 private void Awake()
 {
     Hash = VFXController.StringToHash(effectName);
 }
Example #16
0
 private void Awake()
 {
     m_HashHitEffect = VFXController.StringToHash(hitEffectName);
 }
Example #17
0
 private void Awake()
 {
     HashEndLevelEffect = VFXController.StringToHash(endLevelEffect);
 }
 private void Awake()
 {
     m_CheckPointEffectHash = VFXController.StringToHash(checkPointHitEffectName);
 }
Example #19
0
 private void Awake()
 {
     m_HealthUI    = FindObjectOfType <HealthUI>();
     EffectHash    = VFXController.StringToHash(CollectedEffectName);
     m_RigidBody2D = GetComponent <Rigidbody2D>();
 }
 public void OnPickUpNewAbility()
 {
     //VFXController.Instance.Trigger(VFXController.StringToHash("Implode"), transform.position + Vector3.up *0.6f, 0.1f, false, null);
     VFXController.Instance.Trigger(VFXController.StringToHash("Yellow_Explosion"), transform.position + Vector3.up * 0.6f, 0, false, null);
 }
Example #21
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)

            );
    }
    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)
                )


            );
    }
Example #23
0
 private void Awake()
 {
     m_HashEndLevelEffect = VFXController.StringToHash(endLevelEffect);
     m_Audio = GetComponent <RandomAudioPlayer>();
 }
    // 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"))
                )
            );
    }
 private void Awake()
 {
     player         = FindObjectOfType <PlayerPlatformerController>();
     HashDeadEffect = VFXController.StringToHash(deadEffect);
 }