Esempio n. 1
0
 public override void OnGetDamage(BallController ball, int damagePercentage = 0, DragonBonusType damageType = DragonBonusType.None)
 {
     base.OnGetDamage(ball, damagePercentage, damageType);
     if (hitCounter <= 0)
     {
         SoundManager.instance.OnSpiderDestroy();
         manager.game.OnStateEnded -= Jump;
         manager.game.OnStateEnded -= ChooseNewIndex;
         manager.game.achievementController.OnBrickDeleted(GameSave.ItemType.teleport, level, ball);
     }
 }
Esempio n. 2
0
    public virtual void OnGetDamage(BallController ball, int damagePercentage = 0, DragonBonusType damageType = DragonBonusType.None)
    {
        PlayGetHitSound();
        int damage = 0;
        int logDamage;

        if (damagePercentage > 0)
        {
            damage = (int)(damagePercentage / 100f * (float)(baseHP + 1) * level);

            int totalHPBefore = hitCounter;
            logDamage = damage;
            Color effectColor = Color.white;
            switch (damageType)
            {
            case DragonBonusType.Poison: effectColor = Color.green; break;

            case DragonBonusType.Laser: effectColor = Color.yellow; break;

            case DragonBonusType.SuperFirstBall: effectColor = Color.red; break;

            case DragonBonusType.Freezing: effectColor = new Color(0.5f, 0.952f, 1f); break;
            }

            if (damagePercentage >= 100)
            {
                logDamage  = totalHPBefore;
                hitCounter = 0;
            }
            manager.CreateEffect <DamageLogEffect>(transform.position, Quaternion.identity, null).LogDamage(-logDamage, effectColor);
        }
        else
        {
            hitCounter--;
            logDamage = 1;
        }

        if (manager.game.currentDragonBonus == DragonBonusType.Poison && ball != null)
        {
            wasDamagedOnTurn = true;
            cubeEffectController.PlayPoisonEffect(wasDamagedOnTurn, this);
        }

        if (manager.game.currentDragonBonus == DragonBonusType.Freezing && hitCounter > 0 && ball != null)
        {
            cubeEffectController.ManageFreezeEffect(hpAtTheBeginningOfTheLevel * MetaGameController.instance.freezingHpLevelToBlow > hitCounter, this);
        }


        if (hitCounter == 0 && manager.game.currentDragonBonus == DragonBonusType.Freezing)
        {
            BlowIce();
        }

        if (hitCounter <= 0)
        {
            if (ball == null && damageType == DragonBonusType.Laser)
            {
                manager.game.achievementController.OnBrickKilledByLaserCoin();
            }

            if (!GetType().IsSubclassOf(typeof(CubeController)))
            {
                SoundManager.instance.OnBrickDestroy();
            }
            PlayDestroyEffect();
            if (GetType() == typeof(CubeController))
            {
                manager.game.achievementController.OnBrickDeleted(GameSave.ItemType.cube, level, ball);
            }
            manager.game.CheckBlocksNearPlayer();
            gameObject.SetActive(false);
            manager.game.OnBrickKilled(this);
        }
        else
        {
            countText.text = hitCounter.ToString();
            cubeEffectController.PlayImpactEffect(this);
        }

        manager.game.OnDamageDealtUpdateLevelProgress(logDamage > 0 ? logDamage : 1);
        manager.OnHit(ball);
    }