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); } else if(InputManager->LeftState()) { _camera->SetDirection(WEST); } else if(InputManager->RightState()) { _camera->SetDirection(EAST); } } // if (_camera->moving == true) } // void MapMode::_UpdateExplore()