当前位置: 首页>>代码示例>>C++>>正文


C++ Being::getName方法代码示例

本文整理汇总了C++中Being::getName方法的典型用法代码示例。如果您正苦于以下问题:C++ Being::getName方法的具体用法?C++ Being::getName怎么用?C++ Being::getName使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Being的用法示例。


在下文中一共展示了Being::getName方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: 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;
    }
}
开发者ID:Ablu,项目名称:invertika,代码行数:18,代码来源:beingmanager.cpp

示例2: 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;
    }
}
开发者ID:Ablu,项目名称:invertika,代码行数:12,代码来源:beingmanager.cpp

示例3:

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;
}
开发者ID:Ablu,项目名称:invertika,代码行数:13,代码来源:beingmanager.cpp

示例4: 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);
}
开发者ID:Evonline,项目名称:ManaPlus,代码行数:19,代码来源:partyhandler.cpp

示例5: handleGameChatMessage

void ChatHandler::handleGameChatMessage(Net::MessageIn &msg)
{
    short id = msg.readInt16();
    std::string chatMsg = msg.readString();

    if (id == 0)
    {
        localChatTab->chatLog(chatMsg, BY_SERVER);
        return;
    }

    Being *being = beingManager->findBeing(id);

    std::string mes;
    if (being)
    {
        mes = being->getName() + " : " + chatMsg;
        being->setSpeech(chatMsg, SPEECH_TIME);
    }
    else
        mes = "Unknown : " + chatMsg;

    localChatTab->chatLog(mes, being == player_node ? BY_PLAYER : BY_OTHER);
}
开发者ID:weimingtom,项目名称:guichan-input,代码行数:24,代码来源:chathandler.cpp

示例6: informPlayer


