當前位置: 首頁>>代碼示例>>C++>>正文


C++ GetPositionY函數代碼示例

本文整理匯總了C++中GetPositionY函數的典型用法代碼示例。如果您正苦於以下問題:C++ GetPositionY函數的具體用法?C++ GetPositionY怎麽用?C++ GetPositionY使用的例子?那麽, 這裏精選的函數代碼示例或許可以為您提供幫助。


在下文中一共展示了GetPositionY函數的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的C++代碼示例。

示例1: GetMap

 Creature* Transport::AddNPCPassengerInInstance(uint32 entry, float x, float y, float z, float o, uint32 anim)
 {
        Map* map = GetMap();
        Creature* pCreature = new Creature;

        if (!pCreature->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_UNIT), map, GetPhaseMask(), entry, 0, GetGOInfo()->faction, 0, 0, 0, 0))
        {
                delete pCreature;
                return NULL;
        }

        pCreature->SetTransport(this);
        pCreature->AddUnitMovementFlag(MOVEMENTFLAG_ONTRANSPORT);
        pCreature->m_movementInfo.guid = GetGUID();
        pCreature->m_movementInfo.t_pos.Relocate(x, y, z, o);
        o += GetOrientation();
        MapManager::NormalizeOrientation(o);

        pCreature->Relocate(
            GetPositionX() + (x * cos(GetOrientation()) + y * sin(GetOrientation() + float(M_PI))),
            GetPositionY() + (y * cos(GetOrientation()) + x * sin(GetOrientation())),
            z + GetPositionZ() ,
            o);

        if (!pCreature->IsPositionValid())
        {
            sLog->outError("Creature (guidlow %d, entry %d) not created. Suggested coordinates isn't valid (X: %f Y: %f)", pCreature->GetGUIDLow(), pCreature->GetEntry(), pCreature->GetPositionX(), pCreature->GetPositionY());
            delete pCreature;
            return NULL;
        }

        map->Add(pCreature);
        m_NPCPassengerSet.insert(pCreature);

        pCreature->setActive(true);
        sScriptMgr->OnAddCreaturePassenger(this, pCreature);
        return pCreature;
}
開發者ID:BlueSellafield,項目名稱:ArkCORE,代碼行數:38,代碼來源:Transport.cpp

示例2: GetMap

Creature* Transport::CreateNPCPassenger(uint32 entry, float x, float y, float z, float o, CreatureData const* data /*= NULL*/)
{
    Map* map = GetMap();
    Creature* creature = new Creature();

    if (!creature->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_UNIT), map, GetPhaseMask(), entry, 0, GetGOInfo()->faction, 0.0f, 0.0f, 0.0f, 0.0f, data))
    {
        delete creature;
        return NULL;
    }

    creature->SetTransport(this);
    creature->AddUnitMovementFlag(MOVEMENTFLAG_ONTRANSPORT);
    creature->m_movementInfo.guid = GetGUID();
    creature->m_movementInfo.t_pos.Relocate(x, y, z, o);
    o += GetOrientation();
    MapManager::NormalizeOrientation(o);

    creature->Relocate(GetPositionX() + (x * cos(GetOrientation()) + y * sin(GetOrientation() + float(M_PI))),
                       GetPositionY() + (y * cos(GetOrientation()) + x * sin(GetOrientation())),
                       z + GetPositionZ(), o);

    creature->SetHomePosition(creature->GetPositionX(), creature->GetPositionY(), creature->GetPositionZ(), creature->GetOrientation());

    if (!creature->IsPositionValid())
    {
        sLog->outError("Creature (guidlow %d, entry %d) not created. Suggested coordinates isn't valid (X: %f Y: %f)",creature->GetGUIDLow(),creature->GetEntry(),creature->GetPositionX(),creature->GetPositionY());
        delete creature;
        return NULL;
    }

    map->AddToMap(creature);
    AddPassenger(creature);
    creature->SetWorldObject(true); //so it will not be unloaded with grid

    sScriptMgr->OnAddCreaturePassenger(this, creature);
    return creature;
}
開發者ID:Devilcleave,項目名稱:TrilliumEMU,代碼行數:38,代碼來源:Transport.cpp

