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::updateAI() {
  if (!data) {
    return;
  }

  if (!attackCooldown) {
    DamageInfo damage = virusData->getDamageInfo();

    VirusFilter targetFilter;
    targetFilter.setOwnerFaction(owner);
    targetFilter.setPosition(position);
    std::vector<Virus *> *targets = targetFilter.filter(data->nearbyEntities,
							damage.getRange());
    
    if (targets->size() > 0) {
      Entity *antibody = new Antibody(damage, position, (*targets)[0], frame);
      
      map->addEntity(antibody);
      
      attackCooldown = damage.getDamageCooldown();
    }

    delete targets;
  }

  if (state == VIRUSSTATE_IDLE) {
    executeCurrentCommand();
  }

  if (currentPath.empty()) {
    state = VIRUSSTATE_IDLE;
  } else {
    state = VIRUSSTATE_MOVING;
  }
}