Ejemplo n.º 1
0
Antibody::Antibody(DamageInfo damage, Vector position, 
		   Virus *target, int frame) {
  this->damage = DamageInfo(damage);
  this->position = position;
  this->map = 0;
  this->orientation = (double)(frame % 360);
  this->lifetime = ((damage.getRange()) / CELL_RADIUS) * 90;

  this->target = target;
  this->target->addToNotifyOnDeath(this);

  this->dead = false;

  switch (damage.getDamageColor()) {
  case VIRUS_COLOR_RED:
    this->color = Color(1.0, 0.0, 0.0);
    break;

  case VIRUS_COLOR_GREEN:
    this->color = Color(0.0, 1.0, 0.0);
    break;

  case VIRUS_COLOR_BLUE:
    this->color = Color(0.0, 0.0, 1.0);
    break;

  case VIRUS_COLOR_YELLOW:
    this->color = Color(1.0, 1.0, 0.0);
    break;
  }
}
Ejemplo n.º 2
0
void Virus::dealDamage(const DamageInfo &damage) {
  if (!isActive()) {
    return;
  }

  double modifier = 0.0;

  unsigned char proteinTypes = virusData->getProteinTypes();
  if (proteinTypes & damage.getDamageType()) {
    modifier = 1.0;
  }

  VirusColor color = virusData->getVirusColor();
  if (color == damage.getDamageColor()) {
    modifier *= 2.0;
  }

  if (modifier > 1.0) {
    flash = 45;
    flashColor = Color(1.0, 1.0, 1.0);
  } else if (modifier > 0.0) {
    flash = 22;
    flashColor = Color(1.0, 1.0, 1.0);
  }
  
  this->hp -= (modifier * damage.getDamageValue());
  if (hp <= 0.0) {
    hp = 0.0;
    dead = true;

    VisualEffect *effect = new ShockwaveEffect(position, 10.0, 60, 
					       virusData->getColor());
    map->addVisualEffect(effect);

    effect = new BubbleEffect(position, position, CELL_RADIUS / 3.0,
			      60, virusData->getColor());
    map->addVisualEffect(effect);
  }
}