示例3: GetCaster

void DynamicObject::Update(uint32 p_time)
{
    // caster can be not in world at time dynamic object update, but dynamic object not yet deleted in Unit destructor
    Unit* caster = GetCaster();
    if(!caster)
    {
        Delete();
        return;
    }

    bool deleteThis = false;

    if(m_aliveDuration > int32(p_time))
        m_aliveDuration -= p_time;
    else
        deleteThis = true;

    // TODO: make a timer and update this in larger intervals
    CellPair p(MaNGOS::ComputeCellPair(GetPositionX(), GetPositionY()));
    Cell cell = RedZone::GetZone(p);
    cell.data.Part.reserved = ALL_DISTRICT;
    cell.SetNoCreate();

    MaNGOS::DynamicObjectUpdater notifier(*this,caster);

    TypeContainerVisitor<MaNGOS::DynamicObjectUpdater, WorldTypeMapContainer > world_object_notifier(notifier);
    TypeContainerVisitor<MaNGOS::DynamicObjectUpdater, GridTypeMapContainer > grid_object_notifier(notifier);

    CellLock<GridReadGuard> cell_lock(cell, p);
    cell_lock->Visit(cell_lock, world_object_notifier, *MapManager::Instance().GetMap(GetMapId(), this));
    cell_lock->Visit(cell_lock, grid_object_notifier,  *MapManager::Instance().GetMap(GetMapId(), this));

    if(deleteThis)
    {
        caster->RemoveDynObjectWithGUID(GetGUID());
        Delete();
    }
}
開發者ID:Artea,項目名稱:mangos-svn,代碼行數:38,代碼來源:DynamicObject.cpp

示例4: VALUES

void GameObject::SaveToDB()
{
	std::stringstream ss;
	ss << "REPLACE INTO gameobject_spawns VALUES("
		<< ((m_spawn == NULL) ? 0 : m_spawn->id) << ","
		<< GetEntry() << ","
		<< GetMapId() << ","
		<< GetPositionX() << ","
		<< GetPositionY() << ","
		<< GetPositionZ() << ","
		<< GetOrientation() << ","
		<< GetUInt64Value(GAMEOBJECT_ROTATION) << ","
		<< GetFloatValue(GAMEOBJECT_PARENTROTATION) << ","
		<< GetFloatValue(GAMEOBJECT_PARENTROTATION + 2) << ","
		<< GetFloatValue(GAMEOBJECT_PARENTROTATION + 3) << ","
		<< ( GetByte(GAMEOBJECT_BYTES_1, 0)? 1 : 0 ) << ","
		<< GetUInt32Value(GAMEOBJECT_FLAGS) << ","
		<< GetUInt32Value(GAMEOBJECT_FACTION) << ","
		<< GetFloatValue(OBJECT_FIELD_SCALE_X) << ","
		<< m_phaseMode << ","
		<< m_phaseMode << ")";
	WorldDatabase.Execute(ss.str().c_str());
}
開發者ID:arcticdev,項目名稱:arctic-test,代碼行數:23,代碼來源:GameObject.cpp

示例5: RemoveFromWorld

