本文整理汇总了C++中MapObject::GetType方法的典型用法代码示例。如果您正苦于以下问题:C++ MapObject::GetType方法的具体用法?C++ MapObject::GetType怎么用?C++ MapObject::GetType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类MapObject
的用法示例。
在下文中一共展示了MapObject::GetType方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: Distance
MapObject* CMapObjectManager::getObjectNearBy(int cx,int cy,MapObjectType type)
{
Rect rect;
m_pMap->getViewRect(rect);
float x = 0;
float y = 0;
MapObject* pRet = NULL;
const int minD = 3; //最小格子距离
for ( MapObjectList::iterator itr = m_Objects.begin();itr != m_Objects.end();++itr)
{
MapObject* pObject = *itr;
if ( pObject && !pObject->GetDeleted() )
{
x = pObject->getPositionX();
y = pObject->getPositionY();
int distance = Distance(cx,cy,pObject->GetCellX(),pObject->GetCellY());
if ( rect.containsPoint(Point(x,y)) && pObject->GetType() == type && distance < minD )
{
pRet = pObject;
//minD = distance;
}
}
}
return pRet;
}
示例2:
int CMapObjectManager::getObjectsInView(MapObjectType type,MapObjectList& objects)
{
Rect rect;
m_pMap->getViewRect(rect);
float x = 0;
float y = 0;
for ( MapObjectList::iterator itr = m_Objects.begin();itr != m_Objects.end();++itr)
{
MapObject* pObject = *itr;
if ( pObject && !pObject->GetDeleted() )
{
x = pObject->getPositionX();
y = pObject->getPositionY();
if ( rect.containsPoint(Point(x,y)) && pObject->GetType() == type )
{
objects.push_back(pObject);
}
}
}
return (int)objects.size();
}
示例3: _BeginLine
void DialogueSupervisor::_BeginLine()
{
// Starts possible events at new line.
MapMode *map_mode = MapMode::CurrentInstance();
std::string line_event = _current_dialogue->GetLineBeginEvent(_line_counter);
if(!line_event.empty() && !map_mode->GetEventSupervisor()->IsEventActive(line_event)) {
map_mode->GetEventSupervisor()->StartEvent(line_event);
}
// The current speaker id
uint32 speaker_id = _current_dialogue->GetLineSpeaker(_line_counter);
// Starts possible emote first.
std::string emote_event = _current_dialogue->GetLineEmote(_line_counter);
if(!emote_event.empty() && !_emote_triggered) {
MapSprite* sprite = (speaker_id > 0) ?
dynamic_cast<MapSprite *>(map_mode->GetObjectSupervisor()->GetObject(speaker_id))
: NULL;
if(sprite) {
sprite->Emote(emote_event, (vt_map::private_map::ANIM_DIRECTIONS)sprite->GetCurrentAnimationDirection());
_state = DIALOGUE_STATE_EMOTE;
_emote_triggered = true;
return;
}
}
_emote_triggered = true;
_state = DIALOGUE_STATE_LINE;
_current_options = dynamic_cast<MapDialogueOptions *>(_current_dialogue->GetLineOptions(_line_counter));
// Initialize the line timer
if(_current_dialogue->GetLineDisplayTime(_line_counter) >= 0) {
_line_timer.Initialize(_current_dialogue->GetLineDisplayTime(_line_counter));
_line_timer.Run();
}
// If the line has no timer specified, set the line time to zero and put the timer in the finished state
else {
_line_timer.Initialize(0);
_line_timer.Finish();
}
// Setup the text and graphics for the dialogue window
_dialogue_window.Clear();
_dialogue_window.GetDisplayTextBox().SetDisplayText(_current_dialogue->GetLineText(_line_counter));
MapObject *object = speaker_id > 0 ? map_mode->GetObjectSupervisor()->GetObject(speaker_id) : NULL;
if(object && object->GetType() != SPRITE_TYPE) {
IF_PRINT_WARNING(MAP_DEBUG) << "dialogue #" << _current_dialogue->GetDialogueID()
<< " referenced a map object which was not a sprite with id: " << speaker_id << std::endl;
return;
}
if(!object) {
// Clear the speaker name and potential portrait.
_dialogue_window.GetNameText().Clear();
_dialogue_window.SetPortraitImage(NULL);
} else {
MapSprite *speaker = dynamic_cast<MapSprite *>(object);
_dialogue_window.GetNameText().SetText(speaker->GetName());
_dialogue_window.SetPortraitImage(speaker->GetFacePortrait());
}
if(_current_options) {
for(uint32 i = 0; i < _current_options->GetNumberOptions(); ++i)
_dialogue_window.GetDisplayOptionBox().AddOption(_current_options->GetOptionText(i));
_dialogue_window.GetDisplayOptionBox().SetSelection(0);
_state = DIALOGUE_STATE_OPTION;
}
}
示例4: _UpdateExplore
void MapMode::_UpdateExplore()
{
// First go to menu mode if the user requested it
if(_menu_enabled && InputManager->MenuPress()) {
MenuMode *MM = new MenuMode();
ModeManager->Push(MM);
return;
}
// Only update the status effect supervisor in Exploration mode
// and if they are allowed.
if (_status_effects_enabled)
_status_effect_supervisor.UpdateEffects();
// Update the running state of the camera object. Check if the character is running and if so,
// update the stamina value if the operation is permitted
_camera->is_running = false;
if(_camera->moved_position && !_running_disabled && InputManager->CancelState() &&
(InputManager->UpState() || InputManager->DownState() || InputManager->LeftState() || InputManager->RightState())) {
if(_unlimited_stamina) {
_camera->is_running = true;
} else if(_run_stamina > SystemManager->GetUpdateTime() * 2) {
_run_stamina -= (SystemManager->GetUpdateTime() * 2);
_camera->is_running = true;
} else {
_run_stamina = 0;
}
}
// Regenerate the stamina at 1/2 the consumption rate
else if(_run_stamina < 10000) {
_run_stamina += SystemManager->GetUpdateTime();
if(_run_stamina > 10000)
_run_stamina = 10000;
}
// If the user requested a confirm event, check if there is a nearby object that the player may interact with
// Interactions are currently limited to dialogue with sprites and opening of treasures
if(InputManager->ConfirmPress()) {
MapObject *obj = _object_supervisor->FindNearestInteractionObject(_camera);
if(obj != NULL) {
if(obj->GetType() == PHYSICAL_TYPE) {
PhysicalObject *phs = reinterpret_cast<PhysicalObject *>(obj);
if(!phs->GetEventIdWhenTalking().empty()) {
_camera->moving = false;
_camera->is_running = false;
if (!_event_supervisor->IsEventActive(phs->GetEventIdWhenTalking()))
_event_supervisor->StartEvent(phs->GetEventIdWhenTalking());
return;
}
}
else if(obj->GetType() == SPRITE_TYPE) {
MapSprite *sp = reinterpret_cast<MapSprite *>(obj);
if(sp->HasAvailableDialogue()) {
_camera->moving = false;
_camera->is_running = false;
sp->InitiateDialogue();
return;
}
} else if(obj->GetType() == TREASURE_TYPE) {
TreasureObject *treasure_object = reinterpret_cast<TreasureObject *>(obj);
if(!treasure_object->GetTreasure()->IsTaken()) {
_camera->moving = false;
treasure_object->Open();
}
} else if(obj->GetType() == SAVE_TYPE && _save_points_enabled) {
// Make sure the character will be centered in the save point
SaveMode *save_mode = new SaveMode(true, obj->GetXPosition(), obj->GetYPosition() - 1.0f);
ModeManager->Push(save_mode, false, false);
}
}
}
// Detect movement input from the user
if(InputManager->UpState() || InputManager->DownState() || InputManager->LeftState() || InputManager->RightState()) {
_camera->moving = true;
} else {
_camera->moving = false;
}
// Determine the direction of movement. Priority of movement is given to: up, down, left, right.
// In the case of diagonal movement, the direction that the sprite should face also needs to be deduced.
if(_camera->moving == true) {
if(InputManager->UpState()) {
if(InputManager->LeftState())
_camera->SetDirection(MOVING_NORTHWEST);
else if(InputManager->RightState())
_camera->SetDirection(MOVING_NORTHEAST);
else
_camera->SetDirection(NORTH);
} else if(InputManager->DownState()) {
if(InputManager->LeftState())
_camera->SetDirection(MOVING_SOUTHWEST);
else if(InputManager->RightState())
_camera->SetDirection(MOVING_SOUTHEAST);
else
_camera->SetDirection(SOUTH);
//.........这里部分代码省略.........
示例5: Click
void WorldMap::Click(MapObject& obj)
{
sf::Vector2i node = GetIndex(obj.GetPos());
mapGrid[node.y][node.x].second.ChangeType(obj.GetType());
}