本文整理汇总了C++中Door::isExit方法的典型用法代码示例。如果您正苦于以下问题:C++ Door::isExit方法的具体用法?C++ Door::isExit怎么用?C++ Door::isExit使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Door
的用法示例。
在下文中一共展示了Door::isExit方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: update
//.........这里部分代码省略.........
vector3df toPlayer = playerPos - objPos;
if (toPlayer.getLength() < 5 && (getCurrentRoom() == obj->getCurrentRoom())){
if (obj->getItemName() == "key") {
_hasKey = true;
std::cout << _hasKey << std::endl;
}
obj->setPickedUp(true);
this->setCarriedItem(obj);
this->_isCarrying = true;
//does the player need a hint?
HudManager* hud = (HudManager*)EntityManager::getNamedEntities("Hudman")->front();
if (!hud->hasHintBeenShownFor("Throw")){
hud->drawHintFor("Throw");
}
break;
}
iter++;
}
}
}
if (inputHandler.getCurrentMouse().LeftButton){
if (_isCarrying){//dropping
if (this->getCarriedItem() != NULL){
this->_isCarrying = false;
Message m(this->getCarriedItem(), "thrown", 0);
MessageHandler::sendMessage(m);
this->clearCarriedItem();
_noiseAllowance -= 5.0f;
//does the player need a hint?
HudManager* hud = (HudManager*)EntityManager::getNamedEntities("Hudman")->front();
if (!hud->hasHintBeenShownFor("Noise")){
hud->drawHintFor("Noise");
}
_hasKey = false;
}
}
}
/* CHECKING THE DOORS */
std::list<Entity*>* doors = EntityManager::getNamedEntities("Door");
vector3df playerPos = _node->getPosition();
auto doorIter = doors->begin();
while (doorIter != doors->end()){
Door* door = (Door*)(*doorIter);
btVector3 btPos = door->getRigidBody()->getCenterOfMassPosition();
vector3df doorPos = vector3df(btPos.x(), btPos.y(), btPos.z());
vector3df toPlayer = playerPos - doorPos;
if (toPlayer.getLength() < 3 && inputHandler.isKeyDown(KEY_KEY_F) && !inputHandler.wasKeyDown(KEY_KEY_F)) {
btTransform transform = getRigidBody()->getCenterOfMassTransform();
if (door->getDirection() == 1 && playerPos.X < doorPos.X && !door->isExit()) {
transform.setOrigin(btVector3(doorPos.X + 2.0f, playerPos.Y, doorPos.Z));
}
else if (door->getDirection() == 2 && playerPos.X > doorPos.X && !door->isExit()) {
transform.setOrigin(btVector3(doorPos.X - 2.0f, playerPos.Y, doorPos.Z));
}
else if (door->getDirection() == 3 && playerPos.Z < doorPos.Z && !door->isExit()) {
transform.setOrigin(btVector3(doorPos.X, playerPos.Y, doorPos.Z + 2.0f));
}
else if (door->getDirection() == 4 && playerPos.Z > doorPos.Z && !door->isExit()) {
transform.setOrigin(btVector3(doorPos.X, playerPos.Y, doorPos.Z - 2.0f));
}
else if (door->getDirection() == 2 && playerPos.X > doorPos.X && door->isExit() && _hasKey) {
//exitdoor with key
game.setEndCause((allItemsCollected() ? "win" : "fail"));
game.setNoiseMade(_startingNoise - _noiseAllowance);
inputHandler.setEnded(true);
}
else if (door->getDirection() == 2 && playerPos.X > doorPos.X && door->isExit() && !_hasKey){
game.getAudioEngine()->play2D("sounds/common/locked_door.wav");
}
getRigidBody()->setCenterOfMassTransform(transform);
}
doorIter++;
}
/* GET THE ROOM THE PLAYER IS IN */
std::list<Entity*>* rooms = EntityManager::getNamedEntities("Room");
playerPos = _node->getPosition();
auto iterator = rooms->begin();
while (iterator != rooms->end()){
Room* room = (Room*)(*iterator);
vector3df roomPos = room->getPosition();
vector3df roomScale = room->getScale();
vector3df toPlayer = playerPos - roomPos;
if (toPlayer.getLength() < roomScale.Z / 2)
setCurrentRoom(room->getName());
iterator++;
}
if (_noiseAllowance<0.0f){
game.setEndCause("lose");
inputHandler.setEnded(true);
}
}