void Transporter::TeleportTransport(uint32 newMapid, uint32 oldmap, float x, float y, float z)
{
    //sEventMgr.RemoveEvents(this, EVENT_TRANSPORTER_NEXT_WAYPOINT);

    RemoveFromWorld(false);
    SetMapId(newMapid);
    SetPosition(x, y, z, m_position.o, false);
    AddToWorld();

    WorldPacket packet(SMSG_TRANSFER_PENDING, 12);
    packet << newMapid;
    packet << getEntry();
    packet << oldmap;

    for (auto passengerGuid : m_passengers)
    {
        auto passenger = objmgr.GetPlayer(passengerGuid);
        if (passenger == nullptr)
            continue;

        passenger->GetSession()->SendPacket(&packet);
        bool teleport_successful = passenger->Teleport(LocationVector(x, y, z, passenger->GetOrientation()), this->GetMapMgr());
        if (!teleport_successful)
        {
            passenger->RepopAtGraveyard(passenger->GetPositionX(), passenger->GetPositionY(), passenger->GetPositionZ(), passenger->GetMapId());
        }
        else
        {
            if (!passenger->HasUnitMovementFlag(MOVEFLAG_TRANSPORT))
            {
                passenger->AddUnitMovementFlag(MOVEFLAG_TRANSPORT);
            }
        }
    }

    this->RespawnCreaturePassengers();
}
開發者ID:armm77,項目名稱:AscEmu,代碼行數:37,代碼來源:TransporterHandler.cpp

示例6: GetMap

// gunship data
Creature* Transport::AddNPCPassengerInInstance(uint32 entry, float x, float y, float z, float o, uint32 anim)
{
    Map* map = GetMap();
    Creature* creature = new Creature;

    if (!creature->Create(sObjectMgr->GenerateLowGuid(HIGHGUID_UNIT), map, GetPhaseMask(), entry, 0, GetGOInfo()->faction, 0, 0, 0, 0))
    {
        delete creature;
        return 0;
    }

    creature->SetTransport(this);
    creature->AddUnitMovementFlag(MOVEMENTFLAG_ONTRANSPORT);
    creature->m_movementInfo.guid = GetGUID();
    creature->m_movementInfo.transport.pos.Relocate(x, y, z, o);

    creature->Relocate(
        GetPositionX() + (x * cos(GetOrientation()) + y * sin(GetOrientation() + float(M_PI))),
        GetPositionY() + (y * cos(GetOrientation()) + x * sin(GetOrientation())),
        z + GetPositionZ(),
        o + GetOrientation());

    creature->SetHomePosition(creature->GetPositionX(), creature->GetPositionY(), creature->GetPositionZ(), creature->GetOrientation());

    if (!creature->IsPositionValid())
    {
        delete creature;
        return 0;
    }

    map->AddToMap(creature);
    m_NPCPassengerSet.insert(creature);

    creature->setActive(true);
    sScriptMgr->OnAddCreaturePassenger(this, creature);
    return creature;
}
開發者ID:mynew2,項目名稱:Gunship,代碼行數:38,代碼來源:Transport.cpp

示例7: VALUES

void Creature::SaveToDB()
{
    sDatabase.BeginTransaction();

    sDatabase.PExecuteLog("DELETE FROM `creature` WHERE `guid` = '%u'", m_DBTableGuid);

    std::ostringstream ss;
    ss << "INSERT INTO `creature` VALUES ("
        << m_DBTableGuid << ","
        << GetEntry() << ","
        << GetMapId() <<","
        << GetPositionX() << ","
        << GetPositionY() << ","
        << GetPositionZ() << ","
        << GetOrientation() << ","
        << m_respawnDelay << ","                            //respawn time
        << (float) 0  << ","                                //spawn distance (float)
        << (uint32) (0) << ","                              //currentwaypoint
        << respawn_cord[0] << ","                           //spawn_position_x
        << respawn_cord[1] << ","                           //spawn_position_y
        << respawn_cord[2] << ","                           //spawn_position_z
        << (float)(0) << ","                                //spawn_orientation
        << GetHealth() << ","                               //curhealth
        << GetPower(POWER_MANA) << ","                      //curmana

        << (uint32)(m_deathState) << ","                    // is it really death state or just state?
    //or
    //<< (uint32)(m_state) << ","                     // is it really death state or just state?

        << GetDefaultMovementType() << ","                  // default movement generator type
        << "'')";                                           // should save auras

    sDatabase.PExecuteLog( ss.str( ).c_str( ) );

    sDatabase.CommitTransaction();
}
開發者ID:chrayn,項目名稱:mangos-06,代碼行數:36,代碼來源:Creature.cpp

