本文整理汇总了C++中Being::getType方法的典型用法代码示例。如果您正苦于以下问题:C++ Being::getType方法的具体用法?C++ Being::getType怎么用?C++ Being::getType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Being
的用法示例。
在下文中一共展示了Being::getType方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: abs
Being *BeingManager::findNearestLivingBeing(Being *aroundBeing, int maxdist,
Being::Type type) const
{
Being *closestBeing = NULL;
int dist = 0;
int x = aroundBeing->mX;
int y = aroundBeing->mY;
for (Beings::const_iterator i = mBeings.begin(), i_end = mBeings.end();
i != i_end; ++i)
{
Being *being = (*i);
int d = std::max(abs(being->mX - x), abs(being->mY - y));
if ((being->getType() == type || type == Being::UNKNOWN)
&& (d < dist || closestBeing == NULL) // it is closer
&& being->mAction != Being::DEAD // no dead beings
&& being != aroundBeing)
{
dist = d;
closestBeing = being;
}
}
return (maxdist >= dist) ? closestBeing : NULL;
}
示例2: abs
Being *BeingManager::findNearestLivingBeing(int x, int y,
int maxTileDist,
Being::Type type) const
{
Being *closestBeing = 0;
int dist = 0;
const int maxDist = maxTileDist * 32;
Beings::const_iterator itr = mBeings.begin();
Beings::const_iterator itr_end = mBeings.end();
for (; itr != itr_end; ++itr)
{
Being *being = (*itr);
const Vector &pos = being->getPosition();
int d = abs(((int) pos.x) - x) + abs(((int) pos.y) - y);
if ((being->getType() == type || type == Being::UNKNOWN)
&& (d < dist || !closestBeing) // it is closer
&& being->isAlive()) // no dead beings
{
dist = d;
closestBeing = being;
}
}
return (maxDist >= dist) ? closestBeing : 0;
}
示例3: operator
bool operator() (ActorSprite *actor)
{
if (actor->getType() == ActorSprite::FLOOR_ITEM)
return false;
Game *game = Game::instance();
if (!game)
return false;
Being* b = static_cast<Being*>(actor);
uint16_t other_y = y + ((b->getType() == ActorSprite::NPC) ? 1 : 0);
const Vector &pos = b->getPosition();
return ((int) pos.x / game->getCurrentTileWidth() == x &&
((int) pos.y / game->getCurrentTileHeight() == y
|| (int) pos.y / game->getCurrentTileHeight() == other_y) &&
b->isAlive() &&
(type == ActorSprite::UNKNOWN || b->getType() == type));
}
示例4: getPlayerNames
void BeingManager::getPlayerNames(std::vector<std::string> &names,
bool npcNames)
{
Beings::iterator i = mBeings.begin();
names.clear();
while (i != mBeings.end())
{
Being *being = (*i);
if ((being->getType() == Being::PLAYER
|| (being->getType() == Being::NPC && npcNames))
&& being->getName() != "")
{
names.push_back(being->getName());
}
++i;
}
}
示例5: updatePlayerNames
void BeingManager::updatePlayerNames()
{
Beings::iterator i = mBeings.begin();
while (i != mBeings.end())
{
Being *being = (*i);
if (being->getType() == Being::PLAYER && being->getName() != "")
being->updateName();
++i;
}
}
示例6: handleAttack
void GameHandler::handleAttack(GameClient &client, MessageIn &message)
{
int id = message.readInt16();
LOG_DEBUG("Character " << client.character->getPublicID()
<< " attacked being " << id);
Being *being = findBeingNear(client.character, id);
if (being && being->getType() != OBJECT_NPC)
{
client.character->setTarget(being);
client.character->setAction(ATTACK);
}
}
示例7: forgetTarget
void Monster::forgetTarget(Entity *t)
{
Being *b = static_cast< Being * >(t);
mAnger.erase(b);
b->removeListener(&mTargetListener);
if (b->getType() == OBJECT_CHARACTER)
{
Character *c = static_cast< Character * >(b);
mExpReceivers.erase(c);
mLegalExpReceivers.erase(c);
}
}
示例8:
Being *BeingManager::findBeingByName(const std::string &name,
Being::Type type) const
{
for (Beings::const_iterator i = mBeings.begin(), i_end = mBeings.end();
i != i_end; ++i)
{
Being *being = (*i);
if (being->getName() == name &&
(type == Being::UNKNOWN || type == being->getType()))
return being;
}
return NULL;
}
示例9: handleBeingLooksChangeMessage
void BeingHandler::handleBeingLooksChangeMessage(Net::MessageIn &msg)
{
Being *being = actorSpriteManager->findBeing(msg.readInt16());
if (!being || being->getType() != ActorSprite::PLAYER)
return;
handleLooks(being, msg);
if (msg.getUnreadLength())
{
int style = msg.readInt16();
int color = msg.readInt16();
being->setSprite(SPRITE_HAIR, style * -1, ColorDB::get(color));
}
}
示例10: handleMessage
void BuySellHandler::handleMessage(Net::MessageIn &msg)
{
Being *being = actorSpriteManager->findBeing(msg.readInt16());
if (!being || being->getType() != ActorSprite::NPC)
{
return;
}
int npcId = being->getId();
switch (msg.getId())
{
case GPMSG_NPC_BUY:
{
BuyDialog* dialog = new BuyDialog(npcId);
dialog->reset();
dialog->setMoney(PlayerInfo::getAttribute(MONEY));
while (msg.getUnreadLength())
{
int itemId = msg.readInt16();
int amount = msg.readInt16();
int value = msg.readInt16();
dialog->addItem(itemId, amount, value);
}
break;
}
case GPMSG_NPC_SELL:
{
SellDialog* dialog = new SellDialog(npcId);
dialog->reset();
dialog->setMoney(PlayerInfo::getAttribute(MONEY));
while (msg.getUnreadLength())
{
int itemId = msg.readInt16();
int amount = msg.readInt16();
int value = msg.readInt16();
dialog->addItem(new Item(itemId, amount, false), value);
}
break;
}
}
}
示例11: processPartyLeave
void PartyHandler::processPartyLeave(Net::MessageIn &msg)
{
int id = msg.readInt32();
std::string nick = msg.readString(24);
msg.readInt8(); // fail
if (!player_node)
return;
if (id == player_node->getId())
{
if (Ea::taParty)
{
Ea::taParty->removeFromMembers();
Ea::taParty->clearMembers();
}
SERVER_NOTICE(_("You have left the party."))
delete Ea::partyTab;
Ea::partyTab = nullptr;
if (socialWindow && Ea::taParty)
socialWindow->removeTab(Ea::taParty);
player_node->setPartyName("");
}
else
{
if (Ea::partyTab)
{
Ea::partyTab->chatLog(strprintf(
_("%s has left your party."),
nick.c_str()), BY_SERVER);
}
if (actorSpriteManager)
{
Being *b = actorSpriteManager->findBeing(id);
if (b && b->getType() == Being::PLAYER)
{
b->setParty(nullptr);
b->setPartyName("");
}
}
if (Ea::taParty)
Ea::taParty->removeMember(id);
}
}
示例12: processPartyInvited
void PartyHandler::processPartyInvited(Net::MessageIn &msg)
{
int id = msg.readInt32();
std::string partyName = msg.readString(24);
std::string nick("");
Being *being;
if (actorSpriteManager)
{
if ((being = actorSpriteManager->findBeing(id)))
{
if (being && being->getType() == Being::PLAYER)
nick = being->getName();
}
}
if (socialWindow)
socialWindow->showPartyInvite(partyName, nick);
}
示例13: handleMessage
void BuySellHandler::handleMessage(MessageIn &msg)
{
Being *being = beingManager->findBeing(msg.readInt16());
if (!being || being->getType() != Being::NPC)
{
return;
}
current_npc = being->getId();
switch (msg.getId())
{
case GPMSG_NPC_BUY:
buyDialog->reset();
buyDialog->setMoney(player_node->getMoney());
buyDialog->setVisible(true);
while (msg.getUnreadLength())
{
int itemId = msg.readInt16();
int amount = msg.readInt16();
int value = msg.readInt16();
buyDialog->addItem(itemId, amount, value);
}
break;
case GPMSG_NPC_SELL:
sellDialog->setMoney(player_node->getMoney());
sellDialog->reset();
sellDialog->setVisible(true);
while (msg.getUnreadLength())
{
int itemId = msg.readInt16();
int amount = msg.readInt16();
int value = msg.readInt16();
sellDialog->addItem(new Item(itemId, amount, false), value);
}
break;
}
}
示例14: handleJoystickInput
void InputManager::handleJoystickInput(const SDL_Event &event)
{
if (joystick)
joystick->update();
else
return;
if (!stateManager->isInGame())
return;
if (event.type == SDL_JOYBUTTONUP && !joystick->buttonPressed(3))
{
targetKeyHeld = false; // Stop protecting the target key
}
else if (player_node && player_node->mAction != Being::DEAD)
{
const Uint16 x = player_node->mX;
const Uint16 y = player_node->mY;
if (!keyboard.isKeyActive(keyboard.KEY_CLEAR_TARGET))
{
Being *target = player_node->getTarget();
// Target the nearest monster
if (joystick->buttonPressed(3) && !targetKeyHeld)
{
target = beingManager->findNearestLivingBeing(x, y, 20,
Being::MONSTER);
player_node->setTarget(target);
targetKeyHeld = true;
}
if (joystick->buttonPressed(0) && target &&
target->getType() != Being::NPC)
{
player_node->attack(target, true);
}
}
if (joystick->buttonPressed(1))
{
FloorItem *item = floorItemManager->findByCoordinates(x, y);
if (item)
player_node->pickUp(item);
}
if (joystick->buttonPressed(2))
player_node->toggleSit();
unsigned char direction = 0;
// Translate pressed keys to movement and direction
if (joystick->isUp())
direction |= Being::UP;
else if (joystick->isDown())
direction |= Being::DOWN;
if (joystick->isLeft())
direction |= Being::LEFT;
else if (joystick->isRight())
direction |= Being::RIGHT;
player_node->setWalkingDir(direction);
}
}
示例15: handleLink
void PopupMenu::handleLink(const std::string &link)
{
Being *being = beingManager->findBeing(mBeingId);
// Talk To actiondar :
if (link == "talk" &&
being &&
being->getType() == Being::NPC &&
current_npc == 0)
{
dynamic_cast<NPC*>(being)->talk();
}
// Trade action
else if (link == "trade" &&
being &&
being->getType() == Being::PLAYER)
{
Net::getTradeHandler()->request(being);
tradePartnerName = being->getName();
}
// Attack action
else if (link == "attack" && being)
{
player_node->attack(being, true);
}
else if (link == "unignore" &&
being &&
being->getType() == Being::PLAYER)
{
player_relations.setRelation(being->getName(), PlayerRelation::NEUTRAL);
}
else if (link == "ignore" &&
being &&
being->getType() == Being::PLAYER)
{
player_relations.setRelation(being->getName(), PlayerRelation::IGNORED);
}
else if (link == "disregard" &&
being &&
being->getType() == Being::PLAYER)
{
player_relations.setRelation(being->getName(), PlayerRelation::DISREGARDED);
}
else if (link == "friend" &&
being &&
being->getType() == Being::PLAYER)
{
player_relations.setRelation(being->getName(), PlayerRelation::FRIEND);
}
#ifdef TMWSERV_SUPPORT
// Guild action
else if (link == "guild" &&
being != NULL &&
being->getType() == Being::PLAYER)
{
player_node->inviteToGuild(being);
}
#endif
/*
// Follow Player action
else if (link == "follow")
{
}*/
/*
// Add Buddy action
else if ((link == "buddy") && being && being->isPlayer())
{
if (!buddyWindow->isVisible())
buddyWindow->setVisible(true);
buddyWindow->addBuddy(being->getName());
}*/
// Pick Up Floor Item action
else if ((link == "pickup") && mFloorItem)
{
player_node->pickUp(mFloorItem);
}
// Look To action
else if (link == "look")
{
}
else if (link == "use")
{
assert(mItem);
if (mItem->isEquipment())
{
if (mItem->isEquipped())
Net::getInventoryHandler()->unequipItem(mItem);
else
Net::getInventoryHandler()->equipItem(mItem);
}
else
//.........这里部分代码省略.........