void OnTriggerEnter2D(Collider2D other) { EnemyBattleBase collidingEnemy = null; //was an enemy if ((collidingEnemy = other.gameObject.GetComponent <EnemyBattleBase>()) != null) { if (successBlock) { SuccessBlock(collidingEnemy); } else if (successDodge) { SuccessDodge(); } else { TakeDamage(collidingEnemy.GetDamageAmount()); collidingEnemy.CollideWithPlayer(); } } //was a projectile else if ((collidingEnemy = other.gameObject.GetComponentInParent <EnemyBattleBase>()) != null) { if (successBlock) { SuccessBlock(collidingEnemy); } else if (successDodge) { SuccessDodge(); } else { TakeDamage(collidingEnemy.GetDamageAmount()); } //Destroy(other.gameObject); } else { Debug.Log("No damage component found!"); } isInsideBlock = false; isInsideDodge = false; }
private void SuccessBlock(EnemyBattleBase enemy) { int reduction = 1; foreach (AbilityBase ability in battleSystem.battleAbilites) { reduction += ability.Block(); } TakeDamage(enemy.GetDamageAmount() - reduction); //ResetAction(); }