//.........这里部分代码省略.........

            if (oold == opos)
            {
                // o does not move, nothing more to report.
                continue;
            }
        }

        if (!willBeInRange)
        {
            // o is no longer visible from p. Send leave message.
            MessageOut leaveMsg(GPMSG_BEING_LEAVE);
            leaveMsg.writeInt16(oid);
            gameHandler->sendTo(p, leaveMsg);
            continue;
        }

        if (!wereInRange)
        {
            // o is now visible by p. Send enter message.
            MessageOut enterMsg(GPMSG_BEING_ENTER);
            enterMsg.writeInt8(otype);
            enterMsg.writeInt16(oid);
            enterMsg.writeInt8(static_cast< Being *>(o)->getAction());
            enterMsg.writeInt16(opos.x);
            enterMsg.writeInt16(opos.y);
            enterMsg.writeInt8(o->getDirection());
            enterMsg.writeInt8(o->getGender());
            switch (otype)
            {
                case OBJECT_CHARACTER:
                {
                    Character *q = static_cast< Character * >(o);
                    enterMsg.writeString(q->getName());
                    enterMsg.writeInt8(q->getHairStyle());
                    enterMsg.writeInt8(q->getHairColor());
                    serializeLooks(q, enterMsg);
                } break;

                case OBJECT_MONSTER:
                {
                    Monster *q = static_cast< Monster * >(o);
                    enterMsg.writeInt16(q->getSpecy()->getId());
                    enterMsg.writeString(q->getName());
                } break;

                case OBJECT_NPC:
                {
                    NpcComponent *npcComponent = o->getComponent<NpcComponent>();
                    enterMsg.writeInt16(npcComponent->getNpcId());
                    enterMsg.writeString(o->getName());
                } break;

                default:
                    assert(false); // TODO
                    break;
            }
            gameHandler->sendTo(p, enterMsg);
        }

        if (opos != oold)
        {
            // Add position check coords every 5 seconds.
            if (currentTick % 50 == 0)
                flags |= MOVING_POSITION;
开发者ID:hanwujunlc,项目名称:manaserv,代码行数:66,代码来源:state.cpp

示例7: 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
//.........这里部分代码省略.........
开发者ID:mekolat,项目名称:elektrogamesvn,代码行数:101,代码来源:popupmenu.cpp

示例8: handleMessage

void TradeHandler::handleMessage(Net::MessageIn &msg)
{
    switch (msg.getId())
    {
        case GPMSG_TRADE_REQUEST:
        {
            Being *being = actorSpriteManager->findBeing(msg.readInt16());
            if (!being || !mAcceptTradeRequests)
            {
                respond(false);
                break;
            }
            mTrading = true;
            tradePartnerName = being->getName();
            tradePartnerID = being->getId();
            ConfirmDialog *dlg = new ConfirmDialog(_("Request for Trade"),
                    strprintf(_("%s wants to trade with you, do you accept?"),
                            tradePartnerName.c_str()));
            dlg->addActionListener(&listener);
        }   break;

        case GPMSG_TRADE_ADD_ITEM:
        {
            int type = msg.readInt16();
            int amount = msg.readInt8();
            tradeWindow->addItem(type, false, amount);
        }   break;

        case GPMSG_TRADE_SET_MONEY:
            tradeWindow->setMoney(msg.readInt32());
            break;

        case GPMSG_TRADE_START:
            tradeWindow->reset();
            tradeWindow->setCaption(strprintf(_("Trading with %s"),
                                              tradePartnerName.c_str()));
            tradeWindow->setVisible(true);
            break;

        case GPMSG_TRADE_BOTH_CONFIRM:
            tradeWindow->receivedOk(false);
            break;

        case GPMSG_TRADE_AGREED:
            tradeWindow->receivedOk(false);
            break;

        case GPMSG_TRADE_CANCEL:
            SERVER_NOTICE(_("Trade canceled."))
            tradeWindow->setVisible(false);
            tradeWindow->reset();
            mTrading = false;
            break;

        case GPMSG_TRADE_COMPLETE:
            SERVER_NOTICE(_("Trade completed."))
            tradeWindow->setVisible(false);
            tradeWindow->reset();
            mTrading = false;
            break;
    }
}
开发者ID:TonyRice,项目名称:mana,代码行数:62,代码来源:tradehandler.cpp

示例9: handleSpawn

static void handleSpawn(Character *player, std::string &args)
{
    MonsterClass *mc;
    MapComposite *map = player->getMap();
    const Point &pos = player->getPosition();
    int value = 0;

    // get the arguments
    std::string monsterclass = getArgument(args);
    std::string valuestr = getArgument(args);

    // check all arguments are there
    if (monsterclass.empty())
    {
        say("Invalid amount of arguments given.", player);
        say("Usage: @spawn <monster> [number]", player);
        return;
    }

    // identify the monster type
    if (utils::isNumeric(monsterclass))
    {
        int id = utils::stringToInt(monsterclass);
        mc = monsterManager->getMonster(id);
    }
    else
    {
        mc = monsterManager->getMonsterByName(monsterclass);
    }
    // check for valid monster
    if (!mc)
    {
        say("Invalid monster", player);
        return;
    }

    //identify the amount
    if  (valuestr.empty())
    {
        value = 1;
    }
    else if (utils::isNumeric(valuestr))
    {
        value = utils::stringToInt(valuestr);
    }
    // check for valid amount
    if (value <= 0)
    {
        say("Invalid number of monsters", player);
        return;
    }

    // create the monsters and put them on the map
    for (int i = 0; i < value; ++i)
    {
        Being *monster = new Monster(mc);
        monster->setMap(map);
        monster->setPosition(pos);
        monster->clearDestination();
        if (!GameState::insertOrDelete(monster))
        {
            // The map is full. Break out.
            break;
        }

        // log transaction
        std::string msg = "User created monster " + monster->getName();
        accountHandler->sendTransaction(player->getDatabaseID(), TRANS_CMD_SPAWN, msg);
    }
}
开发者ID:cubemoon,项目名称:manaserv,代码行数:70,代码来源:commandhandler.cpp

示例10: handleMessage


//.........这里部分代码省略.........
                    return;

                if (player_relations.hasPermission(nick, PlayerRelation::WHISPER))
                {
                    Event event(Event::Whisper);
                    event.setString("nick", nick);
                    event.setString("message", chatMsg);
                    event.trigger(Event::ChatChannel);
                }
            }
            else
            {
                SERVER_NOTICE(chatMsg)
            }

            break;

        // Received speech from being
        case SMSG_BEING_CHAT:
        {
            chatMsgLength = msg.readInt16() - 8;
            int beingId = msg.readInt32();
            being = actorSpriteManager->findBeing(beingId);

            if (!being || chatMsgLength <= 0)
                break;

            chatMsg = msg.readString(chatMsgLength);

            std::string::size_type pos = chatMsg.find(" : ", 0);
            std::string sender_name = ((pos == std::string::npos)
                                       ? "" : chatMsg.substr(0, pos));

            if (sender_name != being->getName()
                && being->getType() == Being::PLAYER)
            {
                if (!being->getName().empty())
                    sender_name = being->getName();
            }
            else
            {
                chatMsg.erase(0, pos + 3);
            }

            int perms;

            if (being->getType() == Being::PLAYER)
            {
                perms = player_relations.checkPermissionSilently(sender_name,
                    PlayerRelation::SPEECH_LOG | PlayerRelation::SPEECH_FLOAT);
            }
            else
            {
                perms = player_relations.getDefault()
                        & (PlayerRelation::SPEECH_LOG
                           | PlayerRelation::SPEECH_FLOAT);
            }

            trim(chatMsg);

            std::string reducedMessage = chatMsg;
            chatMsg = removeColors(sender_name) + " : " + reducedMessage;

            Event event(Event::Being);
            event.setString("message", chatMsg);
            event.setString("text", reducedMessage);
开发者ID:jurkan,项目名称:mana,代码行数:67,代码来源:chathandler.cpp

示例11: handleMessage

void PartyHandler::handleMessage(MessageIn *msg)
{
    switch (msg->getId())
    {
        case SMSG_PARTY_CREATE:
            mParty->createResponse(msg->readInt8());
            break;
        case SMSG_PARTY_INFO:
            break;
        case SMSG_PARTY_INVITE:
            {
                std::string nick = msg->readString(24);
                int status = msg->readInt8();
                mParty->inviteResponse(nick, status);
                break;
            }
        case SMSG_PARTY_INVITED:
            {
                int id = msg->readInt32();
                Being *being = beingManager->findBeing(id);
                if (!being)
                {
                    break;
                }
                std::string nick;
                int gender = 0;
                std::string partyName = "";
                if (being->getType() != Being::PLAYER)
                {
                    nick = "";
                }
                else
                {
                    nick = being->getName();
                    gender = being->getGender();
                    partyName = msg->readString(24);
                }
                mParty->invitedAsk(nick, gender, partyName);
                break;
            }
        case SMSG_PARTY_SETTINGS:
            break;
        case SMSG_PARTY_MEMBER_INFO:
            break;
        case SMSG_PARTY_LEAVE:
            {
                /*int id = */msg->readInt32();
                std::string nick = msg->readString(24);
                /*int fail = */msg->readInt8();
                mParty->leftResponse(nick);
                break;
            }
        case SMSG_PARTY_UPDATE_HP:
            break;
        case SMSG_PARTY_UPDATE_COORDS:
            break;
        case SMSG_PARTY_MESSAGE:
            { // new block to enable local variables
                int msgLength = msg->readInt16() - 8;
                if (msgLength <= 0)
                    return;

                int id = msg->readInt32();
                Being *being = beingManager->findBeing(id);
                std::string chatMsg = msg->readString(msgLength);
                mParty->receiveChat(being, chatMsg);
            }
            break;
    }
}
开发者ID:Aethyra,项目名称:Client,代码行数:70,代码来源:partyhandler.cpp

示例12: logic

void TargetDebugTab::logic()
{
    if (player_node && player_node->getTarget())
    {
        Being *target = player_node->getTarget();

        mTargetLabel->setCaption(strprintf("%s %s (%d, %d)", _("Target:"),
            target->getName().c_str(), target->getTileX(),
            target->getTileY()));

        mTargetIdLabel->setCaption(strprintf("%s %d",
            _("Target Id:"), target->getId()));
        if (target->getLevel())
        {
            mTargetLevelLabel->setCaption(strprintf("%s %d",
                _("Target Level:"), target->getLevel()));
        }
        else
        {
            mTargetLevelLabel->setCaption(strprintf("%s ?",
                _("Target Level:")));
        }

        mTargetRaceLabel->setCaption(strprintf("%s %s",
            _("Target race:"), target->getRaceName().c_str()));

        mTargetPartyLabel->setCaption(strprintf("%s %s", _("Target Party:"),
            target->getPartyName().c_str()));

        mTargetGuildLabel->setCaption(strprintf("%s %s", _("Target Guild:"),
            target->getGuildName().c_str()));

        mMinHitLabel->setCaption(strprintf("%s %d",
            _("Minimal hit:"), target->getMinHit()));
        mMaxHitLabel->setCaption(strprintf("%s %d",
            _("Maximum hit:"), target->getMaxHit()));
        mCriticalHitLabel->setCaption(strprintf("%s %d",
            _("Critical hit:"), target->getCriticalHit()));

        const int delay = target->getAttackDelay();
        if (delay)
        {
            mAttackDelayLabel->setCaption(strprintf("%s %d",
                _("Attack delay:"), delay));
        }
        else
        {
            mAttackDelayLabel->setCaption(strprintf(
                "%s ?", _("Attack delay:")));
        }
    }
    else
    {
        mTargetLabel->setCaption(strprintf("%s ?", _("Target:")));
        mTargetIdLabel->setCaption(strprintf("%s ?", _("Target Id:")));
        mTargetLevelLabel->setCaption(strprintf("%s ?", _("Target Level:")));
        mTargetPartyLabel->setCaption(strprintf("%s ?", _("Target Party:")));
        mTargetGuildLabel->setCaption(strprintf("%s ?", _("Target Guild:")));
        mAttackDelayLabel->setCaption(strprintf("%s ?", _("Attack delay:")));
        mMinHitLabel->setCaption(strprintf("%s ?", _("Minimal hit:")));
        mMaxHitLabel->setCaption(strprintf("%s ?", _("Maximum hit:")));
        mCriticalHitLabel->setCaption(strprintf("%s ?", _("Critical hit:")));
    }

    mTargetLabel->adjustSize();
    mTargetIdLabel->adjustSize();
    mTargetLevelLabel->adjustSize();
    mTargetPartyLabel->adjustSize();
    mTargetGuildLabel->adjustSize();
    mAttackDelayLabel->adjustSize();
}
开发者ID:EvolOnline,项目名称:ManaPlus,代码行数:71,代码来源:debugwindow.cpp

示例13: handleLink

void PopupMenu::handleLink(const std::string &link)
{
    Being *being = actorSpriteManager->findBeing(mBeingId);

    // Talk To action
    if (link == "talk" && being && being->canTalk())
    {
        being->talkTo();
    }

    // Trade action
    else if (link == "trade" && being &&
             being->getType() == ActorSprite::PLAYER)
    {
        Net::getTradeHandler()->request(being);
        tradePartnerName = being->getName();
    }
    // Attack action
    else if (link == "attack" && being)
    {
        player_node->attack(being, true);
    }
    else if (link == "whisper" && being)
    {
        chatWindow->addInputText("/w \"" + being->getName() + "\" ");
    }
    else if (link == "unignore" && being &&
             being->getType() == ActorSprite::PLAYER)
    {
        player_relations.setRelation(being->getName(), PlayerRelation::NEUTRAL);
    }

    else if (link == "ignore" && being &&
             being->getType() == ActorSprite::PLAYER)
    {
        player_relations.setRelation(being->getName(), PlayerRelation::IGNORED);
    }

    else if (link == "disregard" && being &&
             being->getType() == ActorSprite::PLAYER)
    {
        player_relations.setRelation(being->getName(), PlayerRelation::DISREGARDED);
    }

    else if (link == "friend" && being &&
             being->getType() == ActorSprite::PLAYER)
    {
        player_relations.setRelation(being->getName(), PlayerRelation::FRIEND);
    }
    // Guild action
    else if (link == "guild" && being &&
             being->getType() == ActorSprite::PLAYER)
    {
        player_node->inviteToGuild(being);
    }

    // Follow Player action
    else if (link == "follow" && being)
    {
        player_node->setFollow(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
        {
            Net::getInventoryHandler()->useItem(mItem);
        }
    }

    else if (link == "chat")
    {
        if (mItem)
            chatWindow->addItemText(mItem->getInfo().getName());
        else if (mFloorItem)
            chatWindow->addItemText(mFloorItem->getInfo().getName());
    }

    else if (link == "split")
    {
        ItemAmountWindow::showWindow(ItemAmountWindow::ItemSplit,
//.........这里部分代码省略.........
开发者ID:Ablu,项目名称:invertika,代码行数:101,代码来源:popupmenu.cpp


注:本文中的Being::getName方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。