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


C++ Being类代码示例

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


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

示例1: while

void BeingHandler::handleBeingsDamageMessage(Net::MessageIn &msg)
{
    while (msg.getUnreadLength())
    {
        Being *being = actorSpriteManager->findBeing(msg.readInt16());
        int damage = msg.readInt16();
        if (being)
        {
            being->takeDamage(0, damage, Being::HIT);
        }
    }
}
开发者ID:mobilehub,项目名称:mana,代码行数:12,代码来源:beinghandler.cpp

示例2: getEverything

void MapComposite::update()
{
    // Update object status
    const std::vector< Entity * > &entities = getEverything();
    for (std::vector< Entity * >::const_iterator it = entities.begin(),
         it_end = entities.end(); it != it_end; ++it)
    {
        (*it)->update();
    }

    if (mUpdateCallback.isValid())
    {
        Script *s = ScriptManager::currentState();
        s->setMap(this);
        s->prepare(mUpdateCallback);
        s->push(mID);
        s->execute();
    }

    // Move objects around and update zones.
    for (BeingIterator it(getWholeMapIterator()); it; ++it)
    {
        (*it)->move();
    }

    for (int i = 0; i < mContent->mapHeight * mContent->mapWidth; ++i)
    {
        mContent->zones[i].destinations.clear();
    }

    // Cannot use a WholeMap iterator as objects will change zones under its feet.
    for (std::vector< Entity * >::iterator i = mContent->entities.begin(),
         i_end = mContent->entities.end(); i != i_end; ++i)
    {
        if (!(*i)->canMove())
            continue;

        Being *obj = static_cast< Being * >(*i);

        const Point &pos1 = obj->getOldPosition(),
                    &pos2 = obj->getPosition();

        MapZone &src = mContent->getZone(pos1),
                &dst = mContent->getZone(pos2);
        if (&src != &dst)
        {
            addZone(src.destinations, &dst - mContent->zones);
            src.remove(obj);
            dst.insert(obj);
        }
    }
}
开发者ID:landoffire,项目名称:manaserv,代码行数:52,代码来源:mapcomposite.cpp

示例3: LOG_DEBUG

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

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

示例5: 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));
    }
}
开发者ID:mobilehub,项目名称:mana,代码行数:13,代码来源:beinghandler.cpp

示例6: handleBeingAttackMessage

void BeingHandler::handleBeingAttackMessage(Net::MessageIn &msg)
{
    Being *being = actorSpriteManager->findBeing(msg.readInt16());
    const BeingDirection direction = (BeingDirection) msg.readInt8();
    const int attackType = msg.readInt8();

    if (!being)
        return;

    being->setDirection(direction);

    being->setAction(Being::ATTACK, attackType);
}
开发者ID:mobilehub,项目名称:mana,代码行数:13,代码来源:beinghandler.cpp

示例7:

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

示例8: draw

void DebugWindow::draw(gcn::Graphics *g)
{
    Window::draw(g);

    if (player_node)
    {
        Being *target = player_node->getTarget();
        if (target)
        {
            Graphics *g2 = static_cast<Graphics*>(g);
            target->draw(g2, -target->getPixelX() + 16 + getWidth() / 2,
                         -target->getPixelY() + 32 + getHeight() / 2);
        }
    }
}
开发者ID:EvolOnline,项目名称:ManaPlus,代码行数:15,代码来源:debugwindow.cpp

示例9:

static Being *findBeingNear(Actor *p, int id)
{
    MapComposite *map = p->getMap();
    const Point &ppos = p->getPosition();
    // See map.h for tiles constants
    const int pixelDist = DEFAULT_TILE_LENGTH * TILES_TO_BE_NEAR;
    for (BeingIterator i(map->getAroundPointIterator(ppos, pixelDist)); i; ++i)
    {
        Being *b = *i;
        if (b->getPublicID() != id)
            continue;
        return ppos.inRangeOf(b->getPosition(), pixelDist) ? b : 0;
    }
    return 0;
}
开发者ID:hanwujunlc,项目名称:manaserv,代码行数:15,代码来源:gamehandler.cpp