示例8: DeleteFromDB

void Corpse::SaveToDB()
{
    // prevent DB data inconsistence problems and duplicates
    SQLTransaction trans = CharacterDatabase.BeginTransaction();
    DeleteFromDB(trans);

    uint16 index = 0;
    PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_CORPSE);
    stmt->setUInt64(index++, GetOwnerGUID().GetCounter());                            // guid
    stmt->setFloat (index++, GetPositionX());                                         // posX
    stmt->setFloat (index++, GetPositionY());                                         // posY
    stmt->setFloat (index++, GetPositionZ());                                         // posZ
    stmt->setFloat (index++, GetOrientation());                                       // orientation
    stmt->setUInt16(index++, GetMapId());                                             // mapId
    stmt->setUInt32(index++, GetUInt32Value(CORPSE_FIELD_DISPLAY_ID));                // displayId
    stmt->setString(index++, _ConcatFields(CORPSE_FIELD_ITEM, EQUIPMENT_SLOT_END));   // itemCache
    stmt->setUInt32(index++, GetUInt32Value(CORPSE_FIELD_BYTES_1));                   // bytes1
    stmt->setUInt32(index++, GetUInt32Value(CORPSE_FIELD_BYTES_2));                   // bytes2
    stmt->setUInt8 (index++, GetUInt32Value(CORPSE_FIELD_FLAGS));                     // flags
    stmt->setUInt8 (index++, GetUInt32Value(CORPSE_FIELD_DYNAMIC_FLAGS));             // dynFlags
    stmt->setUInt32(index++, uint32(m_time));                                         // time
    stmt->setUInt8 (index++, GetType());                                              // corpseType
    stmt->setUInt32(index++, GetInstanceId());                                        // instanceId
    trans->Append(stmt);

    for (uint32 phaseId : GetPhases())
    {
        index = 0;
        stmt = CharacterDatabase.GetPreparedStatement(CHAR_INS_CORPSE_PHASES);
        stmt->setUInt64(index++, GetOwnerGUID().GetCounter());                        // OwnerGuid
        stmt->setUInt32(index++, phaseId);                                            // PhaseId
        trans->Append(stmt);
    }

    CharacterDatabase.CommitTransaction(trans);
}
開發者ID:doriangray2,項目名稱:TrinityCore-devil,代碼行數:36,代碼來源:Corpse.cpp

示例9: GetMap

void Transport::UpdatePosition(float x, float y, float z, float o)
{
    bool newActive = GetMap()->IsGridLoaded(x, y);
    Cell oldCell(GetPositionX(), GetPositionY());

    Relocate(x, y, z, o);
    UpdateModelPosition();

    UpdatePassengerPositions(_passengers);

    /* There are four possible scenarios that trigger loading/unloading passengers:
      1. transport moves from inactive to active grid
      2. the grid that transport is currently in becomes active
      3. transport moves from active to inactive grid
      4. the grid that transport is currently in unloads
    */
    if (_staticPassengers.empty() && newActive) // 1.
        LoadStaticPassengers();
    else if (!_staticPassengers.empty() && !newActive && oldCell.DiffGrid(Cell(GetPositionX(), GetPositionY()))) // 3.
        UnloadStaticPassengers();
    else
        UpdatePassengerPositions(_staticPassengers);
    // 4. is handed by grid unload
}
開發者ID:boom8866,項目名稱:MaddieCore,代碼行數:24,代碼來源:Transport.cpp

示例10: GetMainWindow

