Example #1
0
void Level::changeLevel(Position destination, Creature* c) {
  Vec2 oldPos = c->getPosition().getCoord();
  if (model->changeLevel(destination, c)) {
    eraseCreature(c);
    getSafeSquare(oldPos)->removeCreature();
    bucketMap->removeElement(oldPos, c);
  }
}
Example #2
0
void Level::changeLevel(StairKey key, Creature* c) {
  Vec2 oldPos = c->getPosition().getCoord();
  Level* otherLevel = model->getLinkedLevel(this, key);
  if (otherLevel->landCreature(key, c))
    eraseCreature(c, oldPos);
  else {
    Position otherPos = Random.choose(otherLevel->landingSquares.at(key));
    if (Creature* other = otherPos.getCreature()) {
      if (!other->isPlayer() && c->getPosition().canEnterEmpty(other) && otherPos.canEnterEmpty(c)) {
        otherLevel->eraseCreature(other, otherPos.getCoord());
        eraseCreature(c, oldPos);
        putCreature(oldPos, other);
        otherLevel->putCreature(otherPos.getCoord(), c);
        c->playerMessage("You switch levels with " + other->getName().a());
      }
    }
  }
}
Example #3
0
void Level::killCreature(Creature* creature) {
  bucketMap->removeElement(creature->getPosition().getCoord(), creature);
  eraseCreature(creature);
  creature->getPosition().removeCreature();
}
Example #4
0
void Level::changeLevel(Position destination, Creature* c) {
  Vec2 oldPos = c->getPosition().getCoord();
  if (destination.isValid() && destination.getLevel()->landCreature({destination}, c))
    eraseCreature(c, oldPos);
}
Example #5
0
void Level::killCreature(Creature* creature) {
  eraseCreature(creature, creature->getPosition().getCoord());
}