示例10: detailspage

Command Interface::detailspage(Being & b) {
    Command c;
    bool viewingplayer = false;

    do {
        Being & viewed = (viewingplayer ? GAME.being[0] : b);
        displaydetails(viewed);
        if (viewed.isplayer) {
            if (b.isplayer)
                msg("Viewing your system details. Press any key...");
            else {
                char msgbuf[128];

                strcpy(msgbuf, "\
Viewing your system details. Press d to view ");
                strcat(msgbuf, b.getname());
                strcat(msgbuf, "'s systems.");
                msg(msgbuf);
            }
        }
        else {
            char msgbuf[128];

            strcpy(msgbuf, "Viewing ");
            strcat(msgbuf, viewed.getname());
            strcat(msgbuf, "'s system details. Press d to view your systems.");
            msg(msgbuf);
        }
        c = getcommand();
        if (c == COMMAND_DETAILS)
            if (b.isplayer)
                c = COMMAND_UNDEFINED;
            else
                viewingplayer = !viewingplayer;
    } while (c == COMMAND_DETAILS);
开发者ID:amagnasco,项目名称:scrap,代码行数:35,代码来源:ui.cpp

示例11: 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;
        }
    }
}
开发者ID:B-Rich,项目名称:mana,代码行数:47,代码来源:buysellhandler.cpp

示例12: changeAnger

void Monster::changeAnger(Actor *target, int amount)
{
    if (target && (target->getType() == OBJECT_MONSTER
        || target->getType() == OBJECT_CHARACTER))
    {
        Being *t = static_cast< Being * >(target);
        if (mAnger.find(t) != mAnger.end())
        {
            mAnger[t] += amount;
        }
        else
        {
            mAnger[t] = amount;
            t->addListener(&mTargetListener);
        }
    }
}
开发者ID:cubemoon,项目名称:manaserv,代码行数:17,代码来源:monster.cpp

示例13: mDisplayName

void Being::showName()
{
    delete mDispName;
    mDispName = 0;
    std::string mDisplayName(mName);

    Being* player =  static_cast<Being*>(this);
    if (player)
    {
        if (config.getBoolValue("showgender"))
        {
            if (getGender() == GENDER_FEMALE)
                mDisplayName += " \u2640";
            else if (getGender() == GENDER_MALE)
                mDisplayName += " \u2642";
        }

        // Display the IP when under tmw-Athena (GM only).
        if (Net::getNetworkType() == ServerInfo::TMWATHENA && local_player
        && local_player->getShowIp() && player->getIp())
        {
            mDisplayName += strprintf(" %s", ipToString(player->getIp()));
        }
    }

    if (getType() == MONSTER)
    {
        if (config.getBoolValue("showMonstersTakedDamage"))
        {
            mDisplayName += ", " + toString(getDamageTaken());
        }
    }

    gcn::Font *font = 0;
    if (local_player && local_player->getTarget() == this
        && getType() != MONSTER)
    {
        font = boldFont;
    }

    mDispName = new FlashText(mDisplayName, getPixelX(), getPixelY(),
                              gcn::Graphics::CENTER, mNameColor, font);

    updateCoords();
}
开发者ID:Ablu,项目名称:mana,代码行数:45,代码来源:being.cpp

示例14: spawn

static void spawn(Character *from, MonsterClass *specy, int nb)
{
    MapComposite *map = from->getMap();
    const Point &pos = from->getPosition();

    for (int i = 0; i < nb; ++i)
    {
        Being *monster = new Monster(specy);
        monster->setMap(map);
        monster->setPosition(pos);
        monster->clearDestination();
        if (!GameState::insertSafe(monster))
        {
            // The map is full. Break out.
            break;
        }
    }
}
开发者ID:Ablu,项目名称:invertika,代码行数:18,代码来源:command.cpp

示例15: while

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


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