void PictureTextCBox::Draw(const Point2i &/*mousePosition*/)
{
  Surface & video_window = GetMainWindow();

  if (m_value) {
    uint enabled_x = GetPositionX() + (GetSizeX() - m_enabled.GetWidth())/2 ;
    uint enabled_y = GetPositionY();
    uint outside_x = std::max(uint(0), GetPositionX() - enabled_x);
    uint outside_y = std::max(uint(0), GetPositionY() - enabled_y);

    enabled_x += outside_x;
    enabled_y += outside_y;
    Rectanglei srcRect(outside_x, outside_y, m_enabled.GetWidth() - outside_x,
                       m_enabled.GetHeight() - outside_y);
    video_window.Blit(m_enabled, srcRect, Point2i(enabled_x, enabled_y));
  } else {
    uint disabled_x = GetPositionX() + (GetSizeX() - m_disabled_back.GetWidth())/2 ;
    uint disabled_y = GetPositionY();
    uint outside_x = std::max(uint(0), GetPositionX() - disabled_x);
    uint outside_y = std::max(uint(0), GetPositionY() - disabled_y);

    disabled_x += outside_x;
    disabled_y += outside_y;
    Rectanglei srcRect(outside_x, outside_y, m_disabled_back.GetWidth() - outside_x,
                       m_disabled_back.GetHeight() - outside_y);
    video_window.Blit(m_disabled_back, srcRect, Point2i(disabled_x, disabled_y));
  }

  // center the image
  uint tmp_x = GetPositionX() + (GetSizeX() - m_image.GetWidth())/2 ;
  uint tmp_y = GetPositionY() + (m_enabled.GetHeight() - m_image.GetHeight())/2;

  video_window.Blit(m_image, Point2i(tmp_x, tmp_y));

  Text::DrawCenterTop(GetPosition() + Point2i(GetSizeX()/2,
                      GetSizeY() - Text::GetHeight()));

  if (!m_value) {
    uint disabled_x = GetPositionX() + (GetSizeX() - m_disabled_front.GetWidth())/2 ;
    uint disabled_y = GetPositionY() + (m_enabled.GetHeight() - m_disabled_front.GetHeight())/2;
    video_window.Blit(m_disabled_front, Point2i(disabled_x, disabled_y));
  }
}
開發者ID:fluxer,項目名稱:warmux,代碼行數:43,代碼來源:picture_text_cbox.cpp

示例11: SetMap

bool DynamicObject::CreateDynamicObject(ObjectGuid::LowType guidlow, Unit* caster, uint32 spellId, Position const& pos, float radius, DynamicObjectType type)
{
    SetMap(caster->GetMap());
    Relocate(pos);
    if (!IsPositionValid())
    {
        TC_LOG_ERROR("misc", "DynamicObject (spell %u) not created. Suggested coordinates isn't valid (X: %f Y: %f)", spellId, GetPositionX(), GetPositionY());
        return false;
    }

    WorldObject::_Create(guidlow, HighGuid::DynamicObject, caster->GetPhaseMask());

    SetEntry(spellId);
    SetObjectScale(1);
    SetGuidValue(DYNAMICOBJECT_CASTER, caster->GetGUID());

    // The lower word of DYNAMICOBJECT_BYTES must be 0x0001. This value means that the visual radius will be overriden
    // by client for most of the "ground patch" visual effect spells and a few "skyfall" ones like Hurricane.
    // If any other value is used, the client will _always_ use the radius provided in DYNAMICOBJECT_RADIUS, but
    // precompensation is necessary (eg radius *= 2) for many spells. Anyway, blizz sends 0x0001 for all the spells
    // I saw sniffed...
    SetByteValue(DYNAMICOBJECT_BYTES, 0, type);
    SetUInt32Value(DYNAMICOBJECT_SPELLID, spellId);
    SetFloatValue(DYNAMICOBJECT_RADIUS, radius);
    SetUInt32Value(DYNAMICOBJECT_CASTTIME, GameTime::GetGameTimeMS());

    if (IsWorldObject())
        setActive(true);    //must before add to map to be put in world container

    Transport* transport = caster->GetTransport();
    if (transport)
    {
        float x, y, z, o;
        pos.GetPosition(x, y, z, o);
        transport->CalculatePassengerOffset(x, y, z, &o);
        m_movementInfo.transport.pos.Relocate(x, y, z, o);

        // This object must be added to transport before adding to map for the client to properly display it
        transport->AddPassenger(this);
    }

    if (!GetMap()->AddToMap(this))
    {
        // Returning false will cause the object to be deleted - remove from transport
        if (transport)
            transport->RemovePassenger(this);
        return false;
    }

    return true;
}
開發者ID:AvariusProject,項目名稱:AvariusCore,代碼行數:51,代碼來源:DynamicObject.cpp

示例12: switch

void GameObject::Use(Unit* user)
{
    // by default spell caster is user
    Unit* spellCaster = user;
    uint32 spellId = 0;

    switch(GetGoType())
    {
        case GAMEOBJECT_TYPE_DOOR:                          //0
        case GAMEOBJECT_TYPE_BUTTON:                        //1
            //doors/buttons never really despawn, only reset to default state/flags
            UseDoorOrButton();

            // activate script
            sWorld.ScriptsStart(sGameObjectScripts, GetDBTableGUIDLow(), spellCaster, this);
            return;

        case GAMEOBJECT_TYPE_QUESTGIVER:                    //2
        {
            if(user->GetTypeId()!=TYPEID_PLAYER)
                return;

            Player* player = (Player*)user;

            player->PrepareQuestMenu( GetGUID() );
            player->SendPreparedQuest( GetGUID() );
            return;
        }
        //Sitting: Wooden bench, chairs enzz
        case GAMEOBJECT_TYPE_CHAIR:                         //7
        {
            GameObjectInfo const* info = GetGOInfo();
            if(!info)
                return;

            if(user->GetTypeId()!=TYPEID_PLAYER)
                return;

            Player* player = (Player*)user;

            // a chair may have n slots. we have to calculate their positions and teleport the player to the nearest one

            // check if the db is sane
            if(info->chair.slots > 0)
            {
                float lowestDist = DEFAULT_VISIBILITY_DISTANCE;

                float x_lowest = GetPositionX();
                float y_lowest = GetPositionY();

                // the object orientation + 1/2 pi
                // every slot will be on that straight line
                float orthogonalOrientation = GetOrientation()+M_PI*0.5f;
                // find nearest slot
                for(uint32 i=0; i<info->chair.slots; i++)
                {
                    // the distance between this slot and the center of the go - imagine a 1D space
                    float relativeDistance = (info->size*i)-(info->size*(info->chair.slots-1)/2.0f);

                    float x_i = GetPositionX() + relativeDistance * cos(orthogonalOrientation);
                    float y_i = GetPositionY() + relativeDistance * sin(orthogonalOrientation);

                    // calculate the distance between the player and this slot
                    float thisDistance = player->GetDistance2d(x_i, y_i);

                    /* debug code. It will spawn a npc on each slot to visualize them.
                    Creature* helper = player->SummonCreature(14496, x_i, y_i, GetPositionZ(), GetOrientation(), TEMPSUMMON_TIMED_OR_DEAD_DESPAWN, 10000);
                    std::ostringstream output;
                    output << i << ": thisDist: " << thisDistance;
                    helper->MonsterSay(output.str().c_str(), LANG_UNIVERSAL, 0);
                    */

                    if(thisDistance <= lowestDist)
                    {
                        lowestDist = thisDistance;
                        x_lowest = x_i;
                        y_lowest = y_i;
                    }
                }
                player->TeleportTo(GetMapId(), x_lowest, y_lowest, GetPositionZ(), GetOrientation(),TELE_TO_NOT_LEAVE_TRANSPORT | TELE_TO_NOT_LEAVE_COMBAT | TELE_TO_NOT_UNSUMMON_PET);
            }
            else
            {
                // fallback, will always work
                player->TeleportTo(GetMapId(), GetPositionX(), GetPositionY(), GetPositionZ(), GetOrientation(),TELE_TO_NOT_LEAVE_TRANSPORT | TELE_TO_NOT_LEAVE_COMBAT | TELE_TO_NOT_UNSUMMON_PET);
            }
            player->SetStandState(PLAYER_STATE_SIT_LOW_CHAIR+info->chair.height);
            return;
        }
        //big gun, its a spell/aura
        case GAMEOBJECT_TYPE_GOOBER:                        //10
        {
            GameObjectInfo const* info = GetGOInfo();

            if(user->GetTypeId()==TYPEID_PLAYER)
            {
                Player* player = (Player*)user;

                // show page
                if(info->goober.pageId)
//.........這裏部分代碼省略.........
開發者ID:Actionfox,項目名稱:mangos,代碼行數:101,代碼來源:GameObject.cpp

示例13: SetMap

bool DynamicObject::CreateDynamicObject(ObjectGuid::LowType guidlow, Unit* caster, SpellInfo const* spell, Position const& pos, float radius, DynamicObjectType type)
{
    SetMap(caster->GetMap());
    Relocate(pos);
    if (!IsPositionValid())
    {
        TC_LOG_ERROR("misc", "DynamicObject (spell %u) not created. Suggested coordinates isn't valid (X: %f Y: %f)", spell->Id, GetPositionX(), GetPositionY());
        return false;
    }

    WorldObject::_Create(ObjectGuid::Create<HighGuid::DynamicObject>(GetMapId(), spell->Id, guidlow));
    SetPhaseMask(caster->GetPhaseMask(), false);

    SetEntry(spell->Id);
    SetObjectScale(1.0f);
    SetGuidValue(DYNAMICOBJECT_CASTER, caster->GetGUID());
    SetUInt32Value(DYNAMICOBJECT_BYTES, spell->GetSpellVisual(GetMap()->GetDifficultyID()) | (type << 28));
    SetUInt32Value(DYNAMICOBJECT_SPELLID, spell->Id);
    SetFloatValue(DYNAMICOBJECT_RADIUS, radius);
    SetUInt32Value(DYNAMICOBJECT_CASTTIME, getMSTime());

    if (IsWorldObject())
        setActive(true);    //must before add to map to be put in world container

    Transport* transport = caster->GetTransport();
    if (transport)
    {
        float x, y, z, o;
        pos.GetPosition(x, y, z, o);
        transport->CalculatePassengerOffset(x, y, z, &o);
        m_movementInfo.transport.pos.Relocate(x, y, z, o);

        // This object must be added to transport before adding to map for the client to properly display it
        transport->AddPassenger(this);
    }

    if (!GetMap()->AddToMap(this))
    {
        // Returning false will cause the object to be deleted - remove from transport
        if (transport)
            transport->RemovePassenger(this);
        return false;
    }

    return true;
}
開發者ID:gearsofdeath,項目名稱:DeathCore_6.x-1,代碼行數:46,代碼來源:DynamicObject.cpp

示例14: Draw

void BonusTile::Update()
{
    if (IsRemoved())
        return;

    if (GAME_STATE_PAUSED(sGame.GetGameState()))
    {
        Draw(animationFinished ? &imageUsed : NULL, true);
        return;
    }

    SpecialTile::Update();

    if (isUsed && animating && !animationFinished)
    {
        animating = true;

        if (movingUp)
        {
            SetPositionY(GetPositionY() - 9.0f);

            if (GetPositionY() < startPosition.y - 40.0f)
                movingUp = false;
        }
        else
        {
            SetPositionY(GetPositionY() + 9.0f);

            if (GetPositionY() >= startPosition.y)
            {
                SetPositionY(startPosition.y);
                movingUp = true;
                animating = false;
                animationFinished = true;
                sf::Texture imageCoin;
                imageCoin.loadFromFile("Graphics/Tiles/coin_gold.png");

                switch (urand(0, 1))
                {
                    case 0:
                        sGame.AddCoin(new Coin(window, sf::Vector2f(GetPositionX(), GetPositionY() - 70.0f), imageCoin));
                        break;
                    case 1:
                        sGame.AddCoin(new Coin(window, sf::Vector2f(GetPositionX(), GetPositionY() - 70.0f), imageCoin));
                        break;
                    default:
                        std::cout << "Typo in BonusTile::Update switch (urand)" << std::endl;
                        break;
                }
            }
        }
    }

    if (sf::Keyboard::isKeyPressed(sf::Keyboard::F2))
    {
        SetPosition(startPosition.x, startPosition.y);
        animationFinished = false;
        movingUp = true;
    }

    Draw(animationFinished ? &imageUsed : NULL, true);
}
開發者ID:Discover-,項目名稱:Platformer-SFML,代碼行數:62,代碼來源:bonustile.cpp

示例15: GetPositionX

bool AreaTrigger::CheckIsInPolygon2D(Position const* pos) const
{
    float testX = pos->GetPositionX();
    float testY = pos->GetPositionY();

    //this method uses the ray tracing algorithm to determine if the point is in the polygon
    bool locatedInPolygon = false;

    for (std::size_t vertex = 0; vertex < _polygonVertices.size(); ++vertex)
    {
        std::size_t nextVertex;

        //repeat loop for all sets of points
        if (vertex == (_polygonVertices.size() - 1))
        {
            //if i is the last vertex, let j be the first vertex
            nextVertex = 0;
        }
        else
        {
            //for all-else, let j=(i+1)th vertex
            nextVertex = vertex + 1;
        }

        float vertX_i = GetPositionX() + _polygonVertices[vertex].GetPositionX();
        float vertY_i = GetPositionY() + _polygonVertices[vertex].GetPositionY();
        float vertX_j = GetPositionX() + _polygonVertices[nextVertex].GetPositionX();
        float vertY_j = GetPositionY() + _polygonVertices[nextVertex].GetPositionY();

        // following statement checks if testPoint.Y is below Y-coord of i-th vertex
        bool belowLowY = vertY_i > testY;
        // following statement checks if testPoint.Y is below Y-coord of i+1-th vertex
        bool belowHighY = vertY_j > testY;

        /* following statement is true if testPoint.Y satisfies either (only one is possible)
        -->(i).Y < testPoint.Y < (i+1).Y        OR
        -->(i).Y > testPoint.Y > (i+1).Y

        (Note)
        Both of the conditions indicate that a point is located within the edges of the Y-th coordinate
        of the (i)-th and the (i+1)- th vertices of the polygon. If neither of the above
        conditions is satisfied, then it is assured that a semi-infinite horizontal line draw
        to the right from the testpoint will NOT cross the line that connects vertices i and i+1
        of the polygon
        */
        bool withinYsEdges = belowLowY != belowHighY;

        if (withinYsEdges)
        {
            // this is the slope of the line that connects vertices i and i+1 of the polygon
            float slopeOfLine = (vertX_j - vertX_i) / (vertY_j - vertY_i);

            // this looks up the x-coord of a point lying on the above line, given its y-coord
            float pointOnLine = (slopeOfLine* (testY - vertY_i)) + vertX_i;

            //checks to see if x-coord of testPoint is smaller than the point on the line with the same y-coord
            bool isLeftToLine = testX < pointOnLine;

            if (isLeftToLine)
            {
                //this statement changes true to false (and vice-versa)
                locatedInPolygon = !locatedInPolygon;
            }//end if (isLeftToLine)
        }//end if (withinYsEdges
    }

    return locatedInPolygon;
}
開發者ID:Rochet2,項目名稱:TrinityCore,代碼行數:68,代碼來源:AreaTrigger.cpp


注:本文中的GetPositionY函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。