checkCanReceiveDamage method

bool checkCanReceiveDamage(
  1. AttackFromEnum attacker
)

This method is used to check if this component can receive damage from any attacker.

Implementation

bool checkCanReceiveDamage(AttackFromEnum attacker) {
  switch (receivesAttackFrom) {
    case ReceivesAttackFromEnum.ALL:
      return true;
    case ReceivesAttackFromEnum.ENEMY:
      if (attacker == AttackFromEnum.ENEMY) {
        return true;
      }
      break;
    case ReceivesAttackFromEnum.PLAYER_AND_ALLY:
      if (attacker == AttackFromEnum.PLAYER_OR_ALLY) {
        return true;
      }
      break;
    case ReceivesAttackFromEnum.NONE:
      return false;
  }

  return false;
}