Exemplo n.º 1
0
 /// <summary>
 /// Init this instance.
 /// </summary>
 override protected void PostInit()
 {
     base.PostInit();
     if (landingDamageHitHox != null)
     {
         landingDamageHitHox.Init(new DamageInfo(attacks[0].damageAmount, attacks[0].damageType, Vector2.zero, character));
     }
     attackEventArgs = new AttackEventArgs(character, null);
 }
Exemplo n.º 2
0
        /// <summary>
        /// Init this enemy AI.
        /// </summary>
        override public void Init(Enemy enemy)
        {
            base.Init(enemy);
            // Listen to damage events and if we get them hide
            enemy.Damaged  += EnemyDamaged;
            enemy.Collided += EnemyDamaged;

            // If we need it try and find a charge movement
            if (useChargeState)
            {
                EnemyMovement_Distributor distributor = enemy.GetComponentInChildren <EnemyMovement_Distributor>();
                if (distributor != null)
                {
                    foreach (EnemyStateToMovement estm in distributor.statesToMovements)
                    {
                        if (estm.state == EnemyState.CHARGING)
                        {
                            chargeMovement = estm.movement;
                            break;
                        }
                    }
                }
                else
                {
                    chargeMovement = enemy.GetComponentInChildren <EnemyMovement_Charge>();
                }
            }
            // Try to find a cahracter hurt box so we can collect coins and damage other enemies
            characterHitBox = GetComponentInChildren <CharacterHitBox>();
            if (characterHitBox != null)
            {
                // Don't hit ourselves
                EnemyHurtBox myHurtBox = enemy.GetComponentInChildren <EnemyHurtBox>();
                if (myHurtBox != null)
                {
                    Physics2D.IgnoreCollision(characterHitBox.GetComponent <Collider2D>(), myHurtBox.GetComponent <Collider2D>());
                }
                // Init hit box
                characterHitBox.Init(new DamageInfo(1, DamageType.PHYSICAL, Vector2.zero));
            }
        }