示例#1
0
文件: being.cpp 项目: Ablu/mana
void Being::setSubtype(Uint16 subtype)
{
    if (subtype == mSubType)
        return;

    mSubType = subtype;

    if (getType() == MONSTER)
    {
        mInfo = MonsterDB::get(mSubType);
        setName(mInfo->getName());
        setupSpriteDisplay(mInfo->getDisplay());
    }
    else if (getType() == NPC)
    {
        mInfo = NPCDB::get(mSubType);
        setupSpriteDisplay(mInfo->getDisplay(), false);
    }
    else if (getType() == PLAYER)
    {
        int id = -100 - subtype;

        // Prevent showing errors when sprite doesn't exist
        if (!itemDb->exists(id))
            id = -100;

        setSprite(Net::getCharHandler()->baseSprite(), id);
    }
}
示例#2
0
void FloorItem::postInit(Map *const map, int subX, int subY)
{
    setMap(map);
    const ItemInfo &info = ItemDB::get(mItemId);
    if (map)
    {
        const int max = info.getMaxFloorOffset();
        if (subX > max)
            subX = max;
        else if (subX < -max)
            subX = -max;
        if (subY > max)
            subY = max;
        else if (subY < -max)
            subY = -max;
        mPos.x = static_cast<float>(mX * map->getTileWidth()
            + subX + mapTileSize / 2 - 8);
        mPos.y = static_cast<float>(mY * map->getTileHeight()
            + subY + mapTileSize - 8);
    }
    else
    {
        mPos.x = 0;
        mPos.y = 0;
    }

    mCursor = info.getPickupCursor();
    setupSpriteDisplay(info.getDisplay(), true, 1,
        info.getDyeColorsString(mColor));
    mYDiff = 31;
}
示例#3
0
void FloorItem::postInit(Map *const map, int subX, int subY)
{
    setMap(map);
    const ItemInfo &info = ItemDB::get(mItemId);
    if (map)
    {
        const int maxX = info.getMaxFloorOffsetX();
        const int maxY = info.getMaxFloorOffsetY();

        if (!serverFeatures->haveExtendedDropsPosition())
        {
            if (subX > maxX)
                subX = maxX;
            else if (subX < -maxX)
                subX = -maxX;
            if (subY > maxY)
                subY = maxY;
            else if (subY < -maxY)
                subY = -maxY;

            subX -= 8;
            subY -= 8;
        }

        mHeightPosDiff = map->getHeightOffset(mX, mY) * 16;
        mPixelX = mX * map->getTileWidth()
                  + subX + mapTileSize / 2;
        mPixelY = mY * map->getTileHeight()
                  + subY + mapTileSize - mHeightPosDiff;
        mPos.x = static_cast<float>(mPixelX);
        mPos.y = static_cast<float>(mPixelY);
        mYDiff = 31 - mHeightPosDiff;
    }
    else
    {
        mPixelX = 0;
        mPixelY = 0;
        mPos.x = 0;
        mPos.y = 0;
        mYDiff = 31;
    }

    mCursor = info.getPickupCursor();
    setupSpriteDisplay(info.getDisplay(),
                       ForceDisplay_true,
                       1,
                       info.getDyeIconColorsString(mColor));
}
示例#4
0
文件: flooritem.cpp 项目: Ablu/mana
FloorItem::FloorItem(int id,
                     int itemId,
                     const Vector &position,
                     Map *map):
    ActorSprite(id),
    mItemId(itemId),
    mX(0), mY(0)
{
    mPos = position;

    setMap(map);

    mX = (int)position.x / map->getTileWidth();
    mY = (int)position.y / map->getTileHeight();

    setupSpriteDisplay(itemDb->get(itemId).getDisplay());
}
示例#5
0
文件: npc.cpp 项目: Ablu/invertika
void NPC::setSubtype(Uint16 subtype)
{
    Being::setSubtype(subtype);

    setupSpriteDisplay(NPCDB::get(subtype